[PATCH v6 1/5] PCI/DPC: Clarify naming for error port in DPC Handling

Shuai Xue
2025-10-15T02:42:05Z

dpc_handler() is registered for error port which recevie DPC interrupt
and acpi_dpc_port_get() locate the port that experienced the containment
event.

Rename edev and pdev to err_port for clear so that later patch will
avoid misused err_port in pcie_do_recovery().

No functional changes intended.

Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
drivers/pci/pcie/dpc.c | 10 +++++-----
drivers/pci/pcie/edr.c | 34 +++++++++++++++++-----------------
2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index fc18349614d7..bff29726c6a5 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -361,21 +361,21 @@ static bool dpc_is_surprise_removal(struct pci_dev *pdev)

static irqreturn_t dpc_handler(int irq, void *context)
{
- struct pci_dev *pdev = context;
+ struct pci_dev *err_port = context;

/*
* According to PCIe r6.0 sec 6.7.6, errors are an expected side effect
* of async removal and should be ignored by software.
*/
- if (dpc_is_surprise_removal(pdev)) {
- dpc_handle_surprise_removal(pdev);
+ if (dpc_is_surprise_removal(err_port)) {
+ dpc_handle_surprise_removal(err_port);
return IRQ_HANDLED;
}

- dpc_process_error(pdev);
+ dpc_process_error(err_port);

/* We configure DPC so it only triggers on ERR_FATAL */
- pcie_do_recovery(pdev, pci_channel_io_frozen, dpc_reset_link);
+ pcie_do_recovery(err_port, pci_channel_io_frozen, dpc_reset_link);

return IRQ_HANDLED;
}
diff --git a/drivers/pci/pcie/edr.c b/drivers/pci/pcie/edr.c
index e86298dbbcff..521fca2f40cb 100644
--- a/drivers/pci/pcie/edr.c
+++ b/drivers/pci/pcie/edr.c
@@ -150,7 +150,7 @@ static int acpi_send_edr_status(struct pci_dev *pdev, struct pci_dev *edev,

static void edr_handle_event(acpi_handle handle, u32 event, void *data)
{
- struct pci_dev *pdev = data, *edev;
+ struct pci_dev *pdev = data, *err_port;
pci_ers_result_t estate = PCI_ERS_RESULT_DISCONNECT;
u16 status;

@@ -169,36 +169,36 @@ static void edr_handle_event(acpi_handle handle, u32 event, void *data)
* may be that port or a parent of it (PCI Firmware r3.3, sec
* 4.6.13).
*/
- edev = acpi_dpc_port_get(pdev);
- if (!edev) {
+ err_port = acpi_dpc_port_get(pdev);
+ if (!err_port) {
pci_err(pdev, "Firmware failed to locate DPC port\n");
return;
}

- pci_dbg(pdev, "Reported EDR dev: %s\n", pci_name(edev));
+ pci_dbg(pdev, "Reported EDR dev: %s\n", pci_name(err_port));

/* If port does not support DPC, just send the OST */
- if (!edev->dpc_cap) {
- pci_err(edev, FW_BUG "This device doesn't support DPC\n");
+ if (!err_port->dpc_cap) {
+ pci_err(err_port, FW_BUG "This device doesn't support DPC\n");
goto send_ost;
}

/* Check if there is a valid DPC trigger */
- pci_read_config_word(edev, edev->dpc_cap + PCI_EXP_DPC_STATUS, &status);
+ pci_read_config_word(err_port, err_port->dpc_cap + PCI_EXP_DPC_STATUS, &status);
if (!(status & PCI_EXP_DPC_STATUS_TRIGGER)) {
- pci_err(edev, "Invalid DPC trigger %#010x\n", status);
+ pci_err(err_port, "Invalid DPC trigger %#010x\n", status);
goto send_ost;
}

- dpc_process_error(edev);
- pci_aer_raw_clear_status(edev);
+ dpc_process_error(err_port);
+ pci_aer_raw_clear_status(err_port);

/*
* 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.
*/
- estate = pcie_do_recovery(edev, pci_channel_io_frozen, dpc_reset_link);
+ estate = pcie_do_recovery(err_port, pci_channel_io_frozen, dpc_reset_link);

send_ost:

@@ -207,15 +207,15 @@ static void edr_handle_event(acpi_handle handle, u32 event, void *data)
* to firmware. If not successful, send _OST(0xF, BDF << 16 | 0x81).
*/
if (estate == PCI_ERS_RESULT_RECOVERED) {
- pci_dbg(edev, "DPC port successfully recovered\n");
- pcie_clear_device_status(edev);
- acpi_send_edr_status(pdev, edev, EDR_OST_SUCCESS);
+ pci_dbg(err_port, "DPC port successfully recovered\n");
+ pcie_clear_device_status(err_port);
+ acpi_send_edr_status(pdev, err_port, EDR_OST_SUCCESS);
} else {
- pci_dbg(edev, "DPC port recovery failed\n");
- acpi_send_edr_status(pdev, edev, EDR_OST_FAILED);
+ pci_dbg(err_port, "DPC port recovery failed\n");
+ acpi_send_edr_status(pdev, err_port, EDR_OST_FAILED);
}

- pci_dev_put(edev);
+ pci_dev_put(err_port);
}

void pci_acpi_add_edr_notifier(struct pci_dev *pdev)
--
2.39.3