Skip to content

Commit 74f0b5f

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI/DPC: Use defines with DPC reason fields
Add new defines for DPC reason fields and use them instead of literals. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> [bhelgaas: shorten comments] Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f00e8db commit 74f0b5f

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

drivers/pci/pcie/dpc.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,27 @@ void dpc_process_error(struct pci_dev *pdev)
274274
pci_info(pdev, "containment event, status:%#06x source:%#06x\n",
275275
status, source);
276276

277-
reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
278-
ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
277+
reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN;
278+
ext_reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT;
279279
pci_warn(pdev, "%s detected\n",
280-
(reason == 0) ? "unmasked uncorrectable error" :
281-
(reason == 1) ? "ERR_NONFATAL" :
282-
(reason == 2) ? "ERR_FATAL" :
283-
(ext_reason == 0) ? "RP PIO error" :
284-
(ext_reason == 1) ? "software trigger" :
285-
"reserved error");
280+
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR) ?
281+
"unmasked uncorrectable error" :
282+
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE) ?
283+
"ERR_NONFATAL" :
284+
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE) ?
285+
"ERR_FATAL" :
286+
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO) ?
287+
"RP PIO error" :
288+
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER) ?
289+
"software trigger" :
290+
"reserved error");
286291

287292
/* show RP PIO error detail information */
288-
if (pdev->dpc_rp_extensions && reason == 3 && ext_reason == 0)
293+
if (pdev->dpc_rp_extensions &&
294+
reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT &&
295+
ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO)
289296
dpc_process_rp_pio_error(pdev);
290-
else if (reason == 0 &&
297+
else if (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR &&
291298
dpc_get_aer_uncorrect_severity(pdev, &info) &&
292299
aer_get_device_error_info(pdev, &info)) {
293300
aer_print_error(pdev, &info);

include/uapi/linux/pci_regs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,15 @@
10441044
#define PCI_EXP_DPC_STATUS 0x08 /* DPC Status */
10451045
#define PCI_EXP_DPC_STATUS_TRIGGER 0x0001 /* Trigger Status */
10461046
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN 0x0006 /* Trigger Reason */
1047+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR 0x0000 /* Uncorrectable error */
1048+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE 0x0002 /* Rcvd ERR_NONFATAL */
1049+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE 0x0004 /* Rcvd ERR_FATAL */
1050+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT 0x0006 /* Reason in Trig Reason Extension field */
10471051
#define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */
10481052
#define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */
10491053
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */
1054+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO 0x0000 /* RP PIO error */
1055+
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER 0x0020 /* DPC SW Trigger bit */
10501056
#define PCI_EXP_DPC_RP_PIO_FEP 0x1f00 /* RP PIO First Err Ptr */
10511057

10521058
#define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */

0 commit comments

Comments
 (0)