From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Utkarsh H Patel <utkarsh.h.patel@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-pci@vger.kernel.org
Subject: [PATCH] PCI: Re-enable downstream port LTR if it was previously enabled
Date: Thu, 14 Jan 2021 16:47:24 +0300 [thread overview]
Message-ID: <20210114134724.79511-1-mika.westerberg@linux.intel.com> (raw)
PCIe r5.0, sec 7.5.3.16 says that the downstream ports must reset the
LTR enable bit if the link goes down (port goes DL_Down status). Now, if
we had LTR previously enabled and the PCIe endpoint gets hot-removed and
then hot-added back the ->ltr_path of the downstream port is still set
but the port now does not have the LTR enable bit set anymore.
For this reason check if the bridge upstrea had LTR enabled set
previously and re-enable it before enabling LTR for the endpoint.
Reported-by: Utkarsh H Patel <utkarsh.h.patel@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/pci/probe.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0eb68b47354f..cd174e06f46f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2153,7 +2153,7 @@ static void pci_configure_ltr(struct pci_dev *dev)
{
#ifdef CONFIG_PCIEASPM
struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
- struct pci_dev *bridge;
+ struct pci_dev *bridge = NULL;
u32 cap, ctl;
if (!pci_is_pcie(dev))
@@ -2191,6 +2191,21 @@ static void pci_configure_ltr(struct pci_dev *dev)
if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
((bridge = pci_upstream_bridge(dev)) &&
bridge->ltr_path)) {
+ /*
+ * Downstream ports reset the LTR enable bit when the
+ * link goes down (e.g on hot-remove) so re-enable the
+ * bit here if not set anymore.
+ * PCIe r5.0, sec 7.5.3.16.
+ */
+ if (bridge && pcie_downstream_port(bridge)) {
+ pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, &ctl);
+ if (!(ctl & PCI_EXP_DEVCTL2_LTR_EN)) {
+ pci_dbg(bridge, "re-enabling LTR\n");
+ pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2,
+ PCI_EXP_DEVCTL2_LTR_EN);
+ }
+ }
+ pci_dbg(dev, "enabling LTR\n");
pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
PCI_EXP_DEVCTL2_LTR_EN);
dev->ltr_path = 1;
--
2.29.2
next reply other threads:[~2021-01-14 13:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 13:47 Mika Westerberg [this message]
2021-01-15 0:10 ` [PATCH] PCI: Re-enable downstream port LTR if it was previously enabled Bjorn Helgaas
2021-01-15 9:00 ` Mika Westerberg
2021-01-16 0:36 ` Bjorn Helgaas
2021-01-18 12:58 ` Mika Westerberg
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=20210114134724.79511-1-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=utkarsh.h.patel@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.