From: Sam Bobroff <hidden> Date: 2020-03-30 04:58:37
Hi everyone,
Here are some fixes and cleanups that have come from other work but that I
think stand on their own.
Only one patch ("Release EEH device state synchronously", suggested by Oliver
O'Halloran) is a significant change: it moves the cleanup of some EEH device
data out of the (possibly asynchronous) device release handler and into the
(synchronously called) bus notifier. This is useful for future work as it makes
it easier to reason about the lifetimes of EEH structures.
Note that I've left a few WARN_ON_ONCEs in the code because I'm paranoid, but I
have not been able to hit them during testing.
Cheers,
Sam.
Sam Bobroff (4):
powerpc/eeh: fix pseries_eeh_configure_bridge()
powerpc/eeh: Release EEH device state synchronously
powerpc/eeh: Remove workaround from eeh_add_device_late()
powerpc/eeh: Clean up edev cleanup for VFs
arch/powerpc/kernel/eeh.c | 49 +++++++++++---------
arch/powerpc/kernel/pci-hotplug.c | 2 -
arch/powerpc/kernel/pci_dn.c | 9 +---
arch/powerpc/platforms/pseries/eeh_pseries.c | 2 +-
4 files changed, 29 insertions(+), 33 deletions(-)
--
2.22.0.216.g00a2a96fc9
From: Sam Bobroff <hidden> Date: 2020-03-30 05:00:07
EEH device state is currently removed (by eeh_remove_device()) during
the device release handler, which is invoked as the device's reference
count drops to zero. This may take some time, or forever, as other
threads may hold references.
However, the PCI device state is released synchronously by
pci_stop_and_remove_bus_device(). This mismatch causes problems, for
example the device may be re-discovered as a new device before the
release handler has been called, leaving the PCI and EEH state
mismatched.
So instead, call eeh_remove_device() from the bus device removal
handlers, which are called synchronously in the removal path.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh.c | 26 ++++++++++++++++++++++++++
arch/powerpc/kernel/pci-hotplug.c | 2 --
2 files changed, 26 insertions(+), 2 deletions(-)
From: Sam Bobroff <hidden> Date: 2020-03-30 05:01:49
If a device is hot unplgged during EEH recovery, it's possible for the
RTAS call to ibm,configure-pe in pseries_eeh_configure() to return
parameter error (-3), however negative return values are not checked
for and this leads to an infinite loop.
Fix this by correctly bailing out on negative values.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/platforms/pseries/eeh_pseries.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Sam Bobroff <hidden> Date: 2020-03-30 05:03:24
When EEH device state was released asynchronously by the device
release handler, it was possible for an outstanding reference to
prevent it's release and it was necessary to work around that if a
device was re-discovered at the same PCI location.
Now that the state is released synchronously that is no longer
possible and the workaround is no longer necessary.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh.c | 23 +----------------------
1 file changed, 1 insertion(+), 22 deletions(-)
From: Sam Bobroff <hidden> Date: 2020-03-30 05:04:56
Because the bus notifier calls eeh_rmv_from_parent_pe() (via
eeh_remove_device()) when a VF is removed, the call in
remove_sriov_vf_pdns() is redundant.
So remove the call.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/pci_dn.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
From: Oliver O'Halloran <oohall@gmail.com> Date: 2020-04-03 04:21:05
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
If a device is hot unplgged during EEH recovery, it's possible for the
RTAS call to ibm,configure-pe in pseries_eeh_configure() to return
parameter error (-3), however negative return values are not checked
for and this leads to an infinite loop.
Fix this by correctly bailing out on negative values.
This should probably be a standalone patch. Looks fine otherwise.
Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
From: Oliver O'Halloran <oohall@gmail.com> Date: 2020-04-03 04:53:00
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted hunk
EEH device state is currently removed (by eeh_remove_device()) during
the device release handler, which is invoked as the device's reference
count drops to zero. This may take some time, or forever, as other
threads may hold references.
However, the PCI device state is released synchronously by
pci_stop_and_remove_bus_device(). This mismatch causes problems, for
example the device may be re-discovered as a new device before the
release handler has been called, leaving the PCI and EEH state
mismatched.
So instead, call eeh_remove_device() from the bus device removal
handlers, which are called synchronously in the removal path.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh.c | 26 ++++++++++++++++++++++++++
arch/powerpc/kernel/pci-hotplug.c | 2 --
2 files changed, 26 insertions(+), 2 deletions(-)
From: Oliver O'Halloran <oohall@gmail.com> Date: 2020-04-03 05:48:13
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
Because the bus notifier calls eeh_rmv_from_parent_pe() (via
eeh_remove_device()) when a VF is removed, the call in
remove_sriov_vf_pdns() is redundant.
eeh_rmv_from_parent_pe() won't actually remove the device if the
recovering flag is set on the PE. Are you sure we're not introducing a
race here?
From: Oliver O'Halloran <oohall@gmail.com> Date: 2020-04-03 06:10:29
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
When EEH device state was released asynchronously by the device
release handler, it was possible for an outstanding reference to
prevent it's release and it was necessary to work around that if a
device was re-discovered at the same PCI location.
I think this is a bit misleading. The main situation where you'll hit
this hack is when recovering a device with a driver that doesn't
implement the error handling callbacks. In that case the device is
removed, reset, then re-probed by the PCI core, but we assume it's the
same physical device so the eeh_device state remains active.
If you actually changed the underlying device I suspect something bad
would happen.
Now that the state is released synchronously that is no longer
possible and the workaround is no longer necessary.
You could probably fold this into the previous patch, but eh. You could
probably fold this into the previous patch, but eh.
From: Sam Bobroff <hidden> Date: 2020-04-08 06:17:56
On Fri, Apr 03, 2020 at 03:51:18PM +1100, Oliver O'Halloran wrote:
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted
EEH device state is currently removed (by eeh_remove_device()) during
the device release handler, which is invoked as the device's reference
count drops to zero. This may take some time, or forever, as other
threads may hold references.
However, the PCI device state is released synchronously by
pci_stop_and_remove_bus_device(). This mismatch causes problems, for
example the device may be re-discovered as a new device before the
release handler has been called, leaving the PCI and EEH state
mismatched.
So instead, call eeh_remove_device() from the bus device removal
handlers, which are called synchronously in the removal path.
Signed-off-by: Sam Bobroff <redacted>
---
arch/powerpc/kernel/eeh.c | 26 ++++++++++++++++++++++++++
arch/powerpc/kernel/pci-hotplug.c | 2 --
2 files changed, 26 insertions(+), 2 deletions(-)
From: Sam Bobroff <hidden> Date: 2020-04-08 06:23:52
On Fri, Apr 03, 2020 at 05:08:32PM +1100, Oliver O'Halloran wrote:
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted
When EEH device state was released asynchronously by the device
release handler, it was possible for an outstanding reference to
prevent it's release and it was necessary to work around that if a
device was re-discovered at the same PCI location.
I think this is a bit misleading. The main situation where you'll hit
this hack is when recovering a device with a driver that doesn't
implement the error handling callbacks. In that case the device is
removed, reset, then re-probed by the PCI core, but we assume it's the
same physical device so the eeh_device state remains active.
If you actually changed the underlying device I suspect something bad
would happen.
I'm not sure I understand. Isn't the case you're talking about caught by
the earlier check (just above the patch)?
if (edev->pdev == dev) {
eeh_edev_dbg(edev, "Device already referenced!\n");
return;
}
quoted
Now that the state is released synchronously that is no longer
possible and the workaround is no longer necessary.
You could probably fold this into the previous patch, but eh. You could
probably fold this into the previous patch, but eh.
From: Sam Bobroff <hidden> Date: 2020-04-08 06:35:27
On Fri, Apr 03, 2020 at 04:45:47PM +1100, Oliver O'Halloran wrote:
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted
Because the bus notifier calls eeh_rmv_from_parent_pe() (via
eeh_remove_device()) when a VF is removed, the call in
remove_sriov_vf_pdns() is redundant.
eeh_rmv_from_parent_pe() won't actually remove the device if the
recovering flag is set on the PE. Are you sure we're not introducing a
race here?
Ah, I assume you're referring to the difference between calling
eeh_remove_device() and directly calling eeh_rmv_from_parent_pe(), where
the behaviour for PE's with EEH_PE_KEEP set is subtly different.
I'll take a closer look at it and make sure to explain it better in v2.
On Wed, Apr 8, 2020 at 4:22 PM Sam Bobroff [off-list ref] wrote:
On Fri, Apr 03, 2020 at 05:08:32PM +1100, Oliver O'Halloran wrote:
quoted
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted
When EEH device state was released asynchronously by the device
release handler, it was possible for an outstanding reference to
prevent it's release and it was necessary to work around that if a
device was re-discovered at the same PCI location.
I think this is a bit misleading. The main situation where you'll hit
this hack is when recovering a device with a driver that doesn't
implement the error handling callbacks. In that case the device is
removed, reset, then re-probed by the PCI core, but we assume it's the
same physical device so the eeh_device state remains active.
If you actually changed the underlying device I suspect something bad
would happen.
I'm not sure I understand. Isn't the case you're talking about caught by
the earlier check (just above the patch)?
if (edev->pdev == dev) {
eeh_edev_dbg(edev, "Device already referenced!\n");
return;
}
No, in the case I'm talking about the pci_dev is torn down and
freed(). After the PE is reset we re-probe the device and create a new
pci_dev. If the release of the old pci_dev is delayed we need the
hack this patch is removing.
The check above should probably be a WARN_ON() since we should never
be re-running the EEH probe on the same device. I think there is a
case where that can happen, but I don't remember the details.
Oliver
From: Sam Bobroff <hidden> Date: 2020-04-15 06:47:04
On Wed, Apr 08, 2020 at 04:53:36PM +1000, Oliver O'Halloran wrote:
On Wed, Apr 8, 2020 at 4:22 PM Sam Bobroff [off-list ref] wrote:
quoted
On Fri, Apr 03, 2020 at 05:08:32PM +1100, Oliver O'Halloran wrote:
quoted
On Mon, 2020-03-30 at 15:56 +1100, Sam Bobroff wrote:
quoted
When EEH device state was released asynchronously by the device
release handler, it was possible for an outstanding reference to
prevent it's release and it was necessary to work around that if a
device was re-discovered at the same PCI location.
I think this is a bit misleading. The main situation where you'll hit
this hack is when recovering a device with a driver that doesn't
implement the error handling callbacks. In that case the device is
removed, reset, then re-probed by the PCI core, but we assume it's the
same physical device so the eeh_device state remains active.
If you actually changed the underlying device I suspect something bad
would happen.
I'm not sure I understand. Isn't the case you're talking about caught by
the earlier check (just above the patch)?
if (edev->pdev == dev) {
eeh_edev_dbg(edev, "Device already referenced!\n");
return;
}
No, in the case I'm talking about the pci_dev is torn down and
freed(). After the PE is reset we re-probe the device and create a new
pci_dev. If the release of the old pci_dev is delayed we need the
hack this patch is removing.
Oh, yes, that is the case I was intending to change here. But I must be
missing something, isn't it also the case that's changed by patch 2/4?
What I intended was, after patch 2, eeh_remove_device() is called from
the bus notifier so it happens imediately when recovery calls
pci_stop_and_remove_bus_device(). Once it returns, edev->pdev has
already been set to NULL by eeh_remove_device() so this case can't be
hit anymore, and we should clean it up (this patch).
(There is a slight difference in the way EEH_PE_KEEP is handled between
the code removed here and the body of eeh_remove_device(), but checking
and explaining that is already on my list for v2.)
(I did test recovery on an unaware device and didn't hit the
WARN_ON_ONCE().)
The check above should probably be a WARN_ON() since we should never
be re-running the EEH probe on the same device. I think there is a
case where that can happen, but I don't remember the details.
Yeah, I also certainly see the "Device already referenced!" message
while debugging, and it would be good to track down.