PCI: pcie, aer: change error print format
authorHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Mon, 7 Sep 2009 08:16:45 +0000 (17:16 +0900)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Wed, 9 Sep 2009 20:50:05 +0000 (13:50 -0700)
Use dev_printk like format.

Sample (real machine + dummy error injected by aer-inject):

- Before:

+------ PCI-Express Device Error ------+
Error Severity          : Corrected
PCIE Bus Error type     : Data Link Layer
Bad TLP                 :
Receiver ID             : 2800
VendorID=8086h, DeviceID=1096h, Bus=28h, Device=00h, Function=00h
+------ PCI-Express Device Error ------+
Error Severity          : Corrected
PCIE Bus Error type     : Data Link Layer
Bad TLP                 :
Bad DLLP                :
Receiver ID             : 2801
VendorID=8086h, DeviceID=1096h, Bus=28h, Device=00h, Function=01h
Error of this Agent(2801) is reported first

- After:

pcieport-driver 0000:00:02.0: AER: Multiple Corrected error received: id=2801
e1000e 0000:28:00.0: PCIE Bus Error: severity=Corrected, type=Data Link Layer, id=2800(Receiver ID)
e1000e 0000:28:00.0:   device [8086:1096] error status/mask=00000040/00000000
e1000e 0000:28:00.0:    [ 6] Bad TLP
e1000e 0000:28:00.1: PCIE Bus Error: severity=Corrected, type=Data Link Layer, id=2801(Receiver ID)
e1000e 0000:28:00.1:   device [8086:1096] error status/mask=000000c0/00000000
e1000e 0000:28:00.1:    [ 6] Bad TLP
e1000e 0000:28:00.1:    [ 7] Bad DLLP
e1000e 0000:28:00.1:   Error of this Agent(2801) is reported first

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pcie/aer/aerdrv.h
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/pcie/aer/aerdrv_errprint.c

index 78c977c..f9979eb 100644 (file)
@@ -124,6 +124,7 @@ extern void aer_delete_rootport(struct aer_rpc *rpc);
 extern int aer_init(struct pcie_device *dev);
 extern void aer_isr(struct work_struct *work);
 extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
+extern void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info);
 extern irqreturn_t aer_irq(int irq, void *context);
 
 #ifdef CONFIG_ACPI
index 9626469..d9185cd 100644 (file)
@@ -813,6 +813,8 @@ static void aer_isr_one_error(struct pcie_device *p_device,
                         PCI_ERR_ROOT_MULTI_UNCOR_RCV))
                        e_info->multi_error_valid = 1;
 
+               aer_print_port_info(p_device->port, e_info);
+
                find_source_device(p_device->port, e_info);
                aer_process_err_devices(p_device, e_info);
        }
index f0bdf0f..44acde7 100644 (file)
        (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
        AER_TRANSACTION_LAYER_ERROR)
 
-#define AER_PR(info, fmt, args...)                             \
-       printk("%s" fmt, (info->severity == AER_CORRECTABLE) ?  \
-               KERN_WARNING : KERN_ERR, ## args)
+#define AER_PR(info, pdev, fmt, args...)                               \
+       printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ?   \
+               KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
+               dev_name(&pdev->dev), ## args)
 
 /*
  * AER error strings
@@ -152,7 +153,7 @@ static char *aer_agent_string[] = {
        "Transmitter ID"
 };
 
-static void aer_print_error_source(struct aer_err_info *info)
+static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
 {
        int i, status;
        char *errmsg = NULL;
@@ -169,48 +170,44 @@ static void aer_print_error_source(struct aer_err_info *info)
                        errmsg = aer_uncorrectable_error_string[i];
 
                if (errmsg)
-                       AER_PR(info, "%s\t: %s\n", errmsg,
-                               info->first_error == i ? "First" : "");
+                       AER_PR(info, dev, "   [%2d] %s%s\n", i, errmsg,
+                               info->first_error == i ? " (First)" : "");
                else
-                       AER_PR(info, "Unknown Error Bit %2d  \t: %s\n",
-                               i, info->first_error == i ? "First" : "");
+                       AER_PR(info, dev, "   [%2d] Unknown Error Bit%s\n", i,
+                               info->first_error == i ? " (First)" : "");
        }
 }
 
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 {
-       int err_layer, agent;
        int id = ((dev->bus->number << 8) | dev->devfn);
 
-       AER_PR(info, "+------ PCI-Express Device Error ------+\n");
-       AER_PR(info, "Error Severity\t\t: %s\n",
-               aer_error_severity_string[info->severity]);
-
        if (info->status == 0) {
-               AER_PR(info, "PCIE Bus Error type\t: (Unaccessible)\n");
-               AER_PR(info, "Unregistered Agent ID\t: %04x\n", id);
+               AER_PR(info, dev,
+                       "PCIE Bus Error: severity=%s, type=Unaccessible, "
+                       "id=%04x(Unregistered Agent ID)\n",
+                       aer_error_severity_string[info->severity], id);
        } else {
-               err_layer = AER_GET_LAYER_ERROR(info->severity, info->status);
-               AER_PR(info, "PCIE Bus Error type\t: %s\n",
-                       aer_error_layer[err_layer]);
-
-               aer_print_error_source(info);
+               int layer, agent;
 
+               layer = AER_GET_LAYER_ERROR(info->severity, info->status);
                agent = AER_GET_AGENT(info->severity, info->status);
-               AER_PR(info, "%s\t\t: %04x\n", aer_agent_string[agent], id);
 
-               AER_PR(info, "VendorID=%04xh, DeviceID=%04xh,"
-                       " Bus=%02xh, Device=%02xh, Function=%02xh\n",
-                       dev->vendor,
-                       dev->device,
-                       dev->bus->number,
-                       PCI_SLOT(dev->devfn),
-                       PCI_FUNC(dev->devfn));
+               AER_PR(info, dev,
+                       "PCIE Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
+                       aer_error_severity_string[info->severity],
+                       aer_error_layer[layer], id, aer_agent_string[agent]);
+
+               AER_PR(info, dev,
+                       "  device [%04x:%04x] error status/mask=%08x/%08x\n",
+                       dev->vendor, dev->device, info->status, info->mask);
+
+               __aer_print_error(info, dev);
 
                if (info->tlp_header_valid) {
                        unsigned char *tlp = (unsigned char *) &info->tlp;
-                       AER_PR(info, "TLP Header:\n");
-                       AER_PR(info, "%02x%02x%02x%02x %02x%02x%02x%02x"
+                       AER_PR(info, dev, "  TLP Header:"
+                               " %02x%02x%02x%02x %02x%02x%02x%02x"
                                " %02x%02x%02x%02x %02x%02x%02x%02x\n",
                                *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
                                *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
@@ -221,6 +218,13 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
        }
 
        if (info->id && info->error_dev_num > 1 && info->id == id)
-               AER_PR(info, "Error of this Agent(%04x) is reported first\n",
-                       id);
+               AER_PR(info, dev,
+                       "  Error of this Agent(%04x) is reported first\n", id);
+}
+
+void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
+{
+       dev_info(&dev->dev, "AER: %s%s error received: id=%04x\n",
+               info->multi_error_valid ? "Multiple " : "",
+               aer_error_severity_string[info->severity], info->id);
 }