linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] PCI, AER: Add a TLP header print helper
@ 2013-12-08 15:12 Borislav Petkov
  2013-12-08 15:12 ` [PATCH 2/2] PCI, AER: Clean up error printing code a bit Borislav Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Borislav Petkov @ 2013-12-08 15:12 UTC (permalink / raw)
  To: LKML
  Cc: Borislav Petkov, Bjorn Helgaas, Lance Ortiz, Tony Luck,
	Rafael J. Wysocki, linux-pci

From: Borislav Petkov <bp@suse.de>

... and call it instead of duplicating the large printk format
statement.

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 drivers/pci/pcie/aer/aerdrv_errprint.c | 44 ++++++++++++++++------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 2c7c9f5f592c..32efc5e0d2eb 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -124,6 +124,21 @@ static const char *aer_agent_string[] = {
 	"Transmitter ID"
 };
 
+static void __print_tlp_header(struct pci_dev *dev,
+			       struct aer_header_log_regs *t)
+{
+	unsigned char *tlp = (unsigned char *)&t;
+
+	dev_err(&dev->dev, "  TLP Header:"
+		" %02x%02x%02x%02x %02x%02x%02x%02x"
+		" %02x%02x%02x%02x %02x%02x%02x%02x\n",
+		*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
+		*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
+		*(tlp + 11), *(tlp + 10), *(tlp + 9),
+		*(tlp + 8), *(tlp + 15), *(tlp + 14),
+		*(tlp + 13), *(tlp + 12));
+}
+
 static void __aer_print_error(struct pci_dev *dev,
 			      struct aer_err_info *info)
 {
@@ -178,17 +193,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 
 		__aer_print_error(dev, info);
 
-		if (info->tlp_header_valid) {
-			unsigned char *tlp = (unsigned char *) &info->tlp;
-			dev_err(&dev->dev, "  TLP Header:"
-				" %02x%02x%02x%02x %02x%02x%02x%02x"
-				" %02x%02x%02x%02x %02x%02x%02x%02x\n",
-				*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
-				*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
-				*(tlp + 11), *(tlp + 10), *(tlp + 9),
-				*(tlp + 8), *(tlp + 15), *(tlp + 14),
-				*(tlp + 13), *(tlp + 12));
-		}
+		if (info->tlp_header_valid)
+			__print_tlp_header(dev, &info->tlp);
 	}
 
 	if (info->id && info->error_dev_num > 1 && info->id == id)
@@ -250,18 +256,10 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
 	if (aer_severity != AER_CORRECTABLE)
 		dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n",
 		       aer->uncor_severity);
-	if (tlp_header_valid) {
-		const unsigned char *tlp;
-		tlp = (const unsigned char *)&aer->header_log;
-		dev_err(&dev->dev, "aer_tlp_header:"
-			" %02x%02x%02x%02x %02x%02x%02x%02x"
-			" %02x%02x%02x%02x %02x%02x%02x%02x\n",
-			*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
-			*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
-			*(tlp + 11), *(tlp + 10), *(tlp + 9),
-			*(tlp + 8), *(tlp + 15), *(tlp + 14),
-			*(tlp + 13), *(tlp + 12));
-	}
+
+	if (tlp_header_valid)
+		__print_tlp_header(dev, &aer->header_log);
+
 	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
 			aer_severity);
 }
-- 
1.8.4


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

* [PATCH 2/2] PCI, AER: Clean up error printing code a bit
  2013-12-08 15:12 [PATCH 1/2] PCI, AER: Add a TLP header print helper Borislav Petkov
@ 2013-12-08 15:12 ` Borislav Petkov
  2013-12-08 16:05 ` [PATCH 1/2] PCI, AER: Add a TLP header print helper Joe Perches
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2013-12-08 15:12 UTC (permalink / raw)
  To: LKML
  Cc: Borislav Petkov, Bjorn Helgaas, Lance Ortiz, Tony Luck,
	Rafael J. Wysocki, linux-pci

From: Borislav Petkov <bp@suse.de>

Save one indentation level in aer_print_error for the generic case where
we have info->status of an error, disregard 80 cols rule a bit for the
sake of better readability, fix alignment.

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 drivers/pci/pcie/aer/aerdrv_errprint.c | 51 ++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 32efc5e0d2eb..34ff7026440c 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -168,39 +168,39 @@ static void __aer_print_error(struct pci_dev *dev,
 
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 {
+	int layer, agent;
 	int id = ((dev->bus->number << 8) | dev->devfn);
 
-	if (info->status == 0) {
+	if (!info->status) {
 		dev_err(&dev->dev,
 			"PCIe Bus Error: severity=%s, type=Unaccessible, "
 			"id=%04x(Unregistered Agent ID)\n",
 			aer_error_severity_string[info->severity], id);
-	} else {
-		int layer, agent;
+		goto out;
+	}
 
-		layer = AER_GET_LAYER_ERROR(info->severity, info->status);
-		agent = AER_GET_AGENT(info->severity, info->status);
+	layer = AER_GET_LAYER_ERROR(info->severity, info->status);
+	agent = AER_GET_AGENT(info->severity, info->status);
 
-		dev_err(&dev->dev,
-			"PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
-			aer_error_severity_string[info->severity],
-			aer_error_layer[layer], id, aer_agent_string[agent]);
+	dev_err(&dev->dev,
+		"PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
+		aer_error_severity_string[info->severity],
+		aer_error_layer[layer], id, aer_agent_string[agent]);
 
-		dev_err(&dev->dev,
-			"  device [%04x:%04x] error status/mask=%08x/%08x\n",
-			dev->vendor, dev->device,
-			info->status, info->mask);
+	dev_err(&dev->dev,
+		"  device [%04x:%04x] error status/mask=%08x/%08x\n",
+		dev->vendor, dev->device,
+		info->status, info->mask);
 
-		__aer_print_error(dev, info);
+	__aer_print_error(dev, info);
 
-		if (info->tlp_header_valid)
-			__print_tlp_header(dev, &info->tlp);
-	}
+	if (info->tlp_header_valid)
+		__print_tlp_header(dev, &info->tlp);
 
+out:
 	if (info->id && info->error_dev_num > 1 && info->id == id)
-		dev_err(&dev->dev,
-			   "  Error of this Agent(%04x) is reported first\n",
-			id);
+		dev_err(&dev->dev, "  Error of this Agent(%04x) is reported first\n", id);
+
 	trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask),
 			info->severity);
 }
@@ -234,6 +234,7 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
 	const char **status_strs;
 
 	aer_severity = cper_severity_to_aer(cper_severity);
+
 	if (aer_severity == AER_CORRECTABLE) {
 		status = aer->cor_status;
 		mask = aer->cor_mask;
@@ -246,16 +247,18 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
 		status_strs_size = ARRAY_SIZE(aer_uncorrectable_error_string);
 		tlp_header_valid = status & AER_LOG_TLP_MASKS;
 	}
+
 	layer = AER_GET_LAYER_ERROR(aer_severity, status);
 	agent = AER_GET_AGENT(aer_severity, status);
-	dev_err(&dev->dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n",
-	       status, mask);
+
+	dev_err(&dev->dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
 	cper_print_bits("", status, status_strs, status_strs_size);
 	dev_err(&dev->dev, "aer_layer=%s, aer_agent=%s\n",
-	       aer_error_layer[layer], aer_agent_string[agent]);
+		aer_error_layer[layer], aer_agent_string[agent]);
+
 	if (aer_severity != AER_CORRECTABLE)
 		dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n",
-		       aer->uncor_severity);
+			aer->uncor_severity);
 
 	if (tlp_header_valid)
 		__print_tlp_header(dev, &aer->header_log);
-- 
1.8.4


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

* Re: [PATCH 1/2] PCI, AER: Add a TLP header print helper
  2013-12-08 15:12 [PATCH 1/2] PCI, AER: Add a TLP header print helper Borislav Petkov
  2013-12-08 15:12 ` [PATCH 2/2] PCI, AER: Clean up error printing code a bit Borislav Petkov
@ 2013-12-08 16:05 ` Joe Perches
  2013-12-08 16:13   ` Borislav Petkov
  2013-12-08 20:59 ` Joe Perches
  2013-12-16 21:03 ` Bjorn Helgaas
  3 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2013-12-08 16:05 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Borislav Petkov, Bjorn Helgaas, Lance Ortiz, Tony Luck,
	Rafael J. Wysocki, linux-pci

On Sun, 2013-12-08 at 16:12 +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> ... and call it instead of duplicating the large printk format
> statement.
> 
> No functionality change.

You do change the output.
Perhaps it'd be better to pass the header prefix too.

> diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
[]
> @@ -124,6 +124,21 @@ static const char *aer_agent_string[] = {

> +static void __print_tlp_header(struct pci_dev *dev,
> +			       struct aer_header_log_regs *t)
> +{
> +	unsigned char *tlp = (unsigned char *)&t;
> +
> +	dev_err(&dev->dev, "  TLP Header:"

Always indents and emits "  TLP Header:"

> @@ -250,18 +256,10 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
>  	if (aer_severity != AER_CORRECTABLE)
>  		dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n",
>  		       aer->uncor_severity);
> -	if (tlp_header_valid) {
> -		const unsigned char *tlp;
> -		tlp = (const unsigned char *)&aer->header_log;
> -		dev_err(&dev->dev, "aer_tlp_header:"

vs removing this "aer_tlp_header:"



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

* Re: [PATCH 1/2] PCI, AER: Add a TLP header print helper
  2013-12-08 16:05 ` [PATCH 1/2] PCI, AER: Add a TLP header print helper Joe Perches
@ 2013-12-08 16:13   ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2013-12-08 16:13 UTC (permalink / raw)
  To: Joe Perches
  Cc: LKML, Borislav Petkov, Bjorn Helgaas, Lance Ortiz, Tony Luck,
	Rafael J. Wysocki, linux-pci

On Sun, Dec 08, 2013 at 08:05:24AM -0800, Joe Perches wrote:
> On Sun, 2013-12-08 at 16:12 +0100, Borislav Petkov wrote:
> > From: Borislav Petkov <bp@suse.de>
> > 
> > ... and call it instead of duplicating the large printk format
> > statement.
> > 
> > No functionality change.
> 
> You do change the output.

That's ok. "TLP Header:" is the proper way to print it anyway.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH 1/2] PCI, AER: Add a TLP header print helper
  2013-12-08 15:12 [PATCH 1/2] PCI, AER: Add a TLP header print helper Borislav Petkov
  2013-12-08 15:12 ` [PATCH 2/2] PCI, AER: Clean up error printing code a bit Borislav Petkov
  2013-12-08 16:05 ` [PATCH 1/2] PCI, AER: Add a TLP header print helper Joe Perches
@ 2013-12-08 20:59 ` Joe Perches
  2013-12-16 21:03 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2013-12-08 20:59 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Borislav Petkov, Bjorn Helgaas, Lance Ortiz, Tony Luck,
	Rafael J. Wysocki, linux-pci

On Sun, 2013-12-08 at 16:12 +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> ... and call it instead of duplicating the large printk format
> statement.
[]
> diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
[]
> @@ -124,6 +124,21 @@ static const char *aer_agent_string[] = {

> +static void __print_tlp_header(struct pci_dev *dev,
> +			       struct aer_header_log_regs *t)
> +{
> +	unsigned char *tlp = (unsigned char *)&t;
> +
> +	dev_err(&dev->dev, "  TLP Header:"
> +		" %02x%02x%02x%02x %02x%02x%02x%02x"
> +		" %02x%02x%02x%02x %02x%02x%02x%02x\n",
> +		*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
> +		*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
> +		*(tlp + 11), *(tlp + 10), *(tlp + 9),
> +		*(tlp + 8), *(tlp + 15), *(tlp + 14),
> +		*(tlp + 13), *(tlp + 12));
> +}

Hey again Borislav:

Come to think of it, given this struct:

include/linux/aer.h:struct aer_header_log_regs {
include/linux/aer.h-    unsigned int dw0;
include/linux/aer.h-    unsigned int dw1;
include/linux/aer.h-    unsigned int dw2;
include/linux/aer.h-    unsigned int dw3;
include/linux/aer.h-};

this would be a lot more readable as:

static void __print_tlp_header(struct pci_dev *dev,
			       struct aer_header_log_regs *t)
{
	dev_err(&dev->dev, "  TLP Header: %08x %08x %08x %08x\n",
		tlp->dw0, tlp->dw1, tlp->dw2, tlp->dw3);
}

though if the desire really is to show le output,
maybe these should use:

	dev_err(&dev->dev, "  TLP Header: %08x %08x %08x %08x\n",
		cpu_to_le32(tlp->dw0), cpu_to_le32(tlp->dw1),
		cpu_to_le32(tlp->dw2), cpu_to_le32(tlp->dw3));



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

* Re: [PATCH 1/2] PCI, AER: Add a TLP header print helper
  2013-12-08 15:12 [PATCH 1/2] PCI, AER: Add a TLP header print helper Borislav Petkov
                   ` (2 preceding siblings ...)
  2013-12-08 20:59 ` Joe Perches
@ 2013-12-16 21:03 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2013-12-16 21:03 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Borislav Petkov, Lance Ortiz, Tony Luck, Rafael J. Wysocki,
	linux-pci

On Sun, Dec 08, 2013 at 04:12:50PM +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> ... and call it instead of duplicating the large printk format
> statement.
> 
> No functionality change.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>

I applied both of these to my pci/aer branch for v3.14, thanks!

Bjorn

> ---
>  drivers/pci/pcie/aer/aerdrv_errprint.c | 44 ++++++++++++++++------------------
>  1 file changed, 21 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
> index 2c7c9f5f592c..32efc5e0d2eb 100644
> --- a/drivers/pci/pcie/aer/aerdrv_errprint.c
> +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
> @@ -124,6 +124,21 @@ static const char *aer_agent_string[] = {
>  	"Transmitter ID"
>  };
>  
> +static void __print_tlp_header(struct pci_dev *dev,
> +			       struct aer_header_log_regs *t)
> +{
> +	unsigned char *tlp = (unsigned char *)&t;
> +
> +	dev_err(&dev->dev, "  TLP Header:"
> +		" %02x%02x%02x%02x %02x%02x%02x%02x"
> +		" %02x%02x%02x%02x %02x%02x%02x%02x\n",
> +		*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
> +		*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
> +		*(tlp + 11), *(tlp + 10), *(tlp + 9),
> +		*(tlp + 8), *(tlp + 15), *(tlp + 14),
> +		*(tlp + 13), *(tlp + 12));
> +}
> +
>  static void __aer_print_error(struct pci_dev *dev,
>  			      struct aer_err_info *info)
>  {
> @@ -178,17 +193,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
>  
>  		__aer_print_error(dev, info);
>  
> -		if (info->tlp_header_valid) {
> -			unsigned char *tlp = (unsigned char *) &info->tlp;
> -			dev_err(&dev->dev, "  TLP Header:"
> -				" %02x%02x%02x%02x %02x%02x%02x%02x"
> -				" %02x%02x%02x%02x %02x%02x%02x%02x\n",
> -				*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
> -				*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
> -				*(tlp + 11), *(tlp + 10), *(tlp + 9),
> -				*(tlp + 8), *(tlp + 15), *(tlp + 14),
> -				*(tlp + 13), *(tlp + 12));
> -		}
> +		if (info->tlp_header_valid)
> +			__print_tlp_header(dev, &info->tlp);
>  	}
>  
>  	if (info->id && info->error_dev_num > 1 && info->id == id)
> @@ -250,18 +256,10 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
>  	if (aer_severity != AER_CORRECTABLE)
>  		dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n",
>  		       aer->uncor_severity);
> -	if (tlp_header_valid) {
> -		const unsigned char *tlp;
> -		tlp = (const unsigned char *)&aer->header_log;
> -		dev_err(&dev->dev, "aer_tlp_header:"
> -			" %02x%02x%02x%02x %02x%02x%02x%02x"
> -			" %02x%02x%02x%02x %02x%02x%02x%02x\n",
> -			*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
> -			*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
> -			*(tlp + 11), *(tlp + 10), *(tlp + 9),
> -			*(tlp + 8), *(tlp + 15), *(tlp + 14),
> -			*(tlp + 13), *(tlp + 12));
> -	}
> +
> +	if (tlp_header_valid)
> +		__print_tlp_header(dev, &aer->header_log);
> +
>  	trace_aer_event(dev_name(&dev->dev), (status & ~mask),
>  			aer_severity);
>  }
> -- 
> 1.8.4
> 

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

end of thread, other threads:[~2013-12-16 21:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-08 15:12 [PATCH 1/2] PCI, AER: Add a TLP header print helper Borislav Petkov
2013-12-08 15:12 ` [PATCH 2/2] PCI, AER: Clean up error printing code a bit Borislav Petkov
2013-12-08 16:05 ` [PATCH 1/2] PCI, AER: Add a TLP header print helper Joe Perches
2013-12-08 16:13   ` Borislav Petkov
2013-12-08 20:59 ` Joe Perches
2013-12-16 21:03 ` Bjorn Helgaas

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).