提交 918b4053 编写于 作者: V Vijay Mohan Pandarathil 提交者: Bjorn Helgaas

PCI/AER: Report success only when every device has AER-aware driver

When an error is detected on a PCIe device which does not have an
AER-aware driver, prevent AER infrastructure from reporting
successful error recovery.

This is because the report_error_detected() function that gets
called in the first phase of recovery process allows forward
progress even when the driver for the device does not have AER
capabilities. It seems that all callbacks (in pci_error_handlers
structure) registered by drivers that gets called during error
recovery are not mandatory. So the intention of the infrastructure
design seems to be to allow forward progress even when a specific
callback has not been registered by a driver. However, if error
handler structure itself has not been registered, it doesn't make
sense to allow forward progress.

As a result of the current design, in the case of a single device
having an AER-unaware driver or in the case of any function in a
multi-function card having an AER-unaware driver, a successful
recovery is reported.

Typical scenario this happens is when a PCI device is detached
from a KVM host and the pci-stub driver on the host claims the
device. The pci-stub driver does not have error handling capabilities
but the AER infrastructure still reports that the device recovered
successfully.

The changes proposed here leaves the device(s)in an unrecovered state
if the driver for the device or for any device in the subtree
does not have error handler structure registered. This reflects
the true state of the device and prevents any partial recovery (or no
recovery at all) reported as successful.

[bhelgaas: changelog]
Signed-off-by: NVijay Mohan Pandarathil <vijaymohan.pandarathil@hp.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: NLinas Vepstas <linasvepstas@gmail.com>
Reviewed-by: NMyron Stowe <myron.stowe@redhat.com>
上级 71fbad6c
...@@ -87,6 +87,9 @@ struct aer_broadcast_data { ...@@ -87,6 +87,9 @@ struct aer_broadcast_data {
static inline pci_ers_result_t merge_result(enum pci_ers_result orig, static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
enum pci_ers_result new) enum pci_ers_result new)
{ {
if (new == PCI_ERS_RESULT_NO_AER_DRIVER)
return PCI_ERS_RESULT_NO_AER_DRIVER;
if (new == PCI_ERS_RESULT_NONE) if (new == PCI_ERS_RESULT_NONE)
return orig; return orig;
...@@ -97,7 +100,7 @@ static inline pci_ers_result_t merge_result(enum pci_ers_result orig, ...@@ -97,7 +100,7 @@ static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
break; break;
case PCI_ERS_RESULT_DISCONNECT: case PCI_ERS_RESULT_DISCONNECT:
if (new == PCI_ERS_RESULT_NEED_RESET) if (new == PCI_ERS_RESULT_NEED_RESET)
orig = new; orig = PCI_ERS_RESULT_NEED_RESET;
break; break;
default: default:
break; break;
......
...@@ -231,11 +231,26 @@ static int report_error_detected(struct pci_dev *dev, void *data) ...@@ -231,11 +231,26 @@ static int report_error_detected(struct pci_dev *dev, void *data)
dev->driver ? dev->driver ?
"no AER-aware driver" : "no driver"); "no AER-aware driver" : "no driver");
} }
return 0;
/*
* If there's any device in the subtree that does not
* have an error_detected callback, returning
* PCI_ERS_RESULT_NO_AER_DRIVER prevents calling of
* the subsequent mmio_enabled/slot_reset/resume
* callbacks of "any" device in the subtree. All the
* devices in the subtree are left in the error state
* without recovery.
*/
if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE))
vote = PCI_ERS_RESULT_NO_AER_DRIVER;
else
vote = PCI_ERS_RESULT_NONE;
} else {
err_handler = dev->driver->err_handler;
vote = err_handler->error_detected(dev, result_data->state);
} }
err_handler = dev->driver->err_handler;
vote = err_handler->error_detected(dev, result_data->state);
result_data->result = merge_result(result_data->result, vote); result_data->result = merge_result(result_data->result, vote);
return 0; return 0;
} }
......
...@@ -538,6 +538,9 @@ enum pci_ers_result { ...@@ -538,6 +538,9 @@ enum pci_ers_result {
/* Device driver is fully recovered and operational */ /* Device driver is fully recovered and operational */
PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5, PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
/* No AER capabilities registered for the driver */
PCI_ERS_RESULT_NO_AER_DRIVER = (__force pci_ers_result_t) 6,
}; };
/* PCI bus error event callbacks */ /* PCI bus error event callbacks */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册