From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Feng Tang <feng.tang@linux.alibaba.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Lukas Wunner <lukas@wunner.de>,
Sathyanarayanan Kuppuswamy
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Liguang Zhang <zhangliguang@linux.alibaba.com>,
Guanghui Feng <guanghuifeng@linux.alibaba.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Markus Elfring <Markus.Elfring@web.de>,
lkp@intel.com, Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-pci@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/4] PCI/portdrv: Add necessary wait for disabling hotplug events
Date: Mon, 24 Feb 2025 17:00:03 +0200 (EET) [thread overview]
Message-ID: <abb50795-df83-511a-8850-cdf30f187935@linux.intel.com> (raw)
In-Reply-To: <20250224034500.23024-3-feng.tang@linux.alibaba.com>
On Mon, 24 Feb 2025, Feng Tang wrote:
> There was problem reported by firmware developers that they received
> two PCIe hotplug commands in very short intervals on an ARM server,
> which doesn't comply with PCIe spec, and broke their state machine and
> work flow. According to PCIe 6.1 spec, section 6.7.3.2, software needs
> to wait at least 1 second for the command-complete event, before
> resending the command or sending a new command.
>
> In the failure case, the first PCIe hotplug command firmware received
> is from get_port_device_capability(), which sends command to disable
> PCIe hotplug interrupts without waiting for its completion, and the
> second command comes from pcie_enable_notification() of pciehp driver,
> which enables hotplug interrupts again.
>
> Fix it by adding the necessary wait to comply with PCIe spec.
>
> Fixes: 2bd50dd800b5 ("PCI: PCIe: Disable PCIe port services during port initialization")
> Originally-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
> Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
> ---
> drivers/pci/pci.h | 2 ++
> drivers/pci/pcie/portdrv.c | 19 +++++++++++++++++--
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4c94a589de4a..a1138ebc2689 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -760,6 +760,7 @@ static inline void pcie_ecrc_get_policy(char *str) { }
> void pcie_reset_lbms_count(struct pci_dev *port);
> int pcie_lbms_count(struct pci_dev *port, unsigned long *val);
> int pcie_poll_sltctl_cmd(struct pci_dev *dev, int timeout_ms);
> +void pcie_disable_hp_interrupts_early(struct pci_dev *dev);
> #else
> static inline void pcie_reset_lbms_count(struct pci_dev *port) {}
> static inline int pcie_lbms_count(struct pci_dev *port, unsigned long *val)
> @@ -770,6 +771,7 @@ static inline int pcie_poll_sltctl_cmd(struct pci_dev *dev, int timeout_ms)
> {
> return 0;
> }
> +static inline void pcie_disable_hp_interrupts_early(struct pci_dev *dev) {}
> #endif
>
> struct pci_dev_reset_methods {
> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index bb00ba45ee51..ca4f21dff486 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -230,6 +230,22 @@ int pcie_poll_sltctl_cmd(struct pci_dev *dev, int timeout_ms)
> return ret;
> }
>
> +void pcie_disable_hp_interrupts_early(struct pci_dev *dev)
> +{
> + u16 slot_ctrl = 0;
Unnecessary initialization
> +
> + pcie_capability_read_word(dev, PCI_EXP_SLTCTL, &slot_ctrl);
> + /* Bail out early if it is already disabled */
> + if (!(slot_ctrl & (PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE)))
> + return;
> +
> + pcie_capability_clear_word(dev, PCI_EXP_SLTCTL,
> + PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);
Align to (. You might need to put the bits to own lines.
> +
> + if (pcie_poll_sltctl_cmd(dev, 1000))
> + pci_info(dev, "Timeout on disabling PCIe hot-plug interrupt\n");
> +}
> +
> /**
> * get_port_device_capability - discover capabilities of a PCI Express port
> * @dev: PCI Express port to examine
> @@ -255,8 +271,7 @@ static int get_port_device_capability(struct pci_dev *dev)
> * Disable hot-plug interrupts in case they have been enabled
> * by the BIOS and the hot-plug service driver is not loaded.
> */
> - pcie_capability_clear_word(dev, PCI_EXP_SLTCTL,
> - PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);
> + pcie_disable_hp_interrupts_early(dev);
Doesn't calling this here delay setup for all portdrv services, not just
hotplug? And the delay can be relatively long.
> }
>
> #ifdef CONFIG_PCIEAER
>
--
i.
next prev parent reply other threads:[~2025-02-24 15:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 3:44 [PATCH v3 0/4] PCIe hotplug interrupt related fixes Feng Tang
2025-02-24 3:44 ` [PATCH v3 1/4] PCI: portdrv: pciehp: Move PCIe hotplug command waiting logic to port driver Feng Tang
2025-02-24 15:06 ` Ilpo Järvinen
2025-02-25 8:18 ` Feng Tang
2025-02-24 3:44 ` [PATCH v3 2/4] PCI/portdrv: Add necessary wait for disabling hotplug events Feng Tang
2025-02-24 9:42 ` Markus Elfring
2025-02-24 15:00 ` Ilpo Järvinen [this message]
2025-02-25 5:51 ` Feng Tang
2025-02-24 18:12 ` Lukas Wunner
2025-02-25 3:06 ` Feng Tang
2025-02-25 4:01 ` Lukas Wunner
2025-02-25 4:42 ` Feng Tang
2025-02-28 6:29 ` Feng Tang
2025-02-28 7:14 ` Lukas Wunner
2025-02-28 9:33 ` Feng Tang
2025-02-28 10:01 ` Feng Tang
2025-02-24 3:44 ` [PATCH v3 3/4] PCI/portdrv: Loose the condition check for disabling hotplug interrupts Feng Tang
2025-02-24 9:47 ` Markus Elfring
2025-02-25 4:09 ` Lukas Wunner
2025-02-26 2:54 ` Feng Tang
2025-02-24 3:45 ` [PATCH v3 4/4] PCI: Disable PCIe hotplug interrupts early when msi is disabled Feng Tang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abb50795-df83-511a-8850-cdf30f187935@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Markus.Elfring@web.de \
--cc=bhelgaas@google.com \
--cc=feng.tang@linux.alibaba.com \
--cc=guanghuifeng@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lkp@intel.com \
--cc=lukas@wunner.de \
--cc=rafael@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=zhangliguang@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox