linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/pnv: Avoid bogus output
Date: Thu, 18 Oct 2012 13:53:30 +0800	[thread overview]
Message-ID: <20121018055330.GA9360@shangw.(null)> (raw)
In-Reply-To: <1350528404-8009-1-git-send-email-shangw@linux.vnet.ibm.com>

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

On Thu, Oct 18, 2012 at 10:46:44AM +0800, Gavin Shan wrote:
>There're couples of functions defined to print debugging messages
>during initializing P7IOC. However, we got bogus output from those
>functions like pe_info(). The problem here is that the message
>level (the first parameter to printk()) isn't printable and that
>caused the bogus output.
>
>The patch fixes the issue by merging __pe_printk() to the macro
>define_pe_printk_level() so that we can pass the message level
>directly to printk().
>
>Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>---
> arch/powerpc/platforms/powernv/pci-ioda.c |   25 +++++++++++--------------
> 1 files changed, 11 insertions(+), 14 deletions(-)
>
>diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
>index 07ce33c..ff7e7a1 100644
>--- a/arch/powerpc/platforms/powernv/pci-ioda.c
>+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
>@@ -34,24 +34,12 @@
> #include "powernv.h"
> #include "pci.h"
>
>-static int __pe_printk(const char *level, const struct pnv_ioda_pe *pe,
>-		       struct va_format *vaf)
>-{
>-	char pfix[32];
>-
>-	if (pe->pdev)
>-		strlcpy(pfix, dev_name(&pe->pdev->dev), sizeof(pfix));
>-	else
>-		sprintf(pfix, "%04x:%02x     ",
>-			pci_domain_nr(pe->pbus), pe->pbus->number);
>-	return printk("pci %s%s: [PE# %.3d] %pV", level, pfix, pe->pe_number, vaf);
>-}
>-
> #define define_pe_printk_level(func, kern_level)		\
> static int func(const struct pnv_ioda_pe *pe, const char *fmt, ...)	\
> {								\
> 	struct va_format vaf;					\
> 	va_list args;						\
>+	char pfix[32];						\
> 	int r;							\
> 								\
> 	va_start(args, fmt);					\
>@@ -59,7 +47,16 @@ static int func(const struct pnv_ioda_pe *pe, const char *fmt, ...)	\
> 	vaf.fmt = fmt;						\
> 	vaf.va = &args;						\
> 								\
>-	r = __pe_printk(kern_level, pe, &vaf);			\
>+	if (pe->pdev)						\
>+		strlcpy(pfix, dev_name(&pe->pdev->dev),		\
>+			sizeof(pfix));				\
>+        else							\
>+                sprintf(pfix, "%04x:%02x     ",			\
>+                        pci_domain_nr(pe->pbus),		\

The space before sprintf() should be replaced by "tab" as
the attached patch :-)

>+			pe->pbus->number);			\
>+	r = printk(kern_level "pci %s: [PE# %.3d] %pV",		\
>+		   pfix, pe->pe_number, &vaf);			\
>+								\
> 	va_end(args);						\
> 								\
> 	return r;	 					\

Thanks,
Gavin


[-- Attachment #2: 0001-powerpc-pnv-Avoid-bogus-output.patch --]
[-- Type: text/x-diff, Size: 2392 bytes --]

>From 4ee539b85676c986122087fe84d59e3b764396d5 Mon Sep 17 00:00:00 2001
From: Gavin Shan <shangw@linux.vnet.ibm.com>
Date: Thu, 18 Oct 2012 10:09:12 +0800
Subject: [PATCH] powerpc/pnv: Avoid bogus output

There're couples of functions defined to print debugging messages
during initializing P7IOC. However, we got bogus output from those
functions like pe_info(). The problem here is that the message
level (the first parameter to printk()) isn't printable and that
caused the bogus output.

The patch fixes the issue by merging __pe_printk() to the macro
define_pe_printk_level() so that we can pass the message level
directly to printk().

Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 07ce33c..7687778 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -34,24 +34,12 @@
 #include "powernv.h"
 #include "pci.h"
 
-static int __pe_printk(const char *level, const struct pnv_ioda_pe *pe,
-		       struct va_format *vaf)
-{
-	char pfix[32];
-
-	if (pe->pdev)
-		strlcpy(pfix, dev_name(&pe->pdev->dev), sizeof(pfix));
-	else
-		sprintf(pfix, "%04x:%02x     ",
-			pci_domain_nr(pe->pbus), pe->pbus->number);
-	return printk("pci %s%s: [PE# %.3d] %pV", level, pfix, pe->pe_number, vaf);
-}
-
 #define define_pe_printk_level(func, kern_level)		\
 static int func(const struct pnv_ioda_pe *pe, const char *fmt, ...)	\
 {								\
 	struct va_format vaf;					\
 	va_list args;						\
+	char pfix[32];						\
 	int r;							\
 								\
 	va_start(args, fmt);					\
@@ -59,7 +47,16 @@ static int func(const struct pnv_ioda_pe *pe, const char *fmt, ...)	\
 	vaf.fmt = fmt;						\
 	vaf.va = &args;						\
 								\
-	r = __pe_printk(kern_level, pe, &vaf);			\
+	if (pe->pdev)						\
+		strlcpy(pfix, dev_name(&pe->pdev->dev),		\
+			sizeof(pfix));				\
+	else							\
+		sprintf(pfix, "%04x:%02x     ",			\
+			pci_domain_nr(pe->pbus),		\
+			pe->pbus->number);			\
+	r = printk(kern_level "pci %s: [PE# %.3d] %pV",		\
+		   pfix, pe->pe_number, &vaf);			\
+								\
 	va_end(args);						\
 								\
 	return r;						\
-- 
1.7.5.4


      reply	other threads:[~2012-10-18  5:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18  2:46 [PATCH] powerpc/pnv: Avoid bogus output Gavin Shan
2012-10-18  5:53 ` Gavin Shan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20121018055330.GA9360@shangw.(null)' \
    --to=shangw@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).