* [PATCH] PCI/ERR: handle disconnected devices in report_error_detected
@ 2022-06-01 7:40 Christoph Hellwig
2022-06-08 5:02 ` Sathyanarayanan Kuppuswamy
2022-06-08 20:11 ` Bjorn Helgaas
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-06-01 7:40 UTC (permalink / raw)
To: ruscur, oohall, bhelgaas; +Cc: linuxppc-dev, linux-pci, kbusch
When a device is already unplugged by pciehp by the time that the AER
handler is invoked, the PCIe device will lready be in the
pci_channel_io_perm_failure state. In that case we should simply
return PCI_ERS_RESULT_DISCONNECT instead of trying to do a state
transition that will fail.
Also untangle the state transition failure from the lack of methods to
improve the debugging output in case it will happen ever again.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/pci/pcie/err.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 0c5a143025af4..59c90d04a609a 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -55,10 +55,14 @@ static int report_error_detected(struct pci_dev *dev,
device_lock(&dev->dev);
pdrv = dev->driver;
- if (!pci_dev_set_io_state(dev, state) ||
- !pdrv ||
- !pdrv->err_handler ||
- !pdrv->err_handler->error_detected) {
+ if (pci_dev_is_disconnected(dev)) {
+ vote = PCI_ERS_RESULT_DISCONNECT;
+ } else if (!pci_dev_set_io_state(dev, state)) {
+ pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
+ dev->error_state, state);
+ vote = PCI_ERS_RESULT_NONE;
+ } else if (!pdrv || !pdrv->err_handler ||
+ !pdrv->err_handler->error_detected) {
/*
* If any device in the subtree does not have an error_detected
* callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/ERR: handle disconnected devices in report_error_detected
2022-06-01 7:40 [PATCH] PCI/ERR: handle disconnected devices in report_error_detected Christoph Hellwig
@ 2022-06-08 5:02 ` Sathyanarayanan Kuppuswamy
2022-06-08 20:11 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2022-06-08 5:02 UTC (permalink / raw)
To: Christoph Hellwig, ruscur, oohall, bhelgaas
Cc: linuxppc-dev, linux-pci, kbusch
Hi,
On 6/1/22 12:40 AM, Christoph Hellwig wrote:
> When a device is already unplugged by pciehp by the time that the AER
> handler is invoked, the PCIe device will lready be in the
/s/lready/already
> pci_channel_io_perm_failure state. In that case we should simply
> return PCI_ERS_RESULT_DISCONNECT instead of trying to do a state
> transition that will fail.
>
> Also untangle the state transition failure from the lack of methods to
> improve the debugging output in case it will happen ever again.
Otherwise, it looks good to me.
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/pci/pcie/err.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 0c5a143025af4..59c90d04a609a 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -55,10 +55,14 @@ static int report_error_detected(struct pci_dev *dev,
>
> device_lock(&dev->dev);
> pdrv = dev->driver;
> - if (!pci_dev_set_io_state(dev, state) ||
> - !pdrv ||
> - !pdrv->err_handler ||
> - !pdrv->err_handler->error_detected) {
> + if (pci_dev_is_disconnected(dev)) {
> + vote = PCI_ERS_RESULT_DISCONNECT;
> + } else if (!pci_dev_set_io_state(dev, state)) {
> + pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
> + dev->error_state, state);
> + vote = PCI_ERS_RESULT_NONE;
> + } else if (!pdrv || !pdrv->err_handler ||
> + !pdrv->err_handler->error_detected) {
> /*
> * If any device in the subtree does not have an error_detected
> * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/ERR: handle disconnected devices in report_error_detected
2022-06-01 7:40 [PATCH] PCI/ERR: handle disconnected devices in report_error_detected Christoph Hellwig
2022-06-08 5:02 ` Sathyanarayanan Kuppuswamy
@ 2022-06-08 20:11 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2022-06-08 20:11 UTC (permalink / raw)
To: Christoph Hellwig
Cc: ruscur, oohall, bhelgaas, kbusch, linux-pci, linuxppc-dev
On Wed, Jun 01, 2022 at 09:40:24AM +0200, Christoph Hellwig wrote:
> When a device is already unplugged by pciehp by the time that the AER
> handler is invoked, the PCIe device will lready be in the
> pci_channel_io_perm_failure state. In that case we should simply
> return PCI_ERS_RESULT_DISCONNECT instead of trying to do a state
> transition that will fail.
>
> Also untangle the state transition failure from the lack of methods to
> improve the debugging output in case it will happen ever again.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Applied with Sathy's reviewed-by to pci/err for v5.20, thanks!
> ---
> drivers/pci/pcie/err.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 0c5a143025af4..59c90d04a609a 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -55,10 +55,14 @@ static int report_error_detected(struct pci_dev *dev,
>
> device_lock(&dev->dev);
> pdrv = dev->driver;
> - if (!pci_dev_set_io_state(dev, state) ||
> - !pdrv ||
> - !pdrv->err_handler ||
> - !pdrv->err_handler->error_detected) {
> + if (pci_dev_is_disconnected(dev)) {
> + vote = PCI_ERS_RESULT_DISCONNECT;
> + } else if (!pci_dev_set_io_state(dev, state)) {
> + pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
> + dev->error_state, state);
> + vote = PCI_ERS_RESULT_NONE;
> + } else if (!pdrv || !pdrv->err_handler ||
> + !pdrv->err_handler->error_detected) {
> /*
> * If any device in the subtree does not have an error_detected
> * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-08 20:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 7:40 [PATCH] PCI/ERR: handle disconnected devices in report_error_detected Christoph Hellwig
2022-06-08 5:02 ` Sathyanarayanan Kuppuswamy
2022-06-08 20:11 ` Bjorn Helgaas
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).