PCI: Annotate PCI quirks in initcall_debug style
authorArjan van de Ven <arjan@infradead.org>
Tue, 31 Jan 2012 04:52:07 +0000 (20:52 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 14 Feb 2012 16:45:04 +0000 (08:45 -0800)
While diagnosing some boot time issues on a platform, all that I
could see in the bootgraph/dmesg was that the system was spending
a lot of time in applying one or more PCI quirks... which
was virtually undebuggable.

This patch adds printk's in "initcall_debug" style to the dmesg,
which are added when the user asks for the initcall_debug
(the nr one tool to use when debugging boot hangs or boot time issues)
kernel command line option.

v2: add #includes so quirks can build on non-x86

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/quirks.c

index 64765474676f6ddd37f893cac1be69d1c07bed91..f5d09f4066f3e6680a05316307ec610156634d7b 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/dmi.h>
 #include <linux/pci-aspm.h>
 #include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/ktime.h>
 #include <asm/dma.h>   /* isa_dma_bridge_buggy */
 #include "pci.h"
 
@@ -2906,6 +2908,22 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f8, quirk_intel_mc_errata);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
 
+
+static void do_one_fixup_debug(void (*fn)(struct pci_dev *dev), struct pci_dev *dev)
+{
+       ktime_t calltime, delta, rettime;
+       unsigned long long duration;
+
+       printk(KERN_DEBUG "calling  %pF @ %i\n", fn, task_pid_nr(current));
+       calltime = ktime_get();
+       fn(dev);
+       rettime = ktime_get();
+       delta = ktime_sub(rettime, calltime);
+       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+       printk(KERN_DEBUG "pci fixup %pF returned after %lld usecs\n", fn,
+               duration);
+}
+
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
                          struct pci_fixup *end)
 {
@@ -2913,7 +2931,10 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
                if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
                    (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
                        dev_dbg(&dev->dev, "calling %pF\n", f->hook);
-                       f->hook(dev);
+                       if (initcall_debug)
+                               do_one_fixup_debug(f->hook, dev);
+                       else
+                               f->hook(dev);
                }
                f++;
        }