Address error and recovery for AER and DPC
Subsystems (3)
v14 cover Address error and recovery for AER and DPC
This patch set brings in error handling support for DPC
The current implementation of AER and error message broadcasting to the EP driver is tightly coupled and limited to AER service driver. It is important to factor out broadcasting and other link handling callbacks. So that not only when AER gets triggered, but also when DPC get triggered (for e.g. ERR_FATAL), callbacks are handled appropriately.
The goal of the patch-set is:
DPC should handle the error handling and recovery similar to AER, because finally both are attempting recovery in some or the other way, and for that error handling and recovery framework has to be loosely coupled.
It achieves uniformity and transparency to the error handling agents such as AER, DPC, with respect to recovery and error handling.
So, this patch-set tries to unify lot of things between error agents and make them behave in a well defined way. (be it error (FATAL, NON_FATAL) handling or recovery).
The FATAL error handling is handled with remove/reset_link/re-enumerate sequence while the NON_FATAL follows the default path. Documentation/PCI/pci-error-recovery.txt talks more on that.
Changes since v13:
Bjorn's comments addressed
> handke FATAL errors with remove devices followed by re-enumeration. > changes in AER and DPC along with required Documentation.
Changes since v12:
Bjorn's and Keith's Comments addressed.
> Made DPC and AER error handling identical <aligned err.c>
> hanldled cases for hotplug enabled system differently.
Changes since v11:
Bjorn's comments addressed.
> rename pcie-err.c to err.c
> removed EXPORT_SYMBOL
> made generic find_serivce function in port driver.
> removed mutex patch as no need to have mutex in pcie_do_recovery > brough in DPC_FATAL in aer.h
> so now all the error codes (AER and DPC) are unified in aer.h
Changes since v10:
Christoph Hellwig's, David Laight's and Randy Dunlap's
comments addressed.
> renamed pci_do_recovery to pcie_do_recovery
> removed inner braces in conditional statements.
> restrctured the code in pci_wait_for_link
> EXPORT_SYMBOL_GPL
Changes since v9:
Sinan's comments addressed.
> bool active = true; unnecessary variable removed.
Changes since v8:
Fixed Kbuild errors.
Changes since v7:
Rebased the code on pci master
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/helgaas/pci
Changes since v6:
Sinan's and Stefan's comments implemented.
> reordered patch 6 and 7
> cleaned up
Changes since v5:
Sinan's and Keith's comments incorporated.
> made separate patch for mutex
> unified error repotting codes into driver/pci/pci.h
> got rid of wait link active/inactive and
made generic function in driver/pci/pci.c
Changes since v4:
Bjorn's comments incorporated.
> Renamed only do_recovery.
> moved the things more locally to drivers/pci/pci.h
Changes since v3:
Bjorn's comments incorporated.
> Made separate patch renaming generic pci_err.c
> Introduce pci_err.h to contain all the error types and recovery > removed all the dependencies on pci.h
Changes since v2:
Based on feedback from Keith:
"
When DPC is triggered due to receipt of an uncorrectable error Message, the Requester ID from the Message is recorded in the DPC Error Source ID register and that Message is discarded and not forwarded Upstream. "
Removed the patch where AER checks if DPC service is active
Changes since v1:
Kbuild errors fixed:
> pci_find_dpc_dev made static
> ras_event.h updated
> pci_find_aer_service call with CONFIG check
> pci_find_dpc_service call with CONFIG check
Oza Pawandeep (9):
PCI/AER: Rename error recovery to generic PCI naming PCI/AER: Factor out error reporting from AER PCI/PORTDRV: Implement generic find service PCI/PORTDRV: Implement generic find device PCI/DPC: Unify and plumb error handling into DPC
PCI: Unify wait for link active into generic PCI PCI/DPC: Disable ERR_NONFATAL for DPC PCI/AER/DPC: Align FATAL error handling for AER and DPC
pci-error-recovery: Add AER_FATAL handling
Documentation/PCI/pci-error-recovery.txt | 35 ++- drivers/pci/hotplug/pciehp_hpc.c | 20 +- drivers/pci/pci.c | 30 +++ drivers/pci/pci.h | 5 + drivers/pci/pcie/Makefile | 2 +- drivers/pci/pcie/aer/aerdrv.c | 2 + drivers/pci/pcie/aer/aerdrv.h | 30 --- drivers/pci/pcie/aer/aerdrv_core.c | 317 +------------------------- drivers/pci/pcie/err.c | 374 +++++++++++++++++++++++++++++++ drivers/pci/pcie/pcie-dpc.c | 63 +++--- drivers/pci/pcie/portdrv.h | 4 + drivers/pci/pcie/portdrv_core.c | 69 ++++++ include/linux/aer.h | 2 + include/uapi/linux/pci_regs.h | 3 +- 14 files changed, 552 insertions(+), 404 deletions(-) create mode 100644 drivers/pci/pcie/err.c
Signature · 1 line
2.7.4
PATCH v14 1/9 PCI/AER: Rename error recovery to generic PCI naming
This patch renames error recovery to generic name with pcie prefix
drivers/pci/pci.h +3 -0
@@ -342,6 +342,9 @@ static inline resource_size_t pci_resource_alignment(struct pci_dev *dev,void pci_enable_acs (struct pci_dev *dev); +/* PCI error reporting and recovery */ +void pcie_do_recovery (struct pci_dev *dev,int severity); +#ifdef CONFIG_PCIEASPM void pcie_aspm_init_link_state (struct pci_dev *pdev);void pcie_aspm_exit_link_state (struct pci_dev *pdev);
drivers/pci/pcie/aer/aerdrv_core.c +4 -4
@@ -478,7 +478,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) }/** -* do_recovery - handle nonfatal/fatal error recovery process +* pcie_do_recovery - handle nonfatal/fatal error recovery process * @dev: pointer to a pci_dev data structure of agent detecting an error * @severity: error severity type *
@@ -486,7 +486,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)* error detected message to all downstream drivers within a hierarchy in * question and return the returned code. */ -static void do_recovery (struct pci_dev *dev,int severity) +static void pcie_do_recovery (struct pci_dev *dev,int severity) {pci_ers_result_t status, result =PCI_ERS_RESULT_RECOVERED ;enum pci_channel_state state;
@@ -566,7 +566,7 @@ static void handle_error_source(struct pcie_device *aerdev,pci_write_config_dword (dev, pos +PCI_ERR_COR_STATUS , info->status); }else -do_recovery (dev, info->severity); +pcie_do_recovery (dev, info->severity); }#ifdef CONFIG_ACPI_APEI_PCIEAER
@@ -631,7 +631,7 @@ static void aer_recover_work_func(struct work_struct *work) }cper_print_aer (pdev, entry.severity, entry.regs);if (entry.severity !=AER_CORRECTABLE ) -do_recovery (pdev, entry.severity); +pcie_do_recovery (pdev, entry.severity);pci_dev_put (pdev); } }
Signature · 1 line
2.7.4
PATCH v14 2/9 PCI/AER: Factor out error reporting from AER
In reply to Oza PawandeepThis patch factors out error reporting callbacks, which are currently tightly coupled with AER.
DPC should be able to register callbacks and attempt recovery when DPC trigger event occurs.
drivers/pci/pcie/Makefile +1 -1
@@ -6,7 +6,7 @@ # Build PCI Express ASPM if needed obj-$(CONFIG_PCIEASPM) += aspm.o -pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o +pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o err.o pcieportdrv-$(CONFIG_ACPI) += portdrv_acpi.o obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o
drivers/pci/pcie/aer/aerdrv.h +0 -30
@@ -76,36 +76,6 @@ struct aer_rpc {*/ }; -struct aer_broadcast_data { -enum pci_channel_state state; -enum pci_ers_result result; -}; - -static inline pci_ers_result_t merge_result (enum pci_ers_result orig, -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 ) -return orig; - -switch (orig) { -case PCI_ERS_RESULT_CAN_RECOVER : -case PCI_ERS_RESULT_RECOVERED : - orig = new; -break ; -case PCI_ERS_RESULT_DISCONNECT : -if (new ==PCI_ERS_RESULT_NEED_RESET ) - orig =PCI_ERS_RESULT_NEED_RESET ; -break ; -default : -break ; - } - -return orig; -} -extern struct bus_type pcie_port_bus_type;void aer_isr (struct work_struct *work);void aer_print_error (struct pci_dev *dev,struct aer_err_info *info);
drivers/pci/pcie/aer/aerdrv_core.c +2 -287
313 lines not on this page · raw message
drivers/pci/pcie/err.c new file +334 -0
334 lines not on this page · raw message
drivers/pci/pcie/portdrv.h +1 -0
@@ -79,4 +79,5 @@ static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask)static inline void pcie_port_platform_notify (struct pci_dev *port,int *mask){}#endif /* !CONFIG_ACPI */ +struct pcie_port_service_driver *find_aer_service (struct pci_dev *dev);#endif /* _PORTDRV_H_ */
Signature · 1 line
2.7.4
PATCH v14 3/9 PCI/PORTDRV: Implement generic find service
In reply to Oza PawandeepThis patch implements generic pcie_port_find_service() routine.
drivers/pci/pcie/aer/aerdrv_core.c +0 -26
@@ -231,32 +231,6 @@ static bool find_source_device(struct pci_dev *parent,return true; } -static int find_aer_service_iter (struct device *device,void *data) -{ -struct pcie_port_service_driver *service_driver, **drv; - - drv = (struct pcie_port_service_driver **) data; - -if (device->bus == &pcie_port_bus_type && device->driver) { - service_driver =to_service_driver (device->driver); -if (service_driver->service ==PCIE_PORT_SERVICE_AER ) { - *drv = service_driver; -return 1 ; - } - } - -return 0 ; -} - -struct pcie_port_service_driver *find_aer_service (struct pci_dev *dev) -{ -struct pcie_port_service_driver *drv =NULL ; - -device_for_each_child (&dev->dev, &drv, find_aer_service_iter); - -return drv; -} -/** * handle_error_source - handle logging error into an event log * @aerdev: pointer to pcie_device data structure of the root port
drivers/pci/pcie/err.c +1 -3
@@ -193,10 +193,8 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) udev = dev->bus->self; } -#if IS_ENABLED (CONFIG_PCIEAER )/* Use the aer driver of the component firstly */ - driver =find_aer_service (udev); -#endif + driver =pcie_port_find_service (udev,PCIE_PORT_SERVICE_AER );if (driver && driver->reset_link) { status = driver->reset_link (udev);
drivers/pci/pcie/portdrv.h +2 -1
@@ -79,5 +79,6 @@ static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask)static inline void pcie_port_platform_notify (struct pci_dev *port,int *mask){}#endif /* !CONFIG_ACPI */ -struct pcie_port_service_driver *find_aer_service (struct pci_dev *dev); +struct pcie_port_service_driver *pcie_port_find_service (struct pci_dev *dev, +u32 service);#endif /* _PORTDRV_H_ */
drivers/pci/pcie/portdrv_core.c +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v14 4/9 PCI/PORTDRV: Implement generic find device
In reply to Oza PawandeepThis patch implements generic pcie_port_find_device() routine.
drivers/pci/pcie/portdrv.h +2 -0
@@ -81,4 +81,6 @@ static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){}struct pcie_port_service_driver *pcie_port_find_service (struct pci_dev *dev,u32 service); +struct device *pcie_port_find_device (struct pci_dev *dev, +u32 service);#endif /* _PORTDRV_H_ */
drivers/pci/pcie/portdrv_core.c +24 -0
@@ -25,6 +25,7 @@ bool pciehp_msi_disabled;struct portdrv_service_data {struct pcie_port_service_driver *drv; +struct device *dev;u32 service; };
@@ -432,12 +433,14 @@ static int find_service_iter(struct device *device, void *data) service_driver =to_service_driver (device->driver);if (service_driver->service == service) { pdrvs->drv = service_driver; + pdrvs->dev = device;return 1 ; } }return 0 ; } +/** * pcie_port_find_service - find the service driver * @dev: PCI Express port the service devices associated with
@@ -460,6 +463,27 @@ struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev, }/** +* pcie_port_find_device - find the struct device +* @dev: PCI Express port the service devices associated with +* @service: For the service to find +* +* Find PCI Express port service driver associated with given service +*/ +struct device *pcie_port_find_device (struct pci_dev *dev, +u32 service) +{ +struct device *device; +struct portdrv_service_data pdrvs; + + pdrvs.dev =NULL ; + pdrvs.service = service; +device_for_each_child (&dev->dev, &pdrvs, find_service_iter); + + device = pdrvs.dev; +return device; +} + +/** * pcie_port_device_remove - unregister PCI Express port service devices * @dev: PCI Express port the service devices to unregister are associated with *
Signature · 1 line
2.7.4
PATCH v14 5/9 PCI/DPC: Unify and plumb error handling into DPC
In reply to Oza PawandeepCurrent DPC driver does not do recovery, e.g. calling end-point's driver's callbacks, which sanitize the sw.
DPC driver implements link_reset callback, and calls pci_do_recovery().
drivers/pci/pcie/err.c +14 -6
@@ -19,6 +19,7 @@#include <linux/aer.h> #include <linux/pcieport_if.h> #include "portdrv.h" +#include "./../pci.h" struct aer_broadcast_data {enum pci_channel_state state;
@@ -179,11 +180,12 @@ static pci_ers_result_t default_reset_link(struct pci_dev *dev)return PCI_ERS_RESULT_RECOVERED ; } -static pci_ers_result_t reset_link (struct pci_dev *dev) +static pci_ers_result_t reset_link (struct pci_dev *dev,int severity) {struct pci_dev *udev;pci_ers_result_t status;struct pcie_port_service_driver *driver =NULL ; +u32 service;if (dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) {/* Reset this port for all subordinates */
@@ -193,8 +195,12 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) udev = dev->bus->self; } -/* Use the aer driver of the component firstly */ - driver =pcie_port_find_service (udev,PCIE_PORT_SERVICE_AER ); +if (severity ==DPC_FATAL ) + service =PCIE_PORT_SERVICE_DPC ; +else + service =PCIE_PORT_SERVICE_AER ; + + driver =pcie_port_find_service (udev, service);if (driver && driver->reset_link) { status = driver->reset_link (udev);
@@ -281,7 +287,8 @@ void pcie_do_recovery(struct pci_dev *dev, int severity)pci_ers_result_t status, result =PCI_ERS_RESULT_RECOVERED ;enum pci_channel_state state; -if (severity ==AER_FATAL ) +if ((severity ==AER_FATAL ) || + (severity ==DPC_FATAL )) state = pci_channel_io_frozen;else state = pci_channel_io_normal;
@@ -291,8 +298,9 @@ void pcie_do_recovery(struct pci_dev *dev, int severity)"error_detected" , report_error_detected); -if (severity ==AER_FATAL ) { - result =reset_link (dev); +if ((severity ==AER_FATAL ) || + (severity ==DPC_FATAL )) { + result =reset_link (dev, severity);if (result !=PCI_ERS_RESULT_RECOVERED ) goto failed; }
drivers/pci/pcie/pcie-dpc.c +30 -5
@@ -13,6 +13,7 @@#include <linux/pcieport_if.h> #include "../pci.h" #include "aer/aerdrv.h" +#include "portdrv.h" struct dpc_dev {struct pcie_device *dev;
@@ -82,12 +83,25 @@ static void dpc_wait_link_inactive(struct dpc_dev *dpc)dev_warn (dev,"Link state not disabled for DPC event\n" ); } -static void dpc_work (struct work_struct *work) +/** +* dpc_reset_link - reset link DPC routine +* @pdev: pointer to Root Port's pci_dev data structure +* +* Invoked by Port Bus driver when performing link reset at Root Port. +*/ +static pci_ers_result_t dpc_reset_link (struct pci_dev *pdev) { - struct dpc_dev *dpc = container_of(work, struct dpc_dev, work); -struct pci_dev *dev, *temp, *pdev = dpc->dev->port;struct pci_bus *parent = pdev->subordinate; -u16 cap = dpc->cap_pos, ctl; +struct pci_dev *dev, *temp; +struct dpc_dev *dpc; +struct pcie_device *pciedev; +struct device *devdpc; +u16 cap, ctl; + + devdpc =pcie_port_find_device (pdev,PCIE_PORT_SERVICE_DPC ); + pciedev =to_pcie_device (devdpc); + dpc =get_service_data (pciedev); + cap = dpc->cap_pos;pci_lock_rescan_remove (); list_for_each_entry_safe_reverse(dev, temp, &parent->devices,
@@ -104,7 +118,7 @@ static void dpc_work(struct work_struct *work)dpc_wait_link_inactive (dpc);if (dpc->rp_extensions &&dpc_wait_rp_inactive (dpc)) -return ; +return PCI_ERS_RESULT_DISCONNECT ;if (dpc->rp_extensions && dpc->rp_pio_status) {pci_write_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_STATUS , dpc->rp_pio_status);
@@ -117,8 +131,18 @@ static void dpc_work(struct work_struct *work)pci_read_config_word (pdev, cap +PCI_EXP_DPC_CTL , &ctl);pci_write_config_word (pdev, cap +PCI_EXP_DPC_CTL , ctl |PCI_EXP_DPC_CTL_INT_EN ); + +return PCI_ERS_RESULT_RECOVERED ; } +static void dpc_work (struct work_struct *work) +{ + struct dpc_dev *dpc = container_of(work, struct dpc_dev, work); +struct pci_dev *pdev = dpc->dev->port; + +/* From DPC point of view error is always FATAL. */ +pcie_do_recovery (pdev,DPC_FATAL ); +}static void dpc_process_rp_pio_error (struct dpc_dev *dpc) {struct device *dev = &dpc->dev->device;
@@ -297,6 +321,7 @@ static struct pcie_port_service_driver dpcdriver = { .service = PCIE_PORT_SERVICE_DPC, .probe = dpc_probe, .remove = dpc_remove, + .reset_link = dpc_reset_link, };static int __init dpc_service_init (void )
include/linux/aer.h +2 -0
@@ -15,6 +15,8 @@#define AER_FATAL 1#define AER_CORRECTABLE 2 +#define DPC_FATAL 4 +struct pci_dev ;struct aer_header_log_regs {
Signature · 1 line
2.7.4
PATCH v14 6/9 PCI: Unify wait for link active into generic PCI
In reply to Oza PawandeepClients such as HP, DPC are using pcie_wait_link_active(), which waits till the link becomes active or inactive.
Made generic function and moved it to drivers/pci/pci.c
drivers/pci/hotplug/pciehp_hpc.c +3 -17
@@ -231,25 +231,11 @@ bool pciehp_check_link_active(struct controller *ctrl)return ret; } -static void __pcie_wait_link_active (struct controller *ctrl,bool active) -{ -int timeout =1000 ; - -if (pciehp_check_link_active (ctrl) == active) -return ; -while (timeout >0 ) { -msleep (10 ); - timeout -=10 ; -if (pciehp_check_link_active (ctrl) == active) -return ; - } -ctrl_dbg (ctrl,"Data Link Layer Link Active not %s in 1000 msec\n" , - active ?"set" :"cleared" ); -} -static void pcie_wait_link_active (struct controller *ctrl) { -__pcie_wait_link_active (ctrl, true); +struct pci_dev *pdev =ctrl_dev (ctrl); + +pcie_wait_for_link (pdev, true); }static bool pci_bus_check_dev (struct pci_bus *bus,int devfn)
drivers/pci/pci.c +30 -0
@@ -4176,6 +4176,36 @@ static int pci_pm_reset(struct pci_dev *dev, int probe)return 0 ; } +/** +* pcie_wait_for_link - Wait for link till it's active/inactive +* @pdev: Bridge device +* @active: waiting for active or inactive ? +* +* Use this to wait till link becomes active or inactive. +*/ +bool pcie_wait_for_link (struct pci_dev *pdev,bool active) +{ +int timeout =1000 ; +bool ret; +u16 lnk_status; + +for (;;) { +pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnk_status); + ret = !!(lnk_status &PCI_EXP_LNKSTA_DLLLA ); +if (ret == active) +return true; +if (timeout <=0 ) +break ; +msleep (10 ); + timeout -=10 ; + } + +pci_info (pdev,"Data Link Layer Link Active not %s in 1000 msec\n" , + active ?"set" :"cleared" ); + +return false; +} +void pci_reset_secondary_bus (struct pci_dev *dev) {u16 ctrl;
drivers/pci/pci.h +2 -0
@@ -345,6 +345,8 @@ void pci_enable_acs(struct pci_dev *dev);/* PCI error reporting and recovery */ void pcie_do_recovery (struct pci_dev *dev,int severity); +bool pcie_wait_for_link (struct pci_dev *pdev,bool active); +#ifdef CONFIG_PCIEASPM void pcie_aspm_init_link_state (struct pci_dev *pdev);void pcie_aspm_exit_link_state (struct pci_dev *pdev);
drivers/pci/pcie/pcie-dpc.c +1 -11
@@ -68,19 +68,9 @@ static int dpc_wait_rp_inactive(struct dpc_dev *dpc)static void dpc_wait_link_inactive (struct dpc_dev *dpc) { -unsigned long timeout = jiffies +HZ ;struct pci_dev *pdev = dpc->dev->port; -struct device *dev = &dpc->dev->device; -u16 lnk_status; -pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnk_status); -while (lnk_status &PCI_EXP_LNKSTA_DLLLA && - !time_after (jiffies, timeout)) { -msleep (10 ); -pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnk_status); - } -if (lnk_status &PCI_EXP_LNKSTA_DLLLA ) -dev_warn (dev,"Link state not disabled for DPC event\n" ); +pcie_wait_for_link (pdev, false); }/**
Signature · 1 line
2.7.4
PATCH v14 7/9 PCI/DPC: Disable ERR_NONFATAL and enable ERR_FATAL for DPC
In reply to Oza PawandeepThis patch disables ERR_NONFATAL trigger for DPC, so now DPC handles only ERR_FATAL.
drivers/pci/pcie/pcie-dpc.c +3 -2
@@ -283,7 +283,8 @@ static int dpc_probe(struct pcie_device *dev) } } - ctl = (ctl &0xfff4 ) |PCI_EXP_DPC_CTL_EN_NONFATAL |PCI_EXP_DPC_CTL_INT_EN ; + ctl = (ctl &0xfff4 ) |PCI_EXP_DPC_CTL_EN_FATAL | +PCI_EXP_DPC_CTL_INT_EN ;pci_write_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , ctl); dev_info(device, "DPC error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
@@ -301,7 +302,7 @@ static void dpc_remove(struct pcie_device *dev)u16 ctl;pci_read_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , &ctl); - ctl &= ~(PCI_EXP_DPC_CTL_EN_NONFATAL |PCI_EXP_DPC_CTL_INT_EN ); + ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL |PCI_EXP_DPC_CTL_INT_EN );pci_write_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , ctl); }
include/uapi/linux/pci_regs.h +2 -1
@@ -978,7 +978,8 @@#define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000/* ERR_COR signal on DL_Active supported */ #define PCI_EXP_DPC_CTL 6/* DPC control */ -#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x0002/* Enable trigger on ERR_NONFATAL message */ +#define PCI_EXP_DPC_CTL_EN_FATAL 0x0001/* Enable trigger on ERR_FATAL message */ +#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x0002/* Enable trigger on ERR_NONFATAL message */ #define PCI_EXP_DPC_CTL_INT_EN 0x0008/* DPC Interrupt Enable */ #define PCI_EXP_DPC_STATUS 8/* DPC Status */
Signature · 1 line
2.7.4
PATCH v14 8/9 PCI/AER/DPC: Align FATAL error handling for AER and DPC
In reply to Oza PawandeepIf there is a DPC support in the switch then ERR_FATAL and ERR_NONFATAL should be handled in a same way with respect to DPC.
This patch alters the behavior of handling of ERR_FATAL, where removal of devices is initiated, followed by reset link, followed by re-enumeration, and it is applicable to both AER and DPC, so that we have unified error handling from error agents (SW) point of view.
drivers/pci/pcie/aer/aerdrv.c +2 -0
@@ -334,6 +334,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 |=ROOT_PORT_INTR_ON_MESG_MASK ;pci_write_config_dword (dev, pos +PCI_ERR_ROOT_COMMAND , reg32); +aer_error_resume (dev); +return PCI_ERS_RESULT_RECOVERED ; }
drivers/pci/pcie/err.c +45 -10
76 lines not on this page · raw message
drivers/pci/pcie/pcie-dpc.c +0 -15
@@ -81,8 +81,6 @@ static void dpc_wait_link_inactive(struct dpc_dev *dpc)*/ static pci_ers_result_t dpc_reset_link (struct pci_dev *pdev) { -struct pci_bus *parent = pdev->subordinate; -struct pci_dev *dev, *temp;struct dpc_dev *dpc;struct pcie_device *pciedev;struct device *devdpc;
@@ -93,19 +91,6 @@ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev) dpc =get_service_data (pciedev); cap = dpc->cap_pos; -pci_lock_rescan_remove (); -list_for_each_entry_safe_reverse (dev, temp, &parent->devices, - bus_list) { -pci_dev_get (dev); -pci_dev_set_disconnected (dev,NULL ); -if (pci_has_subordinate (dev)) -pci_walk_bus (dev->subordinate, - pci_dev_set_disconnected,NULL ); -pci_stop_and_remove_bus_device (dev); -pci_dev_put (dev); - } -pci_unlock_rescan_remove (); -dpc_wait_link_inactive (dpc);if (dpc->rp_extensions &&dpc_wait_rp_inactive (dpc))return PCI_ERS_RESULT_DISCONNECT ;
Signature · 1 line
2.7.4
kbuild test robot
build bot[RFC PATCH] PCI/AER/DPC: pcie_do_fatal_recovery() can be static
Fixes: 3d7db543cb99 ("PCI/AER/DPC: Align FATAL error handling for AER and DPC")
--- err.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/err.c +1 -1
@@ -273,7 +273,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,return result_data.result; } -pci_ers_result_t pcie_do_fatal_recovery (struct pci_dev *dev,int severity) +static pci_ers_result_t pcie_do_fatal_recovery (struct pci_dev *dev,int severity) {struct pci_dev *udev;struct pci_bus *parent;
kbuild test robot
build botRe: [PATCH v14 8/9] PCI/AER/DPC: Align FATAL error handling for AER and DPC
In reply to Oza PawandeepThank you for the patch! Perhaps something to improve:
Hi Oza,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on v4.16]
[cannot apply to pci/next linus/master v4.17-rc1 next-20180423]
[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/Oza-Pawandeep/Address-error-and-recovery-for-AER-and-DPC/20180424-090411
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__sparse warnings: (new ones prefixed by >>)
>> drivers/pci/pcie/err.c:276:18: sparse: symbol 'pcie_do_fatal_recovery' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v14 9/9 pci-error-recovery: Add AER_FATAL handling
In reply to Oza PawandeepIt adds description on AER_FATAL error handling.
Documentation/PCI/pci-error-recovery.txt +25 -10
@@ -110,7 +110,7 @@ The actual steps taken by a platform to recover from a PCI error event will be platform-dependent, but will follow the general sequence described below. -STEP 0: Error Event +STEP 0: Error Event: ERR_NONFATAL ------------------- A PCI bus error is detected by the PCI hardware. On powerpc, the slot is isolated, in that all I/O is blocked: all reads return 0xffffffff,
@@ -228,13 +228,7 @@ proceeds to either STEP3 (Link Reset) or to STEP 5 (Resume Operations). If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform proceeds to STEP 4 (Slot Reset) -STEP 3: Link Reset ------------------- -The platform resets the link. This is a PCI-Express specific step -and is done whenever a fatal error has been detected that can be -"solved" by resetting the link. - -STEP 4: Slot Reset +STEP 3: Slot Reset ------------------ In response to a return value of PCI_ERS_RESULT_NEED_RESET, the
@@ -320,7 +314,7 @@ Failure). >>> However, it probably should. -STEP 5: Resume Operations +STEP 4: Resume Operations ------------------------- The platform will call the resume() callback on all affected device drivers if all drivers on the segment have returned
@@ -332,7 +326,7 @@ a result code. At this point, if a new error happens, the platform will restart a new error recovery sequence. -STEP 6: Permanent Failure +STEP 5: Permanent Failure ------------------------- A "permanent failure" has occurred, and the platform cannot recover the device. The platform will call error_detected() with a
@@ -355,6 +349,27 @@ errors. See the discussion in powerpc/eeh-pci-error-recovery.txt for additional detail on real-life experience of the causes of software errors. +STEP 0: Error Event: ERR_FATAL +------------------- +PCI bus error is detected by the PCI hardware. On powerpc, the slot is +isolated, in that all I/O is blocked: all reads return 0xffffffff, all +writes are ignored. + +STEP 1: Remove devices +-------------------- +Platform removes the devices depending on the error agent, it could be +this port for all subordinates or upstream component (likely downstream +port) + +STEP 2: Reset link +-------------------- +The platform resets the link. This is a PCI-Express specific step and is +done whenever a fatal error has been detected that can be "solved" by +resetting the link. + +STEP 3: Re-enumerate the devices +-------------------- +Initiates the re-enumeration. Conclusion; General Remarks ---------------------------
Signature · 1 line
2.7.4
Quoted 116 lines · Oza Pawandeep
This patch set brings in error handling support for DPC
The current implementation of AER and error message broadcasting to the EP driver is tightly coupled and limited to AER service driver. It is important to factor out broadcasting and other link handling callbacks. So that not only when AER gets triggered, but also when DPC get triggered (for e.g.
ERR_FATAL), callbacks are handled appropriately.The goal of the patch-set is:
DPC should handle the error handling and recovery similar to AER, because finally both are attempting recovery in some or the other way, and for that error handling and recovery framework has to be loosely coupled.It achieves uniformity and transparency to the error handling agents such as AER, DPC, with respect to recovery and error handling.
So, this patch-set tries to unify lot of things between error agents and make them behave in a well defined way. (be it error (FATAL,
NON_FATAL) handling or recovery).The FATAL error handling is handled with remove/reset_link/re-enumerate sequence while the
NON_FATALfollows the default path.Documentation/PCI/pci-error-recovery.txttalks more on that.Changes since v13:
Bjorn's comments addressed
> handke FATAL errors with remove devices followed by
re-enumeration.Quoted 1 line
changes in AER and DPC along with required Documentation.
Changes since v12:
Bjorn's and Keith's Comments addressed.
> Made DPC and AER error handling identical <alignederr.c> > hanldled cases for hotplug enabled system differently.
Changes since v11:
Bjorn's comments addressed.
> renamepcie-err.ctoerr.c
> removedEXPORT_SYMBOL
> made genericfind_serivcefunction in port driver.
> removed mutex patch as no need to have mutex inpcie_do_recovery> brough inDPC_FATALinaer.h
> so now all the error codes (AER and DPC) are unified inaer.h
Changes since v10:
Christoph Hellwig's, David Laight's and Randy Dunlap's comments addressed.
> renamedpci_do_recoverytopcie_do_recovery
> removed inner braces in conditional statements.
> restrctured the code inpci_wait_for_link
>EXPORT_SYMBOL_GPL
Changes since v9:
Sinan's comments addressed.
> bool active = true; unnecessary variable removed.
Changes since v8:
FixedKbuilderrors.
Changes since v7:
Rebased the code on pci master
>
https://kernel.googlesource.com/pub/scm/linux/kernel/git/helgaas/pci
Changes since v6:
Sinan's and Stefan's comments implemented.
> reordered patch 6 and 7
> cleaned up
Changes since v5:
Sinan's and Keith's comments incorporated.
> made separate patch for mutex
> unified error repotting codes intodriver/pci/pci.h> got rid of wait link active/inactive and
made generic function indriver/pci/pci.c
Changes since v4:
Bjorn's comments incorporated.
> Renamed onlydo_recovery.
> moved the things more locally todrivers/pci/pci.h
Changes since v3:
Bjorn's comments incorporated.
> Made separate patch renaming genericpci_err.c
> Introducepci_err.hto contain all the error types and
recovery
> removed all the dependencies onpci.h
Changes since v2:
Based on feedback from Keith:
"
When DPC is triggered due to receipt of an uncorrectable error
Message,
the Requester ID from the Message is recorded in the DPC Error Source ID register and that Message is discarded and not forwarded
Upstream.
"
Removed the patch where AER checks if DPC service is active
Changes since v1:
Kbuilderrors fixed:
>pci_find_dpc_devmade static
>ras_event.hupdated
>pci_find_aer_servicecall with CONFIG check
>pci_find_dpc_servicecall with CONFIG checkOza Pawandeep (9):
PCI/AER: Rename error recovery to generic PCI naming PCI/AER: Factor out error reporting from AER PCI/PORTDRV: Implement generic find service PCI/PORTDRV: Implement generic find device PCI/DPC: Unify and plumb error handling into DPC
PCI: Unify wait for link active into generic PCI PCI/DPC: DisableERR_NONFATALfor DPC PCI/AER/DPC: Align FATAL error handling for AER and DPC
pci-error-recovery: AddAER_FATALhandlingDocumentation/PCI/pci-error-recovery.txt | 35 ++- drivers/pci/hotplug/pciehp_hpc.c | 20 +- drivers/pci/pci.c | 30 +++ drivers/pci/pci.h | 5 + drivers/pci/pcie/Makefile | 2 +- drivers/pci/pcie/aer/aerdrv.c | 2 + drivers/pci/pcie/aer/aerdrv.h | 30 --- drivers/pci/pcie/aer/aerdrv_core.c | 317 +------------------------- drivers/pci/pcie/err.c | 374
Quoted 8 lines
+++++++++++++++++++++++++++++++
drivers/pci/pcie/pcie-dpc.c | 63 +++--- drivers/pci/pcie/portdrv.h | 4 + drivers/pci/pcie/portdrv_core.c | 69 ++++++ include/linux/aer.h | 2 + include/uapi/linux/pci_regs.h | 3 +- 14 files changed, 552 insertions(+), 404 deletions(-) create mode 100644 drivers/pci/pcie/err.c
Hi Bjorn,
I know I need to rebase this whole patch-set to 4.17 now.
But before I do that, can you please help to comment.
Regards,
Oza.
Quoted 18 lines · On Thu, Apr 26, 2018 at 11:00:52AM +0530, [email protected] wrote:
Quoted 9 lines · Oza Pawandeep
This patch set brings in error handling support for DPC
The current implementation of AER and error message broadcasting to the EP driver is tightly coupled and limited to AER service driver. It is important to factor out broadcasting and other link handling callbacks. So that not only when AER gets triggered, but also when DPC get
triggered (for e.g.ERR_FATAL), callbacks are handled appropriately.Quoted 7 lines
The goal of the patch-set is:
DPC should handle the error handling and recovery similar to AER, because
finally both are attempting recovery in some or the other way, and for that error handling and recovery framework has to be loosely coupled.
...
Quoted 5 lines
Hi Bjorn,
I know I need to rebase this whole patch-set to 4.17 now.
But before I do that, can you please help to comment.
My overall comment is that I think the series will be simpler and read better if you first change AER to do remove/re-enumerate, before doing anything with DPC.
This could be done by extracting just the AER part of "PCI/AER/DPC:
Align FATAL error handling for AER and DPC" (i.e., adding pcie_do_fatal_recovery()) and moving that to be the very first patch.
It's a small change in terms of code size, but significant to drivers, and it's really the core of the series, so it would be good to clearly establish the policy of:
ERR_NONFATAL => call driver recovery entry points
ERR_FATAL => remove and re-enumerate
before bringing DPC into the picture.
Then the subsequent patches would all be more or less mechanical changes to make DPC follow the same model.
Bjorn
Quoted 37 lines · Bjorn Helgaas
Quoted 18 lines · On Thu, Apr 26, 2018 at 11:00:52AM +0530, [email protected] wrote:
Quoted 9 lines · Oza Pawandeep
This patch set brings in error handling support for DPC
The current implementation of AER and error message broadcasting to the EP driver is tightly coupled and limited to AER service driver. It is important to factor out broadcasting and other link handling callbacks. So that not only when AER gets triggered, but also when DPC get
triggered (for e.g.ERR_FATAL), callbacks are handled appropriately.Quoted 7 lines
The goal of the patch-set is:
DPC should handle the error handling and recovery similar to AER, because
finally both are attempting recovery in some or the other way, and for that error handling and recovery framework has to be loosely coupled.
...Quoted 5 lines
Hi Bjorn,
I know I need to rebase this whole patch-set to 4.17 now.
But before I do that, can you please help to comment.
My overall comment is that I think the series will be simpler and read better if you first change AER to do remove/re-enumerate, before doing anything with DPC.
This could be done by extracting just the AER part of "PCI/AER/DPC:
Align FATAL error handling for AER and DPC" (i.e., addingpcie_do_fatal_recovery()) and moving that to be the very first patch.It's a small change in terms of code size, but significant to drivers, and it's really the core of the series, so it would be good to clearly establish the policy of:
Quoted 7 lines
ERR_NONFATAL=> call driver recovery entry points
ERR_FATAL=> remove and re-enumeratebefore bringing DPC into the picture.
Then the subsequent patches would all be more or less mechanical changes to make DPC follow the same model.
ok I have taken care of you comment, please follow v15, coming next.
I could not make that the first patch, because I needed to unify pci_wait_for_link function. hence it is the second patch, but now the order looks quiet obvious and simplified.
Regards,
Oza.
Quoted 2 lines
Bjorn