diff mbox

[RESEND,2/5] PCIe, AER: Replenish missed AER status bits for AER driver

Message ID 1407910961-7798-3-git-send-email-gong.chen@linux.intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Chen Gong Aug. 13, 2014, 6:22 a.m. UTC
Since commit 6c2b374d is commited, the capability of PCI-e AER
has changed a lot. This patch adds all missed CE/UC error bits
existed in PCI-e SPEC r3.0. Meanwhile, adjust the code format
to make it simpler to read/maintain.

Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
---
 drivers/pci/pcie/aer/aerdrv_errprint.c | 60 ++++++++++++++--------------------
 1 file changed, 25 insertions(+), 35 deletions(-)

Comments

Bjorn Helgaas Sept. 5, 2014, 11:15 p.m. UTC | #1
On Wed, Aug 13, 2014 at 02:22:38AM -0400, Chen, Gong wrote:
> Since commit 6c2b374d is commited, the capability of PCI-e AER
> has changed a lot. This patch adds all missed CE/UC error bits
> existed in PCI-e SPEC r3.0. Meanwhile, adjust the code format
> to make it simpler to read/maintain.
> 
> Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
> ---
>  drivers/pci/pcie/aer/aerdrv_errprint.c | 60 ++++++++++++++--------------------
>  1 file changed, 25 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
> index 35d06e177917..5c4f7e252e5e 100644
> --- a/drivers/pci/pcie/aer/aerdrv_errprint.c
> +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
> @@ -75,44 +75,34 @@ static const char *aer_error_layer[] = {
>  };
>  
>  static const char *aer_correctable_error_string[] = {
> -	"Receiver Error",		/* Bit Position 0	*/
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	"Bad TLP",			/* Bit Position 6	*/
> -	"Bad DLLP",			/* Bit Position 7	*/
> -	"RELAY_NUM Rollover",		/* Bit Position 8	*/
> -	NULL,
> -	NULL,
> -	NULL,
> -	"Replay Timer Timeout",		/* Bit Position 12	*/
> -	"Advisory Non-Fatal",		/* Bit Position 13	*/
> +	[0] = "Receiver Error",
> +	[6] = "Bad TLP",
> +	[7] = "Bad DLLP",
> +	[8] = "RELAY_NUM Rollover",
> +	[12] = "Replay Timer Timeout",
> +	[13] = "Advisory Non-Fatal Error",
> +	[14] = "Corrected Internal Error",
> +	[15] = "Header Log Overflow",

You replaced bare numbers with the existing #defines in the previous patch
(thank you), but now we're adding them here.  I'm pretty sure you can use
the #defines here, e.g.,

    [PCI_ERR_COR_RCVR] = "Receiver Error",

In fact, it would be really nice if you could figure out a way to have only
one set of these strings.  Right now, we have the set in
include/ras/ras_event.h, and then another set here in aerdrv_errprint.c,
and they contain exactly the same information.

Bjorn

>  };
>  
>  static const char *aer_uncorrectable_error_string[] = {
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	"Data Link Protocol",		/* Bit Position 4	*/
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	NULL,
> -	"Poisoned TLP",			/* Bit Position 12	*/
> -	"Flow Control Protocol",	/* Bit Position 13	*/
> -	"Completion Timeout",		/* Bit Position 14	*/
> -	"Completer Abort",		/* Bit Position 15	*/
> -	"Unexpected Completion",	/* Bit Position 16	*/
> -	"Receiver Overflow",		/* Bit Position 17	*/
> -	"Malformed TLP",		/* Bit Position 18	*/
> -	"ECRC",				/* Bit Position 19	*/
> -	"Unsupported Request",		/* Bit Position 20	*/
> +	[0] = "Undefined",
> +	[4] = "Data Link Protocol Error",
> +	[5] = "Surprise Down Error",
> +	[12] = "Poisoned TLP",
> +	[13] = "Flow Control Protocol Error",
> +	[14] = "Completion Timeout",
> +	[15] = "Completer Abort",
> +	[16] = "Unexpected Completion",
> +	[17] = "Receiver Overflow",
> +	[18] = "Malformed TLP",
> +	[19] = "ECRC Error",
> +	[20] = "Unsupported Request Error",
> +	[21] = "ACS Violation",
> +	[22] = "Uncorrectable Internal Error",
> +	[23] = "MC Blocked TLP",
> +	[24] = "AtomicOp Egress Blocked",
> +	[25] = "TLP Prefix Blocked Error",
>  };
>  
>  static const char *aer_agent_string[] = {
> -- 
> 2.0.0.rc2
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen Gong Sept. 9, 2014, 7:03 a.m. UTC | #2
On Fri, Sep 05, 2014 at 05:15:43PM -0600, Bjorn Helgaas wrote:
> Date: Fri, 5 Sep 2014 17:15:43 -0600
> From: Bjorn Helgaas <bhelgaas@google.com>
> To: "Chen, Gong" <gong.chen@linux.intel.com>
> Cc: rdunlap@infradead.org, bp@alien8.de, tony.luck@intel.com,
>  linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [RESEND 2/5] PCIe, AER: Replenish missed AER status bits for
>  AER driver
> User-Agent: Mutt/1.5.21 (2010-09-15)
> 
> On Wed, Aug 13, 2014 at 02:22:38AM -0400, Chen, Gong wrote:
> > Since commit 6c2b374d is commited, the capability of PCI-e AER
> > has changed a lot. This patch adds all missed CE/UC error bits
> > existed in PCI-e SPEC r3.0. Meanwhile, adjust the code format
> > to make it simpler to read/maintain.
> > 
> > Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
> > ---
> >  drivers/pci/pcie/aer/aerdrv_errprint.c | 60 ++++++++++++++--------------------
> >  1 file changed, 25 insertions(+), 35 deletions(-)
> > 
> > diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
> > index 35d06e177917..5c4f7e252e5e 100644
> > --- a/drivers/pci/pcie/aer/aerdrv_errprint.c
> > +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
> > @@ -75,44 +75,34 @@ static const char *aer_error_layer[] = {
> >  };
> >  
> >  static const char *aer_correctable_error_string[] = {
> > -	"Receiver Error",		/* Bit Position 0	*/
> > -	NULL,
> > -	NULL,
> > -	NULL,
> > -	NULL,
> > -	NULL,
> > -	"Bad TLP",			/* Bit Position 6	*/
> > -	"Bad DLLP",			/* Bit Position 7	*/
> > -	"RELAY_NUM Rollover",		/* Bit Position 8	*/
> > -	NULL,
> > -	NULL,
> > -	NULL,
> > -	"Replay Timer Timeout",		/* Bit Position 12	*/
> > -	"Advisory Non-Fatal",		/* Bit Position 13	*/
> > +	[0] = "Receiver Error",
> > +	[6] = "Bad TLP",
> > +	[7] = "Bad DLLP",
> > +	[8] = "RELAY_NUM Rollover",
> > +	[12] = "Replay Timer Timeout",
> > +	[13] = "Advisory Non-Fatal Error",
> > +	[14] = "Corrected Internal Error",
> > +	[15] = "Header Log Overflow",
> 
> You replaced bare numbers with the existing #defines in the previous patch
> (thank you), but now we're adding them here.  I'm pretty sure you can use
> the #defines here, e.g.,
> 
>     [PCI_ERR_COR_RCVR] = "Receiver Error",
Considering PCI_ERR_COR_* stuff are not BIT offset, I need a conversion like
[ilog2(PCI_ERR_COR_RCVR)] = "xxx". But in ras_event.h I need the same
conversion like aer_correctable_error_string[ilog2(PCI_ERR_COR_RCVR)]. It looks
like a little bit clumsy and suboptimal. I can add extra BIT definition in
include/uapi/linux/pci_regs.h like below:

#define  PCI_ERR_COR_RCVR       0x00000001      /* Receiver Error Status */
+#define  PCI_ERR_COR_RCVR_BIT   ilog2(PCI_ERR_COR_RCVR)

or more direct way:
#define  PCI_ERR_COR_RCVR       0x00000001      /* Receiver Error Status */
+#define  PCI_ERR_COR_RCVR_BIT   0

I can't find better method by now.
> 
> In fact, it would be really nice if you could figure out a way to have only
> one set of these strings.  Right now, we have the set in
As above implied, I can export aer_correctable_error_string etc.
diff mbox

Patch

diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 35d06e177917..5c4f7e252e5e 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -75,44 +75,34 @@  static const char *aer_error_layer[] = {
 };
 
 static const char *aer_correctable_error_string[] = {
-	"Receiver Error",		/* Bit Position 0	*/
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	"Bad TLP",			/* Bit Position 6	*/
-	"Bad DLLP",			/* Bit Position 7	*/
-	"RELAY_NUM Rollover",		/* Bit Position 8	*/
-	NULL,
-	NULL,
-	NULL,
-	"Replay Timer Timeout",		/* Bit Position 12	*/
-	"Advisory Non-Fatal",		/* Bit Position 13	*/
+	[0] = "Receiver Error",
+	[6] = "Bad TLP",
+	[7] = "Bad DLLP",
+	[8] = "RELAY_NUM Rollover",
+	[12] = "Replay Timer Timeout",
+	[13] = "Advisory Non-Fatal Error",
+	[14] = "Corrected Internal Error",
+	[15] = "Header Log Overflow",
 };
 
 static const char *aer_uncorrectable_error_string[] = {
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	"Data Link Protocol",		/* Bit Position 4	*/
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	"Poisoned TLP",			/* Bit Position 12	*/
-	"Flow Control Protocol",	/* Bit Position 13	*/
-	"Completion Timeout",		/* Bit Position 14	*/
-	"Completer Abort",		/* Bit Position 15	*/
-	"Unexpected Completion",	/* Bit Position 16	*/
-	"Receiver Overflow",		/* Bit Position 17	*/
-	"Malformed TLP",		/* Bit Position 18	*/
-	"ECRC",				/* Bit Position 19	*/
-	"Unsupported Request",		/* Bit Position 20	*/
+	[0] = "Undefined",
+	[4] = "Data Link Protocol Error",
+	[5] = "Surprise Down Error",
+	[12] = "Poisoned TLP",
+	[13] = "Flow Control Protocol Error",
+	[14] = "Completion Timeout",
+	[15] = "Completer Abort",
+	[16] = "Unexpected Completion",
+	[17] = "Receiver Overflow",
+	[18] = "Malformed TLP",
+	[19] = "ECRC Error",
+	[20] = "Unsupported Request Error",
+	[21] = "ACS Violation",
+	[22] = "Uncorrectable Internal Error",
+	[23] = "MC Blocked TLP",
+	[24] = "AtomicOp Egress Blocked",
+	[25] = "TLP Prefix Blocked Error",
 };
 
 static const char *aer_agent_string[] = {