pci: Annotate PCI quirks in initcall_debug style
Quoted 1 line
From
77fcc610189853f9c8cf35f77bb8bcfc68833202Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Mon, 30 Jan 2012 20:30:03 -0800
Subject: [PATCH] pci: Annotate PCI quirks in initcall_debug style
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.
--- drivers/pci/quirks.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
drivers/pci/quirks.c +20 -1
@@ -2906,6 +2906,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 +2929,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++; }
Signature · 8 lines
1.7.6.4 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
Quoted 52 lines · On Mon, 30 Jan 2012 20:52:07 -0800 Arjan van de Ven <[email protected]> wrote:
From
77fcc610189853f9c8cf35f77bb8bcfc68833202Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Mon, 30 Jan 2012 20:30:03 -0800
Subject: [PATCH] pci: Annotate PCI quirks ininitcall_debugstyleWhile 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 theinitcall_debug(the nr one tool to use when debugging boot hangs or boot time issues) kernel command line option.CC Jesse Barnes <[email protected]>Signed-off-by Arjan van de Ven <[email protected]>--- drivers/pci/quirks.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)drivers/pci/quirks.c +16
-0@@ -2906,6 +2906,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 +2929,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) &&
drivers/pci/quirks.c static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, · line 2938
Quoted 10 lines
drivers/pci/quirks.c +4
-1(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++; }
Looks cool Arjan, thanks. Applied to my -next branch.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center