linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: linux-acpi@vger.kernel.org
Cc: Huang Ying <ying.huang@intel.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	Zhang Yanmin <yanmin.zhang@intel.com>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 32/42] PCIe, AER, use pre-generated prefix in error information printing
Date: Wed, 23 Mar 2011 02:42:45 -0400	[thread overview]
Message-ID: <b64a44146540a4761bb1cf8047fffd9dbf0c3090.1300862481.git.len.brown@intel.com> (raw)
In-Reply-To: <1300862575-10206-1-git-send-email-lenb@kernel.org>
In-Reply-To: <073b4964b3b75fd9e19bf3933b26d9c23591c9db.1300862481.git.len.brown@intel.com>

From: Huang Ying <ying.huang@intel.com>

When printing PCIe AER error information, each line is prefixed with
PCIe device and driver information.  In original implementation, the
prefix is generated when each line is printed.  In fact, all lines
share the same prefix.  So this patch pre-generated the prefix, and
use that one when each line is printed.

In addition to common prefix can be pre-generated, the trailing white
spaces in string constants and NULLs in char * array constants can be
removed too.  These can reduce the object file size further.

The size of object file before and after changing is as follow:

           text    data     bss     dec
before:    3038       0       0    3038
after:     2118       0       0    2118

Signed-off-by: Huang Ying <ying.huang@intel.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>
CC: Zhang Yanmin <yanmin.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/pci/pcie/aer/aerdrv_errprint.c |  123 ++++++++++++-------------------
 1 files changed, 48 insertions(+), 75 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 9d3e4c8..7a237f6 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -57,86 +57,44 @@
 	(e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
 	AER_TRANSACTION_LAYER_ERROR)
 
-#define AER_PR(info, pdev, fmt, args...)				\
-	printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ?	\
-		KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev),	\
-		dev_name(&pdev->dev), ## args)
-
 /*
  * AER error strings
  */
-static char *aer_error_severity_string[] = {
+static const char *aer_error_severity_string[] = {
 	"Uncorrected (Non-Fatal)",
 	"Uncorrected (Fatal)",
 	"Corrected"
 };
 
-static char *aer_error_layer[] = {
+static const char *aer_error_layer[] = {
 	"Physical Layer",
 	"Data Link Layer",
 	"Transaction Layer"
 };
-static 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	*/
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
+
+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	*/
 };
 
-static 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	*/
+static const char *aer_uncorrectable_error_string[] = {
 	NULL,
 	NULL,
 	NULL,
 	NULL,
+	"Data Link Protocol",		/* Bit Position 4	*/
 	NULL,
 	NULL,
 	NULL,
@@ -144,19 +102,29 @@ static char *aer_uncorrectable_error_string[] = {
 	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	*/
 };
 
-static char *aer_agent_string[] = {
+static const char *aer_agent_string[] = {
 	"Receiver ID",
 	"Requester ID",
 	"Completer ID",
 	"Transmitter ID"
 };
 
-static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
+static void __aer_print_error(const char *prefix,
+			      struct aer_err_info *info)
 {
 	int i, status;
-	char *errmsg = NULL;
+	const char *errmsg = NULL;
 
 	status = (info->status & ~info->mask);
 
@@ -165,15 +133,17 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
 			continue;
 
 		if (info->severity == AER_CORRECTABLE)
-			errmsg = aer_correctable_error_string[i];
+			errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
+				aer_correctable_error_string[i] : NULL;
 		else
-			errmsg = aer_uncorrectable_error_string[i];
+			errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
+				aer_uncorrectable_error_string[i] : NULL;
 
 		if (errmsg)
-			AER_PR(info, dev, "   [%2d] %s%s\n", i, errmsg,
+			printk("%s""   [%2d] %-22s%s\n", prefix, i, errmsg,
 				info->first_error == i ? " (First)" : "");
 		else
-			AER_PR(info, dev, "   [%2d] Unknown Error Bit%s\n", i,
+			printk("%s""   [%2d] Unknown Error Bit%s\n", prefix, i,
 				info->first_error == i ? " (First)" : "");
 	}
 }
@@ -181,11 +151,15 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 {
 	int id = ((dev->bus->number << 8) | dev->devfn);
+	char prefix[44];
+
+	snprintf(prefix, sizeof(prefix), "%s%s %s: ",
+		 (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR,
+		 dev_driver_string(&dev->dev), dev_name(&dev->dev));
 
 	if (info->status == 0) {
-		AER_PR(info, dev,
-			"PCIe Bus Error: severity=%s, type=Unaccessible, "
-			"id=%04x(Unregistered Agent ID)\n",
+		printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, "
+			"id=%04x(Unregistered Agent ID)\n", prefix,
 			aer_error_severity_string[info->severity], id);
 	} else {
 		int layer, agent;
@@ -193,23 +167,22 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 		layer = AER_GET_LAYER_ERROR(info->severity, info->status);
 		agent = AER_GET_AGENT(info->severity, info->status);
 
-		AER_PR(info, dev,
-			"PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
-			aer_error_severity_string[info->severity],
+		printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
+			prefix, aer_error_severity_string[info->severity],
 			aer_error_layer[layer], id, aer_agent_string[agent]);
 
-		AER_PR(info, dev,
-			"  device [%04x:%04x] error status/mask=%08x/%08x\n",
-			dev->vendor, dev->device, info->status, info->mask);
+		printk("%s""  device [%04x:%04x] error status/mask=%08x/%08x\n",
+			prefix, dev->vendor, dev->device,
+			info->status, info->mask);
 
-		__aer_print_error(info, dev);
+		__aer_print_error(prefix, info);
 
 		if (info->tlp_header_valid) {
 			unsigned char *tlp = (unsigned char *) &info->tlp;
-			AER_PR(info, dev, "  TLP Header:"
+			printk("%s""  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,
+				prefix, *(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),
@@ -218,8 +191,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 	}
 
 	if (info->id && info->error_dev_num > 1 && info->id == id)
-		AER_PR(info, dev,
-			"  Error of this Agent(%04x) is reported first\n", id);
+		printk("%s""  Error of this Agent(%04x) is reported first\n",
+			prefix, id);
 }
 
 void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
-- 
1.7.4.1.343.ga91df


  parent reply	other threads:[~2011-03-23  8:07 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23  6:42 ACPI patch queue for 2.6.39-merge Len Brown
2011-03-23  6:42 ` [PATCH 01/42] ACPI: Do not export functions that are only used in osl.c Len Brown
2011-03-23  6:42   ` [PATCH 02/42] ACPI: Change acpi_ioremap_lock into a mutex Len Brown
2011-03-23  6:42   ` [PATCH 03/42] ACPI: Avoid walking the list of memory mappings in osl.c twice in a row Len Brown
2011-03-23  6:42   ` [PATCH 04/42] ACPI: Make acpi_os_map_memory() avoid creating unnecessary mappings Len Brown
2011-03-23  6:42   ` [PATCH 05/42] ACPI: Do not use krefs under a mutex in osl.c Len Brown
2011-03-23  6:42   ` [PATCH 06/42] ACPI: Introduce acpi_os_get_iomem() Len Brown
2011-03-23  6:42   ` [PATCH 07/42] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2) Len Brown
2011-03-23  6:42   ` [PATCH 08/42] ACPI: Remove the wakeup.run_wake_count device field Len Brown
2011-03-23  6:42   ` [PATCH 09/42] ACPI / Button: Avoid disabling wakeup unnecessarily on remove Len Brown
2011-03-23  6:42   ` [PATCH 10/42] ACPI / PM: Drop acpi_restore_state_mem() Len Brown
2011-03-23  6:42   ` [PATCH 11/42] ACPI / PM: acpi_suspend_enter() need not switch interrupts off Len Brown
2011-03-23  6:42   ` [PATCH 12/42] ACPI / PM: Modify the "low-level resume finished" message Len Brown
2011-03-23  6:42   ` [PATCH 13/42] ACPI / PM: Call acpi_save_state_mem() right before low-level suspend Len Brown
2011-03-23  6:42   ` [PATCH 14/42] ACPI / PM: Merge do_suspend_lowlevel() into acpi_save_state_mem() Len Brown
2011-03-23  6:42   ` [PATCH 15/42] ACPI / PM: acpi_hibernation_enter() need not switch interrupts off Len Brown
2011-03-23  6:42   ` [PATCH 16/42] ACPI: Avoid calling request_irq() many times for the same interrupt Len Brown
2011-03-23  6:42   ` [PATCH 17/42] ACPICA: GPE detect optimization - ignore unused GPE registers Len Brown
2011-03-23  6:42   ` [PATCH 18/42] ACPICA: Remove use of unreliable FADT revision field Len Brown
2011-03-23  6:42   ` [PATCH 19/42] ACPICA: Clarify a couple of error messages Len Brown
2011-03-23  6:42   ` [PATCH 20/42] ACPICA: Split large utglobal into utdecode.c Len Brown
2011-03-23  6:42   ` [PATCH 21/42] ACPICA: Fix unresolved name issue for no-debug and no-error-msg cases Len Brown
2011-03-23  6:42   ` [PATCH 22/42] ACPICA: Split large dsopcode and dsload.c files Len Brown
2011-03-23  6:42   ` [PATCH 23/42] ACPICA: Add support for FunctionalFixedHW in acpi_ut_get_region_name Len Brown
2011-03-23  6:42   ` [PATCH 24/42] ACPICA: Add mechanism to defer _REG methods for some installed handlers Len Brown
2011-03-23  6:42   ` [PATCH 25/42] ACPICA: Update version to 20110211 Len Brown
2011-03-23  6:42   ` [PATCH 26/42] Thermal_Framework-Fix_crash_during_hwmon_unregister Len Brown
2011-03-23  6:42   ` [PATCH 27/42] ACPI: use __init where possible in processor driver Len Brown
2011-03-23  6:42   ` [PATCH 28/42] ACPI: use __cpuinit for the acpi_processor_set_pdc() call tree Len Brown
2011-03-23  6:42   ` [PATCH 29/42] ACPI: Remove the unused EC sysdev class Len Brown
2011-03-23  6:42   ` [PATCH 30/42] ACPI: Use syscore_ops instead of sysdev class and sysdev Len Brown
2011-03-23  6:42   ` [PATCH 31/42] ACPI, APEI, Add ERST record ID cache Len Brown
2011-03-23  6:42   ` Len Brown [this message]
2011-03-23  6:42   ` [PATCH 33/42] ACPI, APEI, Add PCIe AER error information printing support Len Brown
2011-03-23  6:42   ` [PATCH 34/42] ACPI button: remove unused procfs I/F Len Brown
2011-03-23  6:42   ` [PATCH 35/42] ACPI battery: fribble sysfs files from a resume notifier Len Brown
2011-03-23 13:40     ` Kyle McMartin
2011-04-13 10:37     ` Kyle McMartin
2011-04-24 23:55       ` [stable] " Greg KH
2011-03-23  6:42   ` [PATCH 36/42] ACPICA: Fix access width for reset vector Len Brown
2011-03-23  6:42   ` [PATCH 37/42] ACPI: Bug compatibility for Windows on the ACPI reboot vector Len Brown
2011-03-23  6:42   ` [PATCH 38/42] ACPI: Make sure the FADT is at least rev 2 before using the reset register Len Brown
2011-03-23  6:42   ` [PATCH 39/42] ACPICA: Header support for SLIC table Len Brown
2011-03-23  6:42   ` [PATCH 40/42] ACPICA: Update version to 20110316 Len Brown
2011-03-23  6:42   ` [PATCH 41/42] ACPI: make acpi_pad /sys output more readable Len Brown
2011-03-23  6:42   ` [PATCH 42/42] ACPI: minor printk format change in acpi_pad Len Brown

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=b64a44146540a4761bb1cf8047fffd9dbf0c3090.1300862481.git.len.brown@intel.com \
    --to=lenb@kernel.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=yanmin.zhang@intel.com \
    --cc=ying.huang@intel.com \
    /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).