mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
PCI: Add pcie_print_tlp_log() to print TLP Header and Prefix Log
Add pcie_print_tlp_log() to print TLP Header and Prefix Log. Print End-End Prefixes only if they are non-zero. Consolidate the few places which currently print TLP using custom formatting. Link: https://lore.kernel.org/r/20250114170840.1633-9-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
ad41ddeeac
commit
f68ea779d9
@@ -553,6 +553,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
|
||||
int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2,
|
||||
unsigned int tlp_len, struct pcie_tlp_log *log);
|
||||
unsigned int aer_tlp_log_len(struct pci_dev *dev, u32 aercc);
|
||||
void pcie_print_tlp_log(const struct pci_dev *dev,
|
||||
const struct pcie_tlp_log *log, const char *pfx);
|
||||
#endif /* CONFIG_PCIEAER */
|
||||
|
||||
#ifdef CONFIG_PCIEPORTBUS
|
||||
|
||||
@@ -665,12 +665,6 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
|
||||
}
|
||||
}
|
||||
|
||||
static void __print_tlp_header(struct pci_dev *dev, struct pcie_tlp_log *t)
|
||||
{
|
||||
pci_err(dev, " TLP Header: %08x %08x %08x %08x\n",
|
||||
t->dw[0], t->dw[1], t->dw[2], t->dw[3]);
|
||||
}
|
||||
|
||||
static void __aer_print_error(struct pci_dev *dev,
|
||||
struct aer_err_info *info)
|
||||
{
|
||||
@@ -725,7 +719,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
|
||||
__aer_print_error(dev, info);
|
||||
|
||||
if (info->tlp_header_valid)
|
||||
__print_tlp_header(dev, &info->tlp);
|
||||
pcie_print_tlp_log(dev, &info->tlp, dev_fmt(" "));
|
||||
|
||||
out:
|
||||
if (info->id && info->error_dev_num > 1 && info->id == id)
|
||||
@@ -797,7 +791,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
|
||||
aer->uncor_severity);
|
||||
|
||||
if (tlp_header_valid)
|
||||
__print_tlp_header(dev, &aer->header_log);
|
||||
pcie_print_tlp_log(dev, &aer->header_log, dev_fmt(" "));
|
||||
|
||||
trace_aer_event(dev_name(&dev->dev), (status & ~mask),
|
||||
aer_severity, tlp_header_valid, &aer->header_log);
|
||||
|
||||
@@ -220,10 +220,7 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev)
|
||||
pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG,
|
||||
cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG,
|
||||
dpc_tlp_log_len(pdev), &tlp_log);
|
||||
pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n",
|
||||
tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]);
|
||||
for (i = 0; i < pdev->dpc_rp_log_size - PCIE_STD_NUM_TLP_HEADERLOG - 1; i++)
|
||||
pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, tlp_log.prefix[i]);
|
||||
pcie_print_tlp_log(pdev, &tlp_log, dev_fmt(""));
|
||||
|
||||
if (pdev->dpc_rp_log_size < PCIE_STD_NUM_TLP_HEADERLOG + 1)
|
||||
goto clear_status;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/aer.h>
|
||||
#include <linux/array_size.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
@@ -79,3 +80,36 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define EE_PREFIX_STR " E-E Prefixes:"
|
||||
|
||||
/**
|
||||
* pcie_print_tlp_log - Print TLP Header / Prefix Log contents
|
||||
* @dev: PCIe device
|
||||
* @log: TLP Log structure
|
||||
* @pfx: String prefix
|
||||
*
|
||||
* Prints TLP Header and Prefix Log information held by @log.
|
||||
*/
|
||||
void pcie_print_tlp_log(const struct pci_dev *dev,
|
||||
const struct pcie_tlp_log *log, const char *pfx)
|
||||
{
|
||||
char buf[11 * (PCIE_STD_NUM_TLP_HEADERLOG + ARRAY_SIZE(log->prefix)) +
|
||||
sizeof(EE_PREFIX_STR)];
|
||||
unsigned int i;
|
||||
int len;
|
||||
|
||||
len = scnprintf(buf, sizeof(buf), "%#010x %#010x %#010x %#010x",
|
||||
log->dw[0], log->dw[1], log->dw[2], log->dw[3]);
|
||||
|
||||
if (log->prefix[0])
|
||||
len += scnprintf(buf + len, sizeof(buf) - len, EE_PREFIX_STR);
|
||||
for (i = 0; i < ARRAY_SIZE(log->prefix); i++) {
|
||||
if (!log->prefix[i])
|
||||
break;
|
||||
len += scnprintf(buf + len, sizeof(buf) - len,
|
||||
" %#010x", log->prefix[i]);
|
||||
}
|
||||
|
||||
pci_err(dev, "%sTLP Header: %s\n", pfx, buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user