linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: Disable master abort while waiting for an FLR to complete
@ 2017-05-12 18:13 Alexander Duyck
  2017-05-15 16:36 ` Brian Norris
  2017-06-14 22:34 ` Bjorn Helgaas
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Duyck @ 2017-05-12 18:13 UTC (permalink / raw)
  To: bhelgaas, linux-pci, alex.williamson, briannorris

From: Alexander Duyck <alexander.h.duyck@intel.com>

This patch is meant to address issues seen when performing on FLR on some
systems as the long wait can result in a master abort when reading a
function that is not yet ready.

To prevent the master abort from being reported up we should disable
reporting for it while waiting on the reset. Once the reset is completed
then we can re-enable the master abort for the bus.

Fixes: 5adecf817dd6 ("PCI: Wait for up to 1000ms after FLR reset")

Reported-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---

I haven't been able to test this code as I don't have a system that can
reproduce the issue. The fix itself is based on the issue as reported by
Brian so I am hoping he can test this on the Samsung Chromebook Plus with
RK399 OP1 that this was seen on.

 drivers/pci/pci.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7904d02ffdb9..acbdbabeaa0e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3758,14 +3758,31 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev)
  */
 static void pci_flr_wait(struct pci_dev *dev)
 {
+	struct pci_dev *bridge = dev->bus->self;
 	int i = 0;
+	u16 bctl;
 	u32 id;
 
+	/*
+	 * Disable MasterAbortMode while we are waiting to avoid reporting
+	 * bus errors for reading the command register on a device that is
+	 * not ready (in some architectures)
+	 */
+	if (bridge) {
+		pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &bctl);
+		pci_write_config_word(bridge, PCI_BRIDGE_CONTROL,
+				      bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
+	}
+
 	do {
 		msleep(100);
 		pci_read_config_dword(dev, PCI_COMMAND, &id);
 	} while (i++ < 10 && id == ~0);
 
+	/* restore bridge state */
+	if (bridge)
+		pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bctl);
+
 	if (id == ~0)
 		dev_warn(&dev->dev, "Failed to return from FLR\n");
 	else if (i > 1)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-14 22:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 18:13 [PATCH] pci: Disable master abort while waiting for an FLR to complete Alexander Duyck
2017-05-15 16:36 ` Brian Norris
2017-05-15 19:48   ` Alexander Duyck
2017-05-15 20:00     ` Alex Williamson
2017-05-15 21:00     ` Brian Norris
2017-05-15 21:51       ` Brian Norris
2017-06-14 22:34 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).