Enable CXL PCIe port protocol error handling and logging
v3 cover Enable CXL PCIe port protocol error handling and logging
CXL protocol error handling support exists for CXL endpoint devices and CXL restricted host downstream port devices. This patchset adds the same support for CXL PCIe port devices including: CXL root ports, CXL upstream switch ports, and CXL downstream switch ports.[1]
This implementation separates PCIe protocol error handling and CXL protocol error handling. This is necessary because of the different requirements for PCIe and CXL device recovery, specifically uncorrectable error (UCE) handling. PCIe AER handling attempts recovery and uses a device disconnect if recovery fails. CXL devices must use a kernel panic in the case of an uncorrectable errors (UCE). CXL recovery is not attempted because the procedure could corrupt memory while indicating successful recovery.
The first 7 patches update the existing AER service driver to support CXL PCIe port protocol error handling and reporting. This includes AER service driver changes for adding correctable and uncorrectable error support, CXL specific recovery handling, and support for CXL driver callback handlers.
The following 8 patches address CXL driver support for CXL PCIe port protocol errors. This includes the following changes to the CXL drivers:
mapping CXL port and downstream port RAS registers, interface updates for common restricted CXL host mode (RCH) and virtual hierarchy mode (VH), adding port specific error handlers, error logging, and UIE/CIE enablement.
[1] - CXL 3.1 specification, 12.0 Reliability, Availability, and Serviceability
Testing:
Below are test results for this patchset using Qemu with CXL root port(0c:00.0), CXL upstream switchport(0d:00.0), CXL downstream switchport(0e:00.0). The endpoint CE and UCE injection logs are also added.
This was tested using aer-inject updated to support CE and UCE internal error injection. CXL RAS was set using a test patch (not upstreamed but can provide if needed).
- Root Port Correctable Error
root@tbowman-cxl:~/aer-inject# ./root-ce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00004000/00000000 into device 0000:0c:00.0 pcieport 0000:0c:00.0: AER: Correctable error message received from 0000:0c:00.0 pcieport 0000:0c:00.0: CXL Bus Error: severity=Correctable, type=Transaction Layer, (Receiver ID) pcieport 0000:0c:00.0: device [8086:7075] error status/mask=00004000/0000a000 pcieport 0000:0c:00.0: [14] CorrIntErr aer_event: 0000:0c:00.0 CXL Bus Error: severity=Corrected, Corrected Internal Error, TLP Header=Not available cxl_port_aer_correctable_error: device=0000:0c:00.0 host=pci0000:0c status='Received Error From Physical Layer'
- Root Port UnCorrectable Error
root@tbowman-cxl:~/aer-inject# ./root-uce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00000000/00400000 into device 0000:0c:00.0 pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) error message received from 0000:0c:00.0 pcieport 0000:0c:00.0: CXL Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Receiver ID) pcieport 0000:0c:00.0: device [8086:7075] error status/mask=00400000/02000000 pcieport 0000:0c:00.0: [22] UncorrIntErr systemd-journald[482]: Sent WATCHDOG=1 notification. aer_event: 0000:0c:00.0 CXL Bus Error: severity=Fatal, Uncorrectable Internal Error, TLP Header=Not available cxl_port_aer_uncorrectable_error: device=0000:0c:00.0 host=pci0000:0c status: 'Memory Address Parity Error' first_error: 'Memory Address Parity Error' Kernel panic - not syncing: CXL cachemem error. Invoking panic CPU: 10 UID: 0 PID: 150 Comm: irq/24-aerdrv Tainted: G E 6.12.0-rc6test-gb0cd92ab89ad #4507 Tainted: [E]=UNSIGNED_MODULE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x27/0x90 dump_stack+0x10/0x20 panic+0x33e/0x380 cxl_do_recovery+0x122/0x130 ? srso_return_thunk+0x5/0x5f aer_isr+0x3e0/0x710 irq_thread_fn+0x28/0x70 irq_thread+0x179/0x240 ? srso_return_thunk+0x5/0x5f ? __pfx_irq_thread_fn+0x10/0x10 ? __pfx_irq_thread_dtor+0x10/0x10 ? __pfx_irq_thread+0x10/0x10 kthread+0xf5/0x130 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c/0x60 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Kernel Offset: 0x1800000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: CXL cachemem error. Invoking panic ]---
- Upstream Port Correctable Error
root@tbowman-cxl:~/aer-inject# ./us-ce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00004000/00000000 into device 0000:0d:00.0 pcieport 0000:0c:00.0: AER: Correctable error message received from 0000:0d:00.0 pcieport 0000:0d:00.0: CXL Bus Error: severity=Correctable, type=Transaction Layer, (Receiver ID) pcieport 0000:0d:00.0: device [19e5:a128] error status/mask=00004000/0000a000 pcieport 0000:0d:00.0: [14] CorrIntErr aer_event: 0000:0d:00.0 CXL Bus Error: severity=Corrected, Corrected Internal Error, TLP Header=Not available cxl_port_aer_correctable_error: device=0000:0d:00.0 host=0000:0c:00.0 status='Received Error From Physical Layer'
- Upstream Port UnCorrectable Error
root@tbowman-cxl:~/aer-inject# ./root-uce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00000000/00400000 into device 0000:0c:00.0 pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) error message received from 0000:0c:00.0 pcieport 0000:0c:00.0: CXL Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Receiver ID) pcieport 0000:0c:00.0: device [8086:7075] error status/mask=00400000/02000000 pcieport 0000:0c:00.0: [22] UncorrIntErr systemd-journald[482]: Sent WATCHDOG=1 notification. aer_event: 0000:0c:00.0 CXL Bus Error: severity=Fatal, Uncorrectable Internal Error, TLP Header=Not available cxl_port_aer_uncorrectable_error: device=0000:0c:00.0 host=pci0000:0c status: 'Memory Address Parity Error' first_error: 'Memory Address Parity Error' Kernel panic - not syncing: CXL cachemem error. Invoking panic CPU: 10 UID: 0 PID: 150 Comm: irq/24-aerdrv Tainted: G E 6.12.0-rc6test-gb0cd92ab89ad #4507 Tainted: [E]=UNSIGNED_MODULE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x27/0x90 dump_stack+0x10/0x20 panic+0x33e/0x380 cxl_do_recovery+0x122/0x130 ? srso_return_thunk+0x5/0x5f aer_isr+0x3e0/0x710 irq_thread_fn+0x28/0x70 irq_thread+0x179/0x240 ? srso_return_thunk+0x5/0x5f ? __pfx_irq_thread_fn+0x10/0x10 ? __pfx_irq_thread_dtor+0x10/0x10 ? __pfx_irq_thread+0x10/0x10 kthread+0xf5/0x130 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c/0x60 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Kernel Offset: 0x1800000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: CXL cachemem error. Invoking panic ]---
- Downstream Port Correctable Error
root@tbowman-cxl:~/aer-inject# ./ds-ce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00004000/00000000 into device 0000:0e:00.0 pcieport 0000:0c:00.0: AER: Correctable error message received from 0000:0e:00.0 pcieport 0000:0e:00.0: CXL Bus Error: severity=Correctable, type=Transaction Layer, (Receiver ID) pcieport 0000:0e:00.0: device [19e5:a129] error status/mask=00004000/0000a000 pcieport 0000:0e:00.0: [14] CorrIntErr aer_event: 0000:0e:00.0 CXL Bus Error: severity=Corrected, Corrected Internal Error, TLP Header=Not available cxl_port_aer_correctable_error: device=0000:0e:00.0 host=0000:0d:00.0 status='Received Error From Physical Layer'
- Downstream Port UnCorrectable Error
root@tbowman-cxl:~/aer-inject# ./ds-uce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00000000/00400000 into device 0000:0e:00.0 pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) error message received from 0000:0e:00.0 pcieport 0000:0e:00.0: CXL Bus Error: severity=Uncorrectable (Fatal), type=Transaction Layer, (Receiver ID) pcieport 0000:0e:00.0: device [19e5:a129] error status/mask=00400000/02000000 pcieport 0000:0e:00.0: [22] UncorrIntErr aer_event: 0000:0e:00.0 CXL Bus Error: severity=Fatal, Uncorrectable Internal Error, TLP Header=Not available cxl_port_aer_uncorrectable_error: device=0000:0e:00.0 host=0000:0d:00.0 status: 'Memory Address Parity Error' first_error: 'Memory Address Parity Error' Kernel panic - not syncing: CXL cachemem error. Invoking panic CPU: 10 UID: 0 PID: 146 Comm: irq/24-aerdrv Tainted: G E 6.12.0-rc6test-gb0cd92ab89ad #4507 Tainted: [E]=UNSIGNED_MODULE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x27/0x90 dump_stack+0x10/0x20 panic+0x33e/0x380 cxl_do_recovery+0x122/0x130 ? srso_return_thunk+0x5/0x5f aer_isr+0x3e0/0x710 irq_thread_fn+0x28/0x70 irq_thread+0x179/0x240 ? srso_return_thunk+0x5/0x5f ? __pfx_irq_thread_fn+0x10/0x10 ? __pfx_irq_thread_dtor+0x10/0x10 ? __pfx_irq_thread+0x10/0x10 kthread+0xf5/0x130 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c/0x60 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Kernel Offset: 0x1ac00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: CXL cachemem error. Invoking panic ]---
- Endpoint Correctable Error
root@tbowman-cxl:~/aer-inject# ./ep-ce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00000040/00000000 into device 0000:0f:00.0 pcieport 0000:0c:00.0: AER: Correctable error message received from 0000:0f:00.0 cxl_pci 0000:0f:00.0: CXL Bus Error: severity=Correctable, type=Data Link Layer, (Receiver ID) cxl_pci 0000:0f:00.0: device [8086:0d93] error status/mask=00000040/0000e000 systemd-journald[482]: Sent WATCHDOG=1 notification. cxl_pci 0000:0f:00.0: [ 6] BadTLP aer_event: 0000:0f:00.0 CXL Bus Error: severity=Corrected, Bad TLP, TLP Header=Not available
- Endpoint UnCorrectable Error
root@tbowman-cxl:~/aer-inject# ./ep-uce-inject.sh pcieport 0000:0c:00.0: aer_inject: Injecting errors 00000000/00040000 into device 0000:0f:00.0 pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) error message received from 0000:0f:00.0 cxl_pci 0000:0f:00.0: AER: CXL Bus Error: severity=Uncorrectable (Fatal), type=Inaccessible, (Unregistered Agent ID) aer_event: 0000:0f:00.0 CXL Bus Error: severity=Fatal, , TLP Header=Not available cxl_pci 0000:0f:00.0: mem3: frozen state error detected, disable CXL.mem cxl_detach_ep: cxl_mem mem3: disconnect mem3 from port2 cxl_detach_ep: cxl_mem mem3: disconnect mem3 from port1 pcieport 0000:0e:00.0: unlocked secondary bus reset via: pciehp_reset_slot+0xac/0x160 pcieport 0000:0e:00.0: AER: Downstream Port link has been reset (0) cxl_pci 0000:0f:00.0: mem3: restart CXL.mem after slot reset devm_cxl_enumerate_ports: cxl_mem mem3: scan: iter: mem3 dport_dev: 0000:0e:00.0 parent: 0000:0d:00.0 devm_cxl_enumerate_ports: cxl_mem mem3: found already registered port port2:0000:0d:00.0 devm_cxl_enumerate_ports: cxl_mem mem3: scan: iter: 0000:0e:00.0 dport_dev: 0000:0c:00.0 parent: pci0000:0c devm_cxl_enumerate_ports: cxl_mem mem3: found already registered port port1:pci0000:0c cxl_port_alloc: cxl_mem mem3: host-bridge: pci0000:0c cxl_cdat_get_length: cxl_port endpoint6: CDAT length 160 cxl_port_perf_data_calculate: cxl_port endpoint6: Failed to retrieve ep perf coordinates. cxl_endpoint_parse_cdat: cxl_port endpoint6: Failed to do perf coord calculations. init_hdm_decoder: cxl_port endpoint6: decoder6.0: range: 0x0-0xffffffffffffffff iw: 1 ig: 256 add_hdm_decoder: cxl decoder6.0: Added to port endpoint6 init_hdm_decoder: cxl_port endpoint6: decoder6.1: range: 0x0-0xffffffffffffffff iw: 1 ig: 256 add_hdm_decoder: cxl decoder6.1: Added to port endpoint6 init_hdm_decoder: cxl_port endpoint6: decoder6.2: range: 0x0-0xffffffffffffffff iw: 1 ig: 256 add_hdm_decoder: cxl decoder6.2: Added to port endpoint6 init_hdm_decoder: cxl_port endpoint6: decoder6.3: range: 0x0-0xffffffffffffffff iw: 1 ig: 256 add_hdm_decoder: cxl decoder6.3: Added to port endpoint6 cxl_bus_probe: cxl_port endpoint6: probe: 0 devm_cxl_add_port: cxl_mem mem3: endpoint6 added to port2 cxl_bus_probe: cxl_mem mem3: probe: 0 cxl_pci 0000:0f:00.0: mem3: error resume successful pcieport 0000:0e:00.0: AER: device recovery successful
Changes in v2 -> v3
[Terry] Rebase to 6.12-rc7
[Terry] Add UIE/CIE port enablement patch. Needed because only RP are enabled by AER driver. [DaveJ] Isolate reading upstream port's AER info to only the CXL path
[Jonathan, Dan] Add details about separate handling paths for CXL & PCIe [Jonathan] Add details to existing comment in devm_cxl_add_endpoint()
about call to cxl_init_ep_ports_aer()
[Jonathan] Updated cxl_init_ep_ports_aer() w/ checks for NULL;
[Jonathan] Move find_cxl_port() patch immediately before patch to create handlers [Jonathan] Patch title fix: find_cxl_ports() -> find_cxl_port()
[Jonathan] Remove 2 unnecessary dev_warns() in cxl_dport_init_ras_reporting() and cxl_uport_init_ras_reporting().
[Jonathan] Remove unnecessary filter on PCIe port devices in dev_is_cxl_pci() [Jonathan] Remove cleanup declarations in cxl_pci_port_ras()
[Jonathan] Fix spacing in 'struct cxl_error_handlers' declaration.
[Jonathan] Remove unnecessary check for PCI device in __cxl_handle_ras() & __cxl_handle_cor_ras()
Changes in v1 -> v2
[Jonathan] Remove extra NULL check and cleanup in cxl_pci_port_ras()
[Jonathan] Update description to DSP map patch description
[Jonathan] Update cxl_pci_port_ras() to check for NULL port
[Jonathan] Dont call handler before handler port changes are present (patch order) [Bjorn] Fix linebreak in cover sheet URL
[Bjorn] Remove timestamps from test logs in cover sheet
[Bjorn] Retitle AER commits to use "PCI/AER:"
[Bjorn] Retitle patch#3 to use renaming instead of refactoring
[Bjorn] Fix base commit-id on cover sheet
[Bjorn] Add VH spec reference/citation
[Terry] Removed last 2 patches to enable internal errors. Is not needed
because internal errors are enabled in AER driver.
[Dan] Create cxl_do_recovery() and pci_driver::cxl_err_handlers.
[Dan] Use kernel panic in CXL recovery
[Dan] cxl_port_hndlrs -> cxl_port_error_handlers
[Dan] Move cxl_port_error_handlers to pci_driver. Remove module (un)registration. [Terry] Add patch w/ qcxl_assign_port_error_handlers() and cxl_clear_port_error_handlers() [Terry] Removed PCI_ERS_RESULT_PANIC patch. Is no longer needed because the result type parameter is not used in the CXL_err_handlers callbacks.
Changes in RFC -> v1:
[Dan] Rename cxl_rch_handle_error() becomes cxl_handle_error() [Dan] Add cxl_do_recovery()
[Jonathan] Flatten cxl_setup_parent_uport()
[Jonathan] Use cxl_component_regs instead of struct cxl_regs regs [Jonathan] Rename cxl_dev_is_pci_type()
[Ming] bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_uport) can replace these find_cxl_port() and device_find_child(). [Jonathan] Compact call to cxl_port_map_regs() in cxl_setup_parent_uport() [Ming] Dont use endpoint as host to cxl_map_component_regs() [Bjorn] Use "PCIe UIR/CIE" instesad of "AER UI/CIE"
[Bjorn] Dont use Kconfig to enable/disable a CXL external interface
Terry Bowman (15):
PCI/AER: Introduce 'struct cxl_err_handlers' and add to 'struct
pci_driver'
PCI/AER: Rename AER driver's interfaces to also indicate CXL PCIe port
support
cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and
pcie_is_cxl_port()
PCI/AER: Modify AER driver logging to report CXL or PCIe bus error
type
PCI/AER: Add CXL PCIe port correctable error support in AER service
driver
PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe
port devices
PCI/AER: Add CXL PCIe port uncorrectable error recovery in AER service
driver
cxl/pci: Map CXL PCIe root port and downstream switch port RAS
registers
cxl/pci: Map CXL PCIe upstream switch port RAS registers cxl/pci: Update RAS handler interfaces to also support CXL PCIe ports cxl/pci: Change find_cxl_port() to non-static
cxl/pci: Add error handler for CXL PCIe port RAS errors cxl/pci: Add trace logging for CXL PCIe port RAS errors cxl/pci: Add support to assign and clear pci_driver::cxl_err_handlers PCI/AER: Enable internal errors for CXL upstream and downstream switch
ports
drivers/cxl/core/core.h | 3 + drivers/cxl/core/pci.c | 183 ++++++++++++++++++++++++++++------ drivers/cxl/core/port.c | 4 +- drivers/cxl/core/trace.h | 47 +++++++++ drivers/cxl/cxl.h | 10 +- drivers/cxl/mem.c | 36 ++++++- drivers/pci/pci.c | 14 +++ drivers/pci/pci.h | 3 + drivers/pci/pcie/aer.c | 104 +++++++++++-------- drivers/pci/pcie/err.c | 54 ++++++++++ drivers/pci/probe.c | 10 ++ include/linux/aer.h | 1 + include/linux/pci.h | 13 +++ include/ras/ras_event.h | 9 +- include/uapi/linux/pci_regs.h | 3 +- 15 files changed, 410 insertions(+), 84 deletions(-)
base-commit: 2d5404caa8c7bb5c4e0435f94b28834ae5456623
Signature · 1 line
2.34.1
PATCH v3 1/15 PCI/AER: Introduce 'struct cxl_err_handlers' and add to 'struct pci_driver'
CXL.io provides PCIe like protocol error implementation, but CXL.io and PCIe have different handling requirements.
The PCIe AER service driver may attempt recovering PCIe devices with uncorrectable errors while recovery is not used for CXL.io. Recovery is not used in the CXL.io case because of the potential for corruption on what can be system memory.
Create pci_driver::cxl_err_handlers similar to pci_driver::error_handler. Create handlers for correctable and uncorrectable CXL.io error handling.
The CXL error handlers will be used in future patches adding CXL PCIe port protocol error handling.
--- include/linux/pci.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/linux/pci.h +9 -0
@@ -886,6 +886,14 @@ struct pci_error_handlers {void (*cor_error_detected)(struct pci_dev *dev); }; +/* CXL bus error event callbacks */ +struct cxl_error_handlers { +/* CXL bus error detected on this device */ +bool (*error_detected)(struct pci_dev *dev); + +/* Allow device driver to record more details of a correctable error */ +void (*cor_error_detected)(struct pci_dev *dev); +};struct module ;
@@ -956,6 +964,7 @@ struct pci_driver {int (*sriov_set_msix_vec_count)(struct pci_dev *vf,int msix_vec_count);/* On PF */ u32 (*sriov_get_vf_total_msix)(struct pci_dev *pf);const struct pci_error_handlers *err_handler; +const struct cxl_error_handlers *cxl_err_handler;const struct attribute_group **groups;const struct attribute_group **dev_groups;struct device_driver driver;
Signature · 1 line
2.34.1
PATCH v3 2/15 PCI/AER: Rename AER driver's interfaces to also indicate CXL PCIe port support
In reply to Terry BowmanThe AER service driver already includes support for CXL restricted host (RCH) downstream port error handling. The current implementation is based on CXL1.1 using a root complex event collector.
Rename function interfaces and parameters where necessary to include virtual hierarchy (VH) mode CXL PCIe port error handling alongside the RCH handling.[1] The CXL PCIe port error handling will be added in a future patch.
Limit changes to renaming variable and function names. No functional changes are added.
[1] CXL 3.1 Spec, 9.12.2 CXL Virtual Hierarchy
--- drivers/pci/pcie/aer.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/pci/pcie/aer.c +14 -14
@@ -1029,7 +1029,7 @@ static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data)return 0 ; } -static void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +static void cxl_handle_error (struct pci_dev *dev,struct aer_err_info *info) {/* * Internal errors of an RCEC indicate an AER error in an
@@ -1052,30 +1052,30 @@ static int handles_cxl_error_iter(struct pci_dev *dev, void *data) return *handles_cxl; } -static bool handles_cxl_errors (struct pci_dev *rcec) +static bool handles_cxl_errors (struct pci_dev *dev) {bool handles_cxl = false; -if (pci_pcie_type (rcec) ==PCI_EXP_TYPE_RC_EC && -pcie_aer_is_native (rcec)) -pcie_walk_rcec (rcec, handles_cxl_error_iter, &handles_cxl); +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && +pcie_aer_is_native (dev)) +pcie_walk_rcec (dev, handles_cxl_error_iter, &handles_cxl);return handles_cxl; } -static void cxl_rch_enable_rcec (struct pci_dev *rcec) +static void cxl_enable_internal_errors (struct pci_dev *dev) { -if (!handles_cxl_errors (rcec)) +if (!handles_cxl_errors (dev))return ; -pci_aer_unmask_internal_errors (rcec); -pci_info (rcec,"CXL: Internal errors unmasked" ); +pci_aer_unmask_internal_errors (dev); +pci_info (dev,"CXL: Internal errors unmasked" ); }#else -static inline void cxl_rch_enable_rcec (struct pci_dev *dev) { } -static inline void cxl_rch_handle_error (struct pci_dev *dev, -struct aer_err_info *info) { } +static inline void cxl_enable_internal_errors (struct pci_dev *dev) { } +static inline void cxl_handle_error (struct pci_dev *dev, +struct aer_err_info *info) { }#endif /**
@@ -1113,7 +1113,7 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_rch_handle_error (dev, info); +cxl_handle_error (dev, info);pci_aer_handle_error (dev, info);pci_dev_put (dev); }
@@ -1491,7 +1491,7 @@ static int aer_probe(struct pcie_device *dev)return status; } -cxl_rch_enable_rcec (port); +cxl_enable_internal_errors (port);aer_enable_rootport (rpc);pci_info (port,"enabled with IRQ %d\n" , dev->irq);return 0 ;
Signature · 1 line
2.34.1
PATCH v3 3/15 cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
In reply to Terry BowmanCXL and AER drivers need the ability to identify CXL devices and CXL port devices.
First, add set_pcie_cxl() with logic checking for CXL Flexbus DVSEC presence. The CXL Flexbus DVSEC presence is used because it is required for all the CXL PCIe devices.[1]
Add boolean 'struct pci_dev::is_cxl' with the purpose to cache the CXL Flexbus presence.
Add pcie_is_cxl() as a macro to return 'struct pci_dev::is_cxl',
Add pcie_is_cxl_port() to check if a device is a CXL root port, CXL upstream switch port, or CXL downstream switch port. Also, verify the CXL extensions DVSEC for port is present.[1]
[1] CXL 3.1 Spec, 8.1.1 PCIe Designated Vendor-Specific Extended Capability (DVSEC) ID Assignment, Table 8-2
--- drivers/pci/pci.c | 14 ++++++++++++++ drivers/pci/probe.c | 10 ++++++++++ include/linux/pci.h | 4 ++++ include/uapi/linux/pci_regs.h | 3 ++- 4 files changed, 30 insertions(+), 1 deletion(-)
drivers/pci/pci.c +14 -0
@@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev) PCI_DVSEC_CXL_PORT); } +bool pcie_is_cxl_port (struct pci_dev *dev) +{ +if (!pcie_is_cxl (dev)) +return false; + +if ((pci_pcie_type (dev) !=PCI_EXP_TYPE_ROOT_PORT ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_DOWNSTREAM )) +return false; + +return cxl_port_dvsec (dev); +} +EXPORT_SYMBOL_GPL (pcie_is_cxl_port); +static bool cxl_sbr_masked (struct pci_dev *dev) {u16 dvsec, reg;
drivers/pci/probe.c +10 -0
@@ -1631,6 +1631,14 @@ static void set_pcie_thunderbolt(struct pci_dev *dev) dev->is_thunderbolt =1 ; } +static void set_pcie_cxl (struct pci_dev *dev) +{ +u16 dvsec =pci_find_dvsec_capability (dev,PCI_VENDOR_ID_CXL , +PCI_DVSEC_CXL_FLEXBUS ); +if (dvsec) + dev->is_cxl =1 ; +} +static void set_pcie_untrusted (struct pci_dev *dev) {struct pci_dev *parent;
@@ -1945,6 +1953,8 @@ int pci_setup_device(struct pci_dev *dev)/* Need to have dev->cfg_size ready */ set_pcie_thunderbolt (dev); +set_pcie_cxl (dev); +set_pcie_untrusted (dev);/* "Unknown power state" */
include/linux/pci.h +4 -0
@@ -443,6 +443,7 @@ struct pci_dev { unsigned int is_hotplug_bridge:1; unsigned int shpc_managed:1; /* SHPC owned by shpchp */ unsigned int is_thunderbolt:1; /* Thunderbolt controller */ + unsigned int is_cxl:1; /* CXL alternate protocol *//* * Devices marked being untrusted are the ones that can potentially * execute DMA attacks and similar. They are typically connected
@@ -743,6 +744,9 @@ static inline bool pci_is_vga(struct pci_dev *pdev)return false; } +#define pcie_is_cxl (dev) (dev->is_cxl) +bool pcie_is_cxl_port (struct pci_dev *dev); +#define for_each_pci_bridge (dev, bus) \ list_for_each_entry(dev, &bus->devices, bus_list) \ if (!pci_is_bridge(dev)) {} else
include/uapi/linux/pci_regs.h +2 -1
@@ -1186,9 +1186,10 @@#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000 -/* Compute Express Link (CXL r3.1, sec 8.1.5) */ +/* Compute Express Link (CXL r3.1, sec 8.1) */ #define PCI_DVSEC_CXL_PORT 3#define PCI_DVSEC_CXL_PORT_CTL 0x0c#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 +#define PCI_DVSEC_CXL_FLEXBUS 7#endif /* LINUX_PCI_REGS_H */
Signature · 1 line
2.34.1
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 9 lines · Terry Bowman
drivers/pci/pci.c +3
-0@@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev) PCI_DVSEC_CXL_PORT); } +bool pcie_is_cxl_port (struct pci_dev *dev) +{ +if (!pcie_is_cxl (dev))
drivers/pci/pci.c static u16 cxl_port_dvsec(struct pci_dev *dev) · line 5053
Quoted 10 lines
drivers/pci/pci.c +10
-0+return false; + +if ((pci_pcie_type (dev) !=PCI_EXP_TYPE_ROOT_PORT ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_DOWNSTREAM )) +return false; + +return cxl_port_dvsec (dev); +} +EXPORT_SYMBOL_GPL (pcie_is_cxl_port);
This doesn't need to be exported because the only caller introduced in this series is in drivers/pci/pcie/aer.c (in patch 05/15), which is dependent on CONFIG_PCIEAER, which is bool not tristate.
The "!pcie_is_cxl(dev)" check at the top of the function is identical to the return value "cxl_port_dvsec(dev)". This looks redundant. However one cannot call pci_pcie_type() without first checking pci_is_pcie(). So I'm wondering if the "!pcie_is_cxl(dev)" check is actually erroneous and supposed to be "!pci_is_pcie(dev)"? That would make more sense to me.
Alternatively, just return true instead of "cxl_port_dvsec(dev)". That would probably be the simplest solution here.
include/linux/pci.h struct pci_dev { · line 446
Quoted 7 lines
include/linux/pci.h +1
-0@@ -443,6 +443,7 @@ struct pci_dev { unsigned int is_hotplug_bridge:1; unsigned int shpc_managed:1; /* SHPC owned by shpchp */ unsigned int is_thunderbolt:1; /* Thunderbolt controller */ + unsigned int is_cxl:1; /* CXL alternate protocol */
I suspect the audience consists mostly of CXL-unaware PCI developers, so spelling out Compute Express Link here (and omitting "alternate protocol" if it doesn't fit) might be more appropriate.
Thanks,
Lukas
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Hi Lukas,
I added comments below.
Quoted 7 lines · Lukas Wunner
Quoted 6 lines · Terry Bowman
drivers/pci/pci.c +0
-0@@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev) PCI_DVSEC_CXL_PORT); }
Quoted 16 lines
drivers/pci/pci.c static u16 cxl_port_dvsec(struct pci_dev *dev) · line 5053
Quoted 13 lines
drivers/pci/pci.c +13
-0+bool pcie_is_cxl_port (struct pci_dev *dev) +{ +if (!pcie_is_cxl (dev)) +return false; + +if ((pci_pcie_type (dev) !=PCI_EXP_TYPE_ROOT_PORT ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_DOWNSTREAM )) +return false; + +return cxl_port_dvsec (dev); +} +EXPORT_SYMBOL_GPL (pcie_is_cxl_port);This doesn't need to be exported because the only caller introduced in this series is in
drivers/pci/pcie/aer.c(in patch 05/15), which is dependent onCONFIG_PCIEAER, which is bool not tristate.
Ok.
Quoted 6 lines
The "!pcie_is_cxl(dev)" check at the top of the function is identical to the return value "
cxl_port_dvsec(dev)". This looks redundant. However one cannot callpci_pcie_type()without first checkingpci_is_pcie(). So I'm wondering if the "!pcie_is_cxl(dev)" check is actually erroneous and supposed to be "!pci_is_pcie(dev)"? That would make more sense to me.
I see pcie_is_cxl(dev) is different than cxl_port_dvsec(dev).They check different DVSECs.[1] CXL flexbus DVSEC presence is cached in pci_dev::is_cxl and returned by pcie_is_cxl(). This is used for indicating CXL device.
cxl_port_dvsec(dev) returns boolean based on presence of CXL port DVSEC to indicate a CXL port device.
I don't believe they are redundant if you consider you can have a CXL device that is not a CXL port device.
[1] - CXL 3.1, 8.1.1 Specification, PCIe Designated Vendor-Specific Extended Capability (DVSEC) ID Assignment
Quoted 14 lines
Alternatively, just return true instead of "
cxl_port_dvsec(dev)". That would probably be the simplest solution here.include/linux/pci.h struct pci_dev { · line 446
Quoted 7 lines
include/linux/pci.h +1
-0@@ -443,6 +443,7 @@ struct pci_dev { unsigned int is_hotplug_bridge:1; unsigned int shpc_managed:1; /* SHPC owned by shpchp */ unsigned int is_thunderbolt:1; /* Thunderbolt controller */ + unsigned int is_cxl:1; /* CXL alternate protocol */I suspect the audience consists mostly of CXL-unaware PCI developers, so spelling out Compute Express Link here (and omitting "alternate protocol" if it doesn't fit) might be more appropriate.
Quoted 3 lines
Thanks,
Lukas
Ok.
Regards,
Terry
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 29 lines · Terry
Quoted 19 lines · Lukas Wunner
Quoted 18 lines · Terry Bowman
drivers/pci/pci.c +12
-0@@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev) PCI_DVSEC_CXL_PORT); } +bool pcie_is_cxl_port (struct pci_dev *dev) +{ +if (!pcie_is_cxl (dev)) +return false; + +if ((pci_pcie_type (dev) !=PCI_EXP_TYPE_ROOT_PORT ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_DOWNSTREAM )) +return false; + +return cxl_port_dvsec (dev); +}Quoted 8 lines
drivers/pci/pci.c static u16 cxl_port_dvsec(struct pci_dev *dev) · line 5053
Quoted 1 line
drivers/pci/pci.c +1
-0+EXPORT_SYMBOL_GPL (pcie_is_cxl_port);The "!pcie_is_cxl(dev)" check at the top of the function is identical to the return value "
cxl_port_dvsec(dev)". This looks redundant. However one cannot callpci_pcie_type()without first checkingpci_is_pcie(). So I'm wondering if the "!pcie_is_cxl(dev)" check is actually erroneous and supposed to be "!pci_is_pcie(dev)"? That would make more sense to me.
Quoted 2 lines
I see
pcie_is_cxl(dev)is different thancxl_port_dvsec(dev). They check different DVSECs.
Ah, sorry, I missed that.
Quoted 9 lines
CXL flexbus DVSEC presence is cached in
pci_dev::is_cxland returned bypcie_is_cxl(). This is used for indicating CXL device.
cxl_port_dvsec(dev)returns boolean based on presence of CXL port DVSEC to indicate a CXL port device.I don't believe they are redundant if you consider you can have a CXL device that
is not a CXL port device.
Can you have a CXL port that is not a CXL device?
If not, it would seem to me that checking for Flexbus DVSEC presence *is* redundant. Or do you anticipate broken devices which lack the Flexbus DVSEC and that you explicitly want to exclude?
Thanks,
Lukas
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 43 lines · Lukas Wunner
Quoted 27 lines · Terry
Quoted 18 lines · Lukas Wunner
Quoted 17 lines · Terry Bowman
drivers/pci/pci.c +11
-0@@ -5038,6 +5038,20 @@ static u16 cxl_port_dvsec(struct pci_dev *dev) PCI_DVSEC_CXL_PORT); } +bool pcie_is_cxl_port (struct pci_dev *dev) +{ +if (!pcie_is_cxl (dev)) +return false; + +if ((pci_pcie_type (dev) !=PCI_EXP_TYPE_ROOT_PORT ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_UPSTREAM ) && + (pci_pcie_type (dev) !=PCI_EXP_TYPE_DOWNSTREAM )) +return false; + +return cxl_port_dvsec (dev);Quoted 8 lines
drivers/pci/pci.c static u16 cxl_port_dvsec(struct pci_dev *dev) · line 5053
Quoted 2 lines
drivers/pci/pci.c +2
-0+} +EXPORT_SYMBOL_GPL (pcie_is_cxl_port);The "!pcie_is_cxl(dev)" check at the top of the function is identical to the return value "
cxl_port_dvsec(dev)". This looks redundant. However one cannot callpci_pcie_type()without first checkingpci_is_pcie(). So I'm wondering if the "!pcie_is_cxl(dev)" check is actually erroneous and supposed to be "!pci_is_pcie(dev)"? That would make more sense to me.Quoted 2 lines
I see
pcie_is_cxl(dev)is different thancxl_port_dvsec(dev). They check different DVSECs.Ah, sorry, I missed that.
Quoted 9 lines
CXL flexbus DVSEC presence is cached in
pci_dev::is_cxland returned bypcie_is_cxl(). This is used for indicating CXL device.
cxl_port_dvsec(dev)returns boolean based on presence of CXL port DVSEC to indicate a CXL port device.I don't believe they are redundant if you consider you can have a CXL device that
is not a CXL port device.Can you have a CXL port that is not a CXL device?
Quoted 7 lines
If not, it would seem to me that checking for Flexbus DVSEC presence *is* redundant. Or do you anticipate broken devices which lack the Flexbus DVSEC and that you explicitly want to exclude?
Thanks,
Lukas
No, the CXL port device is always a CXL device per spec.
This was added to short-circuit the function by returning immediately if the device is _not_ a CXL device. Otherwise for PCIe Port devices, the CXL Port DVSEC will be searched. I was trying to avoid the unnecessary CXL port DVSEC search unless the other criteria are met. And I expect most cases will not be a CXL device.
I will remove the "if (!pcie_is_cxl(dev))" block as you suggested.
Regards,
Terry
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 8 lines · Terry
Quoted 5 lines
Can you have a CXL port that is not a CXL device?
If not, it would seem to me that checking for Flexbus DVSEC presence *is* redundant. Or do you anticipate broken devices which lack the Flexbus DVSEC and that you explicitly want to exclude?
No, the CXL port device is always a CXL device per spec.
Quoted 7 lines
This was added to short-circuit the function by returning immediately if the device is _not_ a CXL device. Otherwise for PCIe Port devices, the CXL Port DVSEC will be searched. I was trying to avoid the unnecessary CXL port DVSEC search unless the other criteria are met.
And I expect most cases will not be a CXL device.I will remove the "if (!pcie_is_cxl(dev))" block as you suggested.
Ah, this is meant as a speed-up. Actually that makes sense, so feel free to keep it.
If you do remove it, I think you'll have to move the cxl_port_dvsec() invocation up in the function, in front of the pci_pcie_type() checks. The latter require that one first checks that the device is PCIe. That's done implicitly by cxl_port_dvsec() because it returns 0 in the non-PCIe case. (Due to the "if (dev->cfg_size <= PCI_CFG_SPACE_SIZE)" check in pci_find_next_ext_capability().)
Another idea would be to put a "if (!pcie_is_cxl(dev)) return 0;" speed-up in cxl_port_dvsec() so that the other caller benefits from it as well.
Thanks,
Lukas
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 25 lines · Lukas Wunner
Quoted 7 lines · Terry
Quoted 5 lines
Can you have a CXL port that is not a CXL device?
If not, it would seem to me that checking for Flexbus DVSEC presence *is* redundant. Or do you anticipate broken devices which lack the Flexbus DVSEC and that you explicitly want to exclude?
No, the CXL port device is always a CXL device per spec.
Quoted 7 lines
This was added to short-circuit the function by returning immediately if the device is _not_ a CXL device. Otherwise for PCIe Port devices, the CXL Port DVSEC will be searched. I was trying to avoid the unnecessary CXL port DVSEC search unless the other criteria are met.
And I expect most cases will not be a CXL device.I will remove the "if (!pcie_is_cxl(dev))" block as you suggested.
Ah, this is meant as a speed-up. Actually that makes sense, so feel free to keep it.
If you do remove it, I think you'll have to move the
cxl_port_dvsec()invocation up in the function, in front of thepci_pcie_type()checks. The latter require that one first checks that the device is PCIe. That's done implicitly bycxl_port_dvsec()because it returns 0 in the non-PCIe case. (Due to the "if (dev->cfg_size<=PCI_CFG_SPACE_SIZE)" check inpci_find_next_ext_capability().)
Quoted 6 lines
Another idea would be to put a "if (!pcie_is_cxl(dev)) return 0;" speed-up in
cxl_port_dvsec()so that the other caller benefits from it as well.Thanks,
Lukas
Ok, I'll look at adding the same pcie_is_cxl() call and check in cxl_port_devsec().
Regards,
Terry
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 14 lines · Terry
Quoted 13 lines · Lukas Wunner
Quoted 1 line · Terry
I will remove the "if (!pcie_is_cxl(dev))" block as you suggested.
Ah, this is meant as a speed-up. Actually that makes sense, so feel free to keep it.
If you do remove it, I think you'll have to move the
cxl_port_dvsec()invocation up in the function, in front of thepci_pcie_type()checks. The latter require that one first checks that the device is PCIe. That's done implicitly bycxl_port_dvsec()because it returns 0 in the non-PCIe case. (Due to the "if (dev->cfg_size<=PCI_CFG_SPACE_SIZE)" check inpci_find_next_ext_capability().)
Quoted 5 lines
Quoted 2 lines
Another idea would be to put a "if (!pcie_is_cxl(dev)) return 0;" speed-up in
cxl_port_dvsec()so that the other caller benefits from it as well.Ok, I'll look at adding the same
pcie_is_cxl()call and check incxl_port_devsec().
If you put "if (!pcie_is_cxl(dev)) return 0;" in cxl_port_devsec() and move the call to cxl_port_devsec() in pcie_is_cxl_port() up in front of the pci_pcie_type() checks, I think you won't need an additional "!pcie_is_cxl(dev)" check in pcie_is_cxl_port().
Thanks,
Lukas
Re: [PATCH v3 03/15] cxl/pci: Introduce PCIe helper functions pcie_is_cxl() and pcie_is_cxl_port()
Quoted 18 lines · Lukas Wunner
Quoted 13 lines · Terry
Quoted 12 lines · Lukas Wunner
Quoted 1 line · Terry
I will remove the "if (!pcie_is_cxl(dev))" block as you suggested.
Ah, this is meant as a speed-up. Actually that makes sense, so feel free to keep it.
If you do remove it, I think you'll have to move the
cxl_port_dvsec()invocation up in the function, in front of thepci_pcie_type()checks. The latter require that one first checks that the device is PCIe. That's done implicitly bycxl_port_dvsec()because it returns 0 in the non-PCIe case. (Due to the "if (dev->cfg_size<=PCI_CFG_SPACE_SIZE)" check inpci_find_next_ext_capability().)Quoted 4 lines
Quoted 2 lines
Another idea would be to put a "if (!pcie_is_cxl(dev)) return 0;" speed-up in
cxl_port_dvsec()so that the other caller benefits from it as well.Ok, I'll look at adding the same
pcie_is_cxl()call and check incxl_port_devsec().
Quoted 8 lines
If you put "if (!pcie_is_cxl(dev)) return 0;" in
cxl_port_devsec()and move the call tocxl_port_devsec()inpcie_is_cxl_port()up in front of thepci_pcie_type()checks, I think you won't need an additional "!pcie_is_cxl(dev)" check inpcie_is_cxl_port().Thanks,
Lukas
Ok. I'll make that change.
Regards,
Terry
PATCH v3 4/15 PCI/AER: Modify AER driver logging to report CXL or PCIe bus error type
In reply to Terry BowmanThe AER driver and aer_event tracing currently log 'PCIe Bus Type' for all errors.
Update the driver and aer_event tracing to log 'CXL Bus Type' for CXL device errors.
--- drivers/pci/pcie/aer.c | 14 ++++++++------ include/ras/ras_event.h | 9 ++++++--- 2 files changed, 14 insertions(+), 9 deletions(-)
drivers/pci/pcie/aer.c +8 -6
@@ -699,13 +699,14 @@ static void __aer_print_error(struct pci_dev *dev,void aer_print_error (struct pci_dev *dev,struct aer_err_info *info) { +const char *bus_type =pcie_is_cxl (dev) ?"CXL" :"PCIe" ;int layer, agent;int id =pci_dev_id (dev);const char *level;if (!info->status) { -pci_err (dev,"PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n" , - aer_error_severity_string[info->severity]); +pci_err (dev,"%s Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n" , + bus_type, aer_error_severity_string[info->severity]); goto out; }
@@ -714,8 +715,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) level = (info->severity ==AER_CORRECTABLE ) ?KERN_WARNING :KERN_ERR ; -pci_printk (level, dev,"PCIe Bus Error: severity=%s, type=%s, (%s)\n" , - aer_error_severity_string[info->severity], +pci_printk (level, dev,"%s Bus Error: severity=%s, type=%s, (%s)\n" , + bus_type, aer_error_severity_string[info->severity], aer_error_layer[layer], aer_agent_string[agent]); pci_printk(level, dev, " device [%04x:%04x] error status/mask=%08x/%08x\n",
@@ -730,7 +731,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)if (info->id && info->error_dev_num >1 && info->id == id)pci_err (dev," Error of this Agent is reported first\n" ); -trace_aer_event (dev_name (&dev->dev), (info->status & ~info->mask), +trace_aer_event (dev_name (&dev->dev), bus_type, (info->status & ~info->mask), info->severity, info->tlp_header_valid, &info->tlp); }
@@ -764,6 +765,7 @@ EXPORT_SYMBOL_GPL(cper_severity_to_aer);void pci_print_aer (struct pci_dev *dev,int aer_severity,struct aer_capability_regs *aer) { +const char *bus_type =pcie_is_cxl (dev) ?"CXL" :"PCIe" ;int layer, agent, tlp_header_valid =0 ;u32 status, mask;struct aer_err_info info;
@@ -798,7 +800,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,if (tlp_header_valid)__print_tlp_header (dev, &aer->header_log); -trace_aer_event (dev_name (&dev->dev), (status & ~mask), +trace_aer_event (dev_name (&dev->dev), bus_type, (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); }EXPORT_SYMBOL_NS_GPL (pci_print_aer,CXL );
include/ras/ras_event.h +6 -3
@@ -297,15 +297,17 @@ TRACE_EVENT(non_standard_event, TRACE_EVENT(aer_event, TP_PROTO(const char *dev_name, + const char *bus_type, const u32 status, const u8 severity, const u8 tlp_header_valid, struct pcie_tlp_log *tlp), - TP_ARGS(dev_name, status, severity, tlp_header_valid, tlp), + TP_ARGS(dev_name, bus_type, status, severity, tlp_header_valid, tlp), TP_STRUCT__entry( __string( dev_name, dev_name ) + __string( bus_type, bus_type ) __field( u32, status ) __field( u8, severity ) __field( u8, tlp_header_valid)
@@ -314,6 +316,7 @@ TRACE_EVENT(aer_event,TP_fast_assign ( __assign_str(dev_name); +__assign_str (bus_type); __entry->status = status; __entry->severity = severity; __entry->tlp_header_valid = tlp_header_valid;
@@ -325,8 +328,8 @@ TRACE_EVENT(aer_event, } ), - TP_printk("%s PCIe Bus Error: severity=%s, %s, TLP Header=%s\n", - __get_str(dev_name), + TP_printk("%s %s Bus Error: severity=%s, %s, TLP Header=%s\n", + __get_str(dev_name), __get_str(bus_type), __entry->severity == AER_CORRECTABLE ? "Corrected" : __entry->severity == AER_FATAL ? "Fatal" : "Uncorrected, non-fatal",
Signature · 1 line
2.34.1
PATCH v3 5/15 PCI/AER: Add CXL PCIe port correctable error support in AER service driver
In reply to Terry BowmanThe AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
CXL and PCIe protocol error handling have different requirements that necessitate a separate handling path. The AER service driver may try to recover PCIe uncorrectable non-fatal errors (UCE). The same recovery is not suitable for CXL PCIe port devices because of potential for system memory corruption. Instead, CXL protocol error handling must use a kernel panic in the case of a fatal or non-fatal UCE. The AER driver's PCIe error handling does not panic the kernel in response to a UCE.
Introduce a separate path for CXL protocol error handling in the AER service driver. This will allow CXL protocol errors to use CXL specific handling instead of PCIe handling. Add the CXL specific changes without affecting or adding functionality in the PCIe handling.
Make this update alongside the existing downstream port RCH error handling logic, extending support to CXL PCIe ports in VH mode.
is_internal_error() is currently limited by CONFIG_PCIEAER_CXL kernel config. Update is_internal_error()'s function declaration such that it is always available regardless if CONFIG_PCIEAER_CXL kernel config is enabled or disabled.
The uncorrectable error (UCE) handling will be added in a future patch.
[1] CXL 3.1 Spec, 12.2.2 CXL Root Ports, Downstream Switch Ports, and Upstream Switch Ports
--- drivers/pci/pcie/aer.c | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 20 deletions(-)
drivers/pci/pcie/aer.c +39 -20
@@ -941,8 +941,15 @@ static bool find_source_device(struct pci_dev *parent,return true; } -#ifdef CONFIG_PCIEAER_CXL +static bool is_internal_error (struct aer_err_info *info) +{ +if (info->severity ==AER_CORRECTABLE ) +return info->status &PCI_ERR_COR_INTERNAL ; +return info->status &PCI_ERR_UNC_INTN ; +} + +#ifdef CONFIG_PCIEAER_CXL /** * pci_aer_unmask_internal_errors - unmask internal errors * @dev: pointer to the pcie_dev data structure
@@ -994,14 +1001,6 @@ static bool cxl_error_is_native(struct pci_dev *dev)return (pcie_ports_native || host->native_aer); } -static bool is_internal_error (struct aer_err_info *info) -{ -if (info->severity ==AER_CORRECTABLE ) -return info->status &PCI_ERR_COR_INTERNAL ; - -return info->status &PCI_ERR_UNC_INTN ; -} -static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) {struct aer_err_info *info = (struct aer_err_info *)data;
@@ -1033,14 +1032,23 @@ static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data)static void cxl_handle_error (struct pci_dev *dev,struct aer_err_info *info) { -/* -* Internal errors of an RCEC indicate an AER error in an -* RCH's downstream port. Check and handle them in the CXL.mem -* device driver. -*/ -if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && -is_internal_error (info)) +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC )pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); + +if (info->severity ==AER_CORRECTABLE ) { +struct pci_driver *pdrv = dev->driver; +int aer = dev->aer_cap; + +if (aer) +pci_write_config_dword (dev, aer +PCI_ERR_COR_STATUS , + info->status); + +if (pdrv && pdrv->cxl_err_handler && + pdrv->cxl_err_handler->cor_error_detected) + pdrv->cxl_err_handler->cor_error_detected (dev); + +pcie_clear_device_status (dev); + } }static int handles_cxl_error_iter (struct pci_dev *dev,void *data)
@@ -1058,9 +1066,13 @@ static bool handles_cxl_errors(struct pci_dev *dev) {bool handles_cxl = false; -if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && -pcie_aer_is_native (dev)) +if (!pcie_aer_is_native (dev)) +return false; + +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC )pcie_walk_rcec (dev, handles_cxl_error_iter, &handles_cxl); +else + handles_cxl =pcie_is_cxl_port (dev);return handles_cxl; }
@@ -1078,6 +1090,10 @@ static void cxl_enable_internal_errors(struct pci_dev *dev)static inline void cxl_enable_internal_errors (struct pci_dev *dev) { }static inline void cxl_handle_error (struct pci_dev *dev,struct aer_err_info *info) { } +static bool handles_cxl_errors (struct pci_dev *dev) +{ +return false; +}#endif /**
@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }
Signature · 1 line
2.34.1
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }
If you just do this at the top of cxl_handle_error()...
if (!is_internal_error(info)) return;
...you avoid the need to move is_internal_error() around and the patch becomes simpler and easier to review.
Quoted 4 lines
The AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
This is somewhat minor but by convention, patches in the PCI subsystem adhere to spec language and capitalization, e.g. "Downstream Port" instead of "downstream port". Makes it easier to connect the commit message or code comments to the spec. So maybe you want to consider that if/when respinning.
Thanks,
Lukas
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Hi Lukas,
I added comments below.
Quoted 16 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...
Quoted 5 lines
if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.
If is_internal_error()==0, then pci_aer_handle_error() should be called to process the PCIe error. Your suggestion would require returning a value from cxl_handle_error(). And then more "if" logic would be required for the cxl_handle_error() return value. Should both is_internal_error() and handles_cxl_errors()be moved into cxl_handle_error()? Would give this:
static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {
- cxl_handle_error(dev, info);
- pci_aer_handle_error(dev, info);
+ if (!cxl_handle_error(dev, info))
+ pci_aer_handle_error(dev, info);
+
pci_dev_put(dev);
}
Quoted 11 lines
Quoted 5 lines
The AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
This is somewhat minor but by convention, patches in the PCI subsystem adhere to spec language and capitalization, e.g. "Downstream Port" instead of "downstream port". Makes it easier to connect the commit message or code comments to the spec. So maybe you want to consider that if/when respinning.
Quoted 3 lines
Thanks,
Lukas
Thanks for pointing that out. I'll update as you suggest.
Regards,
Terry
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Quoted 18 lines · Terry
Quoted 17 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...
Quoted 8 lines
Quoted 5 lines
if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.If is_internal_error()==0, then
pci_aer_handle_error()should be called to process the PCIe error.
You're absolutely right, I missed that, sorry for the noise.
Thanks,
Lukas
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Quoted 23 lines · Lukas Wunner
Quoted 22 lines · Terry
Quoted 21 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.
Quoted 7 lines
Quoted 2 lines
If is_internal_error()==0, then
pci_aer_handle_error()should be called to process the PCIe error.You're absolutely right, I missed that, sorry for the noise.
Thanks,
Lukas
Thanks for taking the time to review.
Regards,
Terry
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
In reply to Bowman, TerryQuoted 32 lines · Terry
Hi Lukas,
I added comments below.
Quoted 16 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...Quoted 5 lines
if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.If is_internal_error()==0, then
pci_aer_handle_error()should be called to process the PCIe error. Your suggestion would require returning a value fromcxl_handle_error(). And then more "if" logic would be required for thecxl_handle_error()return value. Should bothis_internal_error()and handles_cxl_errors()be moved intocxl_handle_error()? Would give this:static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 7 lines
drivers/pci/pcie/aer.c +3
-2-cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (!cxl_handle_error (dev, info)) +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }
I think is_internal_error() can be moved into handles_cxl_errors(). handles_cxl_errors() helps to check if the error is a CXL error, avoid this detail which CXL error is an internal error in handle_error_source(). Like this:
static void handle_error_source(struct pci_dev *dev, structaer_err_info *info)
{
- cxl_handle_error(dev, info);
- pci_aer_handle_error(dev, info);
+ if (handles_cxl_errors(dev, info))
+ cxl_handle_error(dev, info);
+ else
+ pci_aer_handle_error(dev, info);
+
pci_dev_put(dev);
}
Ming
Quoted 19 lines
Quoted 11 lines
Quoted 5 lines
The AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
This is somewhat minor but by convention, patches in the PCI subsystem adhere to spec language and capitalization, e.g. "Downstream Port" instead of "downstream port". Makes it easier to connect the commit message or code comments to the spec. So maybe you want to consider that if/when respinning.
Quoted 3 lines
Thanks,
Lukas
Thanks for pointing that out. I'll update as you suggest.
Regards,
Terry
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Quoted 30 lines · Li Ming
Quoted 28 lines · Terry
Hi Lukas,
I added comments below.
Quoted 16 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...Quoted 5 lines
if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.If is_internal_error()==0, then
pci_aer_handle_error()should be called to process the PCIe error. Your suggestion would require returning a value fromcxl_handle_error(). And then more "if" logic would be required for thecxl_handle_error()return value. Should bothis_internal_error()and handles_cxl_errors()be moved intocxl_handle_error()? Would give this:
Quoted 10 lines
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 10 lines
static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {drivers/pci/pcie/aer.c +3
-2-cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (!cxl_handle_error (dev, info)) +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }
We could do that. And with that change it might need handles_cxl_errors() renamed to something more correct, like handle_cxl_error()?
Regards,
Terry
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Quoted 33 lines · Terry
Quoted 30 lines · Li Ming
Quoted 28 lines · Terry
Hi Lukas,
I added comments below.
Quoted 16 lines · Lukas Wunner
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 13 lines · Terry Bowman
drivers/pci/pcie/aer.c +5
-2@@ -1115,8 +1131,11 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)static void handle_error_source (struct pci_dev *dev,struct aer_err_info *info) { -cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (is_internal_error (info) &&handles_cxl_errors (dev)) +cxl_handle_error (dev, info); +else +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }If you just do this at the top of
cxl_handle_error()...Quoted 5 lines
if (!is_internal_error(info)) return;...you avoid the need to move
is_internal_error()around and the patch becomes simpler and easier to review.If is_internal_error()==0, then
pci_aer_handle_error()should be called to process the PCIe error. Your suggestion would require returning a value fromcxl_handle_error(). And then more "if" logic would be required for thecxl_handle_error()return value. Should bothis_internal_error()and handles_cxl_errors()be moved intocxl_handle_error()? Would give this:
Quoted 13 lines
Quoted 10 lines
drivers/pci/pcie/aer.c static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1140
Quoted 10 lines
static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {drivers/pci/pcie/aer.c +3
-2-cxl_handle_error (dev, info); -pci_aer_handle_error (dev, info); +if (!cxl_handle_error (dev, info)) +pci_aer_handle_error (dev, info); +pci_dev_put (dev); }We could do that. And with that change it might need
handles_cxl_errors()renamed to something more correct, likehandle_cxl_error()?
Yes, the name you mentioned is better.
Ming
Quoted 5 lines
Regards,
Terry
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
In reply to Terry BowmanQuoted 26 lines · On Wed, 13 Nov 2024 15:54:19 -0600 Terry Bowman <[email protected]> wrote:
The AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
CXL and PCIe protocol error handling have different requirements that necessitate a separate handling path. The AER service driver may try to recover PCIe uncorrectable non-fatal errors (UCE). The same recovery is not suitable for CXL PCIe port devices because of potential for system memory corruption. Instead, CXL protocol error handling must use a kernel panic in the case of a fatal or non-fatal UCE. The AER driver's PCIe error handling does not panic the kernel in response to a UCE.
Introduce a separate path for CXL protocol error handling in the AER service driver. This will allow CXL protocol errors to use CXL specific handling instead of PCIe handling. Add the CXL specific changes without affecting or adding functionality in the PCIe handling.
Make this update alongside the existing downstream port RCH error handling logic, extending support to CXL PCIe ports in VH mode.
is_internal_error()is currently limited byCONFIG_PCIEAER_CXLkernel config. Update is_internal_error()'s function declaration such that it is always available regardless ifCONFIG_PCIEAER_CXLkernel config is enabled or disabled.
Quoted 8 lines
The uncorrectable error (UCE) handling will be added in a future patch.
[1] CXL 3.1 Spec, 12.2.2 CXL Root Ports, Downstream Switch Ports, and Upstream Switch Ports
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>
I took another look and so a question inline.
Jonathan
Quoted 12 lines
static int
cxl_rch_handle_error_iter(struct pci_dev *dev, void *data){drivers/pci/pcie/aer.c +0
-5struct aer_err_info *info = (struct aer_err_info *)data;@@ -1033,14 +1032,23 @@ static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data)static void cxl_handle_error (struct pci_dev *dev,struct aer_err_info *info) { -/* -* Internal errors of an RCEC indicate an AER error in an -* RCH's downstream port. Check and handle them in the CXL.mem -* device driver. -*/
drivers/pci/pcie/aer.c static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data) · line 1042
Quoted 10 lines
drivers/pci/pcie/aer.c +7
-2-if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && -is_internal_error (info)) +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC )pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); + +if (info->severity ==AER_CORRECTABLE ) { +struct pci_driver *pdrv = dev->driver; +int aer = dev->aer_cap; + +if (aer)
How do we get here with no aer?
On a PCIe device AER is optional, but not I think on a CXL device (I can't find the text but there is a change log entry that says to clarify that it is required for CXL devices)
Maybe the optionality is why the PCIe code has this check.
Anyhow, I don't really mind keeping it, was just curious.
Quoted 10 lines
drivers/pci/pcie/aer.c +9
-0+pci_write_config_dword (dev, aer +PCI_ERR_COR_STATUS , + info->status); + +if (pdrv && pdrv->cxl_err_handler && + pdrv->cxl_err_handler->cor_error_detected) + pdrv->cxl_err_handler->cor_error_detected (dev); + +pcie_clear_device_status (dev); + } }
Re: [PATCH v3 05/15] PCI/AER: Add CXL PCIe port correctable error support in AER service driver
Quoted 65 lines · Jonathan Cameron
Quoted 26 lines · On Wed, 13 Nov 2024 15:54:19 -0600 Terry Bowman <[email protected]> wrote:
The AER service driver supports handling downstream port protocol errors in restricted CXL host (RCH) mode also known as CXL1.1. It needs the same functionality for CXL PCIe ports operating in virtual hierarchy (VH) mode.[1]
CXL and PCIe protocol error handling have different requirements that necessitate a separate handling path. The AER service driver may try to recover PCIe uncorrectable non-fatal errors (UCE). The same recovery is not suitable for CXL PCIe port devices because of potential for system memory corruption. Instead, CXL protocol error handling must use a kernel panic in the case of a fatal or non-fatal UCE. The AER driver's PCIe error handling does not panic the kernel in response to a UCE.
Introduce a separate path for CXL protocol error handling in the AER service driver. This will allow CXL protocol errors to use CXL specific handling instead of PCIe handling. Add the CXL specific changes without affecting or adding functionality in the PCIe handling.
Make this update alongside the existing downstream port RCH error handling logic, extending support to CXL PCIe ports in VH mode.
is_internal_error()is currently limited byCONFIG_PCIEAER_CXLkernel config. Update is_internal_error()'s function declaration such that it is always available regardless ifCONFIG_PCIEAER_CXLkernel config is enabled or disabled.Quoted 8 lines
The uncorrectable error (UCE) handling will be added in a future patch.
[1] CXL 3.1 Spec, 12.2.2 CXL Root Ports, Downstream Switch Ports, and Upstream Switch Ports
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Dave Jiang <[email protected]>I took another look and so a question inline.
Jonathan
Quoted 12 lines
static int
cxl_rch_handle_error_iter(struct pci_dev *dev, void *data){drivers/pci/pcie/aer.c +0
-5struct aer_err_info *info = (struct aer_err_info *)data;@@ -1033,14 +1032,23 @@ static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data)static void cxl_handle_error (struct pci_dev *dev,struct aer_err_info *info) { -/* -* Internal errors of an RCEC indicate an AER error in an -* RCH's downstream port. Check and handle them in the CXL.mem -* device driver. -*/ drivers/pci/pcie/aer.c static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data) · line 1042
Quoted 10 lines
drivers/pci/pcie/aer.c +7
-2-if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC && -is_internal_error (info)) +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC )pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); + +if (info->severity ==AER_CORRECTABLE ) { +struct pci_driver *pdrv = dev->driver; +int aer = dev->aer_cap; + +if (aer)How do we get here with no aer?
Quoted 7 lines
On a PCIe device AER is optional, but not I think on a CXL device (I can't find the text but there is a change log entry that says to clarify that it is required for CXL devices)
Maybe the optionality is why the PCIe code has this check.
Anyhow, I don't really mind keeping it, was just curious.
Hi Jonathan,
I agree the check can be removed because AER is required for all CXL devices.[1]
[1] - CXL specification v3.1 - Section 3.1.4 'Optional PCIe Features Required for CXL'
Regards,
Terry
PATCH v3 6/15 PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe port devices
In reply to Terry BowmanThe AER service driver's aer_get_device_error_info() function doesn't read uncorrectable (UCE) fatal error status from PCIe upstream port devices, including CXL upstream switch ports. As a result, fatal errors are not logged or handled as needed for CXL PCIe upstream switch port devices.
Update the aer_get_device_error_info() function to read the UCE fatal status for all CXL PCIe port devices. Make the change to not affect non-CXL PCIe devices.
The fatal error status will be used in future patches implementing CXL PCIe port uncorrectable error handling and logging.
--- drivers/pci/pcie/aer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer.c +2 -1
@@ -1250,7 +1250,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) }else if (type ==PCI_EXP_TYPE_ROOT_PORT || type ==PCI_EXP_TYPE_RC_EC || type ==PCI_EXP_TYPE_DOWNSTREAM || - info->severity ==AER_NONFATAL ) { + info->severity ==AER_NONFATAL || + (pcie_is_cxl (dev) && type ==PCI_EXP_TYPE_UPSTREAM )) {/* Link is still healthy for IO reads */ pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS,
Signature · 1 line
2.34.1
Re: [PATCH v3 06/15] PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe port devices
Quoted 11 lines · Terry Bowman
The AER service driver's
aer_get_device_error_info()function doesn't read uncorrectable (UCE) fatal error status from PCIe upstream port devices, including CXL upstream switch ports. As a result, fatal errors are not logged or handled as needed for CXL PCIe upstream switch port devices.Update the
aer_get_device_error_info()function to read the UCE fatal status for all CXL PCIe port devices. Make the change to not affect non-CXL PCIe devices.The fatal error status will be used in future patches implementing CXL PCIe port uncorrectable error handling and logging.
[...]
drivers/pci/pcie/aer.c int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) · line 1257
Quoted 12 lines
drivers/pci/pcie/aer.c +2
-1@@ -1250,7 +1250,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) }else if (type ==PCI_EXP_TYPE_ROOT_PORT || type ==PCI_EXP_TYPE_RC_EC || type ==PCI_EXP_TYPE_DOWNSTREAM || - info->severity ==AER_NONFATAL ) { + info->severity ==AER_NONFATAL || + (pcie_is_cxl (dev) && type ==PCI_EXP_TYPE_UPSTREAM )) {/* Link is still healthy for IO reads */ pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS,
Just a heads-up, there's another patch pending by Shuai Xue (+cc) which touches the same code lines. It re-enables error reporting for PCIe Upstream Ports (as well as Endpoints) under certain conditions:
https://lore.kernel.org/all/[email protected]/
That was originally disabled by Keith Busch (+cc) with commit 9d938ea53b26 ("PCI/AER: Don't read upstream ports below fatal errors").
There's some merge conflict potential here if your series goes into the cxl tree and Shuai's patch into the pci tree in the next cycle.
Thanks,
Lukas
Re: [PATCH v3 06/15] PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe port devices
Quoted 35 lines · Lukas Wunner
Quoted 11 lines · Terry Bowman
The AER service driver's
aer_get_device_error_info()function doesn't read uncorrectable (UCE) fatal error status from PCIe upstream port devices, including CXL upstream switch ports. As a result, fatal errors are not logged or handled as needed for CXL PCIe upstream switch port devices.Update the
aer_get_device_error_info()function to read the UCE fatal status for all CXL PCIe port devices. Make the change to not affect non-CXL PCIe devices.The fatal error status will be used in future patches implementing CXL PCIe port uncorrectable error handling and logging.
[...]
drivers/pci/pcie/aer.c int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) · line 1257
Quoted 12 lines
drivers/pci/pcie/aer.c +2
-1@@ -1250,7 +1250,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) }else if (type ==PCI_EXP_TYPE_ROOT_PORT || type ==PCI_EXP_TYPE_RC_EC || type ==PCI_EXP_TYPE_DOWNSTREAM || - info->severity ==AER_NONFATAL ) { + info->severity ==AER_NONFATAL || + (pcie_is_cxl (dev) && type ==PCI_EXP_TYPE_UPSTREAM )) {/* Link is still healthy for IO reads */ pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS,Just a heads-up, there's another patch pending by Shuai Xue (+cc) which touches the same code lines. It re-enables error reporting for PCIe Upstream Ports (as well as Endpoints) under certain conditions:
https://lore.kernel.org/all/[email protected]/
That was originally disabled by Keith Busch (+cc) with commit
9d938ea53b26("PCI/AER: Don't read upstream ports below fatal errors").
Quoted 6 lines
There's some merge conflict potential here if your series goes into the cxl tree and Shuai's patch into the pci tree in the next cycle.
Thanks,
Lukas
Thanks Lukas I took a look at the patchset and reached out to Shuai (you're CC'd). Sorry, I thought I responded here earlier.
Regards,
Terry
Re: [PATCH v3 06/15] PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe port devices
Quoted 36 lines · Terry
Quoted 35 lines · Lukas Wunner
Quoted 11 lines · Terry Bowman
The AER service driver's
aer_get_device_error_info()function doesn't read uncorrectable (UCE) fatal error status from PCIe upstream port devices, including CXL upstream switch ports. As a result, fatal errors are not logged or handled as needed for CXL PCIe upstream switch port devices.Update the
aer_get_device_error_info()function to read the UCE fatal status for all CXL PCIe port devices. Make the change to not affect non-CXL PCIe devices.The fatal error status will be used in future patches implementing CXL PCIe port uncorrectable error handling and logging.
[...]
drivers/pci/pcie/aer.c int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) · line 1257
Quoted 12 lines
drivers/pci/pcie/aer.c +2
-1@@ -1250,7 +1250,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) }else if (type ==PCI_EXP_TYPE_ROOT_PORT || type ==PCI_EXP_TYPE_RC_EC || type ==PCI_EXP_TYPE_DOWNSTREAM || - info->severity ==AER_NONFATAL ) { + info->severity ==AER_NONFATAL || + (pcie_is_cxl (dev) && type ==PCI_EXP_TYPE_UPSTREAM )) {/* Link is still healthy for IO reads */ pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS,Just a heads-up, there's another patch pending by Shuai Xue (+cc) which touches the same code lines. It re-enables error reporting for PCIe Upstream Ports (as well as Endpoints) under certain conditions:
https://lore.kernel.org/all/[email protected]/
That was originally disabled by Keith Busch (+cc) with commit
9d938ea53b26("PCI/AER: Don't read upstream ports below fatal errors").
Quoted 8 lines
Quoted 6 lines
There's some merge conflict potential here if your series goes into the cxl tree and Shuai's patch into the pci tree in the next cycle.
Thanks,
Lukas
Thanks Lukas I took a look at the patchset and reached out to Shuai (you're CC'd). Sorry, I thought I responded here earlier.
I'm guessing we might not need this change if we can base querying on the link being good. If the error is on the CXL protocol side, the link should still be fine I think?
Jonathan
Quoted 3 lines
Regards,
Terry
Re: [PATCH v3 06/15] PCI/AER: Change AER driver to read UCE fatal status for all CXL PCIe port devices
Quoted 44 lines · Jonathan Cameron
Quoted 41 lines · Terry
Quoted 40 lines · Lukas Wunner
Quoted 11 lines · Terry Bowman
The AER service driver's
aer_get_device_error_info()function doesn't read uncorrectable (UCE) fatal error status from PCIe upstream port devices, including CXL upstream switch ports. As a result, fatal errors are not logged or handled as needed for CXL PCIe upstream switch port devices.Update the
aer_get_device_error_info()function to read the UCE fatal status for all CXL PCIe port devices. Make the change to not affect non-CXL PCIe devices.The fatal error status will be used in future patches implementing CXL PCIe port uncorrectable error handling and logging.
[...]
drivers/pci/pcie/aer.c int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) · line 1257
Quoted 12 lines
drivers/pci/pcie/aer.c +2
-1@@ -1250,7 +1250,8 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) }else if (type ==PCI_EXP_TYPE_ROOT_PORT || type ==PCI_EXP_TYPE_RC_EC || type ==PCI_EXP_TYPE_DOWNSTREAM || - info->severity ==AER_NONFATAL ) { + info->severity ==AER_NONFATAL || + (pcie_is_cxl (dev) && type ==PCI_EXP_TYPE_UPSTREAM )) {/* Link is still healthy for IO reads */ pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_STATUS,Just a heads-up, there's another patch pending by Shuai Xue (+cc) which touches the same code lines. It re-enables error reporting for PCIe Upstream Ports (as well as Endpoints) under certain conditions:
https://lore.kernel.org/all/[email protected]/
That was originally disabled by Keith Busch (+cc) with commit
9d938ea53b26("PCI/AER: Don't read upstream ports below fatal errors").There's some merge conflict potential here if your series goes into the cxl tree and Shuai's patch into the pci tree in the next cycle.
Thanks,
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Lukas
Thanks Lukas I took a look at the patchset and reached out to Shuai (you're CC'd). Sorry, I thought I responded here earlier.
I'm guessing we might not need this change if we can base querying on the link being good. If the error is on the CXL protocol side, the link should still be fine I think?
Jonathan
Hi Jonathan,
Shuai is determining upstream link viability using a call to pciehp_check_link_active() in dpc.c. But, link viability is not determined dynamically for call to aer_get_device_error_info() in his patchset. I suppose we could add this for CXL devices and continue to isolate the new logic from PCIe devices. Your thoughts? Link to the brief discussion with Shuai is here: https://lore.kernel.org/linux-pci/[email protected]/ Regards, Terry
Quoted 2 lines
Quoted 2 lines
Regards,
Terry
PATCH v3 7/15 PCI/AER: Add CXL PCIe port uncorrectable error recovery in AER service driver
In reply to Terry BowmanExisting recovery procedure for PCIe uncorrectable errors (UCE) does not apply to CXL devices. Recovery can not be used for CXL devices because of the potential for corruption on what can be system memory. Also, current PCIe UCE recovery does not begin at the bridge but begins at the bridge's first downstream device. This will miss handling CXL protocol errors in a CXL root port. A separate CXL recovery is needed because of the different handling requirements
Add a new function, cxl_do_recovery() using the following.
Add cxl_walk_bridge() to iterate the detected error's sub-topology. cxl_walk_bridge() is similar to pci_walk_bridge() but the CXL flavor will begin iteration at the bridge rather than beginning at the bridge's first downstream child.
Add cxl_report_error_detected() as an analog to report_error_detected(). It will call pci_driver::cxl_err_handlers for each iterated downstream child. The pci_driver::cxl_err_handlers UCE handler returns a boolean indicating if there was a UCE error detected during handling.
cxl_do_recovery() uses the status from cxl_report_error_detected() to determine how to proceed. Non-fatal CXL UCE errors will be treated as fatal. If a UCE was present during handling then cxl_do_recovery() will kernel panic.
--- drivers/pci/pci.h | 3 +++ drivers/pci/pcie/aer.c | 5 +++- drivers/pci/pcie/err.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-)
drivers/pci/pci.h +3 -0
@@ -658,6 +658,9 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,pci_channel_state_t state, pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev)); +/* CXL error reporting and handling */ +void cxl_do_recovery (struct pci_dev *dev); +bool pcie_wait_for_link (struct pci_dev *pdev,bool active);int pcie_retrain_link (struct pci_dev *pdev,bool use_lt);
drivers/pci/pcie/aer.c +4 -1
@@ -1048,7 +1048,10 @@ static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info) pdrv->cxl_err_handler->cor_error_detected (dev);pcie_clear_device_status (dev); - } + }else if (info->severity ==AER_NONFATAL ) +cxl_do_recovery (dev); +else if (info->severity ==AER_FATAL ) +cxl_do_recovery (dev); }static int handles_cxl_error_iter (struct pci_dev *dev,void *data)
drivers/pci/pcie/err.c +54 -0
57 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 07/15] PCI/AER: Add CXL PCIe port uncorrectable error recovery in AER service driver
Quoted 1 line · Terry Bowman
Non-fatal CXL UCE errors will be treated as fatal.
Hm, I wonder why?
drivers/pci/pcie/aer.c static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1055
Quoted 12 lines
drivers/pci/pcie/aer.c +4
-1@@ -1048,7 +1048,10 @@ static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info) pdrv->cxl_err_handler->cor_error_detected (dev);pcie_clear_device_status (dev); - } + }else if (info->severity ==AER_NONFATAL ) +cxl_do_recovery (dev); +else if (info->severity ==AER_FATAL ) +cxl_do_recovery (dev); }
Nit: Maybe use curly braces and collapse both if-block into one.
drivers/pci/pcie/aer.c static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info)
Quoted 3 lines
drivers/pci/pcie/aer.c +3
-0+cxl_walk_bridge (bridge, cxl_report_error_detected, &status); +if (status) +panic ("CXL cachemem error. Invoking panic" );
Nit: This will be prefixed by "Kernel panic - not syncing: ", so another "Invoking panic" message seems somewhat redundant.
Thanks,
Lukas
Re: [PATCH v3 07/15] PCI/AER: Add CXL PCIe port uncorrectable error recovery in AER service driver
Quoted 9 lines · Lukas Wunner
Quoted 1 line · Terry Bowman
Non-fatal CXL UCE errors will be treated as fatal.
Hm, I wonder why?
Quoted 5 lines
drivers/pci/pcie/aer.c +0
-0@@ -1048,7 +1048,10 @@ static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info) pdrv->cxl_err_handler->cor_error_detected (dev);
Quoted 8 lines
drivers/pci/pcie/aer.c static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info) · line 1055
Quoted 7 lines
drivers/pci/pcie/aer.c +4
-1pcie_clear_device_status (dev); - } + }else if (info->severity ==AER_NONFATAL ) +cxl_do_recovery (dev); +else if (info->severity ==AER_FATAL ) +cxl_do_recovery (dev); }Nit: Maybe use curly braces and collapse both if-block into one.
I'll make the change.
Quoted 9 lines
drivers/pci/pcie/aer.c static void cxl_handle_error(struct pci_dev *dev, struct aer_err_info *info)
Quoted 3 lines
drivers/pci/pcie/aer.c +3
-0+cxl_walk_bridge (bridge, cxl_report_error_detected, &status); +if (status) +panic ("CXL cachemem error. Invoking panic" );Nit: This will be prefixed by "Kernel panic - not syncing: ", so another "Invoking panic" message seems somewhat redundant.
Thanks,
Lukas
Ok, good idea.
Regards,
Terry
PATCH v3 8/15 cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
In reply to Terry BowmanThe CXL mem driver (cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.
Introduce cxl_init_ep_ports_aer() to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.
Move the RAS register map logic from cxl_dport_map_ras() into cxl_dport_init_ras_reporting(). This eliminates the need for the helper function, cxl_dport_map_ras().
cxl_init_ep_ports_aer() calls cxl_dport_init_ras_reporting() to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting() must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.
--- drivers/cxl/core/pci.c | 36 +++++++++++++++--------------------- drivers/cxl/cxl.h | 6 ++---- drivers/cxl/mem.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 27 deletions(-)
drivers/cxl/core/pci.c +15 -21
@@ -749,18 +749,6 @@ static void cxl_dport_map_rch_aer(struct cxl_dport *dport) } } -static void cxl_dport_map_ras (struct cxl_dport *dport) -{ -struct cxl_register_map *map = &dport->reg_map; -struct device *dev = dport->dport_dev; - -if (!map->component_map.ras.valid) -dev_dbg (dev,"RAS registers not found\n" ); -else if (cxl_map_component_regs (map, &dport->regs.component, -BIT (CXL_CM_CAP_CAP_ID_RAS ))) -dev_dbg (dev,"Failed to map RAS capability.\n" ); -} -static void cxl_disable_rch_root_ints (struct cxl_dport *dport) {void __iomem *aer_base = dport->regs.dport_aer;
@@ -790,20 +778,26 @@ static void cxl_disable_rch_root_ints(struct cxl_dport *dport)* @dport: the cxl_dport that needs to be initialized * @host: host device for devm operations */ -void cxl_dport_init_ras_reporting (struct cxl_dport *dport,struct device *host) +void cxl_dport_init_ras_reporting (struct cxl_dport *dport) { - dport->reg_map.host = host; -cxl_dport_map_ras (dport); - -if (dport->rch) { -struct pci_host_bridge *host_bridge =to_pci_host_bridge (dport->dport_dev); - -if (!host_bridge->native_aer) -return ; +struct device *dport_dev = dport->dport_dev; +struct pci_host_bridge *host_bridge =to_pci_host_bridge (dport_dev); +if (dport->rch && host_bridge->native_aer) {cxl_dport_map_rch_aer (dport);cxl_disable_rch_root_ints (dport); } + +/* dport may have more than 1 downstream EP. Check if already mapped. */ +if (dport->regs.ras) +return ; + + dport->reg_map.host = dport_dev; +if (cxl_map_component_regs (&dport->reg_map, &dport->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS ))) { +dev_err (dport_dev,"Failed to map RAS capability.\n" ); +return ; + } }EXPORT_SYMBOL_NS_GPL (cxl_dport_init_ras_reporting,CXL );
drivers/cxl/cxl.h +2 -4
@@ -763,11 +763,9 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, resource_size_t rcrb);#ifdef CONFIG_PCIEAER_CXL -void cxl_setup_parent_dport (struct device *host,struct cxl_dport *dport); -void cxl_dport_init_ras_reporting (struct cxl_dport *dport,struct device *host); +void cxl_dport_init_ras_reporting (struct cxl_dport *dport);#else -static inline void cxl_dport_init_ras_reporting (struct cxl_dport *dport, -struct device *host) { } +static inline void cxl_dport_init_ras_reporting (struct cxl_dport *dport) { }#endif struct cxl_decoder *to_cxl_decoder (struct device *dev);
drivers/cxl/mem.c +26 -2
@@ -45,6 +45,31 @@ static int cxl_mem_dpa_show(struct seq_file *file, void *data)return 0 ; } +static bool dev_is_cxl_pci (struct device *dev,u32 pcie_type) +{ +struct pci_dev *pdev; + +if (!dev || !dev_is_pci (dev)) +return false; + + pdev =to_pci_dev (dev); + +return (pci_pcie_type (pdev) == pcie_type); +} + +static void cxl_init_ep_ports_aer (struct cxl_ep *ep) +{ +struct cxl_dport *dport = ep->dport; + +if (dport) { +struct device *dport_dev = dport->dport_dev; + +if (dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_DOWNSTREAM ) || +dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_ROOT_PORT )) +cxl_dport_init_ras_reporting (dport); + } +} +static int devm_cxl_add_endpoint (struct device *host,struct cxl_memdev *cxlmd,struct cxl_dport *parent_dport) {
@@ -62,6 +87,7 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep =cxl_ep_load (iter, cxlmd); ep->next = down; +cxl_init_ep_ports_aer (ep); }/* Note: endpoint port component registers are derived from @cxlds */
@@ -166,8 +192,6 @@ static int cxl_mem_probe(struct device *dev)else endpoint_parent = &parent_port->dev; -cxl_dport_init_ras_reporting (dport, dev); - scoped_guard(device, endpoint_parent) {if (!endpoint_parent->driver) { dev_err(dev, "CXL port topology %s not enabled\n",
Signature · 1 line
2.34.1
Re: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
Quoted 24 lines · Terry Bowman
The CXL mem driver (
cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.Introduce
cxl_init_ep_ports_aer()to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.Move the RAS register map logic from
cxl_dport_map_ras()intocxl_dport_init_ras_reporting(). This eliminates the need for the helper function,cxl_dport_map_ras().
cxl_init_ep_ports_aer()callscxl_dport_init_ras_reporting()to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting()must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.Signed-off-by Terry Bowman <[email protected]>
[snip]
Quoted 12 lines
drivers/cxl/mem.c +12
-0+static bool dev_is_cxl_pci (struct device *dev,u32 pcie_type) +{ +struct pci_dev *pdev; + +if (!dev || !dev_is_pci (dev)) +return false; + + pdev =to_pci_dev (dev); + +return (pci_pcie_type (pdev) == pcie_type); +} +
drivers/cxl/mem.c static int cxl_mem_dpa_show(struct seq_file *file, void *data) · line 69
Quoted 10 lines
drivers/cxl/mem.c +10
-0+static void cxl_init_ep_ports_aer (struct cxl_ep *ep) +{ +struct cxl_dport *dport = ep->dport; + +if (dport) { +struct device *dport_dev = dport->dport_dev; + +if (dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_DOWNSTREAM ) || +dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_ROOT_PORT )) +cxl_dport_init_ras_reporting (dport);
I think cxl_dport_init_ras_reporting() is needed for both VH case and RCH case. My understanding is that dport_dev could not be a DSP nor a RP in RCH case.
Ming
Quoted 23 lines
drivers/cxl/mem.c +4
-2+ } +} +static int devm_cxl_add_endpoint (struct device *host,struct cxl_memdev *cxlmd,struct cxl_dport *parent_dport) {@@ -62,6 +87,7 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep =cxl_ep_load (iter, cxlmd); ep->next = down; +cxl_init_ep_ports_aer (ep); }/* Note: endpoint port component registers are derived from @cxlds */ @@ -166,8 +192,6 @@ static int cxl_mem_probe(struct device *dev)else endpoint_parent = &parent_port->dev; -cxl_dport_init_ras_reporting (dport, dev); - scoped_guard(device, endpoint_parent) {if (!endpoint_parent->driver) { dev_err(dev, "CXL port topology %s not enabled\n",
Re: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
Quoted 54 lines · Li Ming
Quoted 24 lines · Terry Bowman
The CXL mem driver (
cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.Introduce
cxl_init_ep_ports_aer()to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.Move the RAS register map logic from
cxl_dport_map_ras()intocxl_dport_init_ras_reporting(). This eliminates the need for the helper function,cxl_dport_map_ras().
cxl_init_ep_ports_aer()callscxl_dport_init_ras_reporting()to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting()must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.Signed-off-by Terry Bowman <[email protected]>[snip]
Quoted 12 lines
drivers/cxl/mem.c +12
-0+static bool dev_is_cxl_pci (struct device *dev,u32 pcie_type) +{ +struct pci_dev *pdev; + +if (!dev || !dev_is_pci (dev)) +return false; + + pdev =to_pci_dev (dev); + +return (pci_pcie_type (pdev) == pcie_type); +} +drivers/cxl/mem.c static int cxl_mem_dpa_show(struct seq_file *file, void *data) · line 69
Quoted 10 lines
drivers/cxl/mem.c +10
-0+static void cxl_init_ep_ports_aer (struct cxl_ep *ep) +{ +struct cxl_dport *dport = ep->dport; + +if (dport) { +struct device *dport_dev = dport->dport_dev; + +if (dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_DOWNSTREAM ) || +dev_is_cxl_pci (dport_dev,PCI_EXP_TYPE_ROOT_PORT )) +cxl_dport_init_ras_reporting (dport);I think
cxl_dport_init_ras_reporting()is needed for both VH case and RCH case. My understanding is thatdport_devcould not be a DSP nor a RP in RCH case.
Quoted 1 line
Ming
Good point. I'll look into that. Thanks Ming!
Regards,
Terry
kernel test robot
build botRe: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
In reply to Terry Bowmankernel test robot noticed the following build warnings:
Hi Terry,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 2d5404caa8c7bb5c4e0435f94b28834ae5456623]
url: https://github.com/intel-lab-lkp/linux/commits/Terry-Bowman/PCI-AER-Introduce-struct-cxl_err_handlers-and-add-to-struct-pci_driver/20241114-060000 base: 2d5404caa8c7bb5c4e0435f94b28834ae5456623 patch link: https://lore.kernel.org/r/20241113215429.3177981-9-terry.bowman%40amd.com patch subject: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers config: i386-randconfig-141-20241116 (https://download.01.org/0day-ci/archive/20241116/[email protected]/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241116/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/cxl/core/pci.c:782: warning: Excess function parameter 'host' description in 'cxl_dport_init_ras_reporting'
vim +782 drivers/cxl/core/pci.c
d1a9def33d7043 Terry Bowman 2023-10-18 775
577a67662ff529 Li Ming 2024-08-30 776 /**
577a67662ff529 Li Ming 2024-08-30 777 * cxl_dport_init_ras_reporting - Setup CXL RAS report on this dport
577a67662ff529 Li Ming 2024-08-30 778 * @dport: the cxl_dport that needs to be initialized
577a67662ff529 Li Ming 2024-08-30 779 * @host: host device for devm operations
577a67662ff529 Li Ming 2024-08-30 780 */
23f51024741fc0 Terry Bowman 2024-11-13 781 void cxl_dport_init_ras_reporting(struct cxl_dport *dport)
f05fd10d138d8b Robert Richter 2023-10-27 @782 {
23f51024741fc0 Terry Bowman 2024-11-13 783 struct device *dport_dev = dport->dport_dev;
23f51024741fc0 Terry Bowman 2024-11-13 784 struct pci_host_bridge *host_bridge = to_pci_host_bridge(dport_dev);
f05fd10d138d8b Robert Richter 2023-10-27 785
23f51024741fc0 Terry Bowman 2024-11-13 786 if (dport->rch && host_bridge->native_aer) {
23f51024741fc0 Terry Bowman 2024-11-13 787 cxl_dport_map_rch_aer(dport);
23f51024741fc0 Terry Bowman 2024-11-13 788 cxl_disable_rch_root_ints(dport);
23f51024741fc0 Terry Bowman 2024-11-13 789 }
6c5f3aacb2963d Terry Bowman 2023-10-18 790
23f51024741fc0 Terry Bowman 2024-11-13 791 /* dport may have more than 1 downstream EP. Check if already mapped. */
23f51024741fc0 Terry Bowman 2024-11-13 792 if (dport->regs.ras)
c8706cc15a5814 Li Ming 2024-08-30 793 return;
d1a9def33d7043 Terry Bowman 2023-10-18 794
23f51024741fc0 Terry Bowman 2024-11-13 795 dport->reg_map.host = dport_dev;
23f51024741fc0 Terry Bowman 2024-11-13 796 if (cxl_map_component_regs(&dport->reg_map, &dport->regs.component,
23f51024741fc0 Terry Bowman 2024-11-13 797 BIT(CXL_CM_CAP_CAP_ID_RAS))) {
23f51024741fc0 Terry Bowman 2024-11-13 798 dev_err(dport_dev, "Failed to map RAS capability.\n");
23f51024741fc0 Terry Bowman 2024-11-13 799 return;
f05fd10d138d8b Robert Richter 2023-10-27 800 }
c8706cc15a5814 Li Ming 2024-08-30 801 }
577a67662ff529 Li Ming 2024-08-30 802 EXPORT_SYMBOL_NS_GPL(cxl_dport_init_ras_reporting, CXL);
f05fd10d138d8b Robert Richter 2023-10-27 803 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
In reply to Terry BowmanQuoted 24 lines · Terry Bowman
The CXL mem driver (
cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.Introduce
cxl_init_ep_ports_aer()to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.Move the RAS register map logic from
cxl_dport_map_ras()intocxl_dport_init_ras_reporting(). This eliminates the need for the helper function,cxl_dport_map_ras().
cxl_init_ep_ports_aer()callscxl_dport_init_ras_reporting()to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting()must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.Signed-off-by Terry Bowman <[email protected]>
[snip]
drivers/cxl/mem.c static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, · line 90
Quoted 8 lines
static int devm_cxl_add_endpoint(struct device *host, struct
cxl_memdev*cxlmd,
structcxl_dport*parent_dport)
{drivers/cxl/mem.c +1
-0@@ -62,6 +87,7 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep =cxl_ep_load (iter, cxlmd); ep->next = down; +cxl_init_ep_ports_aer (ep);
In RCH case, seems like another issue is here, I believe that a RCD will be added to a CXL root directly rather than a CXL host bridge, it means that no chance to call cxl_init_ep_ports_aer() for a RCD, because this loop is only for a EP attaching to a CXL non-root port.
Please correct me if I'm wrong.
Ming
Quoted 12 lines
drivers/cxl/mem.c +0
-2}/* Note: endpoint port component registers are derived from @cxlds */ @@ -166,8 +192,6 @@ static int cxl_mem_probe(struct device *dev)else endpoint_parent = &parent_port->dev; -cxl_dport_init_ras_reporting (dport, dev); - scoped_guard(device, endpoint_parent) {if (!endpoint_parent->driver) { dev_err(dev, "CXL port topology %s not enabled\n",
Re: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
Quoted 41 lines · Li Ming
Quoted 24 lines · Terry Bowman
The CXL mem driver (
cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.Introduce
cxl_init_ep_ports_aer()to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.Move the RAS register map logic from
cxl_dport_map_ras()intocxl_dport_init_ras_reporting(). This eliminates the need for the helper function,cxl_dport_map_ras().
cxl_init_ep_ports_aer()callscxl_dport_init_ras_reporting()to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting()must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.Signed-off-by Terry Bowman <[email protected]>[snip]
drivers/cxl/mem.c static int devm_cxl_add_endpoint(struct device · line 90
Quoted 8 lines
static int
devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, struct cxl_dport *parent_dport)
{drivers/cxl/mem.c +1
-0@@ -62,6 +87,7 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep = cxl_ep_load(iter, cxlmd); ep->next = down; + cxl_init_ep_ports_aer(ep);In RCH case, seems like another issue is here, I believe that a RCD will be added to a CXL root directly rather than a CXL host bridge, it means that no chance to call
cxl_init_ep_ports_aer()for a RCD, because this loop is only for a EP attaching to a CXL non-root port.
Quoted 2 lines
Please correct me if I'm wrong.
I think above explaination is not clear, what I meant is the hierachy in RCH case should be this:
cxl_port(root) <--> cxl_dport(host bridge) <--> cxl_port(RCD endpoint)
RCD endpoint's parent port is a cxl root port, so that the cxl_init_ep_ports_aer() cannot be called in that case.
Ming
Quoted 14 lines
Ming
Quoted 11 lines
(quoted diff) +0
-0} /* Note: endpoint port component registers are derived from@cxlds */
(quoted diff) +0
-0@@ -166,8 +192,6 @@ static int cxl_mem_probe(struct device *dev)else
endpoint_parent=&parent_port->dev;
-cxl_dport_init_ras_reporting(dport, dev);
-
scoped_guard(device, endpoint_parent){
if (!endpoint_parent->driver) {
dev_err(dev, "CXL port topology %s not enabled\n",
Re: [PATCH v3 08/15] cxl/pci: Map CXL PCIe root port and downstream switch port RAS registers
Quoted 49 lines · Li Ming
Quoted 42 lines · Li Ming
Quoted 24 lines · Terry Bowman
The CXL mem driver (
cxl_mem) currently maps and caches a pointer to RAS registers for the endpoint's root port. The same needs to be done for each of the CXL downstream switch ports and CXL root ports found between the endpoint and CXL host bridge.Introduce
cxl_init_ep_ports_aer()to be called for each port in the sub-topology between the endpoint and the CXL host bridge. This function will determine if there are CXL downstream switch ports or CXL root ports associated with this port. The same check will be added in the future for upstream switch ports.Move the RAS register map logic from
cxl_dport_map_ras()intocxl_dport_init_ras_reporting(). This eliminates the need for the helper function,cxl_dport_map_ras().
cxl_init_ep_ports_aer()callscxl_dport_init_ras_reporting()to map the RAS registers for CXL downstream switch ports and CXL root ports.
cxl_dport_init_ras_reporting()must check for previously mapped registers before mapping. This is necessary because endpoints under a CXL switch may share CXL downstream switch ports or CXL root ports. Ensure the port registers are only mapped once.Signed-off-by Terry Bowman <[email protected]>[snip]
drivers/cxl/mem.c static int devm_cxl_add_endpoint(struct device · line 90
Quoted 9 lines
static int devm_cxl_add_endpoint(struct device *host, struct
cxl_memdev*cxlmd,
structcxl_dport*parent_dport)
{drivers/cxl/mem.c +1
-0@@ -62,6 +87,7 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep = cxl_ep_load(iter, cxlmd); ep->next = down; + cxl_init_ep_ports_aer(ep);In RCH case, seems like another issue is here, I believe that a RCD will be added to a CXL root directly rather than a CXL host bridge, it means that no chance to call
cxl_init_ep_ports_aer()for a RCD, because this loop is only for a EP attaching to a CXL non-root port.Quoted 2 lines
Please correct me if I'm wrong.
I think above explaination is not clear, what I meant is the hierachy in RCH case should be this:
Quoted 6 lines
cxl_port(root)<-->cxl_dport(host bridge)<-->cxl_port(RCD endpoint)RCD endpoint's parent port is a cxl root port, so that the
cxl_init_ep_ports_aer()cannot be called in that case.Ming
You make a good point. I will leave the original cxl_dport_init_ras_reporting() but renamed. And will add a check for if RCH mode before calling it.
Regards,
Terry
Quoted 13 lines
Quoted 13 lines
Ming
Quoted 11 lines
(quoted diff) +0
-0} /* Note: endpoint port component registers are derived from@cxlds */
(quoted diff) +0
-0@@ -166,8 +192,6 @@ static int cxl_mem_probe(struct device *dev)else
endpoint_parent=&parent_port->dev;
-cxl_dport_init_ras_reporting(dport, dev);
-
scoped_guard(device, endpoint_parent){
if (!endpoint_parent->driver) {
dev_err(dev, "CXL port topology %s not enabled\n",
PATCH v3 9/15 cxl/pci: Map CXL PCIe upstream switch port RAS registers
In reply to Terry BowmanAdd logic to map CXL PCIe upstream switch port (USP) RAS registers.
Introduce 'struct cxl_regs' member into 'struct cxl_port' to cache a pointer to the upstream port's mapped RAS registers.
Also, introduce cxl_uport_init_ras_reporting() to perform the USP RAS register mapping. This is similar to the existing cxl_dport_init_ras_reporting() but for USP devices.
The upstream port may have multiple downstream endpoints. Before mapping AER registers check if the registers are already mapped.
--- drivers/cxl/core/pci.c | 15 +++++++++++++++ drivers/cxl/cxl.h | 4 ++++ drivers/cxl/mem.c | 8 ++++++++ 3 files changed, 27 insertions(+)
drivers/cxl/core/pci.c +15 -0
@@ -773,6 +773,21 @@ static void cxl_disable_rch_root_ints(struct cxl_dport *dport)writel (aer_cmd, aer_base +PCI_ERR_ROOT_COMMAND ); } +void cxl_uport_init_ras_reporting (struct cxl_port *port) +{ +/* uport may have more than 1 downstream EP. Check if already mapped. */ +if (port->uport_regs.ras) +return ; + + port->reg_map.host = &port->dev; +if (cxl_map_component_regs (&port->reg_map, &port->uport_regs, +BIT (CXL_CM_CAP_CAP_ID_RAS ))) { +dev_err (&port->dev,"Failed to map RAS capability.\n" ); +return ; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_uport_init_ras_reporting,CXL ); +/** * cxl_dport_init_ras_reporting - Setup CXL RAS report on this dport * @dport: the cxl_dport that needs to be initialized
drivers/cxl/cxl.h +4 -0
@@ -592,6 +592,7 @@ struct cxl_dax_region {* @parent_dport: dport that points to this port in the parent * @decoder_ida: allocator for decoder ids * @reg_map: component and ras register mapping parameters +* @uport_regs: mapped component registers * @nr_dports: number of entries in @dports * @hdm_end: track last allocated HDM decoder instance for allocation ordering * @commit_end: cursor to track highest committed decoder for commit ordering
@@ -612,6 +613,7 @@ struct cxl_port {struct cxl_dport *parent_dport;struct ida decoder_ida;struct cxl_register_map reg_map; +struct cxl_component_regs uport_regs;int nr_dports;int hdm_end;int commit_end;
@@ -764,8 +766,10 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port,#ifdef CONFIG_PCIEAER_CXL void cxl_dport_init_ras_reporting (struct cxl_dport *dport); +void cxl_uport_init_ras_reporting (struct cxl_port *port);#else static inline void cxl_dport_init_ras_reporting (struct cxl_dport *dport) { } +static inline void cxl_uport_init_ras_reporting (struct cxl_port *port) { }#endif struct cxl_decoder *to_cxl_decoder (struct device *dev);
drivers/cxl/mem.c +8 -0
@@ -60,6 +60,7 @@ static bool dev_is_cxl_pci(struct device *dev, u32 pcie_type)static void cxl_init_ep_ports_aer (struct cxl_ep *ep) {struct cxl_dport *dport = ep->dport; +struct cxl_port *port = ep->next;if (dport) {struct device *dport_dev = dport->dport_dev;
@@ -68,6 +69,13 @@ static void cxl_init_ep_ports_aer(struct cxl_ep *ep) dev_is_cxl_pci(dport_dev, PCI_EXP_TYPE_ROOT_PORT))cxl_dport_init_ras_reporting (dport); } + +if (port) { +struct device *uport_dev = port->uport_dev; + +if (dev_is_cxl_pci (uport_dev,PCI_EXP_TYPE_UPSTREAM )) +cxl_uport_init_ras_reporting (port); + } } static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd,
Signature · 1 line
2.34.1
PATCH v3 10/15 cxl/pci: Update RAS handler interfaces to also support CXL PCIe ports
In reply to Terry BowmanCXL PCIe port protocol error handling support will be added to the CXL drivers in the future. In preparation, rename the existing interfaces to support handling all CXL PCIe port protocol errors.
The driver's RAS support functions currently rely on a 'struct cxl_dev_state' type parameter, which is not available for CXL port devices. However, since the same CXL RAS capability structure is needed across most CXL components and devices, a common handling approach should be adopted.
To accommodate this, update the __cxl_handle_cor_ras() and __cxl_handle_ras() functions to use a struct device instead of struct cxl_dev_state.
No functional changes are introduced.
[1] CXL 3.1 Spec, 8.2.4 CXL.cache and CXL.mem Registers
--- drivers/cxl/core/pci.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/cxl/core/pci.c +8 -9
@@ -650,7 +650,7 @@ void read_cdat_data(struct cxl_port *port) }EXPORT_SYMBOL_NS_GPL (read_cdat_data,CXL ); -static void __cxl_handle_cor_ras (struct cxl_dev_state *cxlds, +static void __cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) {void __iomem *addr;
@@ -663,13 +663,13 @@ static void __cxl_handle_cor_ras(struct cxl_dev_state *cxlds, status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); -trace_cxl_aer_correctable_error (cxlds->cxlmd, status); +trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); } }static void cxl_handle_endpoint_cor_ras (struct cxl_dev_state *cxlds) { -return __cxl_handle_cor_ras (cxlds, cxlds->regs.ras); +return __cxl_handle_cor_ras (&cxlds->cxlmd->dev, cxlds->regs.ras); }/* CXL spec rev3.0 8.2.4.16.1 */
@@ -693,8 +693,7 @@ static void header_log_copy(void __iomem *ras_base, u32 *log)* Log the state of the RAS status registers and prepare them to log the * next error status. Return 1 if reset needed. */ -static bool __cxl_handle_ras (struct cxl_dev_state *cxlds, -void __iomem *ras_base) +static bool __cxl_handle_ras (struct device *dev,void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_SIZE_U32 ];void __iomem *addr;
@@ -721,7 +720,7 @@ static bool __cxl_handle_ras(struct cxl_dev_state *cxlds, }header_log_copy (ras_base, hl); -trace_cxl_aer_uncorrectable_error (cxlds->cxlmd, status, fe, hl); +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);return true;
@@ -729,7 +728,7 @@ static bool __cxl_handle_ras(struct cxl_dev_state *cxlds,static bool cxl_handle_endpoint_ras (struct cxl_dev_state *cxlds) { -return __cxl_handle_ras (cxlds, cxlds->regs.ras); +return __cxl_handle_ras (&cxlds->cxlmd->dev, cxlds->regs.ras); }#ifdef CONFIG_PCIEAER_CXL
@@ -819,13 +818,13 @@ EXPORT_SYMBOL_NS_GPL(cxl_dport_init_ras_reporting, CXL);static void cxl_handle_rdport_cor_ras (struct cxl_dev_state *cxlds,struct cxl_dport *dport) { -return __cxl_handle_cor_ras (cxlds, dport->regs.ras); +return __cxl_handle_cor_ras (&cxlds->cxlmd->dev, dport->regs.ras); }static bool cxl_handle_rdport_ras (struct cxl_dev_state *cxlds,struct cxl_dport *dport) { -return __cxl_handle_ras (cxlds, dport->regs.ras); +return __cxl_handle_ras (&cxlds->cxlmd->dev, dport->regs.ras); }/*
Signature · 1 line
2.34.1
PATCH v3 11/15 cxl/pci: Change find_cxl_port() to non-static
In reply to Terry BowmanCXL PCIe port protocol error support will be added in the future. This requires searching for a CXL PCIe port device in the CXL topology as provided by find_cxl_port(). But, find_cxl_port() is defined static and as a result is not callable outside of this source file.
Update the find_cxl_port() declaration to be non-static.
--- drivers/cxl/core/core.h | 3 +++ drivers/cxl/core/port.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/cxl/core/core.h +3 -0
@@ -110,4 +110,7 @@ bool cxl_need_node_perf_attrs_update(int nid);int cxl_port_get_switch_dport_bandwidth (struct cxl_port *port,struct access_coordinate *c); +struct cxl_port *find_cxl_port (struct device *dport_dev, +struct cxl_dport **dport); +#endif /* __CXL_CORE_H__ */
drivers/cxl/core/port.c +2 -2
@@ -1342,8 +1342,8 @@ static struct cxl_port *__find_cxl_port(struct cxl_find_port_ctx *ctx)return NULL ; } -static struct cxl_port *find_cxl_port (struct device *dport_dev, -struct cxl_dport **dport) +struct cxl_port *find_cxl_port (struct device *dport_dev, +struct cxl_dport **dport) {struct cxl_find_port_ctx ctx = { .dport_dev = dport_dev,
Signature · 1 line
2.34.1
PATCH v3 12/15 cxl/pci: Add error handler for CXL PCIe port RAS errors
In reply to Terry BowmanIntroduce correctable and uncorrectable CXL PCIe port protocol error handlers.
The handlers will be called with a 'struct pci_dev' parameter indicating the CXL port device requiring handling. The CXL PCIe port device's underlying 'struct device' will match the port device in the CXL topology.
Use the PCIe port's device object to find the matching upstream, downstream, or root port in the CXL topology. The matching device will contain a reference to the RAS register block used to handle and log the error.
Invoke the existing __cxl_handle_ras() or __cxl_handle_cor_ras() passing a reference to the RAS registers as a parameter. These functions will use the register reference to clear the device's RAS status.
Future patches will assign the error handlers and add trace logging.
--- drivers/cxl/core/pci.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
drivers/cxl/core/pci.c +64 -0
@@ -772,6 +772,70 @@ static void cxl_disable_rch_root_ints(struct cxl_dport *dport)writel (aer_cmd, aer_base +PCI_ERR_ROOT_COMMAND ); } +static int match_uport (struct device *dev,const void *data) +{ +struct device *uport_dev = (struct device *)data; +struct cxl_port *port; + +if (!is_cxl_port (dev)) +return 0 ; + + port =to_cxl_port (dev); + +return port->uport_dev == uport_dev; +} + +static void __iomem *cxl_pci_port_ras (struct pci_dev *pdev) +{ +void __iomem *ras_base; +struct cxl_port *port; + +if (!pdev) +return NULL ; + +if ((pci_pcie_type (pdev) ==PCI_EXP_TYPE_ROOT_PORT ) || + (pci_pcie_type (pdev) ==PCI_EXP_TYPE_DOWNSTREAM )) { +struct cxl_dport *dport; + + port =find_cxl_port (&pdev->dev, &dport); + ras_base = dport ? dport->regs.ras :NULL ; +if (port) +put_device (&port->dev); +return ras_base; + }else if (pci_pcie_type (pdev) ==PCI_EXP_TYPE_UPSTREAM ) { +struct device *port_dev; + + port_dev =bus_find_device (&cxl_bus_type,NULL , &pdev->dev, + match_uport); +if (!port_dev) +return NULL ; + + port =to_cxl_port (port_dev); + ras_base = port ? port->uport_regs.ras :NULL ; +put_device (port_dev); +return ras_base; + } + +return NULL ; +} + +static void cxl_port_cor_error_detected (struct pci_dev *pdev) +{ +void __iomem *ras_base =cxl_pci_port_ras (pdev); + +__cxl_handle_cor_ras (&pdev->dev, ras_base); +} + +static bool cxl_port_error_detected (struct pci_dev *pdev) +{ +void __iomem *ras_base =cxl_pci_port_ras (pdev); +bool ue; + + ue =__cxl_handle_ras (&pdev->dev, ras_base); + +return ue; +} +void cxl_uport_init_ras_reporting (struct cxl_port *port) {/* uport may have more than 1 downstream EP. Check if already mapped. */
Signature · 1 line
2.34.1
PATCH v3 13/15 cxl/pci: Add trace logging for CXL PCIe port RAS errors
In reply to Terry BowmanThe CXL drivers use kernel trace functions for logging endpoint and RCH downstream port RAS errors. Similar functionality is required for CXL root ports, CXL downstream switch ports, and CXL upstream switch ports.
Introduce trace logging functions for both RAS correctable and uncorrectable errors specific to CXL PCIe ports. Additionally, update the PCIe port error handlers to invoke these new trace functions.
--- drivers/cxl/core/pci.c | 16 ++++++++++---- drivers/cxl/core/trace.h | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-)
drivers/cxl/core/pci.c +12 -4
@@ -661,10 +661,14 @@ static void __cxl_handle_cor_ras(struct device *dev, addr = ras_base +CXL_RAS_CORRECTABLE_STATUS_OFFSET ; status =readl (addr); -if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) { -writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); +if (!(status &CXL_RAS_CORRECTABLE_STATUS_MASK )) +return ; +writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); + +if (is_cxl_memdev (dev))trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); - } +else +trace_cxl_port_aer_correctable_error (dev, status); }static void cxl_handle_endpoint_cor_ras (struct cxl_dev_state *cxlds)
@@ -720,7 +724,11 @@ static bool __cxl_handle_ras(struct device *dev, void __iomem *ras_base) }header_log_copy (ras_base, hl); -trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +if (is_cxl_memdev (dev)) +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +else +trace_cxl_port_aer_uncorrectable_error (dev, status, fe, hl); +writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);return true;
drivers/cxl/core/trace.h +47 -0
59 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 14/15 cxl/pci: Add support to assign and clear pci_driver::cxl_err_handlers
In reply to Terry Bowmanpci_driver::cxl_err_handlers are not currently assigned handler callbacks. The handlers can't be set in the pci_driver static definition because the CXL PCIe port devices are bound to the portdrv driver which is not CXL driver aware.
Add cxl_assign_port_error_handlers() in the cxl_core module. This function will assign the default handlers for a CXL PCIe port device.
When the CXL port (cxl_port or cxl_dport) is destroyed the CXL PCIe port device's pci_driver::cxl_err_handlers must be set to NULL to prevent future use. Create cxl_clear_port_error_handlers() and register it to be called when the CXL port device (cxl_port or cxl_dport) is destroyed.
--- drivers/cxl/core/pci.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/cxl/core/pci.c +35 -0
@@ -844,8 +844,36 @@ static bool cxl_port_error_detected(struct pci_dev *pdev)return ue; } +static const struct cxl_error_handlers cxl_port_error_handlers = { + .error_detected = cxl_port_error_detected, + .cor_error_detected = cxl_port_cor_error_detected, +}; + +static void cxl_assign_port_error_handlers (struct pci_dev *pdev) +{ +struct pci_driver *pdrv = pdev->driver; + +if (!pdrv) +return ; + + pdrv->cxl_err_handler = &cxl_port_error_handlers; +} + +static void cxl_clear_port_error_handlers (void *data) +{ +struct pci_dev *pdev = data; +struct pci_driver *pdrv = pdev->driver; + +if (!pdrv) +return ; + + pdrv->cxl_err_handler =NULL ; +} +void cxl_uport_init_ras_reporting (struct cxl_port *port) { +struct pci_dev *pdev =to_pci_dev (port->uport_dev); +/* uport may have more than 1 downstream EP. Check if already mapped. */ if (port->uport_regs.ras)return ;
@@ -856,6 +884,9 @@ void cxl_uport_init_ras_reporting(struct cxl_port *port)dev_err (&port->dev,"Failed to map RAS capability.\n" );return ; } + +cxl_assign_port_error_handlers (pdev); +devm_add_action_or_reset (port->uport_dev, cxl_clear_port_error_handlers, pdev); }EXPORT_SYMBOL_NS_GPL (cxl_uport_init_ras_reporting,CXL );
@@ -868,6 +899,7 @@ void cxl_dport_init_ras_reporting(struct cxl_dport *dport) {struct device *dport_dev = dport->dport_dev;struct pci_host_bridge *host_bridge =to_pci_host_bridge (dport_dev); +struct pci_dev *pdev =to_pci_dev (dport_dev);if (dport->rch && host_bridge->native_aer) {cxl_dport_map_rch_aer (dport);
@@ -884,6 +916,9 @@ void cxl_dport_init_ras_reporting(struct cxl_dport *dport)dev_err (dport_dev,"Failed to map RAS capability.\n" );return ; } + +cxl_assign_port_error_handlers (pdev); +devm_add_action_or_reset (dport_dev, cxl_clear_port_error_handlers, pdev); }EXPORT_SYMBOL_NS_GPL (cxl_dport_init_ras_reporting,CXL );
Signature · 1 line
2.34.1
PATCH v3 15/15 PCI/AER: Enable internal errors for CXL upstream and downstream switch ports
In reply to Terry BowmanThe AER service driver enables uncorrectable internal errors (UIE) and correctable internal errors (CIE) for CXL root ports and CXL RCEC's. The UIE and CIE are used in reporting CXL protocol errors. The same UIE/CIE enablement is needed for CXL PCIe upstream and downstream ports inorder to notify the associated root port and OS.[1]
Export the AER service driver's pci_aer_unmask_internal_errors() function to CXL namsespace.
Remove the function's dependency on the CONFIG_PCIEAER_CXL kernel config because it is now an exported function.
Call pci_aer_unmask_internal_errors() during RAS initialization in:cxl_uport_init_ras_reporting() and cxl_dport_init_ras_reporting().
[1] PCIe Base Spec r6.2-1.0, 6.2.3.2.2 Masking Individual Errors
--- drivers/cxl/core/pci.c | 2 ++ drivers/pci/pcie/aer.c | 5 +++-- include/linux/aer.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/cxl/core/pci.c +2 -0
@@ -887,6 +887,7 @@ void cxl_uport_init_ras_reporting(struct cxl_port *port)cxl_assign_port_error_handlers (pdev);devm_add_action_or_reset (port->uport_dev, cxl_clear_port_error_handlers, pdev); +pci_aer_unmask_internal_errors (pdev); }EXPORT_SYMBOL_NS_GPL (cxl_uport_init_ras_reporting,CXL );
@@ -919,6 +920,7 @@ void cxl_dport_init_ras_reporting(struct cxl_dport *dport)cxl_assign_port_error_handlers (pdev);devm_add_action_or_reset (dport_dev, cxl_clear_port_error_handlers, pdev); +pci_aer_unmask_internal_errors (pdev); }EXPORT_SYMBOL_NS_GPL (cxl_dport_init_ras_reporting,CXL );
drivers/pci/pcie/aer.c +3 -2
@@ -949,7 +949,6 @@ static bool is_internal_error(struct aer_err_info *info)return info->status &PCI_ERR_UNC_INTN ; } -#ifdef CONFIG_PCIEAER_CXL /** * pci_aer_unmask_internal_errors - unmask internal errors * @dev: pointer to the pcie_dev data structure
@@ -960,7 +959,7 @@ static bool is_internal_error(struct aer_err_info *info)* Note: AER must be enabled and supported by the device which must be * checked in advance, e.g. with pcie_aer_is_native(). */ -static void pci_aer_unmask_internal_errors (struct pci_dev *dev) +void pci_aer_unmask_internal_errors (struct pci_dev *dev) {int aer = dev->aer_cap;u32 mask;
@@ -973,7 +972,9 @@ static void pci_aer_unmask_internal_errors(struct pci_dev *dev) mask &= ~PCI_ERR_COR_INTERNAL ;pci_write_config_dword (dev, aer +PCI_ERR_COR_MASK , mask); } +EXPORT_SYMBOL_NS_GPL (pci_aer_unmask_internal_errors,CXL ); +#ifdef CONFIG_PCIEAER_CXL static bool is_cxl_mem_dev (struct pci_dev *dev) {/*
include/linux/aer.h +1 -0
@@ -55,5 +55,6 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,int cper_severity_to_aer (int cper_severity);void aer_recover_queue (int domain,unsigned int bus,unsigned int devfn,int severity,struct aer_capability_regs *aer_regs); +void pci_aer_unmask_internal_errors (struct pci_dev *dev);#endif //_AER_H_
Signature · 1 line
2.34.1
Re: [PATCH v3 15/15] PCI/AER: Enable internal errors for CXL upstream and downstream switch ports
Quoted 2 lines · Terry Bowman
Export the AER service driver's
pci_aer_unmask_internal_errors()function to CXL namsespace.
^^^^^^^^^^ namespace
Quoted 2 lines
Remove the function's dependency on the
CONFIG_PCIEAER_CXLkernel config because it is now an exported function.
[...]
Quoted 11 lines
drivers/pci/pcie/aer.c +0
-1@@ -949,7 +949,6 @@ static bool is_internal_error(struct aer_err_info *info)return info->status &PCI_ERR_UNC_INTN ; } -#ifdef CONFIG_PCIEAER_CXL /** * pci_aer_unmask_internal_errors - unmask internal errors * @dev: pointer to the pcie_dev data structure
drivers/pci/pcie/aer.c static bool is_internal_error(struct aer_err_info *info) · line 962
Quoted 5 lines
drivers/pci/pcie/aer.c +1
-1@@ -960,7 +959,7 @@ static bool is_internal_error(struct aer_err_info *info)* Note: AER must be enabled and supported by the device which must be * checked in advance, e.g. with pcie_aer_is_native(). */ -static void pci_aer_unmask_internal_errors (struct pci_dev *dev) +void pci_aer_unmask_internal_errors (struct pci_dev *dev)
Hm, it seems the reason why you're moving pci_aer_unmask_internal_errors() outside of "ifdef CONFIG_PCIEAER_CXL" is that drivers/cxl/core/pci.c is conditional on CONFIG_CXL_BUS, whereas CONFIG_PCIEAER_CXL depends on CONFIG_CXL_PCI.
In other words, you need this to avoid build breakage if CONFIG_CXL_BUS is enabled but CONFIG_CXL_PCI is not.
I'm wondering (as a CXL ignoramus) why that can happen in the first place, i.e. why is drivers/cxl/core/pci.c compiled at all if CONFIG_CXL_PCI is disabled?
Thanks,
Lukas
Bowman, Terry
Reviewed-by Jonathan CameronRe: [PATCH v3 15/15] PCI/AER: Enable internal errors for CXL upstream and downstream switch ports
Quoted 5 lines · Lukas Wunner
Quoted 2 lines · Terry Bowman
Export the AER service driver's
pci_aer_unmask_internal_errors()function to CXL namsespace.^^^^^^^^^^ namespace
Yup, thanks.
Quoted 27 lines
Quoted 2 lines
Remove the function's dependency on the
CONFIG_PCIEAER_CXLkernel config because it is now an exported function.[...]
Quoted 11 lines
drivers/pci/pcie/aer.c +0
-1@@ -949,7 +949,6 @@ static bool is_internal_error(struct aer_err_info *info)return info->status &PCI_ERR_UNC_INTN ; } -#ifdef CONFIG_PCIEAER_CXL /** * pci_aer_unmask_internal_errors - unmask internal errors * @dev: pointer to the pcie_dev data structure drivers/pci/pcie/aer.c static bool is_internal_error(struct aer_err_info *info) · line 962
Quoted 5 lines
drivers/pci/pcie/aer.c +1
-1@@ -960,7 +959,7 @@ static bool is_internal_error(struct aer_err_info *info)* Note: AER must be enabled and supported by the device which must be * checked in advance, e.g. with pcie_aer_is_native(). */ -static void pci_aer_unmask_internal_errors (struct pci_dev *dev) +void pci_aer_unmask_internal_errors (struct pci_dev *dev)Hm, it seems the reason why you're moving
pci_aer_unmask_internal_errors()outside of "ifdefCONFIG_PCIEAER_CXL" is thatdrivers/cxl/core/pci.cis conditional onCONFIG_CXL_BUS, whereasCONFIG_PCIEAER_CXLdepends onCONFIG_CXL_PCI.In other words, you need this to avoid build breakage if
CONFIG_CXL_BUSis enabled butCONFIG_CXL_PCIis not.
Quoted 7 lines
I'm wondering (as a CXL ignoramus) why that can happen in the first place, i.e. why is
drivers/cxl/core/pci.ccompiled at all ifCONFIG_CXL_PCIis disabled?Thanks,
Lukas
I moved the function out of the 'ifdef' block because it would be used in another subsystem. Bjorn requested in earlier review that functions used across subsystems should not use ifdef.
The drivers/cxl/Makefile file shows CONFIG_CXL_PCI gates cxl_pci.c build with:
obj-$(CONFIG_CXL_PCI) += cxl_pci.o
BTW, CONFIG_CXL_PCI was added in the commit (68cdd3d2af69) below.
commit 68cdd3d2af6964dae2f8d9b53ee94f740dcbda35
Author: Ben Widawsky <[email protected]>
Date: Sun Jan 23 16:28:44 2022 -0800
cxl: Rename CXL_MEM to CXL_PCI
The cxl_mem module was renamed cxl_pci in commit 21e9f76733a8 ("cxl:
Rename mem to pci"). In preparation for adding an ancillary driver for cxl_memdev devices (registered on the cxl bus by cxl_pci), go ahead and rename CONFIG_CXL_MEM to CONFIG_CXL_PCI. Free up the CXL_MEM name for that new driver to manage CXL.mem endpoint operations.
Regards,
Terry
Re: [PATCH v3 15/15] PCI/AER: Enable internal errors for CXL upstream and downstream switch ports
Quoted 12 lines · Terry
Quoted 11 lines · Lukas Wunner
Hm, it seems the reason why you're moving
pci_aer_unmask_internal_errors()outside of "ifdefCONFIG_PCIEAER_CXL" is thatdrivers/cxl/core/pci.cis conditional onCONFIG_CXL_BUS, whereasCONFIG_PCIEAER_CXLdepends onCONFIG_CXL_PCI.In other words, you need this to avoid build breakage if
CONFIG_CXL_BUSis enabled butCONFIG_CXL_PCIis not.I'm wondering (as a CXL ignoramus) why that can happen in the first place, i.e. why is
drivers/cxl/core/pci.ccompiled at all ifCONFIG_CXL_PCIis disabled?
[...]
Quoted 2 lines
The
drivers/cxl/Makefilefile showsCONFIG_CXL_PCIgatescxl_pci.cbuild with:
obj-$(CONFIG_CXL_PCI) += cxl_pci.o
I wasn't referring to drivers/cxl/pci.c, but drivers/cxl/core/pci.c. That's gated by CONFIG_CXL_BUS, not CONFIG_CXL_PCI, which seems weird.
Thanks,
Lukas