]> git.itanic.dy.fi Git - linux-stable/commitdiff
PCI/DPC: Use defines with DPC reason fields
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 18 Oct 2023 11:32:53 +0000 (14:32 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 24 Oct 2023 15:54:04 +0000 (10:54 -0500)
Add new defines for DPC reason fields and use them instead of literals.

Link: https://lore.kernel.org/r/20231018113254.17616-7-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[bhelgaas: shorten comments]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pcie/dpc.c
include/uapi/linux/pci_regs.h

index 0048a11bd11963165228bf664ed46a2b226581a6..94111e4382413dc57ff10a079e1bdfc50c0e978e 100644 (file)
@@ -274,20 +274,27 @@ void dpc_process_error(struct pci_dev *pdev)
        pci_info(pdev, "containment event, status:%#06x source:%#06x\n",
                 status, source);
 
-       reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
-       ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
+       reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN;
+       ext_reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT;
        pci_warn(pdev, "%s detected\n",
-                (reason == 0) ? "unmasked uncorrectable error" :
-                (reason == 1) ? "ERR_NONFATAL" :
-                (reason == 2) ? "ERR_FATAL" :
-                (ext_reason == 0) ? "RP PIO error" :
-                (ext_reason == 1) ? "software trigger" :
-                                    "reserved error");
+                (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR) ?
+                "unmasked uncorrectable error" :
+                (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE) ?
+                "ERR_NONFATAL" :
+                (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE) ?
+                "ERR_FATAL" :
+                (ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO) ?
+                "RP PIO error" :
+                (ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER) ?
+                "software trigger" :
+                "reserved error");
 
        /* show RP PIO error detail information */
-       if (pdev->dpc_rp_extensions && reason == 3 && ext_reason == 0)
+       if (pdev->dpc_rp_extensions &&
+           reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT &&
+           ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO)
                dpc_process_rp_pio_error(pdev);
-       else if (reason == 0 &&
+       else if (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR &&
                 dpc_get_aer_uncorrect_severity(pdev, &info) &&
                 aer_get_device_error_info(pdev, &info)) {
                aer_print_error(pdev, &info);
index 6c1bad2cb04a131c0f168e6933ca7d9ce78e416c..0fd621505246b17f1279b047c357ddbc5049e5bb 100644 (file)
 #define PCI_EXP_DPC_STATUS             0x08    /* DPC Status */
 #define  PCI_EXP_DPC_STATUS_TRIGGER        0x0001 /* Trigger Status */
 #define  PCI_EXP_DPC_STATUS_TRIGGER_RSN            0x0006 /* Trigger Reason */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR  0x0000 /* Uncorrectable error */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE    0x0002 /* Rcvd ERR_NONFATAL */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE     0x0004 /* Rcvd ERR_FATAL */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT 0x0006 /* Reason in Trig Reason Extension field */
 #define  PCI_EXP_DPC_STATUS_INTERRUPT      0x0008 /* Interrupt Status */
 #define  PCI_EXP_DPC_RP_BUSY               0x0010 /* Root Port Busy */
 #define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO         0x0000  /* RP PIO error */
+#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER     0x0020  /* DPC SW Trigger bit */
 #define  PCI_EXP_DPC_RP_PIO_FEP                    0x1f00 /* RP PIO First Err Ptr */
 
 #define PCI_EXP_DPC_SOURCE_ID           0x0A   /* DPC Source Identifier */