linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pci: Annotate PCI quirks in initcall_debug style
@ 2012-01-31  4:52 Arjan van de Ven
  2012-02-10 19:42 ` Jesse Barnes
  0 siblings, 1 reply; 2+ messages in thread
From: Arjan van de Ven @ 2012-01-31  4:52 UTC (permalink / raw)
  To: linux-pci; +Cc: Jesse Barnes, arjanvandeven

>From 77fcc610189853f9c8cf35f77bb8bcfc68833202 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
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.

CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: linux-pci@vger.kernel.org

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 drivers/pci/quirks.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6476547..b3afa1c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -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++;
 	}
-- 
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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: pci: Annotate PCI quirks in initcall_debug style
  2012-01-31  4:52 pci: Annotate PCI quirks in initcall_debug style Arjan van de Ven
@ 2012-02-10 19:42 ` Jesse Barnes
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2012-02-10 19:42 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: linux-pci, arjanvandeven

[-- Attachment #1: Type: text/plain, Size: 2679 bytes --]

On Mon, 30 Jan 2012 20:52:07 -0800
Arjan van de Ven <arjan@infradead.org> wrote:

> From 77fcc610189853f9c8cf35f77bb8bcfc68833202 Mon Sep 17 00:00:00 2001
> From: Arjan van de Ven <arjan@linux.intel.com>
> 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.
> 
> CC: Jesse Barnes <jbarnes@virtuousgeek.org>
> CC: linux-pci@vger.kernel.org
> 
> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> ---
>  drivers/pci/quirks.c |   21 ++++++++++++++++++++-
>  1 files changed, 20 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index 6476547..b3afa1c 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -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++;
>  	}

Looks cool Arjan, thanks.  Applied to my -next branch.

-- 
Jesse Barnes, Intel Open Source Technology Center

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-10 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31  4:52 pci: Annotate PCI quirks in initcall_debug style Arjan van de Ven
2012-02-10 19:42 ` Jesse Barnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).