aerdrv: Move cper_print_aer() call out of interrupt context
authorLance Ortiz <lance.ortiz@hp.com>
Thu, 30 May 2013 14:25:12 +0000 (08:25 -0600)
committerTony Luck <tony.luck@intel.com>
Thu, 30 May 2013 17:51:20 +0000 (10:51 -0700)
The following warning was seen on 3.9 when a corrected PCIe error was being
handled by the AER subsystem.

WARNING: at .../drivers/pci/search.c:214 pci_get_dev_by_id+0x8a/0x90()

This occurred because a call to pci_get_domain_bus_and_slot() was added to
cper_print_pcie() to setup for the call to cper_print_aer().  The warning
showed up because cper_print_pcie() is called in an interrupt context and
pci_get* functions are not supposed to be called in that context.

The solution is to move the cper_print_aer() call out of the interrupt
context and into aer_recover_work_func() to avoid any warnings when calling
pci_get* functions.

Signed-off-by: Lance Ortiz <lance.ortiz@hp.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/acpi/apei/cper.c
drivers/acpi/apei/ghes.c
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/pcie/aer/aerdrv_errprint.c
include/linux/aer.h

index fefc2ca7cc3e0199b5f98b707107d424dd40b8eb..33dc6a004802120fff9eb1e0e1e757dd542cc4f8 100644 (file)
@@ -250,10 +250,6 @@ static const char *cper_pcie_port_type_strs[] = {
 static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
                            const struct acpi_hest_generic_data *gdata)
 {
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-       struct pci_dev *dev;
-#endif
-
        if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE)
                printk("%s""port_type: %d, %s\n", pfx, pcie->port_type,
                       pcie->port_type < ARRAY_SIZE(cper_pcie_port_type_strs) ?
@@ -285,20 +281,6 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
                printk(
        "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n",
        pfx, pcie->bridge.secondary_status, pcie->bridge.control);
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-       dev = pci_get_domain_bus_and_slot(pcie->device_id.segment,
-                       pcie->device_id.bus, pcie->device_id.function);
-       if (!dev) {
-               pr_err("PCI AER Cannot get PCI device %04x:%02x:%02x.%d\n",
-                       pcie->device_id.segment, pcie->device_id.bus,
-                       pcie->device_id.slot, pcie->device_id.function);
-               return;
-       }
-       if (pcie->validation_bits & CPER_PCIE_VALID_AER_INFO)
-               cper_print_aer(pfx, dev, gdata->error_severity,
-                               (struct aer_capability_regs *) pcie->aer_info);
-       pci_dev_put(dev);
-#endif
 }
 
 static const char *apei_estatus_section_flag_strs[] = {
index d668a8ae602bb4533b793911408cf138c047a4ce..403baf4dffc18dd45d62228c7cd1139efd25ae30 100644 (file)
@@ -454,7 +454,9 @@ static void ghes_do_proc(struct ghes *ghes,
                                aer_severity = cper_severity_to_aer(sev);
                                aer_recover_queue(pcie_err->device_id.segment,
                                                  pcie_err->device_id.bus,
-                                                 devfn, aer_severity);
+                                                 devfn, aer_severity,
+                                                 (struct aer_capability_regs *)
+                                                 pcie_err->aer_info);
                        }
 
                }
index 8ec8b4f485604e384de9bf7eddfe2c97c4cae5d5..0f4554e48cc5f52850d766078dff76f8c1cdc4d0 100644 (file)
@@ -580,6 +580,7 @@ struct aer_recover_entry
        u8      devfn;
        u16     domain;
        int     severity;
+       struct aer_capability_regs *regs;
 };
 
 static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry,
@@ -593,7 +594,7 @@ static DEFINE_SPINLOCK(aer_recover_ring_lock);
 static DECLARE_WORK(aer_recover_work, aer_recover_work_func);
 
 void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
-                      int severity)
+                      int severity, struct aer_capability_regs *aer_regs)
 {
        unsigned long flags;
        struct aer_recover_entry entry = {
@@ -601,6 +602,7 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
                .devfn          = devfn,
                .domain         = domain,
                .severity       = severity,
+               .regs           = aer_regs,
        };
 
        spin_lock_irqsave(&aer_recover_ring_lock, flags);
@@ -627,6 +629,7 @@ static void aer_recover_work_func(struct work_struct *work)
                               PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
                        continue;
                }
+               cper_print_aer(pdev, entry.severity, entry.regs);
                do_recovery(pdev, entry.severity);
                pci_dev_put(pdev);
        }
index 5ab14251839d0f06c395ac0dfc064c166cf3b75a..2c7c9f5f592caa4253b862775bfbb2ee3854af7d 100644 (file)
@@ -220,7 +220,7 @@ int cper_severity_to_aer(int cper_severity)
 }
 EXPORT_SYMBOL_GPL(cper_severity_to_aer);
 
-void cper_print_aer(const char *prefix, struct pci_dev *dev, int cper_severity,
+void cper_print_aer(struct pci_dev *dev, int cper_severity,
                    struct aer_capability_regs *aer)
 {
        int aer_severity, layer, agent, status_strs_size, tlp_header_valid = 0;
@@ -244,7 +244,7 @@ void cper_print_aer(const char *prefix, struct pci_dev *dev, int cper_severity,
        agent = AER_GET_AGENT(aer_severity, status);
        dev_err(&dev->dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n",
               status, mask);
-       cper_print_bits(prefix, status, status_strs, status_strs_size);
+       cper_print_bits("", status, status_strs, status_strs_size);
        dev_err(&dev->dev, "aer_layer=%s, aer_agent=%s\n",
               aer_error_layer[layer], aer_agent_string[agent]);
        if (aer_severity != AER_CORRECTABLE)
index ec10e1b24c1cce50d50581d58c5000cf7b9e5565..737f90ab4b6235abd340b1c47d9308591c138e8b 100644 (file)
@@ -49,10 +49,11 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
 }
 #endif
 
-extern void cper_print_aer(const char *prefix, struct pci_dev *dev,
+extern void cper_print_aer(struct pci_dev *dev,
                           int cper_severity, struct aer_capability_regs *aer);
 extern int cper_severity_to_aer(int cper_severity);
 extern void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
-                             int severity);
+                             int severity,
+                             struct aer_capability_regs *aer_regs);
 #endif //_AER_H_