Skip to content

Commit a0b62cc

Browse files
committed
PCI/DPC: Log Error Source ID only when valid
DPC Error Source ID is only valid when the DPC Trigger Reason indicates that DPC was triggered due to reception of an ERR_NONFATAL or ERR_FATAL Message (PCIe r6.0, sec 7.9.14.5). When DPC was triggered by ERR_NONFATAL (PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE) or ERR_FATAL (PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE) from a downstream device, log the Error Source ID (decoded into domain/bus/device/function). Don't print the source otherwise, since it's not valid. For DPC trigger due to reception of ERR_NONFATAL or ERR_FATAL, the dmesg logging changes: - pci 0000:00:01.0: DPC: containment event, status:0x000d source:0x0200 - pci 0000:00:01.0: DPC: ERR_FATAL detected + pci 0000:00:01.0: DPC: containment event, status:0x000d, ERR_FATAL received from 0000:02:00.0 and when DPC triggered for other reasons, where DPC Error Source ID is undefined, e.g., unmasked uncorrectable error: - pci 0000:00:01.0: DPC: containment event, status:0x0009 source:0x0200 - pci 0000:00:01.0: DPC: unmasked uncorrectable error detected + pci 0000:00:01.0: DPC: containment event, status:0x0009: unmasked uncorrectable error detected Previously the "containment event" message was at KERN_INFO and the "%s detected" message was at KERN_WARNING. Now the single message is at KERN_WARNING. Fixes: 26e5157 ("PCI: Add Downstream Port Containment driver") Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent a424b59 commit a0b62cc

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

drivers/pci/pcie/dpc.c

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -261,37 +261,45 @@ void dpc_process_error(struct pci_dev *pdev)
261261
struct aer_err_info info = {};
262262

263263
pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
264-
pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source);
265-
266-
pci_info(pdev, "containment event, status:%#06x source:%#06x\n",
267-
status, source);
268264

269265
reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN;
270-
ext_reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT;
271-
pci_warn(pdev, "%s detected\n",
272-
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR) ?
273-
"unmasked uncorrectable error" :
274-
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE) ?
275-
"ERR_NONFATAL" :
276-
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE) ?
277-
"ERR_FATAL" :
278-
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO) ?
279-
"RP PIO error" :
280-
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER) ?
281-
"software trigger" :
282-
"reserved error");
283-
284-
/* show RP PIO error detail information */
285-
if (pdev->dpc_rp_extensions &&
286-
reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT &&
287-
ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO)
288-
dpc_process_rp_pio_error(pdev);
289-
else if (reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR &&
290-
dpc_get_aer_uncorrect_severity(pdev, &info) &&
291-
aer_get_device_error_info(pdev, &info)) {
292-
aer_print_error(pdev, &info);
293-
pci_aer_clear_nonfatal_status(pdev);
294-
pci_aer_clear_fatal_status(pdev);
266+
267+
switch (reason) {
268+
case PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR:
269+
pci_warn(pdev, "containment event, status:%#06x: unmasked uncorrectable error detected\n",
270+
status);
271+
if (dpc_get_aer_uncorrect_severity(pdev, &info) &&
272+
aer_get_device_error_info(pdev, &info)) {
273+
aer_print_error(pdev, &info);
274+
pci_aer_clear_nonfatal_status(pdev);
275+
pci_aer_clear_fatal_status(pdev);
276+
}
277+
break;
278+
case PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE:
279+
case PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE:
280+
pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID,
281+
&source);
282+
pci_warn(pdev, "containment event, status:%#06x, %s received from %04x:%02x:%02x.%d\n",
283+
status,
284+
(reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE) ?
285+
"ERR_FATAL" : "ERR_NONFATAL",
286+
pci_domain_nr(pdev->bus), PCI_BUS_NUM(source),
287+
PCI_SLOT(source), PCI_FUNC(source));
288+
break;
289+
case PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT:
290+
ext_reason = status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT;
291+
pci_warn(pdev, "containment event, status:%#06x: %s detected\n",
292+
status,
293+
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO) ?
294+
"RP PIO error" :
295+
(ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER) ?
296+
"software trigger" :
297+
"reserved error");
298+
/* show RP PIO error detail information */
299+
if (ext_reason == PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO &&
300+
pdev->dpc_rp_extensions)
301+
dpc_process_rp_pio_error(pdev);
302+
break;
295303
}
296304
}
297305

0 commit comments

Comments
 (0)