From: Sam Bobroff <hidden> Date: 2018-03-19 02:46:04
Hello everyone,
Here is a set of some small, mostly idempotent, changes to improve
maintainability in some of the EEH code, primarily in eeh_driver.c.
I've kept them all small to aid review but perhaps they should be squashed down
before being applied.
Cheers,
Sam.
Patch set changelog follows:
====== v1 -> v2: ======
Patch 1/9: powerpc/eeh: Remove eeh_handle_event()
Patch 2/9: powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
Patch 3/9: powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
Patch 4/9: powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
Patch 5/9: powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
Patch 6/9: powerpc/eeh: Clarify arguments to eeh_reset_device()
* Re-ordered parameters to eeh_reset_device() to keep pe first.
* Changed eeh_aware_driver to driver_eeh_aware.
Patch 7/9: powerpc/eeh: Remove always-true tests in eeh_reset_device()
Patch 8/9: powerpc/eeh: Factor out common code eeh_reset_device()
* In one case, added braces to "if" to match "else".
Patch 9/9: powerpc/eeh: Add eeh_state_active() helper
====== v1: ======
Patch 1/9: powerpc/eeh: Remove eeh_handle_event()
Patch 2/9: powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
Patch 3/9: powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
Patch 4/9: powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
Patch 5/9: powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
Patch 6/9: powerpc/eeh: Clarify arguments to eeh_reset_device()
Patch 7/9: powerpc/eeh: Remove always-true tests in eeh_reset_device()
Patch 8/9: powerpc/eeh: Factor out common code eeh_reset_device()
Patch 9/9: powerpc/eeh: Add eeh_state_active() helper
Sam Bobroff (9):
powerpc/eeh: Remove eeh_handle_event()
powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
powerpc/eeh: Clarify arguments to eeh_reset_device()
powerpc/eeh: Remove always-true tests in eeh_reset_device()
powerpc/eeh: Factor out common code eeh_reset_device()
powerpc/eeh: Add eeh_state_active() helper
arch/powerpc/include/asm/eeh.h | 6 ++
arch/powerpc/include/asm/eeh_event.h | 3 +-
arch/powerpc/kernel/eeh.c | 19 ++--
arch/powerpc/kernel/eeh_cache.c | 3 +-
arch/powerpc/kernel/eeh_driver.c | 137 +++++++++++----------------
arch/powerpc/kernel/eeh_event.c | 6 +-
arch/powerpc/platforms/powernv/eeh-powernv.c | 9 +-
7 files changed, 72 insertions(+), 111 deletions(-)
--
2.16.1.74.g9b0b1f47b
From: Sam Bobroff <hidden> Date: 2018-03-19 02:46:29
The function eeh_handle_event(pe) does nothing other than switching
between calling eeh_handle_normal_event(pe) and
eeh_handle_special_event(). However it is only called in two places,
one where pe can't be NULL and the other where it must be NULL (see
eeh_event_handler()) so it does nothing but obscure the flow of
control.
So, remove it.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/include/asm/eeh_event.h | 3 ++-
arch/powerpc/kernel/eeh_driver.c | 42 +++++++++++++-----------------------
arch/powerpc/kernel/eeh_event.c | 4 ++--
3 files changed, 19 insertions(+), 30 deletions(-)
@@ -81,10 +81,10 @@ static int eeh_event_handler(void * dummy)pr_info("EEH: Detected PCI bus error on ""PHB#%x-PE#%x\n",pe->phb->global_number,pe->addr);-eeh_handle_event(pe);+eeh_handle_normal_event(pe);eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}else{-eeh_handle_event(NULL);+eeh_handle_special_event();}kfree(event);
From: Sam Bobroff <hidden> Date: 2018-03-19 02:46:41
Currently the EEH_PE_RECOVERING flag for a PE is managed by both the
caller and callee of eeh_handle_normal_event() (among other places not
considered here). This is complicated by the fact that the PE may
or may not have been invalidated by the call.
So move the callee's handling into eeh_handle_normal_event(), which
clarifies it and allows the return type to be changed to void (because
it no longer needs to indicate at the PE has been invalidated).
This should not change behaviour except in eeh_event_handler() where
it was previously possible to cause eeh_pe_state_clear() to be called
on an invalid PE, which is now avoided.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/include/asm/eeh_event.h | 2 +-
arch/powerpc/kernel/eeh_driver.c | 29 +++++++++++------------------
arch/powerpc/kernel/eeh_event.c | 2 --
3 files changed, 12 insertions(+), 21 deletions(-)
@@ -940,12 +941,12 @@ bool eeh_handle_normal_event(struct eeh_pe *pe)pci_lock_rescan_remove();pci_hp_remove_devices(frozen_bus);pci_unlock_rescan_remove();-/* The passed PE should no longer be used */-returntrue;+return;}}-returnfalse;+final:+eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}/**
@@ -73,7 +73,6 @@ static int eeh_event_handler(void * dummy)/* We might have event without binding PE */pe=event->pe;if(pe){-eeh_pe_state_mark(pe,EEH_PE_RECOVERING);if(pe->type&EEH_PE_PHB)pr_info("EEH: Detected error on PHB#%x\n",pe->phb->global_number);
@@ -82,7 +81,6 @@ static int eeh_event_handler(void * dummy)"PHB#%x-PE#%x\n",pe->phb->global_number,pe->addr);eeh_handle_normal_event(pe);-eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}else{eeh_handle_special_event();}
From: Sam Bobroff <hidden> Date: 2018-03-19 02:46:52
Commit "0ba178888b05 powerpc/eeh: Remove reference to PCI device"
removed a call to pci_dev_get() from __eeh_addr_cache_get_device() but
did not update the comment to match.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh_cache.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Sam Bobroff <hidden> Date: 2018-03-19 02:47:01
Remove a test that checks if "frozen_bus" is NULL, because it cannot
have changed since it was tested at the start of the function and so
must be true here.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh_driver.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
@@ -930,20 +930,18 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*allremoveddevicescorrectlytoavoidaccess*thetheirPCIconfiganymore.*/-if(frozen_bus){-if(pe->type&EEH_PE_VF){-eeh_pe_dev_traverse(pe,eeh_rmv_device,NULL);-eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);-}else{-eeh_pe_state_clear(pe,EEH_PE_PRI_BUS);-eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);+if(pe->type&EEH_PE_VF){+eeh_pe_dev_traverse(pe,eeh_rmv_device,NULL);+eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);+}else{+eeh_pe_state_clear(pe,EEH_PE_PRI_BUS);+eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);-pci_lock_rescan_remove();-pci_hp_remove_devices(frozen_bus);-pci_unlock_rescan_remove();-/* The passed PE should no longer be used */-return;-}+pci_lock_rescan_remove();+pci_hp_remove_devices(frozen_bus);+pci_unlock_rescan_remove();+/* The passed PE should no longer be used */+return;}final:eeh_pe_state_clear(pe,EEH_PE_RECOVERING);
From: Sam Bobroff <hidden> Date: 2018-03-19 02:47:10
The name "frozen_bus" is misleading: it's not necessarily frozen, it's
just the PE's PCI bus.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh_driver.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
@@ -754,14 +754,14 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,*/voideeh_handle_normal_event(structeeh_pe*pe){-structpci_bus*frozen_bus;+structpci_bus*bus;structeeh_dev*edev,*tmp;intrc=0;enumpci_ers_resultresult=PCI_ERS_RESULT_NONE;structeeh_rmv_datarmv_data={LIST_HEAD_INIT(rmv_data.edev_list),0};-frozen_bus=eeh_pe_bus_get(pe);-if(!frozen_bus){+bus=eeh_pe_bus_get(pe);+if(!bus){pr_err("%s: Cannot find PCI bus for PHB#%x-PE#%x\n",__func__,pe->phb->global_number,pe->addr);return;
@@ -820,7 +820,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*/if(result==PCI_ERS_RESULT_NONE){pr_info("EEH: Reset with hotplug activity\n");-rc=eeh_reset_device(pe,frozen_bus,NULL);+rc=eeh_reset_device(pe,bus,NULL);if(rc){pr_warn("%s: Unable to reset, err=%d\n",__func__,rc);
@@ -938,7 +938,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);pci_lock_rescan_remove();-pci_hp_remove_devices(frozen_bus);+pci_hp_remove_devices(bus);pci_unlock_rescan_remove();/* The passed PE should no longer be used */return;
From: Sam Bobroff <hidden> Date: 2018-03-19 02:49:12
It is currently difficult to understand the behaviour of
eeh_reset_device() due to the way it's parameters are used. In
particular, when 'bus' is NULL, it's value is still necessary so the
same value is looked up again locally under a different name
('frozen_bus') but behaviour is changed.
To clarify this, add a new parameter 'driver_eeh_aware', and have the
caller set it when it would have passed NULL for 'bus' and always pass
a value for 'bus'. Then change any test that was on 'bus' to one on
'!driver_eeh_aware' and replace uses of 'frozen_bus' with 'bus'.
Also update the function's comment.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh_driver.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
@@ -820,7 +822,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*/if(result==PCI_ERS_RESULT_NONE){pr_info("EEH: Reset with hotplug activity\n");-rc=eeh_reset_device(pe,bus,NULL);+rc=eeh_reset_device(pe,bus,NULL,false);if(rc){pr_warn("%s: Unable to reset, err=%d\n",__func__,rc);
@@ -872,7 +874,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)/* If any device called out for a reset, then reset the slot */if(result==PCI_ERS_RESULT_NEED_RESET){pr_info("EEH: Reset without hotplug activity\n");-rc=eeh_reset_device(pe,NULL,&rmv_data);+rc=eeh_reset_device(pe,bus,&rmv_data,true);if(rc){pr_warn("%s: Cannot reset, err=%d\n",__func__,rc);
From: Sam Bobroff <hidden> Date: 2018-03-19 02:49:14
eeh_reset_device() tests the value of 'bus' more than once but the
only caller, eeh_handle_normal_device() does this test itself and will
never pass NULL.
So, remove the dead tests.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Sam Bobroff <hidden> Date: 2018-03-19 02:49:23
The caller will always pass NULL for 'rmv_data' when
'eeh_aware_driver' is true, so the first two calls to
eeh_pe_dev_traverse() can be combined without changing behaviour as
can the two arms of the final 'if' block.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
---
====== v1 -> v2: ======
arch/powerpc/kernel/eeh_driver.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
From: Sam Bobroff <hidden> Date: 2018-03-19 02:49:32
Checking for a "fully active" device state requires testing two flag
bits, which is open coded in several places, so add a function to do
it.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/include/asm/eeh.h | 6 ++++++
arch/powerpc/kernel/eeh.c | 19 ++++++-------------
arch/powerpc/platforms/powernv/eeh-powernv.c | 9 ++-------
3 files changed, 14 insertions(+), 20 deletions(-)
@@ -919,7 +913,7 @@ int eeh_pe_reset_full(struct eeh_pe *pe)/* Wait until the PE is in a functioning state */state=eeh_ops->wait_state(pe,PCI_BUS_RESET_WAIT_MSEC);-if((state&active_flags)==active_flags)+if(eeh_state_active(state))break;if(state<0){
@@ -1352,16 +1346,15 @@ static int eeh_pe_change_owner(struct eeh_pe *pe)structeeh_dev*edev,*tmp;structpci_dev*pdev;structpci_device_id*id;-intflags,ret;+intret;/* Check PE state */-flags=(EEH_STATE_MMIO_ACTIVE|EEH_STATE_DMA_ACTIVE);ret=eeh_ops->get_state(pe,NULL);if(ret<0||ret==EEH_STATE_NOT_SUPPORT)return0;/* Unfrozen PE, nothing to do */-if((ret&flags)==flags)+if(eeh_state_active(ret))return0;/* Frozen PE, check if it needs PE level reset */
From: kbuild test robot <hidden> Date: 2018-03-20 04:06:35
Hi Sam,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on v4.16-rc4]
[also build test ERROR on next-20180319]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sam-Bobroff/EEH-refactoring-1/20180320-024729
config: powerpc-ppc64_defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
All errors (new ones prefixed by >>):
In file included from include/linux/kernel.h:14:0,
from include/linux/delay.h:22,
from arch/powerpc/kernel/eeh_driver.c:25:
arch/powerpc/kernel/eeh_driver.c: In function 'eeh_reset_device':
quoted
arch/powerpc/kernel/eeh_driver.c:692:5: error: 'eeh_aware_driver' undeclared (first use in this function); did you mean 'eeh_state_active'?
(eeh_aware_driver ? "partial" : "complete"));
^
include/linux/printk.h:308:34: note: in definition of macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
arch/powerpc/kernel/eeh_driver.c:692:5: note: each undeclared identifier is reported only once for each function it appears in
(eeh_aware_driver ? "partial" : "complete"));
^
include/linux/printk.h:308:34: note: in definition of macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
vim +692 arch/powerpc/kernel/eeh_driver.c
5cfb20b96 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-09-30 619
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 620 /**
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 621 * eeh_reset_device - Perform actual reset of a pci slot
a10e51924 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 622 * @driver_eeh_aware: Does the device's driver provide EEH support?
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 623 * @pe: EEH PE
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 624 * @bus: PCI bus corresponding to the isolcated slot
a10e51924 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 625 * @rmv_data: Optional, list to record removed devices
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 626 *
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 627 * This routine must be called to do reset on the indicated PE.
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 628 * During the reset, udev might be invoked because those affected
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 629 * PCI devices will be removed and then added.
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 630 */
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 631 static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
a10e51924 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 632 struct eeh_rmv_data *rmv_data,
a10e51924 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 633 bool driver_eeh_aware)
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 634 {
edfd17ff3 arch/powerpc/kernel/eeh_driver.c Arnd Bergmann 2017-11-04 635 time64_t tstamp;
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 636 int cnt, rc;
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 637 struct eeh_dev *edev;
424054566 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2006-04-28 638
424054566 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2006-04-28 639 /* pcibios will clear the counter; save the value */
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 640 cnt = pe->freeze_count;
5a71978e4 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-06-20 641 tstamp = pe->tstamp;
424054566 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2006-04-28 642
20ee6a970 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-11 643 /*
20ee6a970 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-11 644 * We don't remove the corresponding PE instances because
20ee6a970 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-11 645 * we need the information afterwords. The attached EEH
20ee6a970 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-11 646 * devices are expected to be attached soon when calling
bd251b893 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-05-03 647 * into pci_hp_add_devices().
20ee6a970 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-11 648 */
807a827d4 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 649 eeh_pe_state_mark(pe, EEH_PE_KEEP);
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 650 if (driver_eeh_aware || (pe->type & EEH_PE_VF)) {
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 651 eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data);
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 652 } else {
1c2042c83 arch/powerpc/kernel/eeh_driver.c Rafael J. Wysocki 2014-01-15 653 pci_lock_rescan_remove();
bd251b893 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-05-03 654 pci_hp_remove_devices(bus);
1c2042c83 arch/powerpc/kernel/eeh_driver.c Rafael J. Wysocki 2014-01-15 655 pci_unlock_rescan_remove();
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 656 }
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 657
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 658 /*
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 659 * Reset the pci controller. (Asserts RST#; resets config space).
b6495c0c8 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 660 * Reconfigure bridges and devices. Don't try to bring the system
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 661 * up if the reset failed for some reason.
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 662 *
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 663 * During the reset, it's very dangerous to have uncontrolled PCI
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 664 * config accesses. So we prefer to block them. However, controlled
d0914f503 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 665 * PCI config accesses initiated from EEH itself are allowed.
29f8bf1b7 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-02-27 666 */
6654c9368 arch/powerpc/kernel/eeh_driver.c Russell Currey 2016-11-17 667 rc = eeh_pe_reset_full(pe);
28bf36f92 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-11-14 668 if (rc)
b6495c0c8 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 669 return rc;
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 670
1c2042c83 arch/powerpc/kernel/eeh_driver.c Rafael J. Wysocki 2014-01-15 671 pci_lock_rescan_remove();
1c2042c83 arch/powerpc/kernel/eeh_driver.c Rafael J. Wysocki 2014-01-15 672
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 673 /* Restore PE */
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 674 eeh_ops->configure_bridge(pe);
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 675 eeh_pe_restore_bars(pe);
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 676
dc9c41bd9 arch/powerpc/kernel/eeh_driver.c Andrew Donnellan 2015-12-08 677 /* Clear frozen state */
5cfb20b96 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-09-30 678 rc = eeh_clear_pe_frozen_state(pe, false);
409bf7f8a arch/powerpc/kernel/eeh_driver.c Andrew Donnellan 2016-12-01 679 if (rc) {
409bf7f8a arch/powerpc/kernel/eeh_driver.c Andrew Donnellan 2016-12-01 680 pci_unlock_rescan_remove();
789547006 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 681 return rc;
409bf7f8a arch/powerpc/kernel/eeh_driver.c Andrew Donnellan 2016-12-01 682 }
789547006 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2014-04-24 683
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 684 /* Give the system 5 seconds to finish running the user-space
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 685 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 686 * this is a hack, but if we don't do this, and try to bring
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 687 * the device up before the scripts have taken it down,
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 688 * potentially weird things happen.
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 689 */
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 690 if (!driver_eeh_aware || rmv_data->removed) {
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 691 pr_info("EEH: Sleep 5s ahead of %s hotplug\n",
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 @692 (eeh_aware_driver ? "partial" : "complete"));
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 693 ssleep(5);
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 694
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 695 /*
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 696 * The EEH device is still connected with its parent
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 697 * PE. We should disconnect it so the binding can be
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 698 * rebuilt when adding PCI devices.
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 699 */
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 700 edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 701 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
a3aa256b7 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-06-17 702 if (pe->type & EEH_PE_VF) {
67086e32b arch/powerpc/kernel/eeh_driver.c Wei Yang 2016-03-04 703 eeh_add_virt_device(edev, NULL);
a3aa256b7 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-06-17 704 } else {
e723e4b42 arch/powerpc/kernel/eeh_driver.c Sam Bobroff 2018-03-19 705 if (!eeh_aware_driver)
a3aa256b7 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-06-17 706 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
bd251b893 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-05-03 707 pci_hp_add_devices(bus);
a3aa256b7 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2016-06-17 708 }
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 709 }
f5c57710d arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-07-24 710 eeh_pe_state_clear(pe, EEH_PE_KEEP);
5a71978e4 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-06-20 711
5a71978e4 arch/powerpc/kernel/eeh_driver.c Gavin Shan 2013-06-20 712 pe->tstamp = tstamp;
9b3c76f08 arch/powerpc/platforms/pseries/eeh_driver.c Gavin Shan 2012-09-07 713 pe->freeze_count = cnt;
b6495c0c8 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 714
1c2042c83 arch/powerpc/kernel/eeh_driver.c Rafael J. Wysocki 2014-01-15 715 pci_unlock_rescan_remove();
b6495c0c8 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 716 return 0;
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 717 }
77bd74156 arch/powerpc/platforms/pseries/eeh_driver.c Linas Vepstas 2005-11-03 718
:::::: The code at line 692 was first introduced by commit
:::::: e723e4b4269eefe9c70fbb6c378a26ab202662e2 powerpc/eeh: Factor out common code eeh_reset_device()
:::::: TO: Sam Bobroff [off-list ref]
:::::: CC: 0day robot [off-list ref]
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: kbuild test robot <hidden> Date: 2018-03-20 08:32:48
Hi Sam,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on v4.16-rc4]
[also build test ERROR on next-20180319]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sam-Bobroff/EEH-refactoring-1/20180320-024729
config: powerpc-ppc64_defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
Note: the linux-review/Sam-Bobroff/EEH-refactoring-1/20180320-024729 HEAD 28e7cc1fa029b84221b827a6ea2908dc33b43d10 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
In file included from include/linux/kernel.h:14:0,
from include/linux/delay.h:22,
from arch/powerpc/kernel/eeh_driver.c:25:
arch/powerpc/kernel/eeh_driver.c: In function 'eeh_reset_device':
quoted
arch/powerpc/kernel/eeh_driver.c:692:5: error: 'eeh_aware_driver' undeclared (first use in this function); did you mean 'device_driver'?
(eeh_aware_driver ? "partial" : "complete"));
^
include/linux/printk.h:308:34: note: in definition of macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
arch/powerpc/kernel/eeh_driver.c:692:5: note: each undeclared identifier is reported only once for each function it appears in
(eeh_aware_driver ? "partial" : "complete"));
^
include/linux/printk.h:308:34: note: in definition of macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
vim +692 arch/powerpc/kernel/eeh_driver.c
619
620 /**
621 * eeh_reset_device - Perform actual reset of a pci slot
622 * @driver_eeh_aware: Does the device's driver provide EEH support?
623 * @pe: EEH PE
624 * @bus: PCI bus corresponding to the isolcated slot
625 * @rmv_data: Optional, list to record removed devices
626 *
627 * This routine must be called to do reset on the indicated PE.
628 * During the reset, udev might be invoked because those affected
629 * PCI devices will be removed and then added.
630 */
631 static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
632 struct eeh_rmv_data *rmv_data,
633 bool driver_eeh_aware)
634 {
635 time64_t tstamp;
636 int cnt, rc;
637 struct eeh_dev *edev;
638
639 /* pcibios will clear the counter; save the value */
640 cnt = pe->freeze_count;
641 tstamp = pe->tstamp;
642
643 /*
644 * We don't remove the corresponding PE instances because
645 * we need the information afterwords. The attached EEH
646 * devices are expected to be attached soon when calling
647 * into pci_hp_add_devices().
648 */
649 eeh_pe_state_mark(pe, EEH_PE_KEEP);
650 if (driver_eeh_aware || (pe->type & EEH_PE_VF)) {
651 eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data);
652 } else {
653 pci_lock_rescan_remove();
654 pci_hp_remove_devices(bus);
655 pci_unlock_rescan_remove();
656 }
657
658 /*
659 * Reset the pci controller. (Asserts RST#; resets config space).
660 * Reconfigure bridges and devices. Don't try to bring the system
661 * up if the reset failed for some reason.
662 *
663 * During the reset, it's very dangerous to have uncontrolled PCI
664 * config accesses. So we prefer to block them. However, controlled
665 * PCI config accesses initiated from EEH itself are allowed.
666 */
667 rc = eeh_pe_reset_full(pe);
668 if (rc)
669 return rc;
670
671 pci_lock_rescan_remove();
672
673 /* Restore PE */
674 eeh_ops->configure_bridge(pe);
675 eeh_pe_restore_bars(pe);
676
677 /* Clear frozen state */
678 rc = eeh_clear_pe_frozen_state(pe, false);
679 if (rc) {
680 pci_unlock_rescan_remove();
681 return rc;
682 }
683
684 /* Give the system 5 seconds to finish running the user-space
685 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
686 * this is a hack, but if we don't do this, and try to bring
687 * the device up before the scripts have taken it down,
688 * potentially weird things happen.
689 */
690 if (!driver_eeh_aware || rmv_data->removed) {
691 pr_info("EEH: Sleep 5s ahead of %s hotplug\n",
> 692 (eeh_aware_driver ? "partial" : "complete"));
693 ssleep(5);
694
695 /*
696 * The EEH device is still connected with its parent
697 * PE. We should disconnect it so the binding can be
698 * rebuilt when adding PCI devices.
699 */
700 edev = list_first_entry(&pe->edevs, struct eeh_dev, list);
701 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
702 if (pe->type & EEH_PE_VF) {
703 eeh_add_virt_device(edev, NULL);
704 } else {
705 if (!eeh_aware_driver)
706 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
707 pci_hp_add_devices(bus);
708 }
709 }
710 eeh_pe_state_clear(pe, EEH_PE_KEEP);
711
712 pe->tstamp = tstamp;
713 pe->freeze_count = cnt;
714
715 pci_unlock_rescan_remove();
716 return 0;
717 }
718
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: Sam Bobroff <hidden> Date: 2018-03-21 02:06:51
The caller will always pass NULL for 'rmv_data' when
'eeh_aware_driver' is true, so the first two calls to
eeh_pe_dev_traverse() can be combined without changing behaviour as
can the two arms of the final 'if' block.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
---
====== v2 -> v3: ======
Corrected two missed cases of eeh_aware_driver -> driver_eeh_aware.
arch/powerpc/kernel/eeh_driver.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
Hello everyone,
Here is a set of some small, mostly idempotent, changes to improve
maintainability in some of the EEH code, primarily in eeh_driver.c.
I've kept them all small to aid review but perhaps they should be squashed down
before being applied.
Cheers,
Sam.
Patch set changelog follows:
====== v1 -> v2: ======
Patch 1/9: powerpc/eeh: Remove eeh_handle_event()
Patch 2/9: powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
Patch 3/9: powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
Patch 4/9: powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
Patch 5/9: powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
Patch 6/9: powerpc/eeh: Clarify arguments to eeh_reset_device()
* Re-ordered parameters to eeh_reset_device() to keep pe first.
* Changed eeh_aware_driver to driver_eeh_aware.
Patch 7/9: powerpc/eeh: Remove always-true tests in eeh_reset_device()
Patch 8/9: powerpc/eeh: Factor out common code eeh_reset_device()
* In one case, added braces to "if" to match "else".
Patch 9/9: powerpc/eeh: Add eeh_state_active() helper
====== v1: ======
Patch 1/9: powerpc/eeh: Remove eeh_handle_event()
Patch 2/9: powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
Patch 3/9: powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
Patch 4/9: powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
Patch 5/9: powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
Patch 6/9: powerpc/eeh: Clarify arguments to eeh_reset_device()
Patch 7/9: powerpc/eeh: Remove always-true tests in eeh_reset_device()
Patch 8/9: powerpc/eeh: Factor out common code eeh_reset_device()
Patch 9/9: powerpc/eeh: Add eeh_state_active() helper
Sam Bobroff (9):
powerpc/eeh: Remove eeh_handle_event()
powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
powerpc/eeh: Clarify arguments to eeh_reset_device()
powerpc/eeh: Remove always-true tests in eeh_reset_device()
powerpc/eeh: Factor out common code eeh_reset_device()
powerpc/eeh: Add eeh_state_active() helper
arch/powerpc/include/asm/eeh.h | 6 ++
arch/powerpc/include/asm/eeh_event.h | 3 +-
arch/powerpc/kernel/eeh.c | 19 ++--
arch/powerpc/kernel/eeh_cache.c | 3 +-
arch/powerpc/kernel/eeh_driver.c | 137 +++++++++++----------------
arch/powerpc/kernel/eeh_event.c | 6 +-
arch/powerpc/platforms/powernv/eeh-powernv.c | 9 +-
7 files changed, 72 insertions(+), 111 deletions(-)
The function eeh_handle_event(pe) does nothing other than switching
between calling eeh_handle_normal_event(pe) and
eeh_handle_special_event(). However it is only called in two places,
one where pe can't be NULL and the other where it must be NULL (see
eeh_event_handler()) so it does nothing but obscure the flow of
control.
So, remove it.
Signed-off-by: Sam Bobroff <redacted>
@@ -81,10 +81,10 @@ static int eeh_event_handler(void * dummy)pr_info("EEH: Detected PCI bus error on ""PHB#%x-PE#%x\n",pe->phb->global_number,pe->addr);-eeh_handle_event(pe);+eeh_handle_normal_event(pe);eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}else{-eeh_handle_event(NULL);+eeh_handle_special_event();}kfree(event);
Currently the EEH_PE_RECOVERING flag for a PE is managed by both the
caller and callee of eeh_handle_normal_event() (among other places not
considered here). This is complicated by the fact that the PE may
or may not have been invalidated by the call.
So move the callee's handling into eeh_handle_normal_event(), which
clarifies it and allows the return type to be changed to void (because
it no longer needs to indicate at the PE has been invalidated).
This should not change behaviour except in eeh_event_handler() where
it was previously possible to cause eeh_pe_state_clear() to be called
on an invalid PE, which is now avoided.
Signed-off-by: Sam Bobroff <redacted>
@@ -940,12 +941,12 @@ bool eeh_handle_normal_event(struct eeh_pe *pe)pci_lock_rescan_remove();pci_hp_remove_devices(frozen_bus);pci_unlock_rescan_remove();-/* The passed PE should no longer be used */-returntrue;+return;}}-returnfalse;+final:+eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}/**
@@ -73,7 +73,6 @@ static int eeh_event_handler(void * dummy)/* We might have event without binding PE */pe=event->pe;if(pe){-eeh_pe_state_mark(pe,EEH_PE_RECOVERING);if(pe->type&EEH_PE_PHB)pr_info("EEH: Detected error on PHB#%x\n",pe->phb->global_number);
@@ -82,7 +81,6 @@ static int eeh_event_handler(void * dummy)"PHB#%x-PE#%x\n",pe->phb->global_number,pe->addr);eeh_handle_normal_event(pe);-eeh_pe_state_clear(pe,EEH_PE_RECOVERING);}else{eeh_handle_special_event();}
Commit "0ba178888b05 powerpc/eeh: Remove reference to PCI device"
removed a call to pci_dev_get() from __eeh_addr_cache_get_device() but
did not update the comment to match.
Signed-off-by: Sam Bobroff <redacted>
Remove a test that checks if "frozen_bus" is NULL, because it cannot
have changed since it was tested at the start of the function and so
must be true here.
Signed-off-by: Sam Bobroff <redacted>
@@ -930,20 +930,18 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*allremoveddevicescorrectlytoavoidaccess*thetheirPCIconfiganymore.*/-if(frozen_bus){-if(pe->type&EEH_PE_VF){-eeh_pe_dev_traverse(pe,eeh_rmv_device,NULL);-eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);-}else{-eeh_pe_state_clear(pe,EEH_PE_PRI_BUS);-eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);+if(pe->type&EEH_PE_VF){+eeh_pe_dev_traverse(pe,eeh_rmv_device,NULL);+eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);+}else{+eeh_pe_state_clear(pe,EEH_PE_PRI_BUS);+eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);-pci_lock_rescan_remove();-pci_hp_remove_devices(frozen_bus);-pci_unlock_rescan_remove();-/* The passed PE should no longer be used */-return;-}+pci_lock_rescan_remove();+pci_hp_remove_devices(frozen_bus);+pci_unlock_rescan_remove();+/* The passed PE should no longer be used */+return;}final:eeh_pe_state_clear(pe,EEH_PE_RECOVERING);
@@ -754,14 +754,14 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,*/voideeh_handle_normal_event(structeeh_pe*pe){-structpci_bus*frozen_bus;+structpci_bus*bus;structeeh_dev*edev,*tmp;intrc=0;enumpci_ers_resultresult=PCI_ERS_RESULT_NONE;structeeh_rmv_datarmv_data={LIST_HEAD_INIT(rmv_data.edev_list),0};-frozen_bus=eeh_pe_bus_get(pe);-if(!frozen_bus){+bus=eeh_pe_bus_get(pe);+if(!bus){pr_err("%s: Cannot find PCI bus for PHB#%x-PE#%x\n",__func__,pe->phb->global_number,pe->addr);return;
@@ -820,7 +820,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*/if(result==PCI_ERS_RESULT_NONE){pr_info("EEH: Reset with hotplug activity\n");-rc=eeh_reset_device(pe,frozen_bus,NULL);+rc=eeh_reset_device(pe,bus,NULL);if(rc){pr_warn("%s: Unable to reset, err=%d\n",__func__,rc);
@@ -938,7 +938,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)eeh_pe_dev_mode_mark(pe,EEH_DEV_REMOVED);pci_lock_rescan_remove();-pci_hp_remove_devices(frozen_bus);+pci_hp_remove_devices(bus);pci_unlock_rescan_remove();/* The passed PE should no longer be used */return;
It is currently difficult to understand the behaviour of
eeh_reset_device() due to the way it's parameters are used. In
particular, when 'bus' is NULL, it's value is still necessary so the
same value is looked up again locally under a different name
('frozen_bus') but behaviour is changed.
To clarify this, add a new parameter 'driver_eeh_aware', and have the
caller set it when it would have passed NULL for 'bus' and always pass
a value for 'bus'. Then change any test that was on 'bus' to one on
'!driver_eeh_aware' and replace uses of 'frozen_bus' with 'bus'.
Also update the function's comment.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
@@ -820,7 +822,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)*/if(result==PCI_ERS_RESULT_NONE){pr_info("EEH: Reset with hotplug activity\n");-rc=eeh_reset_device(pe,bus,NULL);+rc=eeh_reset_device(pe,bus,NULL,false);if(rc){pr_warn("%s: Unable to reset, err=%d\n",__func__,rc);
@@ -872,7 +874,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)/* If any device called out for a reset, then reset the slot */if(result==PCI_ERS_RESULT_NEED_RESET){pr_info("EEH: Reset without hotplug activity\n");-rc=eeh_reset_device(pe,NULL,&rmv_data);+rc=eeh_reset_device(pe,bus,&rmv_data,true);if(rc){pr_warn("%s: Cannot reset, err=%d\n",__func__,rc);
eeh_reset_device() tests the value of 'bus' more than once but the
only caller, eeh_handle_normal_device() does this test itself and will
never pass NULL.
So, remove the dead tests.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
The caller will always pass NULL for 'rmv_data' when
'eeh_aware_driver' is true, so the first two calls to
eeh_pe_dev_traverse() can be combined without changing behaviour as
can the two arms of the final 'if' block.
This should not change behaviour.
Signed-off-by: Sam Bobroff <redacted>
Checking for a "fully active" device state requires testing two flag
bits, which is open coded in several places, so add a function to do
it.
Signed-off-by: Sam Bobroff <redacted>
@@ -919,7 +913,7 @@ int eeh_pe_reset_full(struct eeh_pe *pe)/* Wait until the PE is in a functioning state */state=eeh_ops->wait_state(pe,PCI_BUS_RESET_WAIT_MSEC);-if((state&active_flags)==active_flags)+if(eeh_state_active(state))break;if(state<0){
@@ -1352,16 +1346,15 @@ static int eeh_pe_change_owner(struct eeh_pe *pe)structeeh_dev*edev,*tmp;structpci_dev*pdev;structpci_device_id*id;-intflags,ret;+intret;/* Check PE state */-flags=(EEH_STATE_MMIO_ACTIVE|EEH_STATE_DMA_ACTIVE);ret=eeh_ops->get_state(pe,NULL);if(ret<0||ret==EEH_STATE_NOT_SUPPORT)return0;/* Unfrozen PE, nothing to do */-if((ret&flags)==flags)+if(eeh_state_active(ret))return0;/* Frozen PE, check if it needs PE level reset */
From: Michael Ellerman <hidden> Date: 2018-03-28 14:13:26
On Mon, 2018-03-19 at 02:46:20 UTC, Sam Bobroff wrote:
The function eeh_handle_event(pe) does nothing other than switching
between calling eeh_handle_normal_event(pe) and
eeh_handle_special_event(). However it is only called in two places,
one where pe can't be NULL and the other where it must be NULL (see
eeh_event_handler()) so it does nothing but obscure the flow of
control.
So, remove it.
Signed-off-by: Sam Bobroff <redacted>
Reviewed-by: Alexey Kardashevskiy <redacted>