Skip to content

Commit c8f6791

Browse files
drobnikbjorn-helgaas
authored andcommitted
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 <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 6bb4bef commit c8f6791

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

drivers/pci/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ static inline bool pci_dev_test_and_set_removed(struct pci_dev *dev)
588588
struct aer_err_info {
589589
struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
590590
int error_dev_num;
591+
const char *level; /* printk level */
591592

592593
unsigned int id:16;
593594

drivers/pci/pcie/aer.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -669,21 +669,18 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
669669
}
670670
}
671671

672-
static void __aer_print_error(struct pci_dev *dev,
673-
struct aer_err_info *info)
672+
static void __aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
674673
{
675674
const char **strings;
676675
unsigned long status = info->status & ~info->mask;
677-
const char *level, *errmsg;
676+
const char *level = info->level;
677+
const char *errmsg;
678678
int i;
679679

680-
if (info->severity == AER_CORRECTABLE) {
680+
if (info->severity == AER_CORRECTABLE)
681681
strings = aer_correctable_error_string;
682-
level = KERN_WARNING;
683-
} else {
682+
else
684683
strings = aer_uncorrectable_error_string;
685-
level = KERN_ERR;
686-
}
687684

688685
for_each_set_bit(i, &status, 32) {
689686
errmsg = strings[i];
@@ -712,7 +709,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
712709
{
713710
int layer, agent;
714711
int id = pci_dev_id(dev);
715-
const char *level;
712+
const char *level = info->level;
716713

717714
pci_dev_aer_stats_incr(dev, info);
718715
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)
727724
layer = AER_GET_LAYER_ERROR(info->severity, info->status);
728725
agent = AER_GET_AGENT(info->severity, info->status);
729726

730-
level = (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR;
731-
732727
aer_printk(level, dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n",
733728
aer_error_severity_string[info->severity],
734729
aer_error_layer[layer], aer_agent_string[agent]);
@@ -774,9 +769,11 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
774769
if (aer_severity == AER_CORRECTABLE) {
775770
status = aer->cor_status;
776771
mask = aer->cor_mask;
772+
info.level = KERN_WARNING;
777773
} else {
778774
status = aer->uncor_status;
779775
mask = aer->uncor_mask;
776+
info.level = KERN_ERR;
780777
tlp_header_valid = status & AER_LOG_TLP_MASKS;
781778
}
782779

@@ -1306,6 +1303,7 @@ static void aer_isr_one_error(struct pci_dev *root,
13061303
struct aer_err_info e_info = {
13071304
.id = ERR_COR_ID(e_src->id),
13081305
.severity = AER_CORRECTABLE,
1306+
.level = KERN_WARNING,
13091307
.multi_error_valid = multi ? 1 : 0,
13101308
};
13111309

@@ -1318,6 +1316,7 @@ static void aer_isr_one_error(struct pci_dev *root,
13181316
struct aer_err_info e_info = {
13191317
.id = ERR_UNCOR_ID(e_src->id),
13201318
.severity = fatal ? AER_FATAL : AER_NONFATAL,
1319+
.level = KERN_ERR,
13211320
.multi_error_valid = multi ? 1 : 0,
13221321
};
13231322

drivers/pci/pcie/dpc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
252252
else
253253
info->severity = AER_NONFATAL;
254254

255+
info->level = KERN_ERR;
255256
return 1;
256257
}
257258

0 commit comments

Comments
 (0)