PCIe, AER, use pre-generated prefix in error information printing
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>
This commit is contained in:
parent
885b976fad
commit
b64a441465
|
@ -57,26 +57,22 @@
|
||||||
(e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
|
(e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
|
||||||
AER_TRANSACTION_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
|
* AER error strings
|
||||||
*/
|
*/
|
||||||
static char *aer_error_severity_string[] = {
|
static const char *aer_error_severity_string[] = {
|
||||||
"Uncorrected (Non-Fatal)",
|
"Uncorrected (Non-Fatal)",
|
||||||
"Uncorrected (Fatal)",
|
"Uncorrected (Fatal)",
|
||||||
"Corrected"
|
"Corrected"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *aer_error_layer[] = {
|
static const char *aer_error_layer[] = {
|
||||||
"Physical Layer",
|
"Physical Layer",
|
||||||
"Data Link Layer",
|
"Data Link Layer",
|
||||||
"Transaction Layer"
|
"Transaction Layer"
|
||||||
};
|
};
|
||||||
static char *aer_correctable_error_string[] = {
|
|
||||||
|
static const char *aer_correctable_error_string[] = {
|
||||||
"Receiver Error", /* Bit Position 0 */
|
"Receiver Error", /* Bit Position 0 */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -91,27 +87,9 @@ static char *aer_correctable_error_string[] = {
|
||||||
NULL,
|
NULL,
|
||||||
"Replay Timer Timeout", /* Bit Position 12 */
|
"Replay Timer Timeout", /* Bit Position 12 */
|
||||||
"Advisory Non-Fatal", /* Bit Position 13 */
|
"Advisory Non-Fatal", /* Bit Position 13 */
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *aer_uncorrectable_error_string[] = {
|
static const char *aer_uncorrectable_error_string[] = {
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -133,30 +111,20 @@ static char *aer_uncorrectable_error_string[] = {
|
||||||
"Malformed TLP", /* Bit Position 18 */
|
"Malformed TLP", /* Bit Position 18 */
|
||||||
"ECRC", /* Bit Position 19 */
|
"ECRC", /* Bit Position 19 */
|
||||||
"Unsupported Request", /* Bit Position 20 */
|
"Unsupported Request", /* Bit Position 20 */
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *aer_agent_string[] = {
|
static const char *aer_agent_string[] = {
|
||||||
"Receiver ID",
|
"Receiver ID",
|
||||||
"Requester ID",
|
"Requester ID",
|
||||||
"Completer ID",
|
"Completer ID",
|
||||||
"Transmitter 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;
|
int i, status;
|
||||||
char *errmsg = NULL;
|
const char *errmsg = NULL;
|
||||||
|
|
||||||
status = (info->status & ~info->mask);
|
status = (info->status & ~info->mask);
|
||||||
|
|
||||||
|
@ -165,15 +133,17 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (info->severity == AER_CORRECTABLE)
|
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
|
else
|
||||||
errmsg = aer_uncorrectable_error_string[i];
|
errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
|
||||||
|
aer_uncorrectable_error_string[i] : NULL;
|
||||||
|
|
||||||
if (errmsg)
|
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)" : "");
|
info->first_error == i ? " (First)" : "");
|
||||||
else
|
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)" : "");
|
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)
|
void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
|
||||||
{
|
{
|
||||||
int id = ((dev->bus->number << 8) | dev->devfn);
|
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) {
|
if (info->status == 0) {
|
||||||
AER_PR(info, dev,
|
printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, "
|
||||||
"PCIe Bus Error: severity=%s, type=Unaccessible, "
|
"id=%04x(Unregistered Agent ID)\n", prefix,
|
||||||
"id=%04x(Unregistered Agent ID)\n",
|
|
||||||
aer_error_severity_string[info->severity], id);
|
aer_error_severity_string[info->severity], id);
|
||||||
} else {
|
} else {
|
||||||
int layer, agent;
|
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);
|
layer = AER_GET_LAYER_ERROR(info->severity, info->status);
|
||||||
agent = AER_GET_AGENT(info->severity, info->status);
|
agent = AER_GET_AGENT(info->severity, info->status);
|
||||||
|
|
||||||
AER_PR(info, dev,
|
printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
|
||||||
"PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
|
prefix, aer_error_severity_string[info->severity],
|
||||||
aer_error_severity_string[info->severity],
|
|
||||||
aer_error_layer[layer], id, aer_agent_string[agent]);
|
aer_error_layer[layer], id, aer_agent_string[agent]);
|
||||||
|
|
||||||
AER_PR(info, dev,
|
printk("%s"" device [%04x:%04x] error status/mask=%08x/%08x\n",
|
||||||
" device [%04x:%04x] error status/mask=%08x/%08x\n",
|
prefix, dev->vendor, dev->device,
|
||||||
dev->vendor, dev->device, info->status, info->mask);
|
info->status, info->mask);
|
||||||
|
|
||||||
__aer_print_error(info, dev);
|
__aer_print_error(prefix, info);
|
||||||
|
|
||||||
if (info->tlp_header_valid) {
|
if (info->tlp_header_valid) {
|
||||||
unsigned char *tlp = (unsigned char *) &info->tlp;
|
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"
|
||||||
" %02x%02x%02x%02x %02x%02x%02x%02x\n",
|
" %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 + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
|
||||||
*(tlp + 11), *(tlp + 10), *(tlp + 9),
|
*(tlp + 11), *(tlp + 10), *(tlp + 9),
|
||||||
*(tlp + 8), *(tlp + 15), *(tlp + 14),
|
*(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)
|
if (info->id && info->error_dev_num > 1 && info->id == id)
|
||||||
AER_PR(info, dev,
|
printk("%s"" Error of this Agent(%04x) is reported first\n",
|
||||||
" Error of this Agent(%04x) is reported first\n", id);
|
prefix, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
|
void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
|
||||||
|
|
Loading…
Reference in New Issue