Skip to contentSkip to conversation

Add Error Disconnect Recover (EDR) support

PATCH Superseded [email protected] 2 participants 17 messages Oct 3, 2019 – Oct 29, 2019

Subsystems (3)

v9 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v9 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 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 (8):
PCI/ERR: Update error status after reset_link()
PCI/DPC: Allow dpc_probe() even if firmware first mode is enabled PCI/DPC: Add dpc_process_error() wrapper function PCI/DPC: Add Error Disconnect Recover (EDR) support PCI/AER: Allow clearing Error Status Register in FF mode PCI/DPC: Update comments related to DPC recovery on NON_FATAL errors PCI/DPC: Clear AER registers in EDR mode
PCI/ACPI: Enable EDR support

 drivers/acpi/pci_root.c         |   9 ++
 drivers/pci/pci-acpi.c          |  91 +++++++++++++++
 drivers/pci/pcie/Kconfig        |  10 ++
 drivers/pci/pcie/aer.c          |  12 +-
 drivers/pci/pcie/dpc.c          | 194 +++++++++++++++++++++++++++++---
 drivers/pci/pcie/err.c          |  10 +-
 drivers/pci/pcie/portdrv_core.c |   8 +-
 drivers/pci/probe.c             |   1 +
 include/linux/acpi.h            |   6 +-
 include/linux/pci-acpi.h        |  11 ++
 include/linux/pci.h             |   3 +-
 11 files changed, 321 insertions(+), 34 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v9 1/8 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, if the reset is successful there is no need to continue the rest of the error recovery checks. Also, 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().

Fixes bdb5ac85777d ("PCI/ERR: Handle fatal error recovery")
Cc Ashok Raj <[email protected]>
Cc Keith Busch <[email protected]>
---
 drivers/pci/pcie/err.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/pcie/err.c +7 -3
index b0e6048a9208..53cd9200ec2c 100644
@@ -204,9 +204,12 @@ 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;
+		goto done;
+	}
 
 	if (status == PCI_ERS_RESULT_CAN_RECOVER) {
 		status = PCI_ERS_RESULT_RECOVERED;
@@ -228,6 +231,7 @@ void pcie_do_recovery(struct pci_dev *dev, enum pci_channel_state state,
 	if (status != PCI_ERS_RESULT_RECOVERED)
 		goto failed;
 
+done:
 	pci_dbg(dev, "broadcast resume message\n");
 	pci_walk_bus(bus, report_resume, &status);
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH v9 2/8 PCI/DPC: Allow dpc_probe() even if firmware first mode is enabled

In reply to [email protected]

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per ACPI specification v6.3, sec 5.6.6, Error Disconnect Recover (EDR) notification used by firmware to let OS know about the DPC event and permit OS to perform error recovery when processing the EDR notification. 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), it's responsible for initializing Downstream Port Containment Extended Capability Structures per firmware policy. And, OS is permitted to read or write DPC Control and Status registers of a port while processing an Error Disconnect Recover (EDR) notification from firmware on that port.

Currently, if firmware controls DPC (firmware first mode), OS will not create/enumerate DPC PCIe port services. But, if OS supports EDR feature, then as mentioned in above spec references, it should permit enumeration of DPC driver and also support handling ACPI EDR notification. So as first step, allow dpc_probe() to continue even if firmware first mode is enabled. Also add appropriate checks to ensure device registers are not modified outside EDR notification window in firmware first mode. This is a preparatory patch for adding EDR support.

---
 drivers/pci/pcie/dpc.c | 49 +++++++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 13 deletions(-)
drivers/pci/pcie/dpc.c +36 -13
index a32ec3487a8d..9717fda012f8 100644
@@ -22,6 +22,8 @@ struct dpc_dev {
 	u16			cap_pos;
 	bool			rp_extensions;
 	u8			rp_log_size;
+	/* Set True if DPC is controlled by firmware */
+	bool			firmware_dpc;
 };
 
 static const char * const rp_pio_error_string[] = {
@@ -69,6 +71,9 @@ void pci_save_dpc_state(struct pci_dev *dev)
 	if (!dpc)
 		return;
 
+	if (dpc->firmware_dpc)
+		return;
+
 	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC);
 	if (!save_state)
 		return;
@@ -90,6 +95,9 @@ void pci_restore_dpc_state(struct pci_dev *dev)
 	if (!dpc)
 		return;
 
+	if (dpc->firmware_dpc)
+		return;
+
 	save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_DPC);
 	if (!save_state)
 		return;
@@ -291,9 +299,6 @@ static int dpc_probe(struct pcie_device *dev)
 	int status;
 	u16 ctl, cap;
 
-	if (pcie_aer_get_firmware_first(pdev))
-		return -ENOTSUPP;
-
 	dpc = devm_kzalloc(device, sizeof(*dpc), GFP_KERNEL);
 	if (!dpc)
 		return -ENOMEM;
@@ -302,13 +307,25 @@ static int dpc_probe(struct pcie_device *dev)
 	dpc->dev = dev;
 	set_service_data(dev, dpc);
 
-	status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
-					   dpc_handler, IRQF_SHARED,
-					   "pcie-dpc", dpc);
-	if (status) {
-		pci_warn(pdev, "request IRQ%d failed: %d\n", dev->irq,
-			 status);
-		return status;
+	if (pcie_aer_get_firmware_first(pdev))
+		dpc->firmware_dpc = 1;
+
+	/*
+	 * If DPC is handled in firmware and ACPI support is not enabled
+	 * in OS, skip probe and return error.
+	 */
+	if (dpc->firmware_dpc && !IS_ENABLED(CONFIG_ACPI))
+		return -ENODEV;
+
+	if (!dpc->firmware_dpc) {
+		status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
+						   dpc_handler, IRQF_SHARED,
+						   "pcie-dpc", dpc);
+		if (status) {
+			pci_warn(pdev, "request IRQ%d failed: %d\n", dev->irq,
+				 status);
+			return status;
+		}
 	}
 
 	pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CAP, &cap);
@@ -323,9 +340,12 @@ static int dpc_probe(struct pcie_device *dev)
 			dpc->rp_log_size = 0;
 		}
 	}
-
-	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);
+	if (!dpc->firmware_dpc) {
+		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);
+	}
 
 	pci_info(pdev, "error containment capabilities: Int Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
 		 cap & PCI_EXP_DPC_IRQ, FLAG(cap, PCI_EXP_DPC_CAP_RP_EXT),
@@ -343,6 +363,9 @@ static void dpc_remove(struct pcie_device *dev)
 	struct pci_dev *pdev = dev->port;
 	u16 ctl;
 
+	if (dpc->firmware_dpc)
+		return;
+
 	pci_read_config_word(pdev, dpc->cap_pos + PCI_EXP_DPC_CTL, &ctl);
 	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);
Signature · 1 line
2.21.0
#3 lore raw

PATCH v9 3/8 PCI/DPC: Add dpc_process_error() wrapper function

In reply to [email protected]

From: Kuppuswamy Sathyanarayanan <[email protected]>

With Error Disconnect Recover (EDR) support, we need to support processing DPC event either from DPC IRQ or ACPI EDR event. So create a wrapper function dpc_process_error() and move common error handling code in to it. It will be used to process the DPC event in both DPC IRQ and EDR ACPI event contexts.

---
 drivers/pci/pcie/dpc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/pcie/dpc.c +8 -2
index 9717fda012f8..4137ec7b48cc 100644
@@ -232,10 +232,9 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
 	return 1;
 }
 
-static irqreturn_t dpc_handler(int irq, void *context)
+static void dpc_process_error(struct dpc_dev *dpc)
 {
 	struct aer_err_info info;
-	struct dpc_dev *dpc = context;
 	struct pci_dev *pdev = dpc->dev->port;
 	u16 cap = dpc->cap_pos, status, source, reason, ext_reason;
 
@@ -268,6 +267,13 @@ static irqreturn_t dpc_handler(int irq, void *context)
 
 	/* We configure DPC so it only triggers on ERR_FATAL */
 	pcie_do_recovery(pdev, pci_channel_io_frozen, PCIE_PORT_SERVICE_DPC);
+}
+
+static irqreturn_t dpc_handler(int irq, void *context)
+{
+	struct dpc_dev *dpc = context;
+
+	dpc_process_error(dpc);
 
 	return IRQ_HANDLED;
 }
Signature · 1 line
2.21.0
#4 lore raw

PATCH v9 4/8 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. So with EDR support, OS should provide DPC port services even in firmware first mode.

---
 drivers/pci/pci-acpi.c   |  91 ++++++++++++++++++++++++++++
 drivers/pci/pcie/Kconfig |  10 ++++
 drivers/pci/pcie/dpc.c   | 125 ++++++++++++++++++++++++++++++++++++++-
 include/linux/pci-acpi.h |  11 ++++
 4 files changed, 236 insertions(+), 1 deletion(-)
drivers/pci/pci-acpi.c +91 -0
index 0c02d500158f..6d9ddef0caf8 100644
@@ -103,6 +103,97 @@ int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment,
 }
 #endif
 
+#if defined(CONFIG_PCIE_DPC) && defined(CONFIG_ACPI)
+
+/*
+ * _DSM wrapper function to enable/disable DPC port.
+ * @dpc   : DPC device structure
+ * @enable: status of DPC port (0 or 1).
+ *
+ * returns 0 on success or errno on failure.
+ */
+int acpi_enable_dpc_port(struct pci_dev *pdev, acpi_handle handle, bool enable)
+{
+	union acpi_object *obj;
+	int status = 0;
+	union acpi_object argv4;
+
+	argv4.type = ACPI_TYPE_INTEGER;
+	argv4.integer.value = enable;
+
+	obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 5,
+				EDR_PORT_ENABLE_DSM, &argv4);
+	if (!obj)
+		return -EIO;
+
+	if (obj->type != ACPI_TYPE_INTEGER || obj->integer.value != enable)
+		status = -EIO;
+
+	ACPI_FREE(obj);
+
+	return status;
+}
+
+/*
+ * _DSM wrapper function to locate DPC port.
+ * @dpc   : DPC device structure
+ *
+ * returns pci_dev or NULL.
+ */
+struct pci_dev *acpi_locate_dpc_port(struct pci_dev *pdev, acpi_handle handle)
+{
+	union acpi_object *obj;
+	u16 port;
+
+	obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 5,
+				EDR_PORT_LOCATE_DSM, NULL);
+	if (!obj)
+		return pci_dev_get(pdev);
+
+	if (obj->type != ACPI_TYPE_INTEGER) {
+		ACPI_FREE(obj);
+		return NULL;
+	}
+
+	/*
+	 * Firmware returns DPC port BDF details in following format:
+	 *	15:8 = bus
+	 *	7:3 = device
+	 *	2:0 = function
+	 */
+	port = obj->integer.value;
+
+	ACPI_FREE(obj);
+
+	return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+					   PCI_BUS_NUM(port), port & 0xff);
+}
+
+/*
+ * _OST wrapper function to let firmware know the status of EDR event.
+ * @dpc   : DPC device structure.
+ * @status: Status of EDR event.
+ */
+int acpi_send_edr_status(struct pci_dev *pdev,  acpi_handle handle, u16 status)
+{
+	u32 ost_status;
+
+	pci_dbg(pdev, "Sending EDR status :%x\n", status);
+
+	ost_status =  PCI_DEVID(pdev->bus->number, pdev->devfn);
+	ost_status = (ost_status << 16) | status;
+
+	status = acpi_evaluate_ost(handle,
+				   ACPI_NOTIFY_DISCONNECT_RECOVER,
+				   ost_status, NULL);
+	if (ACPI_FAILURE(status))
+		return -EINVAL;
+
+	return 0;
+}
+
+#endif /* CONFIG_PCIE_DPC && CONFIG_ACPI */
+
 phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
 {
 	acpi_status status = AE_NOT_EXIST;
drivers/pci/pcie/Kconfig +10 -0
index 362eb8cfa53b..9a05015af7cd 100644
@@ -150,3 +150,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"
+	default n
+	depends on PCIE_DPC && ACPI
+	help
+	  This options adds Error Disconnect Recover support as specified
+	  in PCI firmware specification v3.2 Downstream Port Containment
+	  Related Enhancements ECN. Enable this if you want to support hybrid
+	  DPC model which uses both firmware and OS to implement DPC.
drivers/pci/pcie/dpc.c +124 -1

173 lines not on this page · raw message

include/linux/pci-acpi.h +11 -0
index 62b7fdcc661c..36ffe1e16e69 100644
@@ -117,6 +117,17 @@ static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
 static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
 #endif	/* CONFIG_ACPI */
 
+#if defined(CONFIG_PCIE_DPC) && defined(CONFIG_ACPI)
+#define EDR_PORT_ENABLE_DSM     0x0C
+#define EDR_PORT_LOCATE_DSM     0x0D
+int acpi_enable_dpc_port(struct pci_dev *pdev, acpi_handle handle,
+			 bool enable);
+struct pci_dev *acpi_locate_dpc_port(struct pci_dev *pdev,
+				     acpi_handle handle);
+int acpi_send_edr_status(struct pci_dev *pdev,
+			 acpi_handle handle, u16 status);
+#endif
+
 #ifdef CONFIG_ACPI_APEI
 extern bool aer_acpi_firmware_first(void);
 #else
Signature · 1 line
2.21.0
#5 lore raw

PATCH v9 5/8 PCI/AER: Allow clearing Error Status Register in FF mode

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, table 4-6, Error Disconnect Recover (EDR) support allows OS to handle error recovery and clearing Error Registers even in FF mode. So remove FF mode checks in pci_cleanup_aer_uncorrect_error_status(), pci_aer_clear_fatal_status() and pci_cleanup_aer_error_status_regs() functions.

---
 drivers/pci/pcie/aer.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/pci/pcie/aer.c +2 -10
index b45bc47d04fe..e1509bb900c5 100644
@@ -383,9 +383,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);
@@ -406,9 +403,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);
@@ -430,9 +424,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);
@@ -455,7 +446,8 @@ void pci_aer_init(struct pci_dev *dev)
 	if (dev->aer_cap)
 		dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
 
-	pci_cleanup_aer_error_status_regs(dev);
+	if (!pcie_aer_get_firmware_first(dev))
+		pci_cleanup_aer_error_status_regs(dev);
 }
 
 void pci_aer_exit(struct pci_dev *dev)
Signature · 1 line
2.21.0
#6 lore raw

Re: [PATCH v9 5/8] PCI/AER: Allow clearing Error Status Register in FF mode

Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:01PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN, sec 4.5.1, table 4-6,

That table adds bit 7, "DPC config control" to the _OSC control field and talks about modifying registers in the DPC capability.

It doesn't say anything about firmware-first or about the OS modifying registers in the AER capability. But this patch doesn't do anything related to DPC or _OSC.

Quoted 48 lines

Error Disconnect
Recover (EDR) support allows OS to handle error recovery and clearing Error Registers even in FF mode. So remove FF mode checks in pci_cleanup_aer_uncorrect_error_status(), pci_aer_clear_fatal_status() and pci_cleanup_aer_error_status_regs() functions.

---
 drivers/pci/pcie/aer.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/pci/pcie/aer.c +0 -9
index b45bc47d04fe..e1509bb900c5 100644
@@ -383,9 +383,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);
@@ -406,9 +403,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);
@@ -430,9 +424,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);

drivers/pci/pcie/aer.c void pci_aer_init(struct pci_dev *dev) · line 450

Quoted 6 lines
drivers/pci/pcie/aer.c +2 -1
@@ -455,7 +446,8 @@ void pci_aer_init(struct pci_dev *dev)
 	if (dev->aer_cap)
 		dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
 
-	pci_cleanup_aer_error_status_regs(dev);
+	if (!pcie_aer_get_firmware_first(dev))
+		pci_cleanup_aer_error_status_regs(dev);

This effectively moves the "if (pcie_aer_get_firmware_first())" check from pci_cleanup_aer_error_status_regs() into one of the callers. But there are two other callers: pci_aer_init() and pci_restore_state(). Do they need the change, or do you want to cleanup the AER error registers there, but not here?

Quoted 6 lines
drivers/pci/pcie/aer.c +0 -0
 }
 
 void pci_aer_exit(struct pci_dev *dev)
Signature · 1 line
2.21.0
#7 lore raw

Re: [PATCH v9 5/8] PCI/AER: Allow clearing Error Status Register in FF mode

Quoted 11 lines · Bjorn Helgaas
Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:01PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN, sec 4.5.1, table 4-6,

That table adds bit 7, "DPC config control" to the _OSC control field and talks about modifying registers in the DPC capability.

It doesn't say anything about firmware-first or about the OS modifying registers in the AER capability. But this patch doesn't do anything related to DPC or _OSC.

Expectation of clearing AER registers is not explicitly mentioned in above DPC ECN. But it has been clarified in the following update to this ECN.

Please check the implementation note in page 10 of
https://members.pcisig.com/wg/PCI-SIG/document/previewpdf/13563.

It  specifies that in EDR mode, firmware expects OS to clear error registers (Check for following string "Bring Portout of DPC, clear port error status, assign bus numbers to child devices").

I will include this ECN reference in follow up update.

Quoted 51 lines
Quoted 51 lines

Error Disconnect
Recover (EDR) support allows OS to handle error recovery and clearing Error Registers even in FF mode. So remove FF mode checks in pci_cleanup_aer_uncorrect_error_status(), pci_aer_clear_fatal_status() and pci_cleanup_aer_error_status_regs() functions.

---
  drivers/pci/pcie/aer.c | 12 ++----------
  1 file changed, 2 insertions(+), 10 deletions(-)
drivers/pci/pcie/aer.c +0 -9
index b45bc47d04fe..e1509bb900c5 100644
@@ -383,9 +383,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);
@@ -406,9 +403,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);
@@ -430,9 +424,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);
@@ -455,7 +446,8 @@ void pci_aer_init(struct pci_dev *dev)
  	if (dev->aer_cap)
  		dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
 
Quoted 8 lines

drivers/pci/pcie/aer.c void pci_aer_init(struct pci_dev *dev) · line 450

Quoted 3 lines
drivers/pci/pcie/aer.c +2 -1
-	pci_cleanup_aer_error_status_regs(dev);
+	if (!pcie_aer_get_firmware_first(dev))
+		pci_cleanup_aer_error_status_regs(dev);

This effectively moves the "if (pcie_aer_get_firmware_first())" check from pci_cleanup_aer_error_status_regs() into one of the callers. But there are two other callers: pci_aer_init() and pci_restore_state(). Do they need the change, or do you want to cleanup the AER error registers there, but not here?

Good catch. I have added this check to pci_aer_init(). But it needs to be added to pci_restore_state() as well. Instead of moving the checks to the caller, If you agree, I could change the API to pci_cleanup_aer_error_status_regs(struct pci_dev *dev, bool skip_ff_check) and let the caller decide whether they want skip the check or not.

Quoted 7 lines
Quoted 7 lines
drivers/pci/pcie/aer.c +0 -0
  }
 
  void pci_aer_exit(struct pci_dev *dev)
Signature · 1 line
2.21.0
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
#8 lore raw

Re: [PATCH v9 5/8] PCI/AER: Allow clearing Error Status Register in FF mode

Quoted 27 lines · Kuppuswamy Sathyanarayanan
Quoted 16 lines · Bjorn Helgaas
Quoted 15 lines · On Thu, Oct 03, 2019 at 04:39:01PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

drivers/pci/pcie/aer.c +0 -4
@@ -430,9 +424,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);
@@ -455,7 +446,8 @@ void pci_aer_init(struct pci_dev *dev)
  	if (dev->aer_cap)
  		dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
-	pci_cleanup_aer_error_status_regs(dev);
Quoted 8 lines

drivers/pci/pcie/aer.c void pci_aer_init(struct pci_dev *dev) · line 450

Quoted 2 lines
drivers/pci/pcie/aer.c +2 -0
+	if (!pcie_aer_get_firmware_first(dev))
+		pci_cleanup_aer_error_status_regs(dev);

This effectively moves the "if (pcie_aer_get_firmware_first())" check from pci_cleanup_aer_error_status_regs() into one of the callers. But there are two other callers: pci_aer_init() and pci_restore_state(). Do they need the change, or do you want to cleanup the AER error registers there, but not here?

Quoted 6 lines

Good catch. I have added this check to pci_aer_init(). But it needs to be added to pci_restore_state() as well. Instead of moving the checks to the caller, If you agree, I could change the API to pci_cleanup_aer_error_status_regs(struct pci_dev *dev, bool skip_ff_check) and let the caller decide whether they want skip the check or not.

If all callers of pci_cleanup_aer_error_status_regs() would have to check pcie_aer_get_firmware_first(), I don't understand why you're moving the check at all.

#9 lore raw

Re: [PATCH v9 5/8] PCI/AER: Allow clearing Error Status Register in FF mode

Quoted 30 lines · Bjorn Helgaas
Quoted 23 lines · Kuppuswamy Sathyanarayanan
Quoted 14 lines · Bjorn Helgaas
Quoted 13 lines · On Thu, Oct 03, 2019 at 04:39:01PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

drivers/pci/pcie/aer.c +0 -3
@@ -430,9 +424,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);
@@ -455,7 +446,8 @@ void pci_aer_init(struct pci_dev *dev)
   	if (dev->aer_cap)
   		dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);
Quoted 8 lines

drivers/pci/pcie/aer.c void pci_aer_init(struct pci_dev *dev) · line 450

Quoted 3 lines
drivers/pci/pcie/aer.c +2 -1
-	pci_cleanup_aer_error_status_regs(dev);
+	if (!pcie_aer_get_firmware_first(dev))
+		pci_cleanup_aer_error_status_regs(dev);

This effectively moves the "if (pcie_aer_get_firmware_first())" check from pci_cleanup_aer_error_status_regs() into one of the callers. But there are two other callers: pci_aer_init() and pci_restore_state(). Do they need the change, or do you want to cleanup the AER error registers there, but not here?

Quoted 6 lines

Good catch. I have added this check to pci_aer_init(). But it needs to be added to pci_restore_state() as well. Instead of moving the checks to the caller, If you agree, I could change the API to pci_cleanup_aer_error_status_regs(struct pci_dev *dev, bool skip_ff_check) and let the caller decide whether they want skip the check or not.

Quoted 3 lines

If all callers of pci_cleanup_aer_error_status_regs() would have to check pcie_aer_get_firmware_first(), I don't understand why you're moving the check at all.

We need exception for the call made from DPC driver. If pcie_aer_get_firmware_first() call is made from DPC driver during EDR mode execution, then FF mode check needs to be skipped.

Quoted 1 line
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
#10 lore raw

PATCH v9 6/8 PCI/DPC: Update comments related to DPC recovery on NON_FATAL errors

In reply to [email protected]

From: Kuppuswamy Sathyanarayanan <[email protected]>

Currently, in native mode, DPC driver is configured to trigger DPC only for FATAL errors and hence it only supports port recovery for FATAL errors. But with Error Disconnect Recover (EDR) support, DPC configuration is done by firmware, and hence we should expect DPC triggered for both FATAL/NON_FATAL errors. So update comments and add details about how NON_FATAL dpc recovery is handled.

---
 drivers/pci/pcie/dpc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/pcie/dpc.c +5 -1
index a8b634e05694..fafc55c00fe0 100644
@@ -275,7 +275,11 @@ static void dpc_process_error(struct dpc_dev *dpc)
 		pci_aer_clear_fatal_status(pdev);
 	}
 
-	/* We configure DPC so it only triggers on ERR_FATAL */
+	/*
+	 * Irrespective of whether the DPC event is triggered by
+	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
+	 * use the FATAL error recovery path for both cases.
+	 */
 	pcie_do_recovery(pdev, pci_channel_io_frozen, PCIE_PORT_SERVICE_DPC);
 }
 
Signature · 1 line
2.21.0
#11 lore raw

PATCH v9 7/8 PCI/DPC: Clear AER registers in EDR mode

In reply to [email protected]

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN, OS is responsible for clearing the AER registers in EDR mode. So clear AER registers in dpc_process_error() function.

---
 drivers/pci/pcie/dpc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pci/pcie/dpc.c +4 -0
index fafc55c00fe0..de2d892bc7c4 100644
@@ -275,6 +275,10 @@ static void dpc_process_error(struct dpc_dev *dpc)
 		pci_aer_clear_fatal_status(pdev);
 	}
 
+	/* In EDR mode, OS is responsible for clearing AER registers */
+	if (dpc->firmware_dpc)
+		pci_cleanup_aer_error_status_regs(pdev);
+
 	/*
 	 * Irrespective of whether the DPC event is triggered by
 	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
Signature · 1 line
2.21.0
#12 lore raw

Re: [PATCH v9 7/8] PCI/DPC: Clear AER registers in EDR mode

Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:03PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN,

Specific reference, please, e.g., the section/table/figure of the PCI Firmware Spec being modified by the ECN.

Quoted 15 lines

OS is responsible for clearing the AER
registers in EDR mode. So clear AER registers in dpc_process_error() function.

---
 drivers/pci/pcie/dpc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pci/pcie/dpc.c +0 -0
index fafc55c00fe0..de2d892bc7c4 100644

drivers/pci/pcie/dpc.c static void dpc_process_error(struct dpc_dev *dpc) · line 279

Quoted 5 lines
drivers/pci/pcie/dpc.c +2 -0
@@ -275,6 +275,10 @@ static void dpc_process_error(struct dpc_dev *dpc)
 		pci_aer_clear_fatal_status(pdev);
 	}
 
+	/* In EDR mode, OS is responsible for clearing AER registers */
+	if (dpc->firmware_dpc)

I guess "EDR mode" is effectively the same as "firmware-first mode"?

At least, the only place we set "firmware_dpc = 1" is:

+ if (pcie_aer_get_firmware_first(pdev))
+ dpc->firmware_dpc = 1;

If they're the same, why do we need two different names for it?

Quoted 8 lines
drivers/pci/pcie/dpc.c +2 -0
+		pci_cleanup_aer_error_status_regs(pdev);
+
 	/*
 	 * Irrespective of whether the DPC event is triggered by
 	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
Signature · 1 line
2.21.0
#13 lore raw

Re: [PATCH v9 7/8] PCI/DPC: Clear AER registers in EDR mode

Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:03PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN,

Specific reference, please, e.g., the section/table/figure of the PCI Firmware Spec being modified by the ECN.

Ok. I will include it.

Quoted 19 lines
Quoted 19 lines

OS is responsible for clearing the AER
registers in EDR mode. So clear AER registers in dpc_process_error() function.

---
  drivers/pci/pcie/dpc.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/pci/pcie/dpc.c +0 -0
index fafc55c00fe0..de2d892bc7c4 100644
@@ -275,6 +275,10 @@ static void dpc_process_error(struct dpc_dev *dpc)
  		pci_aer_clear_fatal_status(pdev);
  	}
 
Quoted 3 lines

drivers/pci/pcie/dpc.c static void dpc_process_error(struct dpc_dev *dpc) · line 279

Quoted 2 lines
drivers/pci/pcie/dpc.c +2 -0
+	/* In EDR mode, OS is responsible for clearing AER registers */
+	if (dpc->firmware_dpc)

I guess "EDR mode" is effectively the same as "firmware-first mode"?

Yes, EDR mode is an upgrade to FF mode in which firmware allows OS to share some of it job by sending ACPI notification. If you don't get ACPI notification, EDR mode is effectively same as FF mode.

Quoted 7 lines

At least, the only place we set "firmware_dpc = 1" is:

+ if (pcie_aer_get_firmware_first(pdev))
+ dpc->firmware_dpc = 1;

If they're the same, why do we need two different names for it?

For better readability and performance, I tried to cache the value of pcie_aer_get_firmware_first() result in DPC driver.

Quoted 9 lines
Quoted 9 lines
drivers/pci/pcie/dpc.c +2 -0
+		pci_cleanup_aer_error_status_regs(pdev);
+
  	/*
  	 * Irrespective of whether the DPC event is triggered by
  	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
Signature · 1 line
2.21.0
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
#14 lore raw

Re: [PATCH v9 7/8] PCI/DPC: Clear AER registers in EDR mode

Quoted 33 lines · Kuppuswamy Sathyanarayanan
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:03PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN,

Specific reference, please, e.g., the section/table/figure of the PCI Firmware Spec being modified by the ECN.

Ok. I will include it.

Quoted 11 lines
Quoted 11 lines

OS is responsible for clearing the AER
registers in EDR mode. So clear AER registers in dpc_process_error() function.

---
  drivers/pci/pcie/dpc.c | 4 ++++
  1 file changed, 4 insertions(+)
Quoted 11 lines

drivers/pci/pcie/dpc.c static void dpc_process_error(struct dpc_dev *dpc) · line 278

Quoted 9 lines
drivers/pci/pcie/dpc.c +2 -0
index fafc55c00fe0..de2d892bc7c4 100644
@@ -275,6 +275,10 @@ static void dpc_process_error(struct dpc_dev *dpc)
  		pci_aer_clear_fatal_status(pdev);
  	}
+	/* In EDR mode, OS is responsible for clearing AER registers */
+	if (dpc->firmware_dpc)

I guess "EDR mode" is effectively the same as "firmware-first mode"?

Quoted 3 lines

Yes, EDR mode is an upgrade to FF mode in which firmware allows OS to share some of it job by sending ACPI notification. If you don't get ACPI notification, EDR mode is effectively same as FF mode.

Hmm, somehow the connection between FF and EDR needs to be clear from the code, so people who weren't involved in the development of EDR and don't even have access to the specs/ECNs can make sense out of this.

Quoted 8 lines
Quoted 6 lines

At least, the only place we set "firmware_dpc = 1" is:

+ if (pcie_aer_get_firmware_first(pdev))
+ dpc->firmware_dpc = 1;

If they're the same, why do we need two different names for it?

For better readability and performance, I tried to cache the value of pcie_aer_get_firmware_first() result in DPC driver.

pcie_aer_get_firmware_first() already caches the value, so I don't think you're gaining any useful performance here, and having two different names *decreases* readability.

I do agree that pcie_aer_get_firmware_first() is not optimally implemented. I think we should probably look up the firmware-first indication explicitly during enumeration so we don't have to bother with the dev->__aer_firmware_first_valid thing. And if we got rid of all those leading underscores, it would probably run faster, too ;)

Quoted 12 lines
Quoted 8 lines
Quoted 8 lines
drivers/pci/pcie/dpc.c +2 -0
+		pci_cleanup_aer_error_status_regs(pdev);
+
  	/*
  	 * Irrespective of whether the DPC event is triggered by
  	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
Signature · 1 line
2.21.0
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
#15 lore raw

Re: [PATCH v9 7/8] PCI/DPC: Clear AER registers in EDR mode

Quoted 30 lines · Bjorn Helgaas
Quoted 29 lines · Kuppuswamy Sathyanarayanan
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · On Thu, Oct 03, 2019 at 04:39:03PM -0700…

From: Kuppuswamy Sathyanarayanan <[email protected]>

As per PCI firmware specification r3.2 Downstream Port Containment Related Enhancements ECN,

Specific reference, please, e.g., the section/table/figure of the PCI Firmware Spec being modified by the ECN.

Ok. I will include it.

Quoted 20 lines
Quoted 15 lines

OS is responsible for clearing the AER
registers in EDR mode. So clear AER registers in dpc_process_error() function.

---
   drivers/pci/pcie/dpc.c | 4 ++++
   1 file changed, 4 insertions(+)
drivers/pci/pcie/dpc.c +0 -0
index fafc55c00fe0..de2d892bc7c4 100644

drivers/pci/pcie/dpc.c static void dpc_process_error(struct dpc_dev *dpc) · line 278

Quoted 4 lines
drivers/pci/pcie/dpc.c +2 -0
@@ -275,6 +275,10 @@ static void dpc_process_error(struct dpc_dev *dpc)
   		pci_aer_clear_fatal_status(pdev);
   	}
+	/* In EDR mode, OS is responsible for clearing AER registers */
+	if (dpc->firmware_dpc)

I guess "EDR mode" is effectively the same as "firmware-first mode"?

Quoted 3 lines
Quoted 3 lines

Yes, EDR mode is an upgrade to FF mode in which firmware allows OS to share some of it job by sending ACPI notification. If you don't get ACPI notification, EDR mode is effectively same as FF mode.

May be I can add some documentation in code to explain the EDR mode better.

Quoted 9 lines

Hmm, somehow the connection between FF and EDR needs to be clear from the code, so people who weren't involved in the development of EDR and don't even have access to the specs/ECNs can make sense out of this.

Quoted 5 lines
Quoted 5 lines

At least, the only place we set "firmware_dpc = 1" is:

+ if (pcie_aer_get_firmware_first(pdev))
+ dpc->firmware_dpc = 1;

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

If they're the same, why do we need two different names for it?

For better readability and performance, I tried to cache the value of pcie_aer_get_firmware_first() result in DPC driver.

pcie_aer_get_firmware_first() already caches the value, so I don't think you're gaining any useful performance here, and having two different names *decreases* readability.

Ok. I can replace "firmware_dpc" with pcie_aer_get_firmware_first() calls.

Quoted 6 lines

I do agree that pcie_aer_get_firmware_first() is not optimally implemented. I think we should probably look up the firmware-first indication explicitly during enumeration so we don't have to bother with the dev->__aer_firmware_first_valid thing. And if we got rid of all those leading underscores, it would probably run faster, too ;)

I agree that pcie_aer_get_firmware_first() can be optimized. I can submit a patch for it once this patch set is merged.

Quoted 13 lines
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines
drivers/pci/pcie/dpc.c +2 -0
+		pci_cleanup_aer_error_status_regs(pdev);
+
   	/*
   	 * Irrespective of whether the DPC event is triggered by
   	 * ERR_FATAL or ERR_NONFATAL, since the link is already down,
Signature · 1 line
2.21.0
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer
#16 lore raw

PATCH v9 8/8 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         | 9 +++++++++
 drivers/pci/pcie/portdrv_core.c | 8 +++++++-
 drivers/pci/probe.c             | 1 +
 include/linux/acpi.h            | 6 ++++--
 include/linux/pci.h             | 3 ++-
 5 files changed, 23 insertions(+), 4 deletions(-)
drivers/acpi/pci_root.c +9 -0
index d1e666ef3fcc..134e20474dfd 100644
@@ -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,9 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
 			control |= OSC_PCI_EXPRESS_AER_CONTROL;
 	}
 
+	if (IS_ENABLED(CONFIG_PCIE_DPC))
+		control |= OSC_PCI_EXPRESS_DPC_CONTROL;
+
 	requested = control;
 	status = acpi_pci_osc_control_set(handle, &control,
 					  OSC_PCI_EXPRESS_CAPABILITY_CONTROL);
@@ -916,6 +923,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/portdrv_core.c +7 -1
index 1b330129089f..1b54a39df795 100644
@@ -250,8 +250,14 @@ static int get_port_device_capability(struct pci_dev *dev)
 		pcie_pme_interrupt_enable(dev, false);
 	}
 
+	/*
+	 * If EDR support is enabled in OS, then even if AER is not handled in
+	 * OS, DPC service can be enabled.
+	 */
 	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
-	    pci_aer_available() && services & PCIE_PORT_SERVICE_AER)
+	    ((IS_ENABLED(CONFIG_PCIE_EDR) && !host->native_dpc) ||
+	    (pci_aer_available() && services & PCIE_PORT_SERVICE_AER &&
+	    (pcie_ports_native || host->native_dpc))))
 		services |= PCIE_PORT_SERVICE_DPC;
 
 	if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM ||
drivers/pci/probe.c +1 -0
index 3d5271a7a849..54be2f93eba3 100644
@@ -596,6 +596,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
index 8b4e516bac00..71452d4959ec 100644
@@ -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 +2 -1
index f9088c89a534..dc0751df03f5 100644
@@ -509,8 +509,9 @@ 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	preserve_config:1;	/* Preserve FW resource setup */
+	unsigned int	native_dpc:1;		/* OS may use PCIe DPC */
 
+	unsigned int	preserve_config:1;	/* Preserve FW resource setup */
 	/* Resource alignment requirements */
 	resource_size_t (*align_resource)(struct pci_dev *dev,
 			const struct resource *res,
Signature · 1 line
2.21.0