[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201007113158.48933-6-haifeng.zhao@intel.com>
Date: Wed, 7 Oct 2020 07:31:57 -0400
From: Ethan Zhao <haifeng.zhao@...el.com>
To: bhelgaas@...gle.com, oohall@...il.com, ruscur@...sell.cc,
lukas@...ner.de, andriy.shevchenko@...ux.intel.com,
stuart.w.hayes@...il.com, mr.nuke.me@...il.com,
mika.westerberg@...ux.intel.com
Cc: linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
ashok.raj@...ux.intel.com, sathyanarayanan.kuppuswamy@...el.com,
xerces.zhao@...il.com, Ethan Zhao <haifeng.zhao@...el.com>
Subject: [PATCH v8 5/6] PCI/ERR: only return true when dev io state is really changed
When uncorrectable error happens, AER driver and DPC driver interrupt
handlers likely call
pcie_do_recovery()
->pci_walk_bus()
->report_frozen_detected()
with pci_channel_io_frozen the same time.
If pci_dev_set_io_state() return true even if the original state is
pci_channel_io_frozen, that will cause AER or DPC handler re-enter
the error detecting and recovery procedure one after another.
The result is the recovery flow mixed between AER and DPC.
So change the pci_dev_set_io_state() function to only return true
when dev->error_state is really changed.
Signed-off-by: Ethan Zhao <haifeng.zhao@...el.com>
---
Changnes:
v2: revise description and code according to suggestion from Andy.
v3: change code to simpler.
v4: no change.
v5: no change.
v6: no change.
v7: changed based on Bjorn's code and truth table.
v8: according to Bjorn's suggestion, rebase on another simplification
patch.
drivers/pci/pci.h | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index bceb3f108744..a11e0f9d9bdf 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -371,17 +371,14 @@ static inline bool pci_dev_set_io_state(struct pci_dev *dev,
* perm_failure | perm_failure* perm_failure* perm_failure
*/
- /* Can always put a device in perm_failure state */
- if (new == pci_channel_io_perm_failure) {
- dev->error_state = pci_channel_io_perm_failure;
- return true;
- }
-
- /* If already in perm_failure, can't set to normal or frozen */
+ /* If already in perm_failure, can't change it's state */
if (dev->error_state == pci_channel_io_perm_failure)
return false;
+ /* not change at all */
+ else if (dev->error_state == new)
+ return false;
- /* Can always change normal to frozen or vice versa */
+ /* Can always change from normal/frozen to other different state */
dev->error_state = new;
return true;
}
--
2.18.4
Powered by blists - more mailing lists