linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: get pm runtime ref before resetting bus
@ 2019-08-27  6:43 Xiongfeng Wang
  0 siblings, 0 replies; only message in thread
From: Xiongfeng Wang @ 2019-08-27  6:43 UTC (permalink / raw)
  To: bhelgaas, lukas
  Cc: linux-pci, linux-kernel, wangxiongfeng2, huawei.libin, guohanjun

When I inject a PCIE Fatal error into a mellanox netdevice, 'dmesg' shows
the device is recovered successfully, but 'lspci' didn't show the
device. I checked the configuration space of the slot where the netdevice
is inserted and found out the bit 'PCI_BRIDGE_CTL_BUS_RESET' is set.
Later, I found out it is because this bit is saved in
'saved_config_space' of 'struct pci_dev' when 'pci_pm_runtime_suspend()'
is called. And 'PCI_BRIDGE_CTL_BUS_RESET' is set every time we restore
the configuration sapce.

This patch use 'pm_runtime_get' to avoid saving the configuration space
of the bridge when the bus is being reset.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/pci/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 9cae66c..0079f0a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4546,6 +4546,9 @@ void pci_reset_secondary_bus(struct pci_dev *dev)
 {
 	u16 ctrl;
 
+	/* avoid wrongly saving 'PCI_BRIDGE_CTL_BUS_RESET' */
+	pm_runtime_get(&dev->dev);
+
 	pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &ctrl);
 	ctrl |= PCI_BRIDGE_CTL_BUS_RESET;
 	pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl);
@@ -4567,6 +4570,8 @@ void pci_reset_secondary_bus(struct pci_dev *dev)
 	 * but we don't make use of them yet.
 	 */
 	ssleep(1);
+
+	pm_runtime_put(&dev->dev);
 }
 
 void __weak pcibios_reset_secondary_bus(struct pci_dev *dev)
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-27  6:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  6:43 [PATCH] pci: get pm runtime ref before resetting bus Xiongfeng Wang

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).