PCI/AER: Check log level once and remember it
When reporting an AER error, we check its type multiple times to determine the log level for each message. Do this check only in the top-level functions (aer_isr_one_error(), pci_print_aer()) and save the level in struct aer_err_info. [bhelgaas: save log level in struct aer_err_info instead of passing it as a parameter] Signed-off-by: Karolina Stolarek <karolina.stolarek@oracle.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://patch.msgid.link/20250522232339.1525671-13-helgaas@kernel.org
This commit is contained in:
parent
6bb4befbd6
commit
c8f6791e33
@ -588,6 +588,7 @@ static inline bool pci_dev_test_and_set_removed(struct pci_dev *dev)
|
||||
struct aer_err_info {
|
||||
struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
|
||||
int error_dev_num;
|
||||
const char *level; /* printk level */
|
||||
|
||||
unsigned int id:16;
|
||||
|
||||
|
||||
@ -669,21 +669,18 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
|
||||
}
|
||||
}
|
||||
|
||||
static void __aer_print_error(struct pci_dev *dev,
|
||||
struct aer_err_info *info)
|
||||
static void __aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
|
||||
{
|
||||
const char **strings;
|
||||
unsigned long status = info->status & ~info->mask;
|
||||
const char *level, *errmsg;
|
||||
const char *level = info->level;
|
||||
const char *errmsg;
|
||||
int i;
|
||||
|
||||
if (info->severity == AER_CORRECTABLE) {
|
||||
if (info->severity == AER_CORRECTABLE)
|
||||
strings = aer_correctable_error_string;
|
||||
level = KERN_WARNING;
|
||||
} else {
|
||||
else
|
||||
strings = aer_uncorrectable_error_string;
|
||||
level = KERN_ERR;
|
||||
}
|
||||
|
||||
for_each_set_bit(i, &status, 32) {
|
||||
errmsg = strings[i];
|
||||
@ -712,7 +709,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
|
||||
{
|
||||
int layer, agent;
|
||||
int id = pci_dev_id(dev);
|
||||
const char *level;
|
||||
const char *level = info->level;
|
||||
|
||||
pci_dev_aer_stats_incr(dev, info);
|
||||
trace_aer_event(pci_name(dev), (info->status & ~info->mask),
|
||||
@ -727,8 +724,6 @@ 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);
|
||||
|
||||
level = (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR;
|
||||
|
||||
aer_printk(level, dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n",
|
||||
aer_error_severity_string[info->severity],
|
||||
aer_error_layer[layer], aer_agent_string[agent]);
|
||||
@ -774,9 +769,11 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
|
||||
if (aer_severity == AER_CORRECTABLE) {
|
||||
status = aer->cor_status;
|
||||
mask = aer->cor_mask;
|
||||
info.level = KERN_WARNING;
|
||||
} else {
|
||||
status = aer->uncor_status;
|
||||
mask = aer->uncor_mask;
|
||||
info.level = KERN_ERR;
|
||||
tlp_header_valid = status & AER_LOG_TLP_MASKS;
|
||||
}
|
||||
|
||||
@ -1306,6 +1303,7 @@ static void aer_isr_one_error(struct pci_dev *root,
|
||||
struct aer_err_info e_info = {
|
||||
.id = ERR_COR_ID(e_src->id),
|
||||
.severity = AER_CORRECTABLE,
|
||||
.level = KERN_WARNING,
|
||||
.multi_error_valid = multi ? 1 : 0,
|
||||
};
|
||||
|
||||
@ -1318,6 +1316,7 @@ static void aer_isr_one_error(struct pci_dev *root,
|
||||
struct aer_err_info e_info = {
|
||||
.id = ERR_UNCOR_ID(e_src->id),
|
||||
.severity = fatal ? AER_FATAL : AER_NONFATAL,
|
||||
.level = KERN_ERR,
|
||||
.multi_error_valid = multi ? 1 : 0,
|
||||
};
|
||||
|
||||
|
||||
@ -252,6 +252,7 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
|
||||
else
|
||||
info->severity = AER_NONFATAL;
|
||||
|
||||
info->level = KERN_ERR;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user