Skip to content

Commit 83cba5b

Browse files
ktbowmandavejiang
authored andcommitted
PCI/AER: Report CXL or PCIe bus type in AER trace logging
The AER service driver and aer_event tracing currently log 'PCIe Bus Type' for all errors. Update the driver and aer_event tracing to log 'CXL Bus Type' for CXL device errors. This requires that AER can identify and distinguish between PCIe errors and CXL errors. Introduce boolean 'is_cxl' to 'struct aer_err_info'. Add assignment in aer_get_device_error_info() and pci_print_aer(). Update the aer_event trace routine to accept a bus type string parameter. Signed-off-by: Terry Bowman <terry.bowman@amd.com> Co-developed-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://patch.msgid.link/20260114182055.46029-15-terry.bowman@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent da71bd3 commit 83cba5b

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

drivers/pci/pci.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ struct aer_err_info {
738738
unsigned int multi_error_valid:1;
739739

740740
unsigned int first_error:5;
741-
unsigned int __pad2:2;
741+
unsigned int __pad2:1;
742+
unsigned int is_cxl:1;
742743
unsigned int tlp_header_valid:1;
743744

744745
unsigned int status; /* COR/UNCOR Error Status */
@@ -749,6 +750,11 @@ struct aer_err_info {
749750
int aer_get_device_error_info(struct aer_err_info *info, int i);
750751
void aer_print_error(struct aer_err_info *info, int i);
751752

753+
static inline const char *aer_err_bus(struct aer_err_info *info)
754+
{
755+
return info->is_cxl ? "CXL" : "PCIe";
756+
}
757+
752758
int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2,
753759
unsigned int tlp_len, bool flit,
754760
struct pcie_tlp_log *log);

drivers/pci/pcie/aer.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ void aer_print_error(struct aer_err_info *info, int i)
870870
struct pci_dev *dev;
871871
int layer, agent, id;
872872
const char *level = info->level;
873+
const char *bus_type = aer_err_bus(info);
873874

874875
if (WARN_ON_ONCE(i >= AER_MAX_MULTI_ERR_DEVICES))
875876
return;
@@ -879,22 +880,22 @@ void aer_print_error(struct aer_err_info *info, int i)
879880

880881
pci_dev_aer_stats_incr(dev, info);
881882
trace_aer_event(pci_name(dev), (info->status & ~info->mask),
882-
info->severity, info->tlp_header_valid, &info->tlp);
883+
info->severity, info->tlp_header_valid, &info->tlp, bus_type);
883884

884885
if (!info->ratelimit_print[i])
885886
return;
886887

887888
if (!info->status) {
888-
pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n",
889-
aer_error_severity_string[info->severity]);
889+
pci_err(dev, "%s Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n",
890+
bus_type, aer_error_severity_string[info->severity]);
890891
goto out;
891892
}
892893

893894
layer = AER_GET_LAYER_ERROR(info->severity, info->status);
894895
agent = AER_GET_AGENT(info->severity, info->status);
895896

896-
aer_printk(level, dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n",
897-
aer_error_severity_string[info->severity],
897+
aer_printk(level, dev, "%s Bus Error: severity=%s, type=%s, (%s)\n",
898+
bus_type, aer_error_severity_string[info->severity],
898899
aer_error_layer[layer], aer_agent_string[agent]);
899900

900901
aer_printk(level, dev, " device [%04x:%04x] error status/mask=%08x/%08x\n",
@@ -928,6 +929,7 @@ EXPORT_SYMBOL_GPL(cper_severity_to_aer);
928929
void pci_print_aer(struct pci_dev *dev, int aer_severity,
929930
struct aer_capability_regs *aer)
930931
{
932+
const char *bus_type;
931933
int layer, agent, tlp_header_valid = 0;
932934
u32 status, mask;
933935
struct aer_err_info info = {
@@ -948,10 +950,13 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
948950

949951
info.status = status;
950952
info.mask = mask;
953+
info.is_cxl = pcie_is_cxl(dev);
954+
955+
bus_type = aer_err_bus(&info);
951956

952957
pci_dev_aer_stats_incr(dev, &info);
953-
trace_aer_event(pci_name(dev), (status & ~mask),
954-
aer_severity, tlp_header_valid, &aer->header_log);
958+
trace_aer_event(pci_name(dev), (status & ~mask), aer_severity,
959+
tlp_header_valid, &aer->header_log, bus_type);
955960

956961
if (!aer_ratelimit(dev, info.severity))
957962
return;
@@ -1306,6 +1311,7 @@ int aer_get_device_error_info(struct aer_err_info *info, int i)
13061311
/* Must reset in this function */
13071312
info->status = 0;
13081313
info->tlp_header_valid = 0;
1314+
info->is_cxl = pcie_is_cxl(dev);
13091315

13101316
/* The device might not support AER */
13111317
if (!aer)

include/ras/ras_event.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,24 @@ TRACE_EVENT(aer_event,
339339
const u32 status,
340340
const u8 severity,
341341
const u8 tlp_header_valid,
342-
struct pcie_tlp_log *tlp),
342+
struct pcie_tlp_log *tlp,
343+
const char *bus_type),
343344

344-
TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp),
345+
346+
TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp, bus_type),
345347

346348
TP_STRUCT__entry(
347349
__string( dev_name, dev_name )
348350
__field( u32, status )
349351
__field( u8, severity )
350352
__field( u8, tlp_header_valid)
351353
__array( u32, tlp_header, PCIE_STD_MAX_TLP_HEADERLOG)
354+
__string( bus_type, bus_type )
352355
),
353356

354357
TP_fast_assign(
355358
__assign_str(dev_name);
359+
__assign_str(bus_type);
356360
__entry->status = status;
357361
__entry->severity = severity;
358362
__entry->tlp_header_valid = tlp_header_valid;
@@ -364,8 +368,8 @@ TRACE_EVENT(aer_event,
364368
}
365369
),
366370

367-
TP_printk("%s PCIe Bus Error: severity=%s, %s, TLP Header=%s\n",
368-
__get_str(dev_name),
371+
TP_printk("%s %s Bus Error: severity=%s, %s, TLP Header=%s\n",
372+
__get_str(dev_name), __get_str(bus_type),
369373
__entry->severity == AER_CORRECTABLE ? "Corrected" :
370374
__entry->severity == AER_FATAL ?
371375
"Fatal" : "Uncorrected, non-fatal",

0 commit comments

Comments
 (0)