powerpc/eeh: Introduce EEH edev logging macros
authorSam Bobroff <sbobroff@linux.ibm.com>
Fri, 16 Aug 2019 04:48:12 +0000 (14:48 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 22 Aug 2019 13:12:46 +0000 (23:12 +1000)
Now that struct eeh_dev includes the BDFN of it's PCI device, make use
of it to replace eeh_edev_info() with a set of dev_dbg()-style macros
that only need a struct edev.

With the BDFN available without the struct pci_dev, eeh_pci_name() is
now unnecessary, so remove it.

While only the "info" level function is used here, the others will be
used in followup work.

Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/f90ae9a53d762be7b0ccbad79e62b5a1b4f4996e.1565930772.git.sbobroff@linux.ibm.com
arch/powerpc/include/asm/eeh.h
arch/powerpc/kernel/eeh_driver.c

index 294efeaf939e975fed3fe5c32417a4e628d48203..56c1b4b0987a4c62fcb6d9cfc19fc3c349bef5bc 100644 (file)
@@ -138,6 +138,17 @@ struct eeh_dev {
        struct pci_dev *physfn;         /* Associated SRIOV PF          */
 };
 
+/* "fmt" must be a simple literal string */
+#define EEH_EDEV_PRINT(level, edev, fmt, ...) \
+       pr_##level("PCI %04x:%02x:%02x.%x#%04x: EEH: " fmt, \
+       (edev)->controller->global_number, PCI_BUSNO((edev)->bdfn), \
+       PCI_SLOT((edev)->bdfn), PCI_FUNC((edev)->bdfn), \
+       ((edev)->pe ? (edev)->pe_config_addr : 0xffff), ##__VA_ARGS__)
+#define eeh_edev_dbg(edev, fmt, ...) EEH_EDEV_PRINT(debug, (edev), fmt, ##__VA_ARGS__)
+#define eeh_edev_info(edev, fmt, ...) EEH_EDEV_PRINT(info, (edev), fmt, ##__VA_ARGS__)
+#define eeh_edev_warn(edev, fmt, ...) EEH_EDEV_PRINT(warn, (edev), fmt, ##__VA_ARGS__)
+#define eeh_edev_err(edev, fmt, ...) EEH_EDEV_PRINT(err, (edev), fmt, ##__VA_ARGS__)
+
 static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
 {
        return edev ? edev->pdn : NULL;
index 1fbe541856f5e644e2ea0e6d0f4c429d40ec06a6..ab576bcbe4dd51b4d43f2cafaf1bcd500100cab4 100644 (file)
@@ -81,23 +81,6 @@ static const char *pci_ers_result_name(enum pci_ers_result result)
        }
 };
 
-static __printf(2, 3) void eeh_edev_info(const struct eeh_dev *edev,
-                                        const char *fmt, ...)
-{
-       struct va_format vaf;
-       va_list args;
-
-       va_start(args, fmt);
-
-       vaf.fmt = fmt;
-       vaf.va = &args;
-
-       printk(KERN_INFO "EEH: PE#%x (PCI %s): %pV\n", edev->pe_config_addr,
-              edev->pdev ? dev_name(&edev->pdev->dev) : "none", &vaf);
-
-       va_end(args);
-}
-
 static enum pci_ers_result pci_ers_merge_result(enum pci_ers_result old,
                                                enum pci_ers_result new)
 {