Skip to content

Commit ede5d5d

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Add defines for TLP Header/Prefix log sizes
Add defines for AER and DPC capabilities TLP Header Logging register sizes (PCIe r6.2, sec 7.8.4 / 7.9.14) and replace literals with them. Link: https://lore.kernel.org/r/[email protected] Suggested-by: Yazen Ghannam <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent a71c592 commit ede5d5d

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

drivers/pci/pcie/dpc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,18 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev)
215215
first_error == i ? " (First)" : "");
216216
}
217217

218-
if (pdev->dpc_rp_log_size < 4)
218+
if (pdev->dpc_rp_log_size < PCIE_STD_NUM_TLP_HEADERLOG)
219219
goto clear_status;
220220
pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, &tlp_log);
221221
pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n",
222222
tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]);
223223

224-
if (pdev->dpc_rp_log_size < 5)
224+
if (pdev->dpc_rp_log_size < PCIE_STD_NUM_TLP_HEADERLOG + 1)
225225
goto clear_status;
226226
pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log);
227227
pci_err(pdev, "RP PIO ImpSpec Log %#010x\n", log);
228228

229-
for (i = 0; i < pdev->dpc_rp_log_size - 5; i++) {
229+
for (i = 0; i < pdev->dpc_rp_log_size - PCIE_STD_NUM_TLP_HEADERLOG - 1; i++) {
230230
pci_read_config_dword(pdev,
231231
cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG + i * 4, &prefix);
232232
pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix);
@@ -404,7 +404,9 @@ void pci_dpc_init(struct pci_dev *pdev)
404404
if (!pdev->dpc_rp_log_size) {
405405
pdev->dpc_rp_log_size =
406406
FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, cap);
407-
if (pdev->dpc_rp_log_size < 4 || pdev->dpc_rp_log_size > 9) {
407+
if (pdev->dpc_rp_log_size < PCIE_STD_NUM_TLP_HEADERLOG ||
408+
pdev->dpc_rp_log_size > PCIE_STD_NUM_TLP_HEADERLOG + 1 +
409+
PCIE_STD_MAX_TLP_PREFIXLOG) {
408410
pci_err(pdev, "RP PIO log size %u is invalid\n",
409411
pdev->dpc_rp_log_size);
410412
pdev->dpc_rp_log_size = 0;

drivers/pci/pcie/tlp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where,
2828

2929
memset(tlp_log, 0, sizeof(*tlp_log));
3030

31-
for (i = 0; i < 4; i++) {
31+
for (i = 0; i < PCIE_STD_NUM_TLP_HEADERLOG; i++) {
3232
ret = pci_read_config_dword(dev, where + i * 4,
3333
&tlp_log->dw[i]);
3434
if (ret)

drivers/pci/quirks.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* file, where their drivers can use them.
1313
*/
1414

15+
#include <linux/aer.h>
1516
#include <linux/align.h>
1617
#include <linux/bitfield.h>
1718
#include <linux/types.h>
@@ -6233,8 +6234,9 @@ static void dpc_log_size(struct pci_dev *dev)
62336234
return;
62346235

62356236
if (FIELD_GET(PCI_EXP_DPC_RP_PIO_LOG_SIZE, val) == 0) {
6236-
pci_info(dev, "Overriding RP PIO Log Size to 4\n");
6237-
dev->dpc_rp_log_size = 4;
6237+
pci_info(dev, "Overriding RP PIO Log Size to %d\n",
6238+
PCIE_STD_NUM_TLP_HEADERLOG);
6239+
dev->dpc_rp_log_size = PCIE_STD_NUM_TLP_HEADERLOG;
62386240
}
62396241
}
62406242
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x461f, dpc_log_size);

include/linux/aer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@
1616
#define AER_CORRECTABLE 2
1717
#define DPC_FATAL 3
1818

19+
/*
20+
* AER and DPC capabilities TLP Logging register sizes (PCIe r6.2, sec 7.8.4
21+
* & 7.9.14).
22+
*/
23+
#define PCIE_STD_NUM_TLP_HEADERLOG 4
24+
#define PCIE_STD_MAX_TLP_PREFIXLOG 4
25+
1926
struct pci_dev;
2027

2128
struct pcie_tlp_log {
22-
u32 dw[4];
29+
u32 dw[PCIE_STD_NUM_TLP_HEADERLOG];
2330
};
2431

2532
struct aer_capability_regs {

0 commit comments

Comments
 (0)