PCI: Consolidate TLP Log reading and printing
Subsystems (9)
cover PCI: Consolidate TLP Log reading and printing
This series consolidates AER & DPC TLP Log handling code. Helpers are added for reading and printing the TLP Log and the format is made to include E-E Prefixes in both cases (previously only one DPC RP PIO displayed the E-E Prefixes).
I'd appreciate if people familiar with ixgbe could check the error handling conversion within the driver is correct.
Ilpo Järvinen (4):
PCI/AER: Cleanup register variable
PCI: Generalize TLP Header Log reading
PCI: Add TLP Prefix reading into pcie_read_tlp_log()
PCI: Create helper to print TLP Header and Prefix Log
drivers/firmware/efi/cper.c | 4 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 39 +++------ drivers/pci/ats.c | 2 +- drivers/pci/pci.c | 79 +++++++++++++++++++ drivers/pci/pci.h | 2 +- drivers/pci/pcie/aer.c | 28 ++----- drivers/pci/pcie/dpc.c | 31 ++++---- drivers/pci/probe.c | 14 ++-- include/linux/aer.h | 16 ++-- include/linux/pci.h | 2 +- include/ras/ras_event.h | 10 +-- include/uapi/linux/pci_regs.h | 2 + 12 files changed, 145 insertions(+), 84 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 PCI/AER: Cleanup register variable
Use u32 for PCIe Capability register variable and name it aercc (Advanced Error Capabilities and Control register, PCIe r6.1 sec 7.8.4.7) instead of temp.
--- drivers/pci/pcie/aer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pcie/aer.c +3 -3
@@ -1210,7 +1210,7 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) {int type =pci_pcie_type (dev);int aer = dev->aer_cap; -int temp; +u32 aercc;/* Must reset in this function */ info->status =0 ;
@@ -1241,8 +1241,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)return 0 ;/* Get First Error Pointer */ -pci_read_config_dword (dev, aer +PCI_ERR_CAP , &temp); - info->first_error =PCI_ERR_CAP_FEP (temp); +pci_read_config_dword (dev, aer +PCI_ERR_CAP , &aercc); + info->first_error =PCI_ERR_CAP_FEP (aercc);if (info->status &AER_LOG_TLP_MASKS ) { info->tlp_header_valid =1 ;
Signature · 1 line
2.39.2
PATCH 2/4 PCI: Generalize TLP Header Log reading
In reply to Ilpo JärvinenBoth AER and DPC RP PIO provide TLP Header Log registers (PCIe r6.1 secs 7.8.4 & 7.9.14) to convey error diagnostics but the struct is named after AER as the struct aer_header_log_regs. Also, not all places that handle TLP Header Log use the struct and the struct members are named individually.
Generalize the struct name and members, and use it consistently where TLP Header Log is being handled so that a pcie_read_tlp_log() helper can be easily added.
--- drivers/firmware/efi/cper.c | 4 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 37 +++++-------------- drivers/pci/pci.c | 26 +++++++++++++ drivers/pci/pci.h | 2 +- drivers/pci/pcie/aer.c | 14 ++----- drivers/pci/pcie/dpc.c | 14 ++----- include/linux/aer.h | 11 +++--- include/ras/ras_event.h | 10 ++--- 8 files changed, 56 insertions(+), 62 deletions(-)
drivers/firmware/efi/cper.c +2 -2
@@ -445,8 +445,8 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,printk ("%saer_uncor_severity: 0x%08x\n" , pfx, aer->uncor_severity);printk ("%sTLP Header: %08x %08x %08x %08x\n" , pfx, - aer->header_log.dw0, aer->header_log.dw1, - aer->header_log.dw2, aer->header_log.dw3); + aer->header_log.dw[0 ], aer->header_log.dw[1 ], + aer->header_log.dw[2 ], aer->header_log.dw[3 ]); } }
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10 -27
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2018 Intel Corporation. */ +#include <linux/aer.h> #include <linux/types.h> #include <linux/module.h> #include <linux/pci.h>
@@ -391,22 +392,6 @@ u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg)return value; } -#ifdef CONFIG_PCI_IOV -static u32 ixgbe_read_pci_cfg_dword (struct ixgbe_hw *hw,u32 reg) -{ -struct ixgbe_adapter *adapter = hw->back; -u32 value; - -if (ixgbe_removed (hw->hw_addr)) -return IXGBE_FAILED_READ_CFG_DWORD ; -pci_read_config_dword (adapter->pdev, reg, &value); -if (value ==IXGBE_FAILED_READ_CFG_DWORD && -ixgbe_check_cfg_remove (hw, adapter->pdev)) -return IXGBE_FAILED_READ_CFG_DWORD ; -return value; -} -#endif /* CONFIG_PCI_IOV */ -void ixgbe_write_pci_cfg_word (struct ixgbe_hw *hw,u32 reg,u16 value) {struct ixgbe_adapter *adapter = hw->back;
@@ -11332,8 +11317,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,#ifdef CONFIG_PCI_IOV struct ixgbe_hw *hw = &adapter->hw;struct pci_dev *bdev, *vfdev; -u32 dw0, dw1, dw2, dw3; -int vf, pos; +struct pcie_tlp_log tlp_log; +int vf, pos, ret;u16 req_id, pf_func; if (adapter->hw.mac.type == ixgbe_mac_82598EB ||
@@ -11351,14 +11336,13 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,if (!pos) goto skip_bad_vf_detection; - dw0 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG ); - dw1 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +4 ); - dw2 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +8 ); - dw3 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +12 ); -if (ixgbe_removed (hw->hw_addr)) + ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , &tlp_log); +if (ret <0 ) { +ixgbe_check_cfg_remove (hw, pdev); goto skip_bad_vf_detection; + } - req_id = dw1 >>16 ; + req_id = tlp_log.dw[1 ] >>16 ;/* On the 82599 if bit 7 of the requestor ID is set then it's a VF */ if (!(req_id &0x0080 )) goto skip_bad_vf_detection;
@@ -11369,9 +11353,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, vf =FIELD_GET (0x7F , req_id);e_dev_err ("VF %d has caused a PCIe error\n" , vf); -e_dev_err ("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: " -"%8.8x\tdw3: %8.8x\n" , - dw0, dw1, dw2, dw3); +e_dev_err ("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: %8.8x\tdw3: %8.8x\n" , + tlp_log.dw[0 ], tlp_log.dw[1 ], tlp_log.dw[2 ], tlp_log.dw[3 ]);switch (adapter->hw.mac.type) {case ixgbe_mac_82599EB: device_id =IXGBE_82599_VF_DEVICE_ID ;
drivers/pci/pci.c +26 -0
@@ -1067,6 +1067,32 @@ static void pci_enable_acs(struct pci_dev *dev)pci_disable_acs_redir (dev); } +/** +* pcie_read_tlp_log - Reads TLP Header Log +* @dev: PCIe device +* @where: PCI Config offset of TLP Header Log +* @tlp_log: TLP Log structure to fill +* +* Fills @tlp_log from TLP Header Log registers. +* +* Return: 0 on success and filled TLP Log structure, <0 on error. +*/ +int pcie_read_tlp_log (struct pci_dev *dev,int where,struct pcie_tlp_log *tlp_log) +{ +int i, ret; + +memset (tlp_log,0 ,sizeof (*tlp_log)); + +for (i =0 ; i <4 ; i++) { + ret =pci_read_config_dword (dev, where + i *4 , &tlp_log->dw[i]); +if (ret) +return pcibios_err_to_errno (ret); + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (pcie_read_tlp_log); +/** * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) * @dev: PCI device to have its BARs restored
drivers/pci/pci.h +1 -1
@@ -409,7 +409,7 @@ struct aer_err_info {unsigned int status;/* COR/UNCOR Error Status */ unsigned int mask;/* COR/UNCOR Error Mask */ -struct aer_header_log_regs tlp;/* TLP Header */ +struct pcie_tlp_log tlp;/* TLP Header */ };int aer_get_device_error_info (struct pci_dev *dev,struct aer_err_info *info);
drivers/pci/pcie/aer.c +3 -11
@@ -664,11 +664,10 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, } } -static void __print_tlp_header (struct pci_dev *dev, -struct aer_header_log_regs *t) +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->dw0, t->dw1, t->dw2, t->dw3); + t->dw[0 ], t->dw[1 ], t->dw[2 ], t->dw[3 ]); } static void __aer_print_error(struct pci_dev *dev,
@@ -1246,14 +1245,7 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)if (info->status &AER_LOG_TLP_MASKS ) { info->tlp_header_valid =1 ; -pci_read_config_dword (dev, - aer +PCI_ERR_HEADER_LOG , &info->tlp.dw0); -pci_read_config_dword (dev, - aer +PCI_ERR_HEADER_LOG +4 , &info->tlp.dw1); -pci_read_config_dword (dev, - aer +PCI_ERR_HEADER_LOG +8 , &info->tlp.dw2); -pci_read_config_dword (dev, - aer +PCI_ERR_HEADER_LOG +12 , &info->tlp.dw3); +pcie_read_tlp_log (dev, aer +PCI_ERR_HEADER_LOG , &info->tlp); } }
drivers/pci/pcie/dpc.c +4 -10
@@ -190,7 +190,8 @@ pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)static void dpc_process_rp_pio_error (struct pci_dev *pdev) {u16 cap = pdev->dpc_cap, dpc_status, first_error; -u32 status, mask, sev, syserr, exc, dw0, dw1, dw2, dw3, log, prefix; +u32 status, mask, sev, syserr, exc, log, prefix; +struct pcie_tlp_log tlp_log;int i;pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_STATUS , &status);
@@ -216,16 +217,9 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev)if (pdev->dpc_rp_log_size <4 ) goto clear_status; -pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG , - &dw0); -pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG +4 , - &dw1); -pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG +8 , - &dw2); -pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG +12 , - &dw3); +pcie_read_tlp_log (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG , &tlp_log);pci_err (pdev,"TLP Header: %#010x %#010x %#010x %#010x\n" , - dw0, dw1, dw2, dw3); + tlp_log.dw[0 ], tlp_log.dw[1 ], tlp_log.dw[2 ], tlp_log.dw[3 ]);if (pdev->dpc_rp_log_size <5 ) goto clear_status;
include/linux/aer.h +5 -6
@@ -18,11 +18,8 @@struct pci_dev ; -struct aer_header_log_regs { -u32 dw0; -u32 dw1; -u32 dw2; -u32 dw3; +struct pcie_tlp_log { +u32 dw[4 ]; };struct aer_capability_regs {
@@ -33,13 +30,15 @@ struct aer_capability_regs {u32 cor_status;u32 cor_mask;u32 cap_control; -struct aer_header_log_regs header_log; +struct pcie_tlp_log header_log;u32 root_command;u32 root_status;u16 cor_err_source;u16 uncor_err_source; }; +int pcie_read_tlp_log (struct pci_dev *pdev,int where,struct pcie_tlp_log *tlp_log); +#if defined(CONFIG_PCIEAER )int pci_aer_clear_nonfatal_status (struct pci_dev *dev);int pcie_aer_is_native (struct pci_dev *dev);
include/ras/ras_event.h +5 -5
@@ -300,7 +300,7 @@ TRACE_EVENT(aer_event,const u32 status, const u8 severity, const u8 tlp_header_valid, - struct aer_header_log_regs *tlp), + struct pcie_tlp_log *tlp), TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp),
@@ -318,10 +318,10 @@ TRACE_EVENT(aer_event, __entry->severity = severity; __entry->tlp_header_valid = tlp_header_valid;if (tlp_header_valid) { - __entry->tlp_header[0 ] = tlp->dw0; - __entry->tlp_header[1 ] = tlp->dw1; - __entry->tlp_header[2 ] = tlp->dw2; - __entry->tlp_header[3 ] = tlp->dw3; + __entry->tlp_header[0 ] = tlp->dw[0 ]; + __entry->tlp_header[1 ] = tlp->dw[1 ]; + __entry->tlp_header[2 ] = tlp->dw[2 ]; + __entry->tlp_header[3 ] = tlp->dw[3 ]; } ),
Signature · 1 line
2.39.2
Re: [PATCH 2/4] PCI: Generalize TLP Header Log reading
[+cc Greg, Jeff -- ancient history, I know, sorry!]
Quoted 80 lines · Ilpo Järvinen
Both AER and DPC RP PIO provide TLP Header Log registers (PCIe r6.1 secs 7.8.4 & 7.9.14) to convey error diagnostics but the struct is named after AER as the struct
aer_header_log_regs. Also, not all places that handle TLP Header Log use the struct and the struct members are named individually.Generalize the struct name and members, and use it consistently where TLP Header Log is being handled so that a
pcie_read_tlp_log()helper can be easily added.Signed-off-by Ilpo Järvinen <[email protected]>drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +8
-24@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2018 Intel Corporation. */ +#include <linux/aer.h> #include <linux/types.h> #include <linux/module.h> #include <linux/pci.h> @@ -391,22 +392,6 @@ u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg)return value; } -#ifdef CONFIG_PCI_IOV -static u32 ixgbe_read_pci_cfg_dword (struct ixgbe_hw *hw,u32 reg) -{ -struct ixgbe_adapter *adapter = hw->back; -u32 value; - -if (ixgbe_removed (hw->hw_addr)) -return IXGBE_FAILED_READ_CFG_DWORD ; -pci_read_config_dword (adapter->pdev, reg, &value); -if (value ==IXGBE_FAILED_READ_CFG_DWORD && -ixgbe_check_cfg_remove (hw, adapter->pdev)) -return IXGBE_FAILED_READ_CFG_DWORD ; -return value; -} -#endif /* CONFIG_PCI_IOV */ -void ixgbe_write_pci_cfg_word (struct ixgbe_hw *hw,u32 reg,u16 value) {struct ixgbe_adapter *adapter = hw->back;@@ -11332,8 +11317,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,#ifdef CONFIG_PCI_IOV struct ixgbe_hw *hw = &adapter->hw;struct pci_dev *bdev, *vfdev; -u32 dw0, dw1, dw2, dw3; -int vf, pos; +struct pcie_tlp_log tlp_log; +int vf, pos, ret;u16 req_id, pf_func; if (adapter->hw.mac.type == ixgbe_mac_82598EB ||@@ -11351,14 +11336,13 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,if (!pos) goto skip_bad_vf_detection; - dw0 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG ); - dw1 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +4 ); - dw2 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +8 ); - dw3 =ixgbe_read_pci_cfg_dword (hw, pos +PCI_ERR_HEADER_LOG +12 ); -if (ixgbe_removed (hw->hw_addr)) + ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , &tlp_log); +if (ret <0 ) { +ixgbe_check_cfg_remove (hw, pdev); goto skip_bad_vf_detection; + } - req_id = dw1 >>16 ; + req_id = tlp_log.dw[1 ] >>16 ;/* On the 82599 if bit 7 of the requestor ID is set then it's a VF */ if (!(req_id &0x0080 )) goto skip_bad_vf_detection;@@ -11369,9 +11353,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, · line 11360
Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2
-3vf =FIELD_GET (0x7F , req_id);e_dev_err ("VF %d has caused a PCIe error\n" , vf); -e_dev_err ("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: " -"%8.8x\tdw3: %8.8x\n" , - dw0, dw1, dw2, dw3); +e_dev_err ("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: %8.8x\tdw3: %8.8x\n" , + tlp_log.dw[0 ], tlp_log.dw[1 ], tlp_log.dw[2 ], tlp_log.dw[3 ]);switch (adapter->hw.mac.type) {case ixgbe_mac_82599EB: device_id =IXGBE_82599_VF_DEVICE_ID ;
The rest of this patch is headed for v6.10, but I dropped this ixgbe change for now.
These TLP Log registers are generic, not device-specific, and if there's something lacking in the PCI core that leads to ixgbe reading and dumping them itself, I'd rather improve the PCI core so all drivers will benefit without having to add code like this.
83c61fa97a7d ("ixgbe: Add protection from VF invalid target DMA") [1] added the ixgbe TLP Log dumping way back in v3.2 (2012). It does do some device-specific VF checking and so on, but even back then, it looks like the PCI core would have dumped the log itself [2], so I don't know why we needed the extra dumping in ixgbe.
So what I'd really like is to remove the TLP Log reading and printing from ixgbe completely, but keep the VF checking.
Bjorn
[1] https://git.kernel.org/linus/83c61fa97a7d
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pcie/aer/aerdrv_errprint.c?id=83c61fa97a7d#n181
PATCH 3/4 PCI: Add TLP Prefix reading into pcie_read_tlp_log()
In reply to Ilpo Järvinenpcie_read_tlp_log() handles only 4 TLP Header Log DWORDs but TLP Prefix Log (PCIe r6.1 secs 7.8.4.12 & 7.9.14.13) may also be present.
Generalize pcie_read_tlp_log() and struct pcie_tlp_log to handle also TLP Prefix Log. The layout of relevant registers in AER and DPC Capability is not identical but the offsets of TLP Header Log and TLP Prefix Log vary so the callers must pass the offsets to pcie_read_tlp_log().
Convert eetlp_prefix_path into integer called eetlp_prefix_max and make is available also when CONFIG_PCI_PASID is not configured to be able to determine the number of E-E Prefixes.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +- drivers/pci/ats.c | 2 +- drivers/pci/pci.c | 37 ++++++++++++++++--- drivers/pci/pcie/aer.c | 4 +- drivers/pci/pcie/dpc.c | 22 +++++++---- drivers/pci/probe.c | 14 ++++--- include/linux/aer.h | 5 ++- include/linux/pci.h | 2 +- include/uapi/linux/pci_regs.h | 2 + 9 files changed, 69 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -1
@@ -11336,7 +11336,9 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,if (!pos) goto skip_bad_vf_detection; - ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , &tlp_log); + ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , + pos +PCI_ERR_PREFIX_LOG , +aer_tlp_log_len (pdev), &tlp_log);if (ret <0 ) {ixgbe_check_cfg_remove (hw, pdev); goto skip_bad_vf_detection;
drivers/pci/ats.c +1 -1
@@ -377,7 +377,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)if (WARN_ON (pdev->pasid_enabled))return -EBUSY ; -if (!pdev->eetlp_prefix_path && !pdev->pasid_no_tlp) +if (!pdev->eetlp_prefix_max && !pdev->pasid_no_tlp)return -EINVAL ;if (!pasid)
drivers/pci/pci.c +31 -6
@@ -1068,23 +1068,48 @@ static void pci_enable_acs(struct pci_dev *dev) }/** -* pcie_read_tlp_log - Reads TLP Header Log +* aer_tlp_log_len - Calculates TLP Header/Prefix Log length +* @dev: PCIe device +* +* Return: TLP Header/Prefix Log length +*/ +unsigned int aer_tlp_log_len (struct pci_dev *dev) +{ +return 4 + dev->eetlp_prefix_max; +} +EXPORT_SYMBOL_GPL (aer_tlp_log_len); + +/** +* pcie_read_tlp_log - Reads TLP Header and Prefix Log * @dev: PCIe device * @where: PCI Config offset of TLP Header Log +* @where2: PCI Config offset of TLP Prefix Log +* @tlp_len: TLP Log length (in DWORDs) * @tlp_log: TLP Log structure to fill * -* Fills @tlp_log from TLP Header Log registers. +* Fills @tlp_log from TLP Header and Prefix Log registers. * * Return: 0 on success and filled TLP Log structure, <0 on error. */ -int pcie_read_tlp_log (struct pci_dev *dev,int where,struct pcie_tlp_log *tlp_log) +int pcie_read_tlp_log (struct pci_dev *dev,int where,int where2, +unsigned int tlp_len,struct pcie_tlp_log *tlp_log) { -int i, ret; +unsigned int i; +int off, ret; +u32 *to;memset (tlp_log,0 ,sizeof (*tlp_log)); -for (i =0 ; i <4 ; i++) { - ret =pci_read_config_dword (dev, where + i *4 , &tlp_log->dw[i]); +for (i =0 ; i < tlp_len; i++) { +if (i <4 ) { + to = &tlp_log->dw[i]; + off = where + i *4 ; + }else { + to = &tlp_log->prefix[i -4 ]; + off = where2 + (i -4 ) *4 ; + } + + ret =pci_read_config_dword (dev, off, to);if (ret)return pcibios_err_to_errno (ret); }
drivers/pci/pcie/aer.c +3 -1
@@ -1245,7 +1245,9 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)if (info->status &AER_LOG_TLP_MASKS ) { info->tlp_header_valid =1 ; -pcie_read_tlp_log (dev, aer +PCI_ERR_HEADER_LOG , &info->tlp); +pcie_read_tlp_log (dev, aer +PCI_ERR_HEADER_LOG , + aer +PCI_ERR_PREFIX_LOG , +aer_tlp_log_len (dev), &info->tlp); } }
drivers/pci/pcie/dpc.c +15 -7
@@ -187,10 +187,19 @@ pci_ers_result_t dpc_reset_link(struct pci_dev *pdev)return ret; } +static unsigned int dpc_tlp_log_len (struct pci_dev *pdev) +{ +/* Remove ImpSpec Log register from the count */ +if (pdev->dpc_rp_log_size >=5 ) +return pdev->dpc_rp_log_size -1 ; + +return pdev->dpc_rp_log_size; +} +static void dpc_process_rp_pio_error (struct pci_dev *pdev) {u16 cap = pdev->dpc_cap, dpc_status, first_error; -u32 status, mask, sev, syserr, exc, log, prefix; +u32 status, mask, sev, syserr, exc, log;struct pcie_tlp_log tlp_log;int i;
@@ -217,20 +226,19 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev)if (pdev->dpc_rp_log_size <4 ) goto clear_status; -pcie_read_tlp_log (pdev, cap +PCI_EXP_DPC_RP_PIO_HEADER_LOG , &tlp_log); +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 -5 ; i++) +pci_err (pdev,"TLP Prefix Header: dw%d, %#010x\n" , i, tlp_log.prefix[i]);if (pdev->dpc_rp_log_size <5 ) goto clear_status;pci_read_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG , &log);pci_err (pdev,"RP PIO ImpSpec Log %#010x\n" , log); -for (i =0 ; i < pdev->dpc_rp_log_size -5 ; i++) { -pci_read_config_dword (pdev, - cap +PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG + i *4 , &prefix); -pci_err (pdev,"TLP Prefix Header: dw%d, %#010x\n" , i, prefix); - } clear_status:pci_write_config_dword (pdev, cap +PCI_EXP_DPC_RP_PIO_STATUS , status); }
drivers/pci/probe.c +9 -5
@@ -2272,8 +2272,8 @@ static void pci_configure_ltr(struct pci_dev *dev)static void pci_configure_eetlp_prefix (struct pci_dev *dev) { -#ifdef CONFIG_PCI_PASID struct pci_dev *bridge; +unsigned int eetlp_max;int pcie_type;u32 cap;
@@ -2285,15 +2285,19 @@ static void pci_configure_eetlp_prefix(struct pci_dev *dev)return ; pcie_type =pci_pcie_type (dev); + + eetlp_max =FIELD_GET (PCI_EXP_DEVCAP2_EE_PREFIX_MAX , cap); +/* 00b means 4 */ + eetlp_max = eetlp_max ?:4 ; +if (pcie_type ==PCI_EXP_TYPE_ROOT_PORT || pcie_type ==PCI_EXP_TYPE_RC_END ) - dev->eetlp_prefix_path =1 ; + dev->eetlp_prefix_max = eetlp_max;else { bridge =pci_upstream_bridge (dev); -if (bridge && bridge->eetlp_prefix_path) - dev->eetlp_prefix_path =1 ; +if (bridge && bridge->eetlp_prefix_max) + dev->eetlp_prefix_max = eetlp_max; } -#endif }static void pci_configure_serr (struct pci_dev *dev)
include/linux/aer.h +4 -1
@@ -20,6 +20,7 @@ struct pci_dev;struct pcie_tlp_log {u32 dw[4 ]; +u32 prefix[4 ]; };struct aer_capability_regs {
@@ -37,7 +38,9 @@ struct aer_capability_regs {u16 uncor_err_source; }; -int pcie_read_tlp_log (struct pci_dev *pdev,int where,struct pcie_tlp_log *tlp_log); +int pcie_read_tlp_log (struct pci_dev *pdev,int where,int where2, +unsigned int tlp_len,struct pcie_tlp_log *tlp_log); +unsigned int aer_tlp_log_len (struct pci_dev *dev);#if defined(CONFIG_PCIEAER )int pci_aer_clear_nonfatal_status (struct pci_dev *dev);
include/linux/pci.h +1 -1
@@ -397,7 +397,7 @@ struct pci_dev {supported from root to here */ #endif unsigned int pasid_no_tlp:1; /* PASID works without TLP Prefix */ - unsigned int eetlp_prefix_path:1; /* End-to-End TLP Prefix */ + unsigned int eetlp_prefix_max:3; /* Max # of End-to-End TLP Prefix, 0=not supported */pci_channel_state_t error_state;/* Current connectivity state */ struct device dev;/* Generic device interface */
include/uapi/linux/pci_regs.h +2 -0
@@ -661,6 +661,7 @@#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000/* New message signaling */ #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000/* Re-use WAKE# for OBFF */ #define PCI_EXP_DEVCAP2_EE_PREFIX 0x00200000/* End-End TLP Prefix */ +#define PCI_EXP_DEVCAP2_EE_PREFIX_MAX 0x00c00000/* Max End-End TLP Prefixes */ #define PCI_EXP_DEVCTL2 0x28/* Device Control 2 */ #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f/* Completion Timeout Value */ #define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010/* Completion Timeout Disable */
@@ -802,6 +803,7 @@#define PCI_ERR_ROOT_FATAL_RCV 0x00000040/* Fatal Received */ #define PCI_ERR_ROOT_AER_IRQ 0xf8000000/* Advanced Error Interrupt Message Number */ #define PCI_ERR_ROOT_ERR_SRC 0x34/* Error Source Identification */ +#define PCI_ERR_PREFIX_LOG 0x38/* TLP Prefix LOG Register (up to 16 bytes) */ /* Virtual Channel */ #define PCI_VC_PORT_CAP1 0x04
Signature · 1 line
2.39.2
Re: [PATCH 3/4] PCI: Add TLP Prefix reading into pcie_read_tlp_log()
Quoted 2 lines · Ilpo Järvinen
pcie_read_tlp_log()handles only 4 TLP Header Log DWORDs but TLP Prefix Log (PCIe r6.1 secs 7.8.4.12 & 7.9.14.13) may also be present.
s/TLP Header Log/Header Log/ to match spec terminology (also below)
Quoted 5 lines
Generalize
pcie_read_tlp_log()and structpcie_tlp_logto handle also TLP Prefix Log. The layout of relevant registers in AER and DPC Capability is not identical but the offsets of TLP Header Log and TLP Prefix Log vary so the callers must pass the offsets topcie_read_tlp_log().
s/is not identical but/is identical, but/ ?
The spec is a little obtuse about Header Log Size.
Quoted 3 lines
Convert
eetlp_prefix_pathinto integer calledeetlp_prefix_maxand make is available also whenCONFIG_PCI_PASIDis not configured to be able to determine the number of E-E Prefixes.
I think this eetlp_prefix_path piece is right, but would be nice in a separate patch since it's a little bit different piece to review.
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, · line 11344
Quoted 12 lines
+++
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.cdrivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3
-1@@ -11336,7 +11336,9 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,if (!pos) goto skip_bad_vf_detection; - ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , &tlp_log); + ret =pcie_read_tlp_log (pdev, pos +PCI_ERR_HEADER_LOG , + pos +PCI_ERR_PREFIX_LOG , +aer_tlp_log_len (pdev), &tlp_log);if (ret <0 ) {ixgbe_check_cfg_remove (hw, pdev); goto skip_bad_vf_detection;
We applied the patch to export pcie_read_tlp_log(), but I'm having
second thoughts about it. I don't think drivers really have any
business here, and I'd rather not expose either pcie_read_tlp_log() or aer_tlp_log_len().
This part of ixgbe_io_error_detected() was added by 83c61fa97a7d ("ixgbe: Add protection from VF invalid target DMA"), and to me it looks like debug code that probably doesn't need to be there as long as the PCI core does the appropriate logging.
Bjorn
PATCH 4/4 PCI: Create helper to print TLP Header and Prefix Log
In reply to Ilpo JärvinenAdd pcie_print_tlp_log() helper 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.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +-- drivers/pci/pci.c | 28 +++++++++++++++++++ drivers/pci/pcie/aer.c | 10 ++----- drivers/pci/pcie/dpc.c | 5 +--- include/linux/aer.h | 2 ++ 5 files changed, 35 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -2
@@ -11355,8 +11355,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, vf =FIELD_GET (0x7F , req_id);e_dev_err ("VF %d has caused a PCIe error\n" , vf); -e_dev_err ("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: %8.8x\tdw3: %8.8x\n" , - tlp_log.dw[0 ], tlp_log.dw[1 ], tlp_log.dw[2 ], tlp_log.dw[3 ]); +pcie_print_tlp_log (pdev, &tlp_log,"" ); +switch (adapter->hw.mac.type) {case ixgbe_mac_82599EB: device_id =IXGBE_82599_VF_DEVICE_ID ;
drivers/pci/pci.c +28 -0
@@ -9,6 +9,7 @@*/ #include <linux/acpi.h> +#include <linux/array_size.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/dmi.h>
@@ -1118,6 +1119,33 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2, }EXPORT_SYMBOL_GPL (pcie_read_tlp_log); +/** +* pcie_print_tlp_log - Print TLP Header / Prefix Log contents +* @dev: PCIe device +* @tlp_log: TLP Log structure +* @pfx: Internal string prefix (for indentation) +* +* Prints TLP Header and Prefix Log information held by @tlp_log. +*/ +void pcie_print_tlp_log (const struct pci_dev *dev, +const struct pcie_tlp_log *tlp_log,const char *pfx) +{ +unsigned int i; + +pci_err (dev,"%sTLP Header: %#010x %#010x %#010x %#010x" , + pfx, tlp_log->dw[0 ], tlp_log->dw[1 ], tlp_log->dw[2 ], tlp_log->dw[3 ]); + +if (tlp_log->prefix[0 ]) +pr_cont (" E-E Prefixes:" ); +for (i =0 ; i <ARRAY_SIZE (tlp_log->prefix); i++) { +if (!tlp_log->prefix[i]) +break ; +pr_cont (" %#010x" , tlp_log->prefix[i]); + } +pr_cont ("\n" ); +} +EXPORT_SYMBOL_GPL (pcie_print_tlp_log); +/** * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) * @dev: PCI device to have its BARs restored
drivers/pci/pcie/aer.c +2 -8
@@ -664,12 +664,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) {
@@ -724,7 +718,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," " ); out:if (info->id && info->error_dev_num >1 && info->id == id)
@@ -796,7 +790,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," " );trace_aer_event (dev_name (&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log);
drivers/pci/pcie/dpc.c +1 -4
@@ -229,10 +229,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 -5 ; i++) -pci_err (pdev,"TLP Prefix Header: dw%d, %#010x\n" , i, tlp_log.prefix[i]); +pcie_print_tlp_log (pdev, &tlp_log,"" );if (pdev->dpc_rp_log_size <5 ) goto clear_status;
include/linux/aer.h +2 -0
@@ -41,6 +41,8 @@ struct aer_capability_regs {int pcie_read_tlp_log (struct pci_dev *pdev,int where,int where2,unsigned int tlp_len,struct pcie_tlp_log *tlp_log);unsigned int aer_tlp_log_len (struct pci_dev *dev); +void pcie_print_tlp_log (const struct pci_dev *dev, +const struct pcie_tlp_log *tlp_log,const char *pfx);#if defined(CONFIG_PCIEAER )int pci_aer_clear_nonfatal_status (struct pci_dev *dev);
Signature · 1 line
2.39.2
Adding Cc Quigshun which I ended up forgotting despite thinking it at one point.
Signature · 1 line
i.
Quoted 29 lines · Ilpo Järvinen
This series consolidates AER & DPC TLP Log handling code. Helpers are added for reading and printing the TLP Log and the format is made to include E-E Prefixes in both cases (previously only one DPC RP PIO displayed the E-E Prefixes).
I'd appreciate if people familiar with ixgbe could check the error handling conversion within the driver is correct.
Ilpo Järvinen (4):
PCI/AER: Cleanup register variable
PCI: Generalize TLP Header Log reading
PCI: Add TLP Prefix reading intopcie_read_tlp_log()
PCI: Create helper to print TLP Header and Prefix Logdrivers/firmware/efi/cper.c | 4 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 39 +++------ drivers/pci/ats.c | 2 +- drivers/pci/pci.c | 79 +++++++++++++++++++ drivers/pci/pci.h | 2 +- drivers/pci/pcie/aer.c | 28 ++----- drivers/pci/pcie/dpc.c | 31 ++++---- drivers/pci/probe.c | 14 ++-- include/linux/aer.h | 16 ++-- include/linux/pci.h | 2 +- include/ras/ras_event.h | 10 +-- include/uapi/linux/pci_regs.h | 2 + 12 files changed, 145 insertions(+), 84 deletions(-)
Bjorn Helgaas
AppliedQuoted 11 lines · Ilpo Järvinen
This series consolidates AER & DPC TLP Log handling code. Helpers are added for reading and printing the TLP Log and the format is made to include E-E Prefixes in both cases (previously only one DPC RP PIO displayed the E-E Prefixes).
I'd appreciate if people familiar with ixgbe could check the error handling conversion within the driver is correct.
Ilpo Järvinen (4):
PCI/AER: Cleanup register variable
PCI: Generalize TLP Header Log reading
I applied these first two to pci/aer for v6.9, thanks, these are all nice improvements!
I postponed the ixgbe part for now because I think we should get an ack from those maintainers or just send it to them since it subtly changes the error and device removal checking there.
Quoted 2 lines
PCI: Add TLP Prefix reading into
pcie_read_tlp_log()
PCI: Create helper to print TLP Header and Prefix Log
I'll respond to these with some minor comments.
Quoted 17 lines
drivers/firmware/efi/cper.c | 4 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 39 +++------ drivers/pci/ats.c | 2 +- drivers/pci/pci.c | 79 +++++++++++++++++++ drivers/pci/pci.h | 2 +- drivers/pci/pcie/aer.c | 28 ++----- drivers/pci/pcie/dpc.c | 31 ++++---- drivers/pci/probe.c | 14 ++-- include/linux/aer.h | 16 ++-- include/linux/pci.h | 2 +- include/ras/ras_event.h | 10 +-- include/uapi/linux/pci_regs.h | 2 + 12 files changed, 145 insertions(+), 84 deletions(-)Signature · 1 line
2.39.2
Quoted 13 lines · Bjorn Helgaas
Quoted 11 lines · Ilpo Järvinen
This series consolidates AER & DPC TLP Log handling code. Helpers are added for reading and printing the TLP Log and the format is made to include E-E Prefixes in both cases (previously only one DPC RP PIO displayed the E-E Prefixes).
I'd appreciate if people familiar with ixgbe could check the error handling conversion within the driver is correct.
Ilpo Järvinen (4):
PCI/AER: Cleanup register variable
PCI: Generalize TLP Header Log reading
Quoted 6 lines
I applied these first two to pci/aer for v6.9, thanks, these are all nice improvements!
I postponed the ixgbe part for now because I think we should get an ack from those maintainers or just send it to them since it subtly changes the error and device removal checking there.
Okay, I'll make sure they're separated properly for the remaining patches (I was already planning on doing that separation and posting v2 to avoid their input blocking the changed but you beat me to it).
Quoted 4 lines
Quoted 2 lines
PCI: Add TLP Prefix reading into
pcie_read_tlp_log()
PCI: Create helper to print TLP Header and Prefix LogI'll respond to these with some minor comments.
Did you forget to send those comments?
Signature · 1 line
i.
Quoted 26 lines · Ilpo Järvinen
Quoted 13 lines · Bjorn Helgaas
Quoted 11 lines · Ilpo Järvinen
This series consolidates AER & DPC TLP Log handling code. Helpers are added for reading and printing the TLP Log and the format is made to include E-E Prefixes in both cases (previously only one DPC RP PIO displayed the E-E Prefixes).
I'd appreciate if people familiar with ixgbe could check the error handling conversion within the driver is correct.
Ilpo Järvinen (4):
PCI/AER: Cleanup register variable
PCI: Generalize TLP Header Log readingQuoted 6 lines
I applied these first two to pci/aer for v6.9, thanks, these are all nice improvements!
I postponed the ixgbe part for now because I think we should get an ack from those maintainers or just send it to them since it subtly changes the error and device removal checking there.
Okay, I'll make sure they're separated properly for the remaining patches (I was already planning on doing that separation and posting v2 to avoid their input blocking the changed but you beat me to it).
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
PCI: Add TLP Prefix reading into
pcie_read_tlp_log()
PCI: Create helper to print TLP Header and Prefix LogI'll respond to these with some minor comments.
Did you forget to send those comments?
Ping.
I still haven't received those comments for patches 3 & 4.
Signature · 1 line
i.