Skip to content

Commit a71c592

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Move TLP Log handling to its own file
TLP Log is a PCIe feature and is processed only by AER and DPC. Configwise, DPC depends AER being enabled. In lack of better place, the TLP Log handling code was initially placed into pci.c but it can be easily placed in a separate file. Move TLP Log handling code to its own file under pcie/ subdirectory and include it only when AER is enabled. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Yazen Ghannam <[email protected]>
1 parent 0135255 commit a71c592

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed

drivers/pci/pci.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,33 +1099,6 @@ static void pci_enable_acs(struct pci_dev *dev)
10991099
pci_write_config_word(dev, pos + PCI_ACS_CTRL, caps.ctrl);
11001100
}
11011101

1102-
/**
1103-
* pcie_read_tlp_log - read TLP Header Log
1104-
* @dev: PCIe device
1105-
* @where: PCI Config offset of TLP Header Log
1106-
* @tlp_log: TLP Log structure to fill
1107-
*
1108-
* Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC.
1109-
*
1110-
* Return: 0 on success and filled TLP Log structure, <0 on error.
1111-
*/
1112-
int pcie_read_tlp_log(struct pci_dev *dev, int where,
1113-
struct pcie_tlp_log *tlp_log)
1114-
{
1115-
int i, ret;
1116-
1117-
memset(tlp_log, 0, sizeof(*tlp_log));
1118-
1119-
for (i = 0; i < 4; i++) {
1120-
ret = pci_read_config_dword(dev, where + i * 4,
1121-
&tlp_log->dw[i]);
1122-
if (ret)
1123-
return pcibios_err_to_errno(ret);
1124-
}
1125-
1126-
return 0;
1127-
}
1128-
11291102
/**
11301103
* pci_restore_bars - restore a device's BAR values (e.g. after wake-up)
11311104
* @dev: PCI device to have its BARs restored

drivers/pci/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,9 @@ struct aer_err_info {
549549

550550
int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info);
551551
void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
552-
#endif /* CONFIG_PCIEAER */
553552

554553
int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log *log);
554+
#endif /* CONFIG_PCIEAER */
555555

556556
#ifdef CONFIG_PCIEPORTBUS
557557
/* Cached RCEC Endpoint Association */

drivers/pci/pcie/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pcieportdrv-y := portdrv.o rcec.o
77
obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o bwctrl.o
88

99
obj-y += aspm.o
10-
obj-$(CONFIG_PCIEAER) += aer.o err.o
10+
obj-$(CONFIG_PCIEAER) += aer.o err.o tlp.o
1111
obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o
1212
obj-$(CONFIG_PCIE_PME) += pme.o
1313
obj-$(CONFIG_PCIE_DPC) += dpc.o

drivers/pci/pcie/tlp.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* PCIe TLP Log handling
4+
*
5+
* Copyright (C) 2024 Intel Corporation
6+
*/
7+
8+
#include <linux/aer.h>
9+
#include <linux/pci.h>
10+
#include <linux/string.h>
11+
12+
#include "../pci.h"
13+
14+
/**
15+
* pcie_read_tlp_log - read TLP Header Log
16+
* @dev: PCIe device
17+
* @where: PCI Config offset of TLP Header Log
18+
* @tlp_log: TLP Log structure to fill
19+
*
20+
* Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC.
21+
*
22+
* Return: 0 on success and filled TLP Log structure, <0 on error.
23+
*/
24+
int pcie_read_tlp_log(struct pci_dev *dev, int where,
25+
struct pcie_tlp_log *tlp_log)
26+
{
27+
int i, ret;
28+
29+
memset(tlp_log, 0, sizeof(*tlp_log));
30+
31+
for (i = 0; i < 4; i++) {
32+
ret = pci_read_config_dword(dev, where + i * 4,
33+
&tlp_log->dw[i]);
34+
if (ret)
35+
return pcibios_err_to_errno(ret);
36+
}
37+
38+
return 0;
39+
}

0 commit comments

Comments
 (0)