Skip to content

Commit 94bc15c

Browse files
committed
PCI/AER: Convert aer_get_device_error_info(), aer_print_error() to index
Previously aer_get_device_error_info() and aer_print_error() took a pointer to struct aer_err_info and a pointer to a pci_dev. Typically the pci_dev was one of the elements of the aer_err_info.dev[] array (DPC was an exception, where the dev[] array was unused). Convert aer_get_device_error_info() and aer_print_error() to take an index into the aer_err_info.dev[] array instead. A future patch will add per-device ratelimit information, so the index makes it convenient to find the ratelimit associated with the device. To accommodate DPC, set info->dev[0] to the DPC port before using these interfaces. Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 09683a6 commit 94bc15c

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

drivers/pci/pci.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,8 @@ struct aer_err_info {
605605
struct pcie_tlp_log tlp; /* TLP Header */
606606
};
607607

608-
int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info);
609-
void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
608+
int aer_get_device_error_info(struct aer_err_info *info, int i);
609+
void aer_print_error(struct aer_err_info *info, int i);
610610

611611
int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2,
612612
unsigned int tlp_len, bool flit,

drivers/pci/pcie/aer.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,18 @@ static void aer_print_source(struct pci_dev *dev, struct aer_err_info *info,
705705
found ? "" : " (no details found");
706706
}
707707

708-
void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
708+
void aer_print_error(struct aer_err_info *info, int i)
709709
{
710-
int layer, agent;
711-
int id = pci_dev_id(dev);
710+
struct pci_dev *dev;
711+
int layer, agent, id;
712712
const char *level = info->level;
713713

714+
if (WARN_ON_ONCE(i >= AER_MAX_MULTI_ERR_DEVICES))
715+
return;
716+
717+
dev = info->dev[i];
718+
id = pci_dev_id(dev);
719+
714720
pci_dev_aer_stats_incr(dev, info);
715721
trace_aer_event(pci_name(dev), (info->status & ~info->mask),
716722
info->severity, info->tlp_header_valid, &info->tlp);
@@ -1193,19 +1199,26 @@ EXPORT_SYMBOL_GPL(aer_recover_queue);
11931199

11941200
/**
11951201
* aer_get_device_error_info - read error status from dev and store it to info
1196-
* @dev: pointer to the device expected to have an error record
11971202
* @info: pointer to structure to store the error record
1203+
* @i: index into info->dev[]
11981204
*
11991205
* Return: 1 on success, 0 on error.
12001206
*
12011207
* Note that @info is reused among all error devices. Clear fields properly.
12021208
*/
1203-
int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
1209+
int aer_get_device_error_info(struct aer_err_info *info, int i)
12041210
{
1205-
int type = pci_pcie_type(dev);
1206-
int aer = dev->aer_cap;
1211+
struct pci_dev *dev;
1212+
int type, aer;
12071213
u32 aercc;
12081214

1215+
if (i >= AER_MAX_MULTI_ERR_DEVICES)
1216+
return 0;
1217+
1218+
dev = info->dev[i];
1219+
aer = dev->aer_cap;
1220+
type = pci_pcie_type(dev);
1221+
12091222
/* Must reset in this function */
12101223
info->status = 0;
12111224
info->tlp_header_valid = 0;
@@ -1257,11 +1270,11 @@ static inline void aer_process_err_devices(struct aer_err_info *e_info)
12571270

12581271
/* Report all before handling them, to not lose records by reset etc. */
12591272
for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
1260-
if (aer_get_device_error_info(e_info->dev[i], e_info))
1261-
aer_print_error(e_info->dev[i], e_info);
1273+
if (aer_get_device_error_info(e_info, i))
1274+
aer_print_error(e_info, i);
12621275
}
12631276
for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
1264-
if (aer_get_device_error_info(e_info->dev[i], e_info))
1277+
if (aer_get_device_error_info(e_info, i))
12651278
handle_error_source(e_info->dev[i], e_info);
12661279
}
12671280
}

drivers/pci/pcie/dpc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
253253
info->severity = AER_NONFATAL;
254254

255255
info->level = KERN_ERR;
256+
257+
info->dev[0] = dev;
258+
info->error_dev_num = 1;
259+
256260
return 1;
257261
}
258262

@@ -270,8 +274,8 @@ void dpc_process_error(struct pci_dev *pdev)
270274
pci_warn(pdev, "containment event, status:%#06x: unmasked uncorrectable error detected\n",
271275
status);
272276
if (dpc_get_aer_uncorrect_severity(pdev, &info) &&
273-
aer_get_device_error_info(pdev, &info)) {
274-
aer_print_error(pdev, &info);
277+
aer_get_device_error_info(&info, 0)) {
278+
aer_print_error(&info, 0);
275279
pci_aer_clear_nonfatal_status(pdev);
276280
pci_aer_clear_fatal_status(pdev);
277281
}

0 commit comments

Comments
 (0)