Add Error Disconnect Recover (EDR) support
Subsystems (3)
v14 cover Add Error Disconnect Recover (EDR) support
From: Kuppuswamy Sathyanarayanan <[email protected]>
This patchset adds support for following features:
1. Error Disconnect Recover (EDR) support.
2. _OSC based negotiation support for DPC.
You can find EDR spec in the following link.
https://members.pcisig.com/wg/PCI-SIG/document/12614
Changes since v13:
* Moved all EDR related code to edr.c
* Addressed Bjorns comments.
Changes since v12:
* Addressed Bjorns comments.
* Added check for CONFIG_PCIE_EDR before requesting DPC control from firmware.
* Removed ff_check parameter from AER APIs.
* Used macros for _OST return status values in DPC driver.
Changes since v11:
* Allowed error recovery to proceed after successful reset_link().
* Used correct ACPI handle for sending EDR status.
* Rebased on top of v5.5-rc5
Changes since v10:
* Added "edr_enabled" member to dpc priv structure, which is used to cache EDR enabling status based on status of pcie_ports_dpc_native and FF mode.
* Changed type of _DSM argument from Integer to Package in acpi_enable_dpc_port() function to fix ACPI related boot warnings.
* Rebased on top of v5.5-rc3
Changes since v9:
* Removed caching of pcie_aer_get_firmware_first() in dpc driver.
* Added proper spec reference in git log for patch 5 & 7.
* Added new function parameter "ff_check" to pci_cleanup_aer_uncorrect_error_status(), pci_aer_clear_fatal_status() and pci_cleanup_aer_error_status_regs() functions.
* Rebased on top of v5.4-rc5
Changes since v8:
* Rebased on top of v5.4-rc1
Changes since v7:
* Updated DSM version number to match the spec.
Changes since v6:
* Modified the order of patches to enable EDR only after all necessary support is added in kernel.
* Addressed Bjorn comments.
Changes since v5:
* Addressed Keith's comments.
* Added additional check for FF mode in pci_aer_init().
* Updated commit history of "PCI/DPC: Add support for DPC recovery on NON_FATAL errors" patch.
Changes since v4:
* Rebased on top of v5.3-rc1
* Fixed lock/unlock issue in edr_handle_event().
* Merged "Update error status after reset_link()" patch into this patchset.
Changes since v3:
* Moved EDR related ACPI functions/definitions to pci-acpi.c
* Modified commit history in few patches to include spec reference.
* Added support to handle DPC triggered by NON_FATAL errors.
* Added edr_lock to protect PCI device receiving duplicate EDR notifications.
* Addressed Bjorn comments.
Changes since v2:
* Split EDR support patch into multiple patches.
* Addressed Bjorn comments.
Changes since v1:
* Rebased on top of v5.1-rc1
Kuppuswamy Sathyanarayanan (5):
PCI/ERR: Update error status after reset_link() PCI/DPC: Remove pcie_device reference from dpc_dev structure PCI/EDR: Export AER, DPC and error recovery functions PCI/DPC: Add Error Disconnect Recover (EDR) support PCI/ACPI: Enable EDR support
drivers/acpi/pci_root.c | 16 +++ drivers/pci/pci-acpi.c | 3 + drivers/pci/pci.h | 8 ++ drivers/pci/pcie/Kconfig | 10 ++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 39 ++++-- drivers/pci/pcie/dpc.c | 92 ++++++++------ drivers/pci/pcie/dpc.h | 20 +++ drivers/pci/pcie/edr.c | 259 ++++++++++++++++++++++++++++++++++++++ drivers/pci/pcie/err.c | 35 ++++-- drivers/pci/probe.c | 1 + include/linux/acpi.h | 6 +- include/linux/pci-acpi.h | 8 ++ include/linux/pci.h | 1 + 14 files changed, 441 insertions(+), 58 deletions(-) create mode 100644 drivers/pci/pcie/dpc.h create mode 100644 drivers/pci/pcie/edr.c
Signature · 1 line
2.21.0
PATCH v14 1/5 PCI/ERR: Update error status after reset_link()
From: Kuppuswamy Sathyanarayanan <[email protected]>
Commit bdb5ac85777d ("PCI/ERR: Handle fatal error recovery") uses reset_link() to recover from fatal errors. But during fatal error recovery, if the initial value of error status is PCI_ERS_RESULT_DISCONNECT or PCI_ERS_RESULT_NO_AER_DRIVER then even after successful recovery (using reset_link()) pcie_do_recovery() will report the recovery result as failure. So update the status of error after reset_link().
--- drivers/pci/pcie/err.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pci/pcie/err.c +5 -3
@@ -204,9 +204,11 @@ void pcie_do_recovery(struct pci_dev *dev, enum pci_channel_state state,else pci_walk_bus (bus, report_normal_detected, &status); -if (state == pci_channel_io_frozen && -reset_link (dev, service) !=PCI_ERS_RESULT_RECOVERED ) - goto failed; +if (state == pci_channel_io_frozen) { + status =reset_link (dev, service); +if (status !=PCI_ERS_RESULT_RECOVERED ) + goto failed; + }if (status ==PCI_ERS_RESULT_CAN_RECOVER ) { status =PCI_ERS_RESULT_RECOVERED ;
Signature · 1 line
2.21.0
PATCH v14 2/5 PCI/DPC: Remove pcie_device reference from dpc_dev structure
In reply to [email protected]From: Kuppuswamy Sathyanarayanan <[email protected]>
Currently the only use of pcie_device member in dpc_dev structure is to get the associated pci_dev reference. Since none of the users of dpc_dev need reference to pcie_device, just remove it and replace it with associated pci_dev pointer reference.
Removing pcie_device reference will help if we have need to call DPC driver functions outside PCIe port drivers.
--- drivers/pci/pcie/dpc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/pcie/dpc.c +6 -6
@@ -18,7 +18,7 @@#include "../pci.h" struct dpc_dev { -struct pcie_device *dev; +struct pci_dev *pdev;u16 cap_pos;bool rp_extensions;u8 rp_log_size;
@@ -101,7 +101,7 @@ void pci_restore_dpc_state(struct pci_dev *dev)static int dpc_wait_rp_inactive (struct dpc_dev *dpc) {unsigned long timeout = jiffies +HZ ; -struct pci_dev *pdev = dpc->dev->port; +struct pci_dev *pdev = dpc->pdev;u16 cap = dpc->cap_pos, status;pci_read_config_word (pdev, cap +PCI_EXP_DPC_STATUS , &status);
@@ -149,7 +149,7 @@ static pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)static void dpc_process_rp_pio_error (struct dpc_dev *dpc) { -struct pci_dev *pdev = dpc->dev->port; +struct pci_dev *pdev = dpc->pdev;u16 cap = dpc->cap_pos, dpc_status, first_error;u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix;int i;
@@ -228,7 +228,7 @@ static irqreturn_t dpc_handler(int irq, void *context) {struct aer_err_info info;struct dpc_dev *dpc = context; -struct pci_dev *pdev = dpc->dev->port; +struct pci_dev *pdev = dpc->pdev;u16 cap = dpc->cap_pos, status, source, reason, ext_reason;pci_read_config_word (pdev, cap +PCI_EXP_DPC_STATUS , &status);
@@ -267,7 +267,7 @@ static irqreturn_t dpc_handler(int irq, void *context)static irqreturn_t dpc_irq (int irq,void *context) {struct dpc_dev *dpc = (struct dpc_dev *)context; -struct pci_dev *pdev = dpc->dev->port; +struct pci_dev *pdev = dpc->pdev;u16 cap = dpc->cap_pos, status;pci_read_config_word (pdev, cap +PCI_EXP_DPC_STATUS , &status);
@@ -299,7 +299,7 @@ static int dpc_probe(struct pcie_device *dev)return -ENOMEM ; dpc->cap_pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_DPC ); - dpc->dev = dev; + dpc->pdev = pdev;set_service_data (dev, dpc); status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
Signature · 1 line
2.21.0
PATCH v14 3/5 PCI/EDR: Export AER, DPC and error recovery functions
In reply to [email protected]From: Kuppuswamy Sathyanarayanan <[email protected]>
This is a preparatory patch for adding EDR support.
As per the Downstream Port Containment Related Enhancements ECN to the PCI Firmware Specification r3.2, sec 4.5.1, table 4-6, If DPC is controlled by firmware, firmware is responsible for initializing Downstream Port Containment Extended Capability Structures per firmware policy. Further, the OS is permitted to read or write DPC Control and Status registers of a port while processing an Error Disconnect Recover notification from firmware on that port. Error Disconnect Recover notification processing begins with the Error Disconnect Recover notify from Firmware, and ends when the OS releases DPC by clearing the DPC Trigger Status bit.Firmware can read DPC Trigger Status bit to determine the ownership of DPC Control and Status registers. Firmware is not permitted to write to DPC Control and Status registers if DPC Trigger Status is set i.e. the link is in DPC state. Outside of the Error Disconnect Recover notification processing window, the OS is not permitted to modify DPC Control or Status registers; only firmware is allowed to.
To add EDR support we need to re-use some of the existing DPC, AER and pCIE error recovery functions. So add necessary interfaces.
--- drivers/pci/pci.h | 8 ++++ drivers/pci/pcie/aer.c | 39 ++++++++++++++------ drivers/pci/pcie/dpc.c | 84 +++++++++++++++++++++++++----------------- drivers/pci/pcie/dpc.h | 20 ++++++++++ drivers/pci/pcie/err.c | 29 ++++++++++++--- 5 files changed, 130 insertions(+), 50 deletions(-) create mode 100644 drivers/pci/pcie/dpc.h
drivers/pci/pci.h +8 -0
@@ -440,6 +440,9 @@ struct aer_err_info {int aer_get_device_error_info (struct pci_dev *dev,struct aer_err_info *info);void aer_print_error (struct pci_dev *dev,struct aer_err_info *info); +int pci_aer_clear_err_uncor_status (struct pci_dev *dev); +void pci_aer_clear_err_fatal_status (struct pci_dev *dev); +int pci_aer_clear_err_status_regs (struct pci_dev *dev);#endif /* CONFIG_PCIEAER */ #ifdef CONFIG_PCIE_DPC
@@ -546,6 +549,11 @@ static inline int pci_dev_specific_disable_acs_redir(struct pci_dev *dev)/* PCI error reporting and recovery */ void pcie_do_recovery (struct pci_dev *dev,enum pci_channel_state state,u32 service); +pci_ers_result_t pcie_do_recovery_common (struct pci_dev *dev, +enum pci_channel_state state, +u32 service, +pci_ers_result_t (*reset_cb)(void *cb_data), +void *cb_data);bool pcie_wait_for_link (struct pci_dev *pdev,bool active);#ifdef CONFIG_PCIEASPM
drivers/pci/pcie/aer.c +27 -12
@@ -376,7 +376,7 @@ void pci_aer_clear_device_status(struct pci_dev *dev)pcie_capability_write_word (dev,PCI_EXP_DEVSTA , sta); } -int pci_cleanup_aer_uncorrect_error_status (struct pci_dev *dev) +int pci_aer_clear_err_uncor_status (struct pci_dev *dev) {int pos;u32 status, sev;
@@ -385,9 +385,6 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)if (!pos)return -EIO ; -if (pcie_aer_get_firmware_first (dev)) -return -EIO ; -/* Clear status bits for ERR_NONFATAL errors only */ pci_read_config_dword (dev, pos +PCI_ERR_UNCOR_STATUS , &status);pci_read_config_dword (dev, pos +PCI_ERR_UNCOR_SEVER , &sev);
@@ -397,9 +394,17 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)return 0 ; } + +int pci_cleanup_aer_uncorrect_error_status (struct pci_dev *dev) +{ +if (pcie_aer_get_firmware_first (dev)) +return -EIO ; + +return pci_aer_clear_err_uncor_status (dev); +}EXPORT_SYMBOL_GPL (pci_cleanup_aer_uncorrect_error_status); -void pci_aer_clear_fatal_status (struct pci_dev *dev) +void pci_aer_clear_err_fatal_status (struct pci_dev *dev) {int pos;u32 status, sev;
@@ -408,9 +413,6 @@ void pci_aer_clear_fatal_status(struct pci_dev *dev)if (!pos)return ; -if (pcie_aer_get_firmware_first (dev)) -return ; -/* Clear status bits for ERR_FATAL errors only */ pci_read_config_dword (dev, pos +PCI_ERR_UNCOR_STATUS , &status);pci_read_config_dword (dev, pos +PCI_ERR_UNCOR_SEVER , &sev);
@@ -419,7 +421,15 @@ void pci_aer_clear_fatal_status(struct pci_dev *dev)pci_write_config_dword (dev, pos +PCI_ERR_UNCOR_STATUS , status); } -int pci_cleanup_aer_error_status_regs (struct pci_dev *dev) +void pci_aer_clear_fatal_status (struct pci_dev *dev) +{ +if (pcie_aer_get_firmware_first (dev)) +return ; + +return pci_aer_clear_err_fatal_status (dev); +} + +int pci_aer_clear_err_status_regs (struct pci_dev *dev) {int pos;u32 status;
@@ -432,9 +442,6 @@ int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)if (!pos)return -EIO ; -if (pcie_aer_get_firmware_first (dev)) -return -EIO ; - port_type =pci_pcie_type (dev);if (port_type ==PCI_EXP_TYPE_ROOT_PORT ) {pci_read_config_dword (dev, pos +PCI_ERR_ROOT_STATUS , &status);
@@ -450,6 +457,14 @@ int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)return 0 ; } +int pci_cleanup_aer_error_status_regs (struct pci_dev *dev) +{ +if (pcie_aer_get_firmware_first (dev)) +return -EIO ; + +return pci_aer_clear_err_status_regs (dev); +} +void pci_save_aer_state (struct pci_dev *dev) {struct pci_cap_saved_state *save_state;
drivers/pci/pcie/dpc.c +51 -33
150 lines not on this page · raw message
drivers/pci/pcie/dpc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef DRIVERS_PCIE_DPC_H +#define DRIVERS_PCIE_DPC_H + +#include <linux/pci.h> + +struct dpc_dev { +struct pci_dev *pdev; +u16 cap_pos; +bool rp_extensions; +u8 rp_log_size; +u16 ctl; +u16 cap; +}; + +pci_ers_result_t dpc_reset_link_common (struct dpc_dev *dpc); +void dpc_process_error (struct dpc_dev *dpc); +void dpc_dev_init (struct pci_dev *pdev,struct dpc_dev *dpc); + +#endif /* DRIVERS_PCIE_DPC_H */
drivers/pci/pcie/err.c +24 -5
@@ -158,11 +158,18 @@ static pci_ers_result_t default_reset_link(struct pci_dev *dev)return rc ?PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_RECOVERED ; } -static pci_ers_result_t reset_link (struct pci_dev *dev,u32 service) +static pci_ers_result_t reset_link (struct pci_dev *dev,u32 service, +pci_ers_result_t (*reset_cb)(void *cb_data), +void *cb_data) {pci_ers_result_t status;struct pcie_port_service_driver *driver =NULL ; +if (reset_cb) { + status =reset_cb (cb_data); + goto done; + } + driver =pcie_port_find_service (dev, service);if (driver && driver->reset_link) { status = driver->reset_link (dev);
@@ -174,6 +181,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service)return PCI_ERS_RESULT_DISCONNECT ; } +done:if (status !=PCI_ERS_RESULT_RECOVERED ) {pci_printk (KERN_DEBUG , dev,"link reset at upstream device %s failed\n" ,pci_name (dev));
@@ -183,8 +191,11 @@ static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service)return status; } -void pcie_do_recovery (struct pci_dev *dev,enum pci_channel_state state, -u32 service) +pci_ers_result_t pcie_do_recovery_common (struct pci_dev *dev, +enum pci_channel_state state, +u32 service, +pci_ers_result_t (*reset_cb)(void *cb_data), +void *cb_data) {pci_ers_result_t status =PCI_ERS_RESULT_CAN_RECOVER ;struct pci_bus *bus;
@@ -205,7 +216,7 @@ void pcie_do_recovery(struct pci_dev *dev, enum pci_channel_state state,pci_walk_bus (bus, report_normal_detected, &status);if (state == pci_channel_io_frozen) { - status =reset_link (dev, service); + status =reset_link (dev, service, reset_cb, cb_data);if (status !=PCI_ERS_RESULT_RECOVERED ) goto failed; }
@@ -236,11 +247,19 @@ void pcie_do_recovery(struct pci_dev *dev, enum pci_channel_state state,pci_aer_clear_device_status (dev);pci_cleanup_aer_uncorrect_error_status (dev);pci_info (dev,"AER: Device recovery successful\n" ); -return ; +return status; failed:pci_uevent_ers (dev,PCI_ERS_RESULT_DISCONNECT );/* TODO: Should kernel panic here? */ pci_info (dev,"AER: Device recovery failed\n" ); + +return status; +} + +void pcie_do_recovery (struct pci_dev *dev,enum pci_channel_state state, +u32 service) +{ +pcie_do_recovery_common (dev, state, service,NULL ,NULL ); }
Signature · 1 line
2.21.0
PATCH v14 4/5 PCI/DPC: Add Error Disconnect Recover (EDR) support
In reply to [email protected]From: Kuppuswamy Sathyanarayanan <[email protected]>
As per ACPI specification r6.3, sec 5.6.6, when firmware owns Downstream Port Containment (DPC), its expected to use the "Error Disconnect Recover" (EDR) notification to alert OSPM of a DPC event and if OS supports EDR, its expected to handle the software state invalidation and port recovery in OS, and also let firmware know the recovery status via _OST ACPI call. Related _OST status codes can be found in ACPI specification r6.3, sec 6.3.5.2.
Also, as per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN, sec 4.5.1, table 4-6, If DPC is controlled by firmware (firmware first mode), firmware is responsible for configuring the DPC and OS is responsible for error recovery. Also, OS is allowed to modify DPC registers only during the EDR notification window.
--- drivers/pci/pci-acpi.c | 3 + drivers/pci/pcie/Kconfig | 10 ++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/edr.c | 257 ++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 8 ++ 5 files changed, 279 insertions(+) create mode 100644 drivers/pci/pcie/edr.c
drivers/pci/pci-acpi.c +3 -0
@@ -1258,6 +1258,7 @@ static void pci_acpi_setup(struct device *dev)acpi_pci_wakeup (pci_dev, false);acpi_device_power_add_dependent (adev, dev); +pci_acpi_add_edr_notifier (pci_dev); }static void pci_acpi_cleanup (struct device *dev)
@@ -1276,6 +1277,8 @@ static void pci_acpi_cleanup(struct device *dev)device_set_wakeup_capable (dev, false); } + +pci_acpi_remove_edr_notifier (pci_dev); }static bool pci_acpi_bus_match (struct device *dev)
drivers/pci/pcie/Kconfig +10 -0
@@ -140,3 +140,13 @@ config PCIE_BW This enables PCI Express Bandwidth Change Notification. If you know link width or rate changes occur only to correct unreliable links, you may answer Y. + +config PCIE_EDR + bool "PCI Express Error Disconnect Recover support" + depends on PCIE_DPC && ACPI + help + This option adds Error Disconnect Recover support as specified + in the Downstream Port Containment Related Enhancements ECN to + the PCI Firmware Specification r3.2. Enable this if you want to + support hybrid DPC model which uses both firmware and OS to + implement DPC.
drivers/pci/pcie/Makefile +1 -0
@@ -13,3 +13,4 @@ obj-$(CONFIG_PCIE_PME) += pme.o obj-$(CONFIG_PCIE_DPC) += dpc.o obj-$(CONFIG_PCIE_PTM) += ptm.o obj-$(CONFIG_PCIE_BW) += bw_notification.o +obj-$(CONFIG_PCIE_EDR) += edr.o
drivers/pci/pcie/edr.c new file +257 -0
257 lines not on this page · raw message
include/linux/pci-acpi.h +8 -0
@@ -112,6 +112,14 @@ extern const guid_t pci_acpi_dsm_guid;#define RESET_DELAY_DSM 0x08#define FUNCTION_DELAY_DSM 0x09 +#ifdef CONFIG_PCIE_EDR +int pci_acpi_add_edr_notifier (struct pci_dev *pdev); +void pci_acpi_remove_edr_notifier (struct pci_dev *pdev); +#else +static inline int pci_acpi_add_edr_notifier (struct pci_dev *pdev) {return 0 ; } +static inline void pci_acpi_remove_edr_notifier (struct pci_dev *pdev) { } +#endif /* CONFIG_PCIE_EDR */ +#else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus (struct pci_bus *bus) { }static inline void acpi_pci_remove_bus (struct pci_bus *bus) { }
Signature · 1 line
2.21.0
PATCH v14 5/5 PCI/ACPI: Enable EDR support
In reply to [email protected]From: Kuppuswamy Sathyanarayanan <[email protected]>
As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN, sec 4.5.1, OS must implement following steps to enable/use EDR feature.
1. OS can use bit 7 of _OSC Control Field to negotiate control over Downstream Port Containment (DPC) configuration of PCIe port. After _OSC negotiation, firmware will Set this bit to grant OS control over PCIe DPC configuration and Clear it if this feature was requested and denied, or was not requested.
2. Also, if OS supports EDR, it should expose its support to BIOS by setting bit 7 of _OSC Support Field. And if OS sets bit 7 of _OSC Control Field it must also expose support for EDR by setting bit 7 of _OSC Support Field.
--- drivers/acpi/pci_root.c | 16 ++++++++++++++++ drivers/pci/pcie/edr.c | 4 +++- drivers/pci/probe.c | 1 + include/linux/acpi.h | 6 ++++-- include/linux/pci.h | 1 + 5 files changed, 25 insertions(+), 3 deletions(-)
drivers/acpi/pci_root.c +16 -0
@@ -131,6 +131,7 @@ static struct pci_osc_bit_struct pci_osc_support_bit[] = { { OSC_PCI_CLOCK_PM_SUPPORT, "ClockPM" }, { OSC_PCI_SEGMENT_GROUPS_SUPPORT, "Segments" }, { OSC_PCI_MSI_SUPPORT, "MSI" }, + { OSC_PCI_EDR_SUPPORT, "EDR" }, { OSC_PCI_HPX_TYPE_3_SUPPORT, "HPX-Type3" }, };
@@ -141,6 +142,7 @@ static struct pci_osc_bit_struct pci_osc_control_bit[] = { { OSC_PCI_EXPRESS_AER_CONTROL, "AER" }, { OSC_PCI_EXPRESS_CAPABILITY_CONTROL, "PCIeCapability" }, { OSC_PCI_EXPRESS_LTR_CONTROL, "LTR" }, + { OSC_PCI_EXPRESS_DPC_CONTROL, "DPC" }, }; static void decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word,
@@ -440,6 +442,8 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, support |=OSC_PCI_ASPM_SUPPORT |OSC_PCI_CLOCK_PM_SUPPORT ;if (pci_msi_enabled ()) support |=OSC_PCI_MSI_SUPPORT ; +if (IS_ENABLED (CONFIG_PCIE_EDR )) + support |=OSC_PCI_EDR_SUPPORT ;decode_osc_support (root,"OS supports" , support); status =acpi_pci_osc_support (root, support);
@@ -487,6 +491,16 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, control |=OSC_PCI_EXPRESS_AER_CONTROL ; } +/* +* Per the Downstream Port Containment Related Enhancements ECN to +* the PCI Firmware Spec, r3.2, sec 4.5.1, table 4-5, +* OSC_PCI_EXPRESS_DPC_CONTROL indicates the OS supports both DPC +* and EDR. So use CONFIG_PCIE_EDR for requesting DPC control which +* will only be turned on if both EDR and DPC is enabled. +*/ +if (IS_ENABLED (CONFIG_PCIE_EDR )) + control |=OSC_PCI_EXPRESS_DPC_CONTROL ; + requested = control; status =acpi_pci_osc_control_set (handle, &control,OSC_PCI_EXPRESS_CAPABILITY_CONTROL );
@@ -916,6 +930,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, host_bridge->native_pme =0 ;if (!(root->osc_control_set &OSC_PCI_EXPRESS_LTR_CONTROL )) host_bridge->native_ltr =0 ; +if (!(root->osc_control_set &OSC_PCI_EXPRESS_DPC_CONTROL )) + host_bridge->native_dpc =0 ;/* * Evaluate the "PCI Boot Configuration" _DSM Function. If it
drivers/pci/pcie/edr.c +3 -1
@@ -201,6 +201,7 @@ static void edr_handle_event(acpi_handle handle, u32 event, void *data)int pci_acpi_add_edr_notifier (struct pci_dev *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev); +struct pci_host_bridge *host =pci_find_host_bridge (pdev->bus);struct dpc_dev *dpc;acpi_status astatus;int status;
@@ -213,7 +214,8 @@ int pci_acpi_add_edr_notifier(struct pci_dev *pdev)* TODO: Remove dependency on ACPI FIRMWARE_FIRST bit to * determine ownership of DPC between firmware or OS. */ -if (!pcie_aer_get_firmware_first (pdev) || pcie_ports_dpc_native) +if (!pcie_aer_get_firmware_first (pdev) || pcie_ports_dpc_native || + (host->native_dpc))return -ENODEV ;if (!adev)
drivers/pci/probe.c +1 -0
@@ -598,6 +598,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_shpc_hotplug =1 ; bridge->native_pme =1 ; bridge->native_ltr =1 ; + bridge->native_dpc =1 ; }struct pci_host_bridge *pci_alloc_host_bridge (size_t priv)
include/linux/acpi.h +4 -2
@@ -515,8 +515,9 @@ extern bool osc_pc_lpi_support_confirmed;#define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004#define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008#define OSC_PCI_MSI_SUPPORT 0x00000010 +#define OSC_PCI_EDR_SUPPORT 0x00000080#define OSC_PCI_HPX_TYPE_3_SUPPORT 0x00000100 -#define OSC_PCI_SUPPORT_MASKS 0x0000011f +#define OSC_PCI_SUPPORT_MASKS 0x0000019f/* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */ #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
@@ -525,7 +526,8 @@ extern bool osc_pc_lpi_support_confirmed;#define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008#define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010#define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 -#define OSC_PCI_CONTROL_MASKS 0x0000003f +#define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 +#define OSC_PCI_CONTROL_MASKS 0x000000bf#define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
include/linux/pci.h +1 -0
@@ -510,6 +510,7 @@ struct pci_host_bridge { unsigned int native_shpc_hotplug:1; /* OS may use SHPC hotplug */ unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ + unsigned int native_dpc:1; /* OS may use PCIe DPC */ unsigned int preserve_config:1; /* Preserve FW resource setup *//* Resource alignment requirements */
Signature · 1 line
2.21.0
Quoted 10 lines · On Fri, Feb 07, 2020 at 04:03:30PM -0800…
From: Kuppuswamy Sathyanarayanan <[email protected]>
This patchset adds support for following features:
1. Error Disconnect Recover (EDR) support.
2._OSCbased negotiation support for DPC.You can find EDR spec in the following link.
Hi Sathy,
Bad timing! Linus tagged v5.6-rc1 on Feb 9, shortly after you posted this. Would you mind refreshing this so it applies on my "master" branch (v5.6-rc1)?
Quoted 91 lines
Changes since v13:
* Moved all EDR related code toedr.c
* Addressed Bjorns comments.Changes since v12:
* Addressed Bjorns comments.
* Added check forCONFIG_PCIE_EDRbefore requesting DPC control from firmware.
* Removedff_checkparameter from AER APIs.
* Used macros for_OSTreturn status values in DPC driver.Changes since v11:
* Allowed error recovery to proceed after successfulreset_link().
* Used correct ACPI handle for sending EDR status.
* Rebased on top of v5.5-rc5Changes since v10:
* Added "edr_enabled" member to dpc priv structure, which is used to cache EDR enabling status based on status ofpcie_ports_dpc_nativeand FF mode.
* Changed type of_DSMargument from Integer to Package inacpi_enable_dpc_port()function to fix ACPI related boot warnings.
* Rebased on top of v5.5-rc3Changes since v9:
* Removed caching ofpcie_aer_get_firmware_first()in dpc driver.
* Added proper spec reference in git log for patch 5 & 7.
* Added new function parameter "ff_check" topci_cleanup_aer_uncorrect_error_status(),pci_aer_clear_fatal_status()andpci_cleanup_aer_error_status_regs()functions.
* Rebased on top of v5.4-rc5Changes since v8:
* Rebased on top of v5.4-rc1Changes since v7:
* Updated DSM version number to match the spec.Changes since v6:
* Modified the order of patches to enable EDR only after all necessary support is added in kernel.
* Addressed Bjorn comments.Changes since v5:
* Addressed Keith's comments.
* Added additional check for FF mode inpci_aer_init().
* Updated commit history of "PCI/DPC: Add support for DPC recovery onNON_FATALerrors" patch.Changes since v4:
* Rebased on top of v5.3-rc1
* Fixed lock/unlock issue inedr_handle_event().
* Merged "Update error status afterreset_link()" patch into this patchset.Changes since v3:
* Moved EDR related ACPI functions/definitions topci-acpi.c
* Modified commit history in few patches to include spec reference.
* Added support to handle DPC triggered byNON_FATALerrors.
* Addededr_lockto protect PCI device receiving duplicate EDR notifications.
* Addressed Bjorn comments.Changes since v2:
* Split EDR support patch into multiple patches.
* Addressed Bjorn comments.Changes since v1:
* Rebased on top of v5.1-rc1Kuppuswamy Sathyanarayanan (5):
PCI/ERR: Update error status afterreset_link()PCI/DPC: Removepcie_devicereference fromdpc_devstructure PCI/EDR: Export AER, DPC and error recovery functions PCI/DPC: Add Error Disconnect Recover (EDR) support PCI/ACPI: Enable EDR supportdrivers/acpi/pci_root.c | 16 +++ drivers/pci/pci-acpi.c | 3 + drivers/pci/pci.h | 8 ++ drivers/pci/pcie/Kconfig | 10 ++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 39 ++++-- drivers/pci/pcie/dpc.c | 92 ++++++++------ drivers/pci/pcie/dpc.h | 20 +++ drivers/pci/pcie/edr.c | 259 ++++++++++++++++++++++++++++++++++++++ drivers/pci/pcie/err.c | 35 ++++-- drivers/pci/probe.c | 1 + include/linux/acpi.h | 6 +- include/linux/pci-acpi.h | 8 ++ include/linux/pci.h | 1 + 14 files changed, 441 insertions(+), 58 deletions(-) create mode 100644 drivers/pci/pcie/dpc.h create mode 100644 drivers/pci/pcie/edr.cSignature · 1 line
2.21.0
Hi Bjorn,
Quoted 8 lines · Bjorn Helgaas
Quoted 7 lines · On Fri, Feb 07, 2020 at 04:03:30PM -0800…
From: Kuppuswamy Sathyanarayanan <[email protected]>
This patchset adds support for following features:
1. Error Disconnect Recover (EDR) support.
2._OSCbased negotiation support for DPC.
Quoted 8 lines
Quoted 3 lines
You can find EDR spec in the following link.
Hi Sathy,
Bad timing! Linus tagged v5.6-rc1 on Feb 9, shortly after you posted this. Would you mind refreshing this so it applies on my "master" branch (v5.6-rc1)?
Sure.
Quoted 92 lines
Quoted 92 lines
Changes since v13:
* Moved all EDR related code toedr.c
* Addressed Bjorns comments.Changes since v12:
* Addressed Bjorns comments.
* Added check forCONFIG_PCIE_EDRbefore requesting DPC control from firmware.
* Removedff_checkparameter from AER APIs.
* Used macros for_OSTreturn status values in DPC driver.Changes since v11:
* Allowed error recovery to proceed after successfulreset_link().
* Used correct ACPI handle for sending EDR status.
* Rebased on top of v5.5-rc5Changes since v10:
* Added "edr_enabled" member to dpc priv structure, which is used to cache EDR enabling status based on status ofpcie_ports_dpc_nativeand FF mode.
* Changed type of_DSMargument from Integer to Package inacpi_enable_dpc_port()function to fix ACPI related boot warnings.
* Rebased on top of v5.5-rc3Changes since v9:
* Removed caching ofpcie_aer_get_firmware_first()in dpc driver.
* Added proper spec reference in git log for patch 5 & 7.
* Added new function parameter "ff_check" topci_cleanup_aer_uncorrect_error_status(),pci_aer_clear_fatal_status()andpci_cleanup_aer_error_status_regs()functions.
* Rebased on top of v5.4-rc5Changes since v8:
* Rebased on top of v5.4-rc1Changes since v7:
* Updated DSM version number to match the spec.Changes since v6:
* Modified the order of patches to enable EDR only after all necessary support is added in kernel.
* Addressed Bjorn comments.Changes since v5:
* Addressed Keith's comments.
* Added additional check for FF mode inpci_aer_init().
* Updated commit history of "PCI/DPC: Add support for DPC recovery onNON_FATALerrors" patch.Changes since v4:
* Rebased on top of v5.3-rc1
* Fixed lock/unlock issue inedr_handle_event().
* Merged "Update error status afterreset_link()" patch into this patchset.Changes since v3:
* Moved EDR related ACPI functions/definitions topci-acpi.c
* Modified commit history in few patches to include spec reference.
* Added support to handle DPC triggered byNON_FATALerrors.
* Addededr_lockto protect PCI device receiving duplicate EDR notifications.
* Addressed Bjorn comments.Changes since v2:
* Split EDR support patch into multiple patches.
* Addressed Bjorn comments.Changes since v1:
* Rebased on top of v5.1-rc1Kuppuswamy Sathyanarayanan (5):
PCI/ERR: Update error status afterreset_link()PCI/DPC: Removepcie_devicereference fromdpc_devstructure PCI/EDR: Export AER, DPC and error recovery functions PCI/DPC: Add Error Disconnect Recover (EDR) support PCI/ACPI: Enable EDR supportdrivers/acpi/pci_root.c | 16 +++ drivers/pci/pci-acpi.c | 3 + drivers/pci/pci.h | 8 ++ drivers/pci/pcie/Kconfig | 10 ++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 39 ++++-- drivers/pci/pcie/dpc.c | 92 ++++++++------ drivers/pci/pcie/dpc.h | 20 +++ drivers/pci/pcie/edr.c | 259 ++++++++++++++++++++++++++++++++++++++ drivers/pci/pcie/err.c | 35 ++++-- drivers/pci/probe.c | 1 + include/linux/acpi.h | 6 +- include/linux/pci-acpi.h | 8 ++ include/linux/pci.h | 1 + 14 files changed, 441 insertions(+), 58 deletions(-)create mode 100644
drivers/pci/pcie/dpc.h
create mode 100644drivers/pci/pcie/edr.cSignature · 1 line
2.21.0
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux kernel developer