Commit 9feed42e authored by Gavin Shan's avatar Gavin Shan Committed by Benjamin Herrenschmidt

powerpc/eeh: Use safe list traversal when walking EEH devices

Currently, we're trasversing the EEH devices list using list_for_each_entry().
That's not safe enough because the EEH devices might be removed from
its parent PE while doing iteration. The patch replaces that with
list_for_each_entry_safe().
Signed-off-by: default avatarGavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 807a827d
...@@ -74,8 +74,8 @@ struct eeh_pe { ...@@ -74,8 +74,8 @@ struct eeh_pe {
struct list_head child; /* Child PEs */ struct list_head child; /* Child PEs */
}; };
#define eeh_pe_for_each_dev(pe, edev) \ #define eeh_pe_for_each_dev(pe, edev, tmp) \
list_for_each_entry(edev, &pe->edevs, list) list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
/* /*
* The struct is used to trace EEH state for the associated * The struct is used to trace EEH state for the associated
......
...@@ -231,7 +231,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len) ...@@ -231,7 +231,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
void eeh_slot_error_detail(struct eeh_pe *pe, int severity) void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
{ {
size_t loglen = 0; size_t loglen = 0;
struct eeh_dev *edev; struct eeh_dev *edev, *tmp;
bool valid_cfg_log = true; bool valid_cfg_log = true;
/* /*
...@@ -251,7 +251,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity) ...@@ -251,7 +251,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
eeh_pe_restore_bars(pe); eeh_pe_restore_bars(pe);
pci_regs_buf[0] = 0; pci_regs_buf[0] = 0;
eeh_pe_for_each_dev(pe, edev) { eeh_pe_for_each_dev(pe, edev, tmp) {
loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen, loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen,
EEH_PCI_REGS_LOG_LEN - loglen); EEH_PCI_REGS_LOG_LEN - loglen);
} }
......
...@@ -176,7 +176,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root, ...@@ -176,7 +176,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
eeh_traverse_func fn, void *flag) eeh_traverse_func fn, void *flag)
{ {
struct eeh_pe *pe; struct eeh_pe *pe;
struct eeh_dev *edev; struct eeh_dev *edev, *tmp;
void *ret; void *ret;
if (!root) { if (!root) {
...@@ -186,7 +186,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root, ...@@ -186,7 +186,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
/* Traverse root PE */ /* Traverse root PE */
for (pe = root; pe; pe = eeh_pe_next(pe, root)) { for (pe = root; pe; pe = eeh_pe_next(pe, root)) {
eeh_pe_for_each_dev(pe, edev) { eeh_pe_for_each_dev(pe, edev, tmp) {
ret = fn(edev, flag); ret = fn(edev, flag);
if (ret) if (ret)
return ret; return ret;
...@@ -501,7 +501,7 @@ static void *__eeh_pe_state_mark(void *data, void *flag) ...@@ -501,7 +501,7 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
{ {
struct eeh_pe *pe = (struct eeh_pe *)data; struct eeh_pe *pe = (struct eeh_pe *)data;
int state = *((int *)flag); int state = *((int *)flag);
struct eeh_dev *tmp; struct eeh_dev *edev, *tmp;
struct pci_dev *pdev; struct pci_dev *pdev;
/* /*
...@@ -511,8 +511,8 @@ static void *__eeh_pe_state_mark(void *data, void *flag) ...@@ -511,8 +511,8 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
* the PCI device driver. * the PCI device driver.
*/ */
pe->state |= state; pe->state |= state;
eeh_pe_for_each_dev(pe, tmp) { eeh_pe_for_each_dev(pe, edev, tmp) {
pdev = eeh_dev_to_pci_dev(tmp); pdev = eeh_dev_to_pci_dev(edev);
if (pdev) if (pdev)
pdev->error_state = pci_channel_io_frozen; pdev->error_state = pci_channel_io_frozen;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment