Skip to content

Commit c8ab5e8

Browse files
l1kbjorn-helgaas
authored andcommitted
PCI/AER: Print TLP Log for errors introduced since PCIe r1.1
When reporting an error, the AER driver prints the TLP Header / Prefix Log only for errors enumerated in the AER_LOG_TLP_MASKS macro. The macro was never amended since its introduction in 2006 with commit 6c2b374 ("PCI-Express AER implemetation: AER core and aerdriver"). At the time, PCIe r1.1 was the latest spec revision. Amend the macro with errors defined since then to avoid omitting the TLP Header / Prefix Log for newer errors. The order of the errors in AER_LOG_TLP_MASKS follows PCIe r1.1 sec 6.2.7 rather than 7.10.2, because only the former documents for which errors a TLP Header / Prefix is logged. Retain this order. The section number is still 6.2.7 in today's PCIe r7.0. For Completion Timeouts, the TLP Header / Prefix is only logged if the Completion Timeout Prefix / Header Log Capable bit is set in the AER Capabilities and Control register. Introduce a tlp_header_logged() helper to check whether the TLP Header / Prefix Log is populated and use it in the two places which currently match against AER_LOG_TLP_MASKS directly. For Uncorrectable Internal Errors, logging of the TLP Header / Prefix is optional per PCIe r7.0 sec 6.2.7. If needed, drivers could indicate through a flag whether devices are capable and tlp_header_logged() could then check that flag. pcitools introduced macros for newer errors with commit 144b0911cc0b ("ls-ecaps: extend decode support for more fields for AER CE and UE status"): https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/commit/?id=144b0911cc0b Unfortunately some of those macros are overly long: PCI_ERR_UNC_POISONED_TLP_EGRESS PCI_ERR_UNC_DMWR_REQ_EGRESS_BLOCKED PCI_ERR_UNC_IDE_CHECK PCI_ERR_UNC_MISR_IDE_TLP PCI_ERR_UNC_PCRC_CHECK PCI_ERR_UNC_TLP_XLAT_EGRESS_BLOCKED This seems unsuitable for <linux/pci_regs.h>, so shorten to: PCI_ERR_UNC_POISON_BLK PCI_ERR_UNC_DMWR_BLK PCI_ERR_UNC_IDE_CHECK PCI_ERR_UNC_MISR_IDE PCI_ERR_UNC_PCRC_CHECK PCI_ERR_UNC_XLAT_BLK Note that some of the existing macros in <linux/pci_regs.h> do not match exactly with pcitools (e.g. PCI_ERR_UNC_SDES versus PCI_ERR_UNC_SURPDN), so it does not seem mandatory for them to be identical. Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/5f707caf1260bd8f15012bb032f7da9a9b898aba.1756712066.git.lukas@wunner.de
1 parent 6633875 commit c8ab5e8

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

drivers/pci/pcie/aer.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,21 @@ struct aer_info {
9696
};
9797

9898
#define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
99+
PCI_ERR_UNC_POISON_BLK | \
99100
PCI_ERR_UNC_ECRC| \
100101
PCI_ERR_UNC_UNSUP| \
101102
PCI_ERR_UNC_COMP_ABORT| \
102103
PCI_ERR_UNC_UNX_COMP| \
103-
PCI_ERR_UNC_MALF_TLP)
104+
PCI_ERR_UNC_ACSV | \
105+
PCI_ERR_UNC_MCBTLP | \
106+
PCI_ERR_UNC_ATOMEG | \
107+
PCI_ERR_UNC_DMWR_BLK | \
108+
PCI_ERR_UNC_XLAT_BLK | \
109+
PCI_ERR_UNC_TLPPRE | \
110+
PCI_ERR_UNC_MALF_TLP | \
111+
PCI_ERR_UNC_IDE_CHECK | \
112+
PCI_ERR_UNC_MISR_IDE | \
113+
PCI_ERR_UNC_PCRC_CHECK)
104114

105115
#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
106116
PCI_EXP_RTCTL_SENFEE| \
@@ -796,6 +806,20 @@ static int aer_ratelimit(struct pci_dev *dev, unsigned int severity)
796806
}
797807
}
798808

809+
static bool tlp_header_logged(u32 status, u32 capctl)
810+
{
811+
/* Errors for which a header is always logged (PCIe r7.0 sec 6.2.7) */
812+
if (status & AER_LOG_TLP_MASKS)
813+
return true;
814+
815+
/* Completion Timeout header is only logged on capable devices */
816+
if (status & PCI_ERR_UNC_COMP_TIME &&
817+
capctl & PCI_ERR_CAP_COMP_TIME_LOG)
818+
return true;
819+
820+
return false;
821+
}
822+
799823
static void __aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
800824
{
801825
const char **strings;
@@ -910,7 +934,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
910934
status = aer->uncor_status;
911935
mask = aer->uncor_mask;
912936
info.level = KERN_ERR;
913-
tlp_header_valid = status & AER_LOG_TLP_MASKS;
937+
tlp_header_valid = tlp_header_logged(status, aer->cap_control);
914938
}
915939

916940
info.status = status;
@@ -1401,7 +1425,7 @@ int aer_get_device_error_info(struct aer_err_info *info, int i)
14011425
pci_read_config_dword(dev, aer + PCI_ERR_CAP, &aercc);
14021426
info->first_error = PCI_ERR_CAP_FEP(aercc);
14031427

1404-
if (info->status & AER_LOG_TLP_MASKS) {
1428+
if (tlp_header_logged(info->status, aercc)) {
14051429
info->tlp_header_valid = 1;
14061430
pcie_read_tlp_log(dev, aer + PCI_ERR_HEADER_LOG,
14071431
aer + PCI_ERR_PREFIX_LOG,

include/uapi/linux/pci_regs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,12 @@
776776
#define PCI_ERR_UNC_MCBTLP 0x00800000 /* MC blocked TLP */
777777
#define PCI_ERR_UNC_ATOMEG 0x01000000 /* Atomic egress blocked */
778778
#define PCI_ERR_UNC_TLPPRE 0x02000000 /* TLP prefix blocked */
779+
#define PCI_ERR_UNC_POISON_BLK 0x04000000 /* Poisoned TLP Egress Blocked */
780+
#define PCI_ERR_UNC_DMWR_BLK 0x08000000 /* DMWr Request Egress Blocked */
781+
#define PCI_ERR_UNC_IDE_CHECK 0x10000000 /* IDE Check Failed */
782+
#define PCI_ERR_UNC_MISR_IDE 0x20000000 /* Misrouted IDE TLP */
783+
#define PCI_ERR_UNC_PCRC_CHECK 0x40000000 /* PCRC Check Failed */
784+
#define PCI_ERR_UNC_XLAT_BLK 0x80000000 /* TLP Translation Egress Blocked */
779785
#define PCI_ERR_UNCOR_MASK 0x08 /* Uncorrectable Error Mask */
780786
/* Same bits as above */
781787
#define PCI_ERR_UNCOR_SEVER 0x0c /* Uncorrectable Error Severity */
@@ -798,6 +804,7 @@
798804
#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
799805
#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
800806
#define PCI_ERR_CAP_PREFIX_LOG_PRESENT 0x00000800 /* TLP Prefix Log Present */
807+
#define PCI_ERR_CAP_COMP_TIME_LOG 0x00001000 /* Completion Timeout Prefix/Header Log Capable */
801808
#define PCI_ERR_CAP_TLP_LOG_FLIT 0x00040000 /* TLP was logged in Flit Mode */
802809
#define PCI_ERR_CAP_TLP_LOG_SIZE 0x00f80000 /* Logged TLP Size (only in Flit mode) */
803810
#define PCI_ERR_HEADER_LOG 0x1c /* Header Log Register (16 bytes) */

0 commit comments

Comments
 (0)