From: Sam Bobroff <sbobroff@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 1/6] powerpc/eeh: Cleanup eeh_pe_clear_frozen_state()
Date: Thu, 29 Nov 2018 14:16:37 +1100 [thread overview]
Message-ID: <44d3c23aa1c58abb6e1790e68b34e613a7ec6909.1543460917.git.sbobroff@linux.ibm.com> (raw)
In-Reply-To: <cover.1543460917.git.sbobroff@linux.ibm.com>
The 'clear_sw_state' parameter for eeh_pe_clear_frozen_state() is
redundant because it has no effect (except in the rare case of a
hardware error part way through unfreezing a tree of PEs, where it
would dangerously allow partial de-isolation before returning
failure).
It is passed down to __eeh_pe_clear_frozen_state(), and from there to
eeh_unfreeze_pe(), where it causes EEH_PE_ISOLATED to be removed
from the state of each PE during the traversal. However, when the
traversal finishes, EEH_PE_ISOLATED is unconditionally removed by a
call to eeh_pe_state_clear() regardless of the parameter's value.
So remove the flag and pass false to eeh_unfreeze_pe() (to avoid the
rare case described above, as it was before the flag was introduced).
Also, perform the recursion directly in the function and eliminate a
bit of boilerplate.
There should be no change in functionality, except as mentioned above.
Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
---
arch/powerpc/kernel/eeh_driver.c | 40 +++++++++++---------------------
1 file changed, 13 insertions(+), 27 deletions(-)
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 9446248eb6b8..aa86a42d98f2 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -591,34 +591,20 @@ static void *eeh_pe_detach_dev(struct eeh_pe *pe, void *userdata)
* PE reset (for 3 times), we try to clear the frozen state
* for 3 times as well.
*/
-static void *__eeh_clear_pe_frozen_state(struct eeh_pe *pe, void *flag)
+static int eeh_clear_pe_frozen_state(struct eeh_pe *root)
{
- bool clear_sw_state = *(bool *)flag;
- int i, rc = 1;
-
- for (i = 0; rc && i < 3; i++)
- rc = eeh_unfreeze_pe(pe, clear_sw_state);
+ struct eeh_pe *pe;
+ int i;
- /* Stop immediately on any errors */
- if (rc) {
- pr_warn("%s: Failure %d unfreezing PHB#%x-PE#%x\n",
- __func__, rc, pe->phb->global_number, pe->addr);
- return (void *)pe;
+ eeh_for_each_pe(root, pe) {
+ for (i = 0; i < 3; i++)
+ if (!eeh_unfreeze_pe(pe, false))
+ break;
+ if (i >= 3)
+ return -EIO;
}
-
- return NULL;
-}
-
-static int eeh_clear_pe_frozen_state(struct eeh_pe *pe,
- bool clear_sw_state)
-{
- void *rc;
-
- rc = eeh_pe_traverse(pe, __eeh_clear_pe_frozen_state, &clear_sw_state);
- if (!rc)
- eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
-
- return rc ? -EIO : 0;
+ eeh_pe_state_clear(root, EEH_PE_ISOLATED);
+ return 0;
}
int eeh_pe_reset_and_recover(struct eeh_pe *pe)
@@ -643,7 +629,7 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe)
}
/* Unfreeze the PE */
- ret = eeh_clear_pe_frozen_state(pe, true);
+ ret = eeh_clear_pe_frozen_state(pe);
if (ret) {
eeh_pe_state_clear(pe, EEH_PE_RECOVERING);
return ret;
@@ -716,7 +702,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
eeh_pe_restore_bars(pe);
/* Clear frozen state */
- rc = eeh_clear_pe_frozen_state(pe, false);
+ rc = eeh_clear_pe_frozen_state(pe);
if (rc) {
pci_unlock_rescan_remove();
return rc;
--
2.19.0.2.gcad72f5712
next prev parent reply other threads:[~2018-11-29 3:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-29 3:16 [PATCH 0/6] powerpc/eeh: Improve recovery of passed-through devices Sam Bobroff
2018-11-29 3:16 ` Sam Bobroff [this message]
2019-02-08 13:02 ` [1/6] powerpc/eeh: Cleanup eeh_pe_clear_frozen_state() Michael Ellerman
2018-11-29 3:16 ` [PATCH 2/6] powerpc/eeh: remove sw_state from eeh_unfreeze_pe() Sam Bobroff
2018-11-29 3:16 ` [PATCH 3/6] powerpc/eeh: Add include_passed to eeh_pe_state_clear() Sam Bobroff
2018-11-29 3:16 ` [PATCH 4/6] powerpc/eeh: Add include_passed to eeh_clear_pe_frozen_state() Sam Bobroff
2018-11-29 3:16 ` [PATCH 5/6] powerpc/eeh: Improve recovery of passed-through devices Sam Bobroff
2018-11-29 3:16 ` [PATCH 6/6] powerpc/eeh: Correct retries in eeh_pe_reset_full() Sam Bobroff
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=44d3c23aa1c58abb6e1790e68b34e613a7ec6909.1543460917.git.sbobroff@linux.ibm.com \
--to=sbobroff@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/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 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).