Enable CXL PCIe Port Protocol Error handling and logging
Subsystems (5)
v20 cover Enable CXL PCIe Port Protocol Error handling and logging
This patch series enables CXL protocol error handling for both CXL Ports and CXL Endpoints (EP). The previous revision is available at:
https://lore.kernel.org/linux-cxl/[email protected]/
The first five patches of v19 (the two RCH register fixes, the raw_spinlock CPER conversion, the CPER kfifo API tightening, and the find_cxl_port rename) were picked up and applied to cxl/next, so this v20 posting is the remaining nine patches.
Today the kernel handles native CXL.cachemem RAS only for Endpoints and Restricted CXL Host (RCH) Downstream Ports. Root Ports, Upstream Switch Ports, and Downstream Switch Ports are uncovered. This series introduces a unified CXL protocol error path for all CXL device types, in both VH and RCH topologies.
CXL protocol errors are layered as a distinct error plane on top of PCIe AER. CXL RAS conditions are signaled as PCIe correctable (CE) and uncorrectable (UCE) Internal AER Errors. The AER driver classifies these events using pcie_is_cxl() and hands them off to cxl_core through the AER-CXL kfifo.
The cxl_core driver dequeues each event, resolves the cxl_port topology, and dispatches to the CE or UCE handler. RCD Endpoints are handled slightly differently: the RCH Downstream Port's RAS state is processed first, then the Endpoint's own RAS follows the common path.
A fatal UCE on an Upstream Switch Port or Endpoint surfaces through the AER path rather than the CXL RAS path. USP devices are bound to the PCIe portdrv driver, so when a USP reports a fatal UCE, the PCIe error handler provided by portdrv is invoked. PCI config reads to the source device are expected to fail in this scenario, so the AER core never retrieves UNCOR_STATUS, and the event cannot be classified as CXL. See the fatal and non-fatal log excerpts for USP and EP below.
== Patch Details ==
Patch 1 - PCI/AER: Introduce AER-CXL protocol error kfifo
Adds the AER-CXL kfifo in drivers/pci/pcie/aer_cxl_vh.c along with the producer helper cxl_forward_error() and the consumer registration helpers cxl_register_proto_err_work() and cxl_unregister_proto_err_work(). The kfifo delivers CXL VH protocol errors from the AER driver to cxl_core. On a full kfifo a correctable error is dropped rather than escalated, so a correctable-error storm cannot force the uncorrectable panic path.
Patch 2 - PCI: Establish common CXL Port protocol error flow Dequeues work from the AER-CXL kfifo and establishes a common flow for all CXL Port protocol error handling. Panics on any uncorrectable CXL RAS error. The producer dispatch and consumer go live atomically.
Patch 3 - cxl/ras: Handle RCH correctable and uncorrectable errors in one pass Folds Restricted CXL Host (RCH) error handling into the common Port flow. An RCD uncorrectable CXL RAS error now panics, matching the policy applied to all other CXL devices.
Patch 4 - cxl/pci: Thread port and dport through RAS handling helpers Refactors cxl_handle_ras() and cxl_handle_cor_ras() to accept struct cxl_port * and struct cxl_dport * directly, eliminating redundant bus walks on the error path.
Patch 5 - cxl: Update CXL Endpoint AER handler
Replaces cxl_error_detected() with cxl_pci_error_detected(). Reads CXL RAS unconditionally; panics on UCE regardless of channel state.
Patch 6 - PCI: Cache PCI DSN into pci_dev->dsn during probe Caches the PCI Device Serial Number at probe time so error handlers and panic paths avoid live config-space reads.
Patch 7 - cxl: Add port and dport identifiers to CXL AER trace events Passes struct cxl_port * and struct cxl_dport * to trace events. Adds new "port" and "dport" string fields for all CXL device classes.
Patch 8 - PCI/CXL: Mask/Unmask CXL protocol errors
Enables CXL Internal Error reporting on CXL Ports and Endpoints. The unmask is paired with RAS register block mapping; the mask is registered as a devres action.
Patch 9 - Documentation: cxl: Document CXL protocol error handling Adds protocol-error-handling.rst describing the end-to-end CXL protocol error path.
== Notes ==
- The CXL AER injection patch used for testing will be posted separately.
- Functional code changed since v19 in 4 patches:
- PCI/AER: Introduce AER-CXL protocol error kfifo
- PCI: Establish common CXL Port protocol error flow
- cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
- cxl: Add port and dport identifiers to CXL AER trace events
The remaining patches changed only comments/commit messages or are unchanged.
Reviewed-by tags are dropped for the 4 above patches.
- @Bjorn, I kindly request your review for the following patches:
Patch 1 - PCI/AER: Introduce AER-CXL protocol error kfifo Patch 2 - PCI: Establish common CXL Port protocol error flow Patch 6 - PCI: Cache PCI DSN into pci_dev->dsn during probe Patch 8 - PCI/CXL: Mask/Unmask CXL protocol errors
- USP/EP fatal UCE follows the AER path because of how the AER core collects status. aer_get_device_error_info() only reads PCI_ERR_UNCOR_STATUS for Root Ports/RCECs/Downstream Ports or non-fatal severities, where config reads to the source are still expected to succeed. For a fatal UCE signaled by an upstream component, config reads to that device are expected to fail, so UNCOR_STATUS is never retrieved. Without the status word, is_cxl_error() cannot classify the event as CXL and the AER path handles it.
- Dan's related series addressing RAS setup has more details:
https://lore.kernel.org/linux-cxl/[email protected]/
- TODOs for future series:
- Move aer_cxl_rch.c to cxl/core/ras_rch.c
- Move RCH traversing for handling from AER driver into CXL driver
- Add CXL Port traversing in cxl_do_recovery()
- Apply the panic-on-any-UCE policy to the firmware-first (CPER/GHES) consumer, which is currently trace-only for a non-fatal UCE
- Fix cxl_dport_map_rch_aer() to request the physical AER register block size instead of sizeof(struct aer_capability_regs)
- RCH uncorrectable logging prints unconditionally, which may duplicate a line already logged via the AER core's ANFE recursion, and double-count that event in the per-device AER statistics. Only affects RCH/RCD with an Advisory Non-Fatal Error present. Precise de-dup needs the core to expose aer_compute_anfe_status(), which is static.
== Testing ==
CXL protocol error injection was re-run on this v20 series via /sys/kernel/debug/cxl/aer_einj_inject. Virtual Hierarchy (VH) was exercised under QEMU (Q35); Restricted CXL Host (RCH) and RCD were exercised on real hardware (AMD ONYX). The VH sub-topology is:
---------------------
| CXL RP - 0c:00.0 |
---------------------
|
---------------------
| CXL USP - 0d:00.0 |
---------------------
|
---------------------
| CXL DSP - 0e:00.0 |
---------------------
|
---------------------
| CXL EP - 0f:00.0 |
---------------------Error Injection Test Results Summary:
Virtual Hierarchy (VH) - QEMU (Q35):
| # | Device Type | BDF | Test | Result | AER | RAS | Verdict | |---|------------------|---------|------|-----------|-----|-----|------------------| | 1 | Root Port | 0c:00.0 | CE | Recovered | OK | OK | PASS | | 2 | Root Port | 0c:00.0 | UCE | Panic | OK | OK | PASS | | 3 | Upstream Port | 0d:00.0 | CE | Recovered | OK | OK | PASS | | 4 | Upstream Port | 0d:00.0 | UCE | Recovered | OK | -- | PASS (Known Lim) | | 5 | Downstream Port | 0e:00.0 | CE | Recovered | OK | OK | PASS | | 6 | Downstream Port | 0e:00.0 | UCE | Panic | OK | OK | PASS | | 7 | Endpoint | 0f:00.0 | CE | Recovered | OK | OK | PASS | | 8 | Endpoint | 0f:00.0 | UCE | Panic | OK | OK | PASS |
Restricted CXL Host (RCH) / RCD - real hardware:
| # | Device Type | BDF | Test | Result | AER | RAS | Verdict | |---|----------------------|---------|------|-----------|-----|-----|---------| | 1 | RCD Endpoint | 7f:00.0 | CE | Recovered | OK | OK | PASS | | 2 | RCD Endpoint | 7f:00.0 | UCE | Panic | OK | OK | PASS | | 3 | RCH Downstream Port | 7f:00.0 | CE | Recovered | OK | OK | PASS | | 4 | RCH Downstream Port | 7f:00.0 | UCE | Panic | OK | OK | PASS |
=== Root Port - CE ===
echo "0000:0c:00.0 CE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
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
pcieport 0000:0c:00.0: device [8086:7075] error status/mask=00004000/00008000
pcieport 0000:0c:00.0: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev= port=port1 dport=0000:0c:00.0 host=pci0000:0c serial=0: status: 'Memory Data ECC Error'
=== Root Port - UCE ===
echo "0000:0c:00.0 UCE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
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)
pcieport 0000:0c:00.0: device [8086:7075] error status/mask=00400000/02000000
pcieport 0000:0c:00.0: [22] UncorrIntErr | Component | Generalcxl_aer_uncorrectable_error: memdev= port=port1 dport=0000:0c:00.0 host=pci0000:0c serial=0: status: 'Cache Address Parity Error' first_error: 'Cache Address Parity Error'
Kernel panic - not syncing: CXL cachemem error Workqueue: events cxl_proto_err_work_fn Call Trace: <TASK> panic+0x56/0x60 cxl_do_recovery+0xa9/0xb0 __cxl_proto_err_work_fn+0x9c/0x1d0 for_each_cxl_proto_err+0x5a/0x80 cxl_proto_err_work_fn+0x26/0x50 process_one_work+0x1a2/0x3e0 worker_thread+0x172/0x2e0 kthread+0xe7/0x120 ret_from_fork+0x1bd/0x220 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end Kernel panic - not syncing: CXL cachemem error ]---
=== Upstream Switch Port - CE ===
echo "0000:0d:00.0 CE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
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
pcieport 0000:0d:00.0: device [19e5:a128] error status/mask=00004000/00008000
pcieport 0000:0d:00.0: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev= port=port2 dport= host=0000:0d:00.0 serial=0: status: 'Memory Data ECC Error'
=== Upstream Switch Port - UCE (fatal - AER recovery, known limitation) ===
echo "0000:0d:00.0 UCE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) Error message received from 0000:0d:00.0 pcieport 0000:0d:00.0: AER: CXL Bus Error: severity=Uncorrectable (Fatal) (Inaccessible) cxl_pci 0000:0f:00.0: mem0: frozen state error detected, disable CXL.mem pcieport 0000:0c:00.0: AER: Root Port link has been reset (0)cxl_pci 0000:0f:00.0: mem0: restart CXL.mem after slot resetcxl_pci 0000:0f:00.0: mem0: error resume successful
pcieport 0000:0c:00.0: AER: device recovery successful
=== Downstream Switch Port - CE ===
echo "0000:0e:00.0 CE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
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
pcieport 0000:0e:00.0: device [19e5:a129] error status/mask=00004000/00008000
pcieport 0000:0e:00.0: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev= port=port2 dport=0000:0e:00.0 host=0000:0d:00.0 serial=0: status: 'Memory Data ECC Error'
=== Downstream Switch Port - UCE ===
echo "0000:0e:00.0 UCE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
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)
pcieport 0000:0e:00.0: device [19e5:a129] error status/mask=00400000/02000000
pcieport 0000:0e:00.0: [22] UncorrIntErr | Component | Generalcxl_aer_uncorrectable_error: memdev= port=port2 dport=0000:0e:00.0 host=0000:0d:00.0 serial=0: status: 'Cache Address Parity Error' first_error: 'Cache Address Parity Error'
Kernel panic - not syncing: CXL cachemem error Workqueue: events cxl_proto_err_work_fn Call Trace: <TASK> panic+0x56/0x60 cxl_do_recovery+0xa9/0xb0 __cxl_proto_err_work_fn+0x9c/0x1d0 for_each_cxl_proto_err+0x5a/0x80 cxl_proto_err_work_fn+0x26/0x50 process_one_work+0x1a2/0x3e0 worker_thread+0x172/0x2e0 kthread+0xe7/0x120 ret_from_fork+0x1bd/0x220 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end Kernel panic - not syncing: CXL cachemem error ]---
=== Endpoint - CE ===
echo "0000:0f:00.0 CE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:0c:00.0: AER: Correctable Error message received from 0000:0f:00.0cxl_pci 0000:0f:00.0: CXL Bus Error: severity=Correctablecxl_pci 0000:0f:00.0: device [8086:0d93] error status/mask=00004000/00008000cxl_pci 0000:0f:00.0: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev=mem0 port=endpoint3 dport= host=0000:0f:00.0 serial=0: status: 'Memory Data ECC Error'
=== Endpoint - UCE ===
echo "0000:0f:00.0 UCE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:0c:00.0: AER: Uncorrectable (Fatal) Error message received from 0000:0f:00.0cxl_pci 0000:0f:00.0: AER: CXL Bus Error: severity=Uncorrectable (Fatal) (Inaccessible)cxl_aer_uncorrectable_error: memdev=mem0 port=endpoint3 dport= host=0000:0f:00.0 serial=0: status: 'Cache Address Parity Error' first_error: 'Cache Address Parity Error'
Kernel panic - not syncing: CXL cachemem error Call Trace: <TASK> panic+0x56/0x60 cxl_pci_error_detected+0x18b/0x190 report_error_detected+0xc7/0x1c0 pci_walk_bus+0x2c/0x40 pcie_do_recovery+0x2ed/0x430 aer_isr_one_error_type+0x35f/0x370 aer_isr_one_error+0x112/0x140 aer_isr+0x47/0x80 irq_thread_fn+0x1f/0x60 irq_thread+0x123/0x220 kthread+0xe7/0x120 ret_from_fork+0x1bd/0x220 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end Kernel panic - not syncing: CXL cachemem error ]---
=== Restricted CXL Host (RCH) / RCD ===
RCH and RCD protocol error injection was run on real hardware (AMD ONYX, onyx-7628host) targeting the RCiEP 0000:7f:00.0 under host bridge pci0000:7f. The "RCH" variant exercises the RCH Downstream Port handler (cxl_handle_rdport_errors()); the plain variant targets the RCD Endpoint.
=== RCD Endpoint - CE ===
echo "0000:7f:00.0 CE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:40:00.3: AER: Correctable Error message received from 0000:40:00.3
pcieport 0000:40:00.3: PCIe Bus Error: severity=Correctable
pcieport 0000:40:00.3: device [1022:14a6] error status/mask=00004000/00002000
pcieport 0000:40:00.3: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev=mem0 port=endpoint1 dport= host=0000:7f:00.0 serial=0: status: 'Memory Data ECC Error'
=== RCH Downstream Port - CE ===
echo "0000:7f:00.0 CE 00000000 2 RCH" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:40:00.3: AER: Correctable Error message received from 0000:40:00.3
pcieport 0000:40:00.3: PCIe Bus Error: severity=Correctable
pcieport 0000:40:00.3: device [1022:14a6] error status/mask=00004000/00002000
pcieport 0000:40:00.3: [14] CorrIntErr | Component | Generalcxl_pci 0000:7f:00.0: aer_cor_status: 0x00004000, aer_cor_mask: 0x00000000cxl_pci 0000:7f:00.0: [14] CorrIntErr | Component | Generalcxl_aer_correctable_error: memdev= port=root0 dport=pci0000:7f host=ACPI0017:00 serial=0: status: 'Memory Data ECC Error'
=== RCD Endpoint - UCE ===
echo "0000:7f:00.0 UCE 00000000 2" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:40:00.3: AER: Uncorrectable (Non-Fatal) Error message received from 0000:40:00.3
pcieport 0000:40:00.3: PCIe Bus Error: severity=Uncorrectable (Non-Fatal)
pcieport 0000:40:00.3: device [1022:14a6] error status/mask=00400000/00000000
pcieport 0000:40:00.3: [22] UncorrIntErr | Component | Generalcxl_aer_uncorrectable_error: memdev=mem0 port=endpoint1 dport= host=0000:7f:00.0 serial=0: status: 'Cache Address Parity Error' first_error: 'Cache Address Parity Error'
Kernel panic - not syncing: CXL cachemem error Hardware name: AMD Corporation ONYX/ONYX, BIOS TOX100HB 12/03/2025 Workqueue: events cxl_proto_err_work_fn ---[ end Kernel panic - not syncing: CXL cachemem error ]---
=== RCH Downstream Port - UCE ===
echo "0000:7f:00.0 UCE 00000000 2 RCH" > /sys/kernel/debug/cxl/aer_einj_inject
pcieport 0000:40:00.3: AER: Uncorrectable (Non-Fatal) Error message received from 0000:40:00.3
pcieport 0000:40:00.3: PCIe Bus Error: severity=Uncorrectable (Non-Fatal)
pcieport 0000:40:00.3: device [1022:14a6] error status/mask=00400000/00000000
pcieport 0000:40:00.3: [22] UncorrIntErr | Component | Generalcxl_pci 0000:7f:00.0: aer_uncor_status: 0x00400000, aer_uncor_mask: 0x00000000cxl_pci 0000:7f:00.0: [22] UncorrIntErr | Component | Generalcxl_pci 0000:7f:00.0: aer_uncor_severity: 0x00400000cxl_aer_uncorrectable_error: memdev= port=root0 dport=pci0000:7f host=ACPI0017:00 serial=0: status: 'Cache Address Parity Error' first_error: 'Cache Address Parity Error'
Kernel panic - not syncing: CXL cachemem error Workqueue: events cxl_proto_err_work_fn Call Trace: <TASK> panic+0x56/0x60 cxl_do_recovery+0xa9/0xb0 cxl_handle_rdport_errors+0x285/0x290 __cxl_proto_err_work_fn+0x155/0x1d0 for_each_cxl_proto_err+0x5a/0x80 cxl_proto_err_work_fn+0x26/0x50 process_one_work+0x1a2/0x3e0 worker_thread+0x172/0x2e0 kthread+0xe7/0x120 ret_from_fork+0x1bd/0x220 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end Kernel panic - not syncing: CXL cachemem error ]---
== Changes ==
Changes in v19 -> v20:
NOTE: v19 patches 1-5 were merged to cxl/next. The nine patches below are the
remainder.
PCI/AER: Introduce AER-CXL protocol error kfifo
- Drop a correctable error on full kfifo instead of panicking
- Add explicit ATOMIC_INIT(0) for flush_inflight
- Change is_aer_internal_error() to use mask in evaluation.
- Condense commit message (Jonathan)
- Document constraints for_each_cxl_proto_err()
- Document the @wd and @fn parameters of for_each_cxl_proto_err() (kernel-doc)
PCI: Establish common CXL Port protocol error flow
- Condense commit message (Jonathan)
- Document simultaneous RCH CE+UCE handling in next patch
- Document the cxl_handle_rdport() dport lock
cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
- Add snapshot of aer_regs before the correctable pci_print_aer(). (Sashiko)
- Log the UCE status unconditionally instead of skipping on PCI_ERR_COR_ADV_NFAT
- Add Reviewed-by from Alison Schofield
cxl/pci: Thread port and dport through RAS handling helpers
- None
cxl: Update CXL Endpoint AER handler
- Expand the comment block in cxl_pci_error_detected().
- Clarify commit message's first paragraph. cxl_error_handlers is a variable
- Clarify AER handling in cxl_pci_error_detected() block comment
PCI: Cache PCI DSN into pci_dev->dsn during probe
- Change 2 space to 1 space in comment block in pci_dsn_init
- Add Reviewed-by from Alison Schofield
cxl: Add port and dport identifiers to CXL AER trace events
- Remove host->driver gate. Not required for dev_name() call PCI/CXL: Mask/Unmask CXL protocol errors
- None
Documentation: cxl: Document CXL protocol error handling
- Document the kfifo-overflow panic policy
- Name the CXL Host Bridge device lock (port->uport_dev) in RCH case
- Reword the cxl_do_recovery() no-UE-bits path
- Fix CPER path description: firmware-first is trace-only, no panic
- Diagram: EP RAS read is channel-state independent, not "unconditional"
- Fix cxl_handle_ras() argument count in the fatal-UCE diagram
- Clarify .error_detected skips RAS read without panic when unmapped
Changes in v18->v19:
cxl/ras: Fix cxl_rch_get_aer_info() out-of-bounds AER register read
- New commit. Prepended as first patch in the series. Fixes an out-of-bounds AER register read in the RCH AER info collection path.
cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
- Renamed from "PCI/CXL: Add RCH support to CXL handlers". Reworked to handle RCH correctable and uncorrectable errors in a single pass.
cxl: Add port and dport identifiers to CXL AER trace events
- Reordered to follow "PCI: Cache PCI DSN into pci_dev->dsn during probe".
Documentation: cxl: Document CXL protocol error handling
- Expanded protocol-error-handling.rst.
Changes in v17->v18:
acpi/apei/ghes: Use raw_spinlock_t for CXL CPER work locks
- New commit
- Convert cxl_cper_work_lock and cxl_cper_prot_err_work_lock from spinlock_t to raw_spinlock_t; use guard(raw_spinlock_irqsave) at
all call sites to avoid sleeping-in-hardirq on PREEMPT_RT.
- Add kfifo_reset(&cxl_cper_fifo) to cxl_cper_unregister_work()
- Add WARN_ONCE to cxl_cper_register_work() for double-registration consistency
- Fix cxl_cper_unregister_work() to clear global pointer before cancel_work_sync()
- Remove redundant cancel_work_sync() from cxl_ras_exit()
cxl: Tighten CPER kfifo registration API and symbol visibility
- New commit (split/rework of v17 "Limit CXL-CPER kfifo registration functions scope")
cxl: Rename find_cxl_port() to find_cxl_port_by_dport()
- None
PCI/AER: Introduce AER-CXL protocol error kfifo
- Remove correctable status clear from cxl_forward_error(); the AER core clears all status bits via pci_aer_handle_error() info->status writeback
- Schedule consumer on kfifo overflow so existing entries can be drained
PCI: Establish common CXL Port protocol error flow
- Fix handle_error_source() to call pci_aer_handle_error() unconditionally so AER handling always runs after cxl_forward_error()
- Add cxl_proto_err_flush() call for CXL UCE to drain kfifo before AER recovery tears down the device
- Fix NULL dereference of dport->dport_dev in cxl_handle_cor_ras() and cxl_handle_ras() for UPSTREAM/ENDPOINT port types: use dport->dport_dev when dport is non-NULL, else fall back to port->uport_dev
- Remove duplicate pcie_clear_device_status() call from cxl_handle_proto_error() CE path; pci_aer_handle_error() already clears it
- Clarify panic policy: panic only on confirmed UCE via RAS status read
- Document kfifo consumer serialization against driver unbind via guard(device)(&port->dev) and port->dev.driver check
PCI/CXL: Add RCH support to CXL handlers
- Pass &pdev->dev instead of dport->port->uport_dev in cxl_handle_rdport_errors() to avoid dropping RCH trace events.
- Document trace event attribution change.
- Document removal of cxl_cor_error_detected() and cxlds->rcd branches.
- Capitalize Endpoint per PCI spec convention.
- Use to_ras_base() in cxl_handle_rdport_errors() to centralize RAS base address lookup in preparation for error injection testing.
cxl/pci: Thread port and dport through RAS handling helpers
- New commit
cxl: Update CXL Endpoint AER handler
- Fix cxl_pci_error_detected() to use find_cxl_port_by_uport() and port->uport_dev
- Read CXL RAS unconditionally; panic on UCE regardless of channel state
- Document unconditional read policy and 0xFFFFFFFF behavior in comment
cxl: Add port and dport identifiers to CXL AER trace events
- Consolidate double find_cxl_port_by_dev() in cxl_cper_handle_prot_err()
- Add comment noting dport is NULL for endpoint and upstream port devices
PCI: Cache PCI DSN into pci_dev->dsn during probe
- New commit
PCI/CXL: Mask/Unmask CXL protocol errors
- Make cxl_unmask_proto_interrupts() and cxl_mask_proto_interrupts() static
- Remove dev_is_pci() guard from devm_cxl_dport_rch_ras_setup(); the guard blocked real RCH hardware because pci_host_bridge is not on pci_bus_type
Documentation: cxl: Document CXL protocol error handling
- Simplify document for readability (Jonathan)
- Drop historical context that goes stale (Jonathan)
- Shorten ASCII flow diagram (Jonathan)
- Drop manual backtick markup, use automarkup (Jonathan)
- Clarify USP/DSP as single switch component (Dave)
- Fix line wrapping to 80 chars (Jonathan)
Changes in v16->v17:
PCI/AER: Introduce AER-CXL Kfifo
- Reword "kfifo semaphore" to "kfifo spinlock" to match fifo_lock.
- Defer the handle_error_source() is_cxl_error() switch to the patch that registers the kfifo consumer to keep each commit bisect-safe.
- Rename rwsema to rwsem
- Change CPER exports to use EXPORT_SYMBOL_FOR_MODULES.
- Add work cancel function.
- Replace kfifo_put() with kfifo_in_spinlocked() for multiple producers
- Add fifo_lock spinlock for concurrent producer serialisation
- Initialize the embedded kfifo with INIT_KFIFO() in a subsys_initcall so kfifo->mask, ->esize and ->data are set before first use.
- Clear PCI_ERR_COR_STATUS in cxl_forward_error() before enqueue so the device is acked for correctable events even when the consumer drops the event. Uncorrectable status is left for cxl_do_recovery() to clear after recovery completes, mirroring the AER core convention.
- WARN on double-registration in cxl_register_proto_err_work() to make an unintended second consumer visible at runtime.
- Add direct rwsem.h, cleanup.h and workqueue.h includes for symbols used in aer_cxl_vh.c
- Add MAINTAINERS entries for drivers/pci/pcie/aer_cxl_*.c
- Update message
cxl/ras: Unify Endpoint and Port AER trace events
- Replace cxlds->serial with pci_get_dsn()
- Change 'memdev' to 'device' (Dan)
- Updated Commit message
cxl: Use common CPER handling for all CXL devices
- New commit
cxl: Rename find_cxl_port() to find_cxl_port_by_dport()
- New commit
- Drop the de-staticisation of find_cxl_port_by_uport() and the core.h declarations from this prep patch; both move to the patch that introduces the first cross-file caller.
cxl: Limit CXL-CPER kfifo registration functions scope
- Split from v16 02/10 ("Update unregistration for AER-CXL and CPER-CXL kfifos"); AER-CXL half folded into v17 01/10.
- Convert exports to EXPORT_SYMBOL_FOR_MODULES("cxl_core").
- Change register/unregister return type from int to void.
- Drop work_struct argument from cxl_cper_unregister_prot_err_work(); it now cancels its own work.
- Remove now-redundant cancel_work_sync() from cxl_ras_exit().
- Add WARN_ONCE() in cxl_cper_register_prot_err_work() for double-registration.
PCI: Establish common CXL Port protocol error flow
- get_cxl_port() -> find_cxl_port_by_dev()
- Simplified find_cxl_port_by_dev()
- Replace and remove cxl_serial_number() w/ pci_get_dsn()
- cxl_get_ras_base() -> to_ras_base()
- Drop dependency on PCI_ERS_RESULT_PANIC; cxl_do_recovery() panics directly. (PANIC enum patch dropped from series.)
- Clarify panic semantics: panic on any uncorrectable CXL RAS error, not only AER-FATAL severities.
- Drop the redundant PCI_ERR_COR_STATUS RMW in cxl_handle_proto_error(); cxl_forward_error() already acks the correctable AER status.
- Add is_cxl_error() switch in handle_error_source() here, paired with the kfifo consumer registration, to keep each commit bisect-safe.
- Drop pcie_aer_is_native() guard in cxl_do_recovery() (always native).
- Swap order with the "Limit" patch for bisectability w/ cxl_ras_exit()
- Reword for "any uncorrectable" CXL RAS error panics.
- Restore log messages for port-not-found and port-unbound cases.
- Whitespace cleanup (Jonathan)
- Update to get_cxl_port() documentation (Terry)
- Fix __cxl_proto_err_work_fn() to return 0 for transient errors.
- Drop !port check in cxl_do_recovery(), caller already validated
- Fix kerneldoc @pdev -> @dev in find_cxl_port_by_dev()
- Fix missing space in pr_err_ratelimited()
- Add disconnect check before access
- Made pcie_clear_device_status() and pci_aer_clear_fatal_status() EXPORT_SYMBOL_FOR_MODULES("cxl_core") (Dan)
- Move find_cxl_port_by_dport() and find_cxl_port_by_uport() de-staticisation and core.h declarations from the rename patch to here, where the first cross-file callers in find_cxl_port_by_dev() land.
PCI/CXL: Add RCH support to CXL handlers
- Drop now-dead cxlds->rcd branches from cxl_{cor_,}error_detected().
- Drop duplicate subject line from commit body.
- Document panic-on-uncorrectable behavior change for RCD path.
- Document trace event device-name change (memN -> PCI BDF) for RCH path.
- Rewrite cxl_handle_proto_error() RC_END comment to clarify RCD/RCH shared interrupt relationship
- Rewrite commit message
cxl: Remove Endpoint AER correctable handler
- Update commit message
- Add Reviewed-by from Jonathan and DaveJ
cxl: Update Endpoint AER uncorrectable handler
- Rename pci_error_handlers struct instance to cxl_pci_error_handlers to avoid shadowing the struct type tag.
- Restore scoped_guard(device) and dev->driver check around AER read.
- NULL-check find_cxl_port_by_dev() before deref of port->uport_dev.
- Updated commit message. (Terry)
- Add scope cleanup for port variable in cxl_pci_error_detected() (Terry)
- Drop cxl_uncor_aer_present(), rely on AER state
PCI/CXL: Mask/Unmask CXL protocol errors
- Drop redundant cxl_mask_proto_interrupts() calls from unregister_port() and cxl_dport_remove(); the devres action registered alongside the unmask is the sole mask path.
- Update title
- Remove unnecessary check for aer_capabilities
- Gate cxl_unmask_proto_interrupts() on pcie_aer_is_native()
- Add pci_aer_mask_internal_errors() and cxl_mask_proto_interrupts()
- Only unmask on successful cxl_map_component_regs()
- NULL-check @dev in cxl_{un,}mask_proto_interrupts()
- Drop static and declare in core/core.h
Documentation: cxl: Document CXL protocol error handling
- New commit
Changes in v15->v16:
PCI/AER: Introduce AER-CXL Kfifo
- Add pci_dev_put() and comment at pci_dev_get() (Dan)
- /rw_sema/rwsema/ (Dan)
- Split validation checks in cxl_forward_error() to allow for meaningful reason in log (Terry)
- Shortened commit title to remove wordiness (Terry) PCI/CXL: Update unregistration for AER-CXL and CPER-CXL kfifos
- New commit
cxl: Update CXL Endpoint tracing
- Add Dan's review-by
- Incorporate Dan's comment into commit message:
"Add the serial number at the end to preserve compatibility with libtraceevent parsing of the parameters."
PCI/ERR: Introduce PCI_ERS_RESULT_PANIC
- None
PCI: Establish common CXL Port protocol error flow
- get_ras_base(), initialize dport to NULL (Jonathan)
- Remove guard(device)(&cxlmd->dev) (Jonathan)
- Fix dev_warns() (Jonathan)
- Remove comment in cxl_port_error_detected() (Dan)
- Made pcie_clear_device_status() and pci_aer_clear_fatal_status() "CXL" Export namespace (Dan)
- Update switch-case brackets to follow clang-format (Dan)
- Add PCI_EXP_TYPE_RC_END for cxl_get_ras_base() (Terry)
- Add NULL port check in cxl_serial_number() (Terry) PCI/CXL: Add RCH support to CXL handlers
- New commit
cxl: Update error handlers to support CXL Port devices
- None
cxl: Update Endpoint AER uncorrectable handler
- Update commit message (DaveJ)
- s/cxl_handle_aer()/cxl_uncor_aer_present()/g (Jonathan)
- cxl_uncor_aer_present(): Leave original result calculation based on if a UCE is present and the provided state (Terry)
- Add call to pci_print_aer(). AER fails to log because is upstream link (Terry)
cxl: Remove Endpoint AER correctable handler
- None
cxl: Enable CXL protocol error reporting
- None
Changes in v14->v15:
PCI/AER: Introduce AER-CXL Kfifo in new file, pcie/aer_cxl_vh.c
- Move pci_dev_get() call to this patch (Dave)
cxl: Update CXL Endpoint tracing
- Update commit message
- Moved cxl_handle_ras/cxl_handle_cor_ras() changes to future patch (Terry) PCI/ERR: Introduce PCI_ERS_RESULT_PANIC
- None
PCI/AER: Dequeue forwarded CXL error
- Move pci_dev_get() to cxl_forward_error() (Dave)
- Move in is_cxl_error() change from later patch (Terry)
PCI: Establish common CXL Port protocol error flow
- Update commit message and title. Added Bjorn's ack.
- Move CE and UCE handling logic here (Terry)
cxl: Update error handlers to support CXL Port protocol errors
- New commit (Terry)
cxl: Update Endpoint AER uncorrectable handler
- Title update (Terry)
- Change cxl_pci_error-detected() to handle & log AER (Terry)
- Update commit message (Terry)
- Moved cxl_handle_ras()/cxl_handle_cor_ras() to earlier patch (Terry)
cxl: Remove Endpoint AER correctable handler
- Remove cxl_pci_cor_error_detected(). Is not needed. AER is logged in the AER driver. (Dan)
- Update commit message
Changes in v13->v14:
PCI: Move CXL DVSEC definitions into uapi/linux/pci_regs.h
- Add Jonathan's and Dan's review-by
- Update commit title prefix (Bjorn)
- Revert format fix for cxl_sbr_masked() (Jonathan)
- Update 'Compute Express Link' comment block (Jonathan)
- Move PCI_DVSEC_CXL_FLEXBUS definitions to later patch where
used (Jonathan)
- Removed stray change (Bjorn)
PCI: Update CXL DVSEC definitions
- New patch. Split from previous patch such that there is now a separate move patch and a format fix patch.
- Formatting update requested (Bjorn)
- Remove PCI_DVSEC_HEADER1_LENGTH_MASK because it duplicates PCI_DVSEC_HEADER1_LEN() (Bjorn)
- Add Dan's review-by
PCI: Introduce pcie_is_cxl()
- Move FLEXBUS_STATUS DVSEC here (Jonathan)
- Remove check for EP and USP (Dan)
- Update commit message (Bjorn)
- Fix writing past 80 columns (Bjorn)
- Add pci_is_pcie() parent bridge check at beginning of function (Bjorn)
PCI: Replace cxl_error_is_native() with pcie_aer_is_native()
- New commit
cxl/pci: Move CXL driver's RCH error handling into core/ras_rch.c
- Add sign-off for Dan and Jonathan
- Revert inadvertent formatting of cxl_dport_map_rch_aer() (Jonathan)
- Remove default value for CXL_RCH_RAS (Dan)
- Remove unnecessary pci.h include in core.h & ras_rch.c (Jonathan)
- Add linux/types.h include in ras_rch.c (Jonathan)
- Change CONFIG_CXL_RCH_RAS -> CONFIG_CXL_RAS (Dan)
PCI/AER: Export pci_aer_unmask_internal_errors
- New commit. Bjorn requested separating out and adding immediatetly before being used. This is called from cxl_rch_enable_rcec() in following patch.
PCI/AER: Update is_internal_error() to be non-static is_aer_internal_error()
- New commit
PCI/AER: Move CXL RCH error handling to aer_cxl_rch.c
- Add review-by and signed-off for Dan
- Commit message fixup (Dan)
- Update commit message with use-case description (Dan, Lukas)
- Make cxl_error_is_native() static (Dan)
- Make is_internal_error() non-static, non-export (Terry)
PCI/AER: Use guard() in cxl_rch_handle_error_iter()
- Add review-by for Jonathan, Dave Jiang, Dan WIlliams, and Bjorn
- Remove cleanup.h (Jonathan)
- Reverted comment removal (Bjorn)
- Move this patch after pci/pcie/aer_cxl_rch.c creation (Bjorn) PCI/AER: Replace PCIEAER_CXL symbol with CXL_RAS
- New commit
PCI/AER: Report CXL or PCIe bus type in AER trace logging
- Merged with Dan's commit. Changes are moving bus_type the last parameter in function calls (Dan)
- Removed all DCOs because of changes (Terry)
- Update commit message (Bjorn)
- Add Bjorn's ack-by
PCI/AER: Update struct aer_err_info with kernel-doc formatting
- New commit
cxl/mem: Clarify @host for devm_cxl_add_nvdimm()
- New commit
cxl/port: Remove "enumerate dports" helpers
- New commit
cxl/port: Fix devm resource leaks around with dport management
- New commit
cxl/port: Move dport operations to a driver event
- New commit
cxl/port: Move dport RAS reporting to a port resource
- New commit
cxl: Map CXL Endpoint Port and CXL Switch Port RAS registers
- Correct message spelling (Terry)
cxl/port: Move endpoint component register management to cxl_port
- Correct message spelling (Terry)
cxl/port: Map Port component registers before switchport init
- Updates to use cxl_port_setup_regs() (Dan)
cxl: Change CXL handlers to use guard() instead of scoped_guard()
- Add reviewed-by for Jonathan and Dave Jiang
PCI/ERR: Introduce PCI_ERS_RESULT_PANIC
- Add review-by for Dan
- Update Title prefix (Bjorn)
- Removed merge_result. Only logging error for device reporting the error (Dan)
- Remove PCI_ERS_RESULT_PANIC paragraph in pci-error-recovery.rst (Bjorn) PCI/AER: Move AER driver's CXL VH handling to pcie/aer_cxl_vh.c
- Replaced workqueue_types.h include with 'struct work_struct' predeclaration (Bjorn)
- Update error message (Bjorn)
- Reordered 'struct cxl_proto_err_work_data' (Bjorn)
- Remove export of cxl_error_is_native() here (Bjorn)
cxl/port: Unify endpoint and switch port lookup
- New patch
PCI/AER: Dequeue forwarded CXL error
- Update commit title's prefix (Bjorn)
- Add pdev ref get in AER driver before enqueue and add pdev ref put in CXL driver after dequeue and handling (Dan)
- Removed handling to simplify patch context (Terry)
PCI: Introduce CXL Port protocol error handlers
- Add Dave Jiang's review-by
- Update commit message & headline (Bjorn)
- Refactor cxl_port_error_detected()/cxl_port_cor_error_detected() to one line (Jonathan)
- Remove cxl_walk_port(). Only log the erroring device. No port walking. (Dan)
- Remove cxl_pci_drv_bound(). Check for 'is_cxl' parent port is sufficient (Dan)
- Remove device_lock_if()
- Combine CE and UCE here (Terry)
cxl: Update Endpoint uncorrectable protocol error handling
- Update commit headline (Bjorn)
- Rename pci_error_detected()/pci_cor_error_detected() -> cxl_pci_error_detected/cxl_pci_cor_error_detected() (Jonathan)
- Remove now-invalid comment in cxl_error_detected() (Jonathan)
- Split into separate patches for UCE and CE (Terry)
cxl: Update Endpoint correctable protocol error handling
- New commit
- Change cxl_cor_error_detected() parameter to &pdev->dev device from memdev device. (Terry)
cxl: Enable CXL protocol errors during CXL Port probe
- Update commit title's prefix (Bjorn)
Changes in v12->v13:
CXL/PCI: Move CXL DVSEC definitions into uapi/linux/pci_regs.h
- Add Dave Jiang's reviewed-by
- Remove changes to existing PCI_DVSEC_CXL_PORT* defines. Update commit message. (Jonathan)
PCI/CXL: Introduce pcie_is_cxl()
- Add Ben's "reviewed-by"
cxl/pci: Remove unnecessary CXL Endpoint handling helper functions
- None
cxl/pci: Remove unnecessary CXL RCH handling helper functions
- None
cxl: Remove CXL VH handling in CONFIG_PCIEAER_CXL conditional blocks from core
- None
cxl: Move CXL driver's RCH error handling into core/ras_rch.c
- None
CXL/AER: Replace device_lock() in cxl_rch_handle_error_iter() with guard() lock
- New patch
CXL/AER: Move AER drivers RCH error handling into pcie/aer_cxl_rch.c
- Add forward declararation of 'struct aer_err_info' in pci/pci.h (Terry)
- Changed copyright date from 2025 to 2023 (Jonathan)
- Add David Jiang's, Jonathan's, and Ben's review-by
- Readd 'struct aer_err_info' (Bot)
PCI/AER: Report CXL or PCIe bus error type in trace logging
- Remove duplicated aer_err_info inline comments. Is already in the kernel-doc header (Ben)
cxl/pci: Update RAS handler interfaces to also support CXL Ports
- None
cxl/pci: Log message if RAS registers are unmapped
- Added Bens review-by
cxl/pci: Unify CXL trace logging for CXL Endpoints and CXL Ports
- Added Dave Jiang's review-by
cxl/pci: Update cxl_handle_cor_ras() to return early if no RAS errors
- Add Ben's review-by
cxl/pci: Map CXL Endpoint Port and CXL Switch Port RAS registers
- Change as result of dport delay fix. No longer need switchport and endport approach. Refactor. (Terry)
CXL/PCI: Introduce PCI_ERS_RESULT_PANIC
- Add Dave Jiang's, Jonathan's, Ben's review-by
- Typo fix (Ben)
CXL/AER: Introduce pcie/aer_cxl_vh.c in AER driver for forwarding CXL errors
- Add Dave Jiang's review-by
- Update error message (Ben)
cxl: Introduce cxl_pci_drv_bound() to check for bound driver
- Add Dave Jiang's review-by.
cxl: Change CXL handlers to use guard() instead of scoped_guard()
- New patch
cxl/pci: Introduce CXL protocol error handlers for endpoints
- Updated all the implemetnation and commit message. (Terry)
- Refactored cxl_cor_error_detected()/cxl_error_detected() to remove pdev (Dave Jiang)
CXL/PCI: Introduce CXL Port protocol error handlers
- Move get_pci_cxl_host_dev() and cxl_handle_proto_error() to Dequeue patch (Terry)
- Remove EP case in cxl_get_ras_base(), not used. (Terry)
- Remove check for dport->dport_dev (Dave)
- Remove whitespace (Terry)
PCI/AER: Dequeue forwarded CXL error
- Rewrite cxl_handle_proto_error() and cxl_proto_err_work_fn() (Terry)
- Rename get_cxl_host dev() to be get_cxl_port() (Terry)
- Remove exporting of unused function, pci_aer_clear_fatal_status() (Dave Jiang)
- Change pr_err() calls to ratelimited. (Terry)
- Update commit message. (Terry)
- Remove namespace qualifier from pcie_clear_device_status()
export (Dave Jiang)
- Move locks into cxl_proto_err_work_fn() (Dave)
- Update log messages in cxl_forward_error() (Ben)
CXL/PCI: Export and rename merge_result() to pci_ers_merge_result()
- Renamed pci_ers_merge_result() to pcie_ers_merge_result(). pci_ers_merge_result() is already used in eeh driver. (Bot)
CXL/PCI: Introduce CXL uncorrectable protocol error recovery
- Rewrite report_error_detected() and cxl_walk_port (Terry)
- Add guard() before calling cxl_pci_drv_bound() (Dave Jiang)
- Add guard() calls for EP (cxlds->cxlmd->dev & pdev->dev) and ports (pdev->dev & parent cxl_port) in cxl_report_error_detected() and cxl_handle_proto_error() (Terry)
- Remove unnecessary check for endpoint port. (Dave Jiang)
- Remove check for RCIEP EP in cxl_report_error_detected() (Terry)
CXL/PCI: Enable CXL protocol errors during CXL Port probe
- Add dev and dev_is_pci() NULL checks in cxl_unmask_proto_interrupts() (Terry)
- Add Dave Jiang's and Ben's review-by
CXL/PCI: Disable CXL protocol error interrupts during CXL Port cleanup
- Added dev and dev_is_pci() checks in cxl_mask_proto_interrupts() (Terry)
Changes in v11 -> v12:
cxl/pci: Remove unnecessary CXL Endpoint handling helper functions
- Added Dave Jiang's review by
- Moved to front of series
cxl/pci: Remove unnecessary CXL RCH handling helper functions
- Add reviewed-by for Alejandro & Dave Jiang
- Moved to front of series
cxl: Remove ifdef blocks of CONFIG_PCIEAER_CXL from core/pci.c
- Update CONFIG_CXL_RAS in CXL Kconfig to have CXL_PCI dependency (Terry)
CXL/AER: Remove CONFIG_PCIEAER_CXL and replace with CONFIG_CXL_RAS
- Added review-by for Sathyanarayanan
- Changed Kconfig dependency from PCIEAER_CXL to PCIEAER. Moved
this backwards into this patch.
cxl: Move CXL driver RCH error handling into CONFIG_CXL_RCH_RAS conditio
- Moved CXL_RCH_RAS Kconfig definition here from following commit
CXL/AER: Introduce aer_cxl_rch.c into AER driver for handling CXL RCH errors
- Rename drivers/pci/pcie/cxl_rch.c to drivers/pci/pcie/aer_cxl_rch.c (Lukas)
- Removed forward declararation of 'struct aer_err_info' in pci/pci.h (Terry)
CXL/PCI: Move CXL DVSEC definitions into uapi/linux/pci_regs.h
- Change formatting to be same as existing definitions
- Change GENMASK() -> __GENMASK() and BIT() to _BITUL()
PCI/CXL: Introduce pcie_is_cxl()
- Add review-by for Alejandro
- Add comment in set_pcie_cxl() explaining why updating parent status.
PCI/AER: Report CXL or PCIe bus error type in trace logging
- Change aer_err_info::is_cxl to be bool a bitfield. Update structure padding. (Lukas)
- Add kernel-doc for 'struct aer_err_info' (Lukas)
cxl/pci: Unify CXL trace logging for CXL Endpoints and CXL Ports
- Correct parameters to call trace_cxl_aer_correctable_error() (Shiju)
- Add reviewed-by for Jonathan and Shiju
cxl/pci: Map CXL Endpoint Port and CXL Switch Port RAS registers
- Add check for dport_parent->rch before calling cxl_dport_init_ras_reporting().
- RCH dports are initialized from cxl_dport_init_ras_reporting cxl_mem_probe().
CXL/PCI: Introduce PCI_ERS_RESULT_PANIC
- Documentation requested by (Lukas)
CXL/AER: Introduce aer_cxl_vh.c in AER driver for forwarding CXL errors
- Rename drivers/pci/pcie/cxl_aer.c to drivers/pci/pcie/aer_cxl_vh.c (Lukas)
cxl: Introduce cxl_pci_drv_bound() to check for bound driver
- New patch
PCI/AER: Dequeue forwarded CXL error
- Add guard for CE case in cxl_handle_proto_error() (Dave)
- Updated commit message (Terry)
CXL/PCI: Introduce CXL Port protocol error handlers
- Add call to cxl_pci_drv_bound() in cxl_handle_proto_error() and
pci_to_cxl_dev() (Lukas)
- Change cxl_error_detected() -> cxl_cor_error_detected() (Terry)
- Remove NULL variable assignments (Jonathan)
- Replace bus_find_device() with find_cxl_port_by_uport() for upstream port searches. (Dave)
CXL/PCI: Export and rename merge_result() to pci_ers_merge_result()
- Remove static inline pci_ers_merge_result() definition for !CONFIG_PCIEAER. Is not needed. (Lukas)
CXL/PCI: Introduce CXL uncorrectable protocol error recovery
- Clean up port discovery in cxl_do_recovery() (Dave)
- Add PCI_EXP_TYPE_RC_END to type check in cxl_report_error_detected()
Changes in v10 -> v11:
cxl: Remove ifdef blocks of CONFIG_PCIEAER_CXL from core/pci.c
- New patch
CXL/AER: Remove CONFIG_PCIEAER_CXL and replace with CONFIG_CXL_RAS
- New patch
cxl/pci: Remove unnecessary CXL RCH handling helper functions
- New patch
cxl: Move CXL driver RCH error handling into CONFIG_CXL_RCH_RAS conditional block
- New patch
CXL/AER: Introduce rch_aer.c into AER driver for handling CXL RCH errors
- Remove changes in code-split and move to earlier, new patch
- Add #include <linux/bitfield.h> to cxl_ras.c
- Move cxl_rch_handle_error() & cxl_rch_enable_rcec() declarations from pci.h to aer.h, more localized.
- Introduce CONFIG_CXL_RCH_RAS, includes Makefile changes, ras.c ifdef changes CXL/PCI: Move CXL DVSEC definitions into uapi/linux/pci_regs.h
- New patch
PCI/CXL: Introduce pcie_is_cxl()
- Amended set_pcie_cxl() to check for Upstream Port's and EP's parent downstream port by calling set_pcie_cxl(). (Dan)
- Retitle patch: 'Add' -> 'Introduce'
- Add check for CXL.mem and CXL.cache (Alejandro, Dan)
PCI/AER: Report CXL or PCIe bus error type in trace logging
- Remove duplicate call to trace_aer_event() (Shiju)
- Added Dan William's and Dave Jiang's reviewed-by
CXL/AER: Update PCI class code check to use FIELD_GET()
- Add #include <linux/bitfield.h> to cxl_ras.c (Terry)
- Removed line wrapping at "(CXL 3.2, 8.1.12.1)". (Jonathan)
cxl/pci: Log message if RAS registers are unmapped
- Added Dave Jiang's review-by (Terry)
cxl/pci: Unify CXL trace logging for CXL Endpoints and CXL Ports
- Updated CE and UCE trace routines to maintian consistent TP_Struct ABI and unchanged TP_printk() logging. (Shiju, Alison)
cxl/pci: Update cxl_handle_cor_ras() to return early if no RAS errors
- Added Dave Jiang and Jonathan Cameron's review-by
- Changes moved to core/ras.c
cxl/pci: Map CXL Endpoint Port and CXL Switch Port RAS registers
- Use local pointer for readability in cxl_switch_port_init_ras() (Jonathan Cameron)
- Rename port to be ep in cxl_endpoint_port_init_ras() (Dave Jiang)
- Rename dport to be parent_dport in cxl_endpoint_port_init_ras()
and cxl_switch_port_init_ras() (Dave Jiang)
- Port helper changes were in cxl/port.c, now in core/ras.c (Dave Jiang) cxl/pci: Introduce CXL Endpoint protocol error handlers
- cxl_error_detected() - Change handlers' scoped_guard() to guard() (Jonathan)
- cxl_error_detected() - Remove extra line (Shiju)
- Changes moved to core/ras.c (Terry)
- cxl_error_detected(), remove 'ue' and return with function call. (Jonathan)
- Remove extra space in documentation for PCI_ERS_RESULT_PANIC definition
- Move #include "pci.h from cxl.h to core.h (Terry)
- Remove unnecessary includes of cxl.h and core.h in mem.c (Terry) CXL/AER: Introduce cxl_aer.c into AER driver for forwarding CXL errors
- Move RCH implementation to cxl_rch.c and RCH declarations to pci/pci.h. (Terry)
- Introduce 'struct cxl_proto_err_kfifo' containing semaphore, fifo, and work struct. (Dan)
- Remove embedded struct from cxl_proto_err_work (Dan)
- Make 'struct work_struct *cxl_proto_err_work' definition static (Jonathan)
- Add check for NULL cxl_proto_err_kfifo to determine if CXL driver is not registered for workqueue. (Dan)
PCI/AER: Dequeue forwarded CXL error
- Reword patch commit message to remove RCiEP details (Jonathan)
- Add #include <linux/bitfield.h> (Terry)
- is_cxl_rcd() - Fix short comment message wrap (Jonathan)
- is_cxl_rcd() - Combine return calls into 1 (Jonathan)
- cxl_handle_proto_error() - Move comment earlier (Jonathan)
- Usse FIELD_GET() in discovering class code (Jonathan)
- Remove BDF from cxl_proto_err_work_data. Use 'struct pci_dev *' (Dan) CXL/PCI: Introduce CXL Port protocol error handlers
- Removed check for PCI_EXP_TYPE_RC_END in cxl_report_error_detected() (Terry)
- Update is_cxl_error() to check for acceptable PCI EP and port types CXL/PCI: Export and rename merge_result() to pci_ers_merge_result()
- pci_ers_merge_result() - Change export to non-namespace and rename to be pci_ers_merge_result() (Jonathan)
- Move pci_ers_merge_result() definition to pci.h. Needs pci_ers_result (Terry) CXL/PCI: Introduce CXL uncorrectable protocol error recovery
- pci_ers_merge_results() - Move to earlier patch
CXL/PCI: Disable CXL protocol error interrupts during CXL Port cleanup
- Remove guard() in cxl_mask_proto_interrupts(). Observed device lockup/block during testing. (Terry)
Changes in v9 -> v10:
- Add drivers/pci/pcie/cxl_aer.c
- Add drivers/cxl/core/native_ras.c
- Change cxl_register_prot_err_work()/cxl_unregister_prot_err_work to return void
- Check for pcie_ports_native in cxl_do_recovery()
- Remove debug logging in cxl_do_recovery()
- Update PCI_ERS_RESULT_PANIC definition to indicate is CXL specific
- Revert trace logging changes: name,parent -> memdev,host.
- Use FIELD_GET() to check for EP class code (cxl_aer.c & native_ras.c).
- Change _prot_ to _proto_ everywhere
- cxl_rch_handle_error_iter(), check if driver is cxl_pci_driver
- Remove cxl_create_prot_error_info(). Move logic into forward_cxl_error()
- Remove sbdf_to_pci() and move logic into cxl_handle_proto_error()
- Simplify/refactor get_pci_cxl_host_dev()
- Simplify/refactor cxl_get_ras_base()
- Move patch 'Remove unnecessary CXL Endpoint handling helper functions' to front
- Update description for 'CXL/PCI: Introduce CXL Port protocol error handlers' with why state is not used to determine handling
- Introduce cxl_pci_drv_bound() and call from cxl_rch_handle_error_iter()
Changes in v8 -> v9:
- Updated reference counting to use pci_get_device()/pci_put_device() in cxl_disable_prot_errors()/cxl_enable_prot_errors
- Refactored cxl_create_prot_err_info() to fix reference counting
- Removed 'struct cxl_port' driver changes for error handler. Instead check for CXL device type (EP or Port device) and call handler
- Make pcie_is_cxl() static inline in include/linux/linux.h
- Remove NULL check in create_prot_err_info()
- Change success return in cxl_ras_init() to use hardcoded 0
- Changed 'struct work_struct cxl_prot_err_work' declaration to static
- Change to use rate limited log with dev anchor in forward_cxl_error()
- Refactored forward-cxl_error() to remove severity auto variable
- Changed pci_aer_clear_nonfatal_status() to be static inline for !(CONFIG_PCIEAER)
- Renamed merge_result() to be cxl_merge_result()
- Removed 'ue' condition in cxl_error_detected()
- Updated 2nd parameter in call to __cxl_handle_cor_ras()/__cxl_handle_ras() in unify patch
- Added log message for failure while assigning interrupt disable callback
- Updated pci_aer_mask_internal_errors() to use pci_clear_and_set_config_dword()
- Simplified patch titles for clarity
- Moved CXL error interrupt disabling into cxl/core/port.c with CXL Port teardown
- Updated 'struct cxl_port_err_info' to only contain sbdf and severity Removed everything else.
- Added pdev and CXL device get_device()/put_device() before calling handlers
Changes in v7 -> v8:
[Dan] Use kfifo. Move handling to CXL driver. AER forwards error to CXL driver
[Dan] Add device reference incrementors where needed throughout [Dan] Initiate CXL Port RAS init from Switch Port and Endpoint Port init [Dan] Combine CXL Port and CXL Endpoint trace routine
[Dan] Introduce aer_info::is_cxl. Use to indicate CXL or PCI errors [Jonathan] Add serial number for all devices in trace [DaveJ] Move find_cxl_port() change into patch using it [Terry] Move CXL Port RAS init into cxl/port.c
[Terry] Moved kfifo functions into cxl/core/ras.c
Changes in v6 -> v7:
[Terry] Move updated trace routine call to later patch. Was causing build error.
Changes in v5 -> v6:
[Ira] Move pcie_is_cxl(dev) define to a inline function
[Ira] Update returning value from pcie_is_cxl_port() to bool w/o cast
[Ira] Change cxl_report_error_detected() cleanup to return correct bool
[Ira] Introduce and use PCI_ERS_RESULT_PANIC
[Ira] Reuse comment for PCIe and CXL recovery paths
[Jonathan] Add type check in for cxl_handle_cor_ras() and cxl_handle_ras() [Jonathan] cxl_uport/dport_init_ras_reporting(), added a mutex.
[Jonathan] Add logging example to patches updating trace output
[Jonathan] Make parameter 'const' to eliminate for cast in match_uport() [Jonathan] Use __free() in cxl_pci_port_ras()
[Terry] Add patch to log the PCIe SBDF along with CXL device name
[Terry] Add patch to handle CXL endpoint and RCH DP errors as CXL errors [Terry] Remove patch w USP UCE fatal support @ aer_get_device_error_info() [Terry] Rebase to cxl/next commit 5585e342e8d3 ("cxl/memdev: Remove unused partition values") [Gregory] Pre-initialize pointer to NULL in cxl_pci_port_ras()
[Gregory] Move AER driver bus name detection to a static function
Changes in v4 -> v5:
[Alejandro] Refactor cxl_walk_bridge to simplify 'status' variable usage [Alejandro] Add WARN_ONCE() in __cxl_handle_ras() and cxl_handle_cor_ras() [Ming] Remove unnecessary NULL check in cxl_pci_port_ras() [Terry] Add failure check for call to to_cxl_port() in cxl_pci_port_ras() [Ming] Use port->dev for call to devm_add_action_or_reset() in cxl_dport_init_ras_reporting() and cxl_uport_init_ras_reporting() [Jonathan] Use get_device()/put_device() to prevent race condition in cxl_clear_port_error_handlers() and cxl_clear_port_error_handlers() [Terry] Commit message cleanup. Capitalize keywords from CXL and PCI specifications
Changes in v3 -> v4:
[Lukas] Capitalize PCIe and CXL device names as in specifications [Lukas] Move call to pcie_is_cxl() into cxl_port_devsec()
[Lukas] Correct namespace spelling
[Lukas] Removed export from pcie_is_cxl_port()
[Lukas] Simplify 'if' blocks in cxl_handle_error()
[Lukas] Change panic message to remove redundant 'panic' text
[Ming] Update to call cxl_dport_init_ras_reporting() in RCH case [lkp@intel] 'host' parameter is already removed. Remove parameter description too. [Terry] Added field description for cxl_err_handlers in pci.h comment block
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 Williams (2):
cxl/pci: Thread port and dport through RAS handling helpers
cxl: Add port and dport identifiers to CXL AER trace events
Terry Bowman (7):
PCI/AER: Introduce AER-CXL protocol error kfifo
PCI: Establish common CXL Port protocol error flow cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
cxl: Update CXL Endpoint AER handler
PCI: Cache PCI DSN into pci_dev->dsn during probe PCI/CXL: Mask/Unmask CXL protocol errors
Documentation: cxl: Document CXL protocol error handling
Documentation/driver-api/cxl/index.rst | 1 + .../cxl/linux/protocol-error-handling.rst | 426 ++++++++++++++++++ MAINTAINERS | 2 + drivers/cxl/core/core.h | 29 +- drivers/cxl/core/port.c | 6 +- drivers/cxl/core/ras.c | 405 +++++++++++------ drivers/cxl/core/ras_rch.c | 73 +-- drivers/cxl/core/trace.c | 35 ++ drivers/cxl/core/trace.h | 91 ++-- drivers/cxl/cxlmem.h | 7 + drivers/cxl/cxlpci.h | 11 +- drivers/cxl/pci.c | 9 +- drivers/pci/hotplug/pciehp.h | 4 - drivers/pci/hotplug/pciehp_hpc.c | 7 +- drivers/pci/hotplug/pciehp_pci.c | 4 - drivers/pci/pci.h | 1 - drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 41 +- drivers/pci/pcie/aer_cxl_rch.c | 39 +- drivers/pci/pcie/aer_cxl_vh.c | 246 ++++++++++ drivers/pci/pcie/portdrv.h | 10 +- drivers/pci/probe.c | 17 + include/linux/aer.h | 26 ++ include/linux/pci.h | 1 + tools/testing/cxl/Kbuild | 1 + tools/testing/cxl/test/mock.c | 12 + 26 files changed, 1202 insertions(+), 303 deletions(-) create mode 100644 Documentation/driver-api/cxl/linux/protocol-error-handling.rst create mode 100644 drivers/pci/pcie/aer_cxl_vh.c
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
Signature · 1 line
2.34.1
PATCH v20 1/9 PCI/AER: Introduce AER-CXL protocol error kfifo
CXL VH RAS handling requires the AER driver to hand off CXL protocol errors to cxl_core for logging and recovery before PCIe AER recovery tears down the device. Introduce pci/pcie/aer_cxl_vh.c to implement this handoff via a kfifo-backed work item.
The producer, cxl_forward_error(), is gated by is_cxl_error() and enqueues the error source PCI device and severity. cxl_core registers a consumer via cxl_register_proto_err_work(); the consumer drains the kfifo with for_each_cxl_proto_err(). For uncorrectable errors, cxl_proto_err_wait_for_empty() lets the AER path block until the CXL plane has finished so recovery does not race device teardown.
A rwsem serializes registration, deregistration, enqueue, and dequeue against concurrent AER IRQ threads; a spinlock serializes concurrent kfifo writers. is_aer_internal_error() moves into this file and now evaluates info->status & ~info->mask rather than the raw info->status, so a masked internal-error bit is treated as not-set. For the RCH RCEC path this is equivalent because cxl_rch_enable_rcec() first calls pci_aer_unmask_internal_errors(), which clears those mask bits in hardware before the AER status is read back.
A subsequent patch wires cxl_forward_error() into handle_error_source().
Add MAINTAINERS entries for aer_cxl_vh.c and aer_cxl_rch.c under the CXL entry.
---
Changes in v19->v20:
- Drop a correctable error on full kfifo instead of panicking
- Add explicit ATOMIC_INIT(0) for flush_inflight
- Change is_aer_internal_error() to use mask in evaluation.
- Condense commit message (Jonathan)
- Document constraints for_each_cxl_proto_err()
- Document the @wd and @fn parameters of for_each_cxl_proto_err() (kernel-doc)
Changes in v18 -> v19:
- Rename cxl_proto_err_flush() to cxl_proto_err_wait_for_empty() to better reflect that it waits for the kfifo to drain (Jonathan).
Changes in v17->v18:
- Remove correctable status clear from cxl_forward_error(); the AER core clears all status bits via pci_aer_handle_error() info->status writeback
- Schedule consumer on kfifo overflow so existing entries can be drained
Changes in v16->v17:
- Reword "kfifo semaphore" to "kfifo spinlock" to match fifo_lock.
- Defer the handle_error_source() is_cxl_error() switch to the patch that registers the kfifo consumer to keep each commit bisect-safe.
- Rename rwsema to rwsem
- Change CPER exports to use EXPORT_SYMBOL_FOR_MODULES.
- Add work cancel function.
- Replace kfifo_put() with kfifo_in_spinlocked() for multiple producers
- Add fifo_lock spinlock for concurrent producer serialisation
- Initialize the embedded kfifo with INIT_KFIFO() in a subsys_initcall so kfifo->mask, ->esize and ->data are set before first use.
- Clear PCI_ERR_COR_STATUS in cxl_forward_error() after enqueue so the device is acked for correctable events even when the consumer drops the event. Uncorrectable status is left for cxl_do_recovery() to clear after recovery completes, mirroring the AER core convention.
- WARN on double-registration in cxl_register_proto_err_work() to make an unintended second consumer visible at runtime.
- Add direct rwsem.h, cleanup.h and workqueue.h includes for symbols used in aer_cxl_vh.c
- Add MAINTAINERS entries for drivers/pci/pcie/aer_cxl_*.c
- Update message
--- MAINTAINERS | 2 + drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 10 -- drivers/pci/pcie/aer_cxl_vh.c | 243 ++++++++++++++++++++++++++++++++++ drivers/pci/pcie/portdrv.h | 6 + include/linux/aer.h | 24 ++++ 6 files changed, 276 insertions(+), 10 deletions(-) create mode 100644 drivers/pci/pcie/aer_cxl_vh.c
MAINTAINERS +2 -0
@@ -6572,6 +6572,8 @@ S: Maintained F: Documentation/driver-api/cxl F: Documentation/userspace-api/fwctl/fwctl-cxl.rst F: drivers/cxl/ +F: drivers/pci/pcie/aer_cxl_rch.c +F: drivers/pci/pcie/aer_cxl_vh.c F: include/cxl/ F: include/uapi/linux/cxl_mem.h F: tools/testing/cxl/
drivers/pci/pcie/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o bwctrl.o obj-y += aspm.o obj-$(CONFIG_PCIEAER) += aer.o err.o tlp.o obj-$(CONFIG_CXL_RAS) += aer_cxl_rch.o +obj-$(CONFIG_CXL_RAS) += aer_cxl_vh.o obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o obj-$(CONFIG_PCIE_PME) += pme.o obj-$(CONFIG_PCIE_DPC) += dpc.o
drivers/pci/pcie/aer.c +0 -10
@@ -1288,16 +1288,6 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)*/ EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); -#ifdef CONFIG_CXL_RAS -bool is_aer_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 ; -} -#endif -/** * pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device
drivers/pci/pcie/aer_cxl_vh.c new file +243 -0
243 lines not on this page · raw message
drivers/pci/pcie/portdrv.h +6 -0
@@ -130,9 +130,15 @@ struct aer_err_info;bool is_aer_internal_error (struct aer_err_info *info);void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info);void cxl_rch_enable_rcec (struct pci_dev *rcec); +bool is_cxl_error (struct pci_dev *pdev,struct aer_err_info *info); +bool cxl_forward_error (struct pci_dev *pdev,struct aer_err_info *info); +void cxl_proto_err_wait_for_empty (void );#else static inline bool is_aer_internal_error (struct aer_err_info *info) {return false; }static inline void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { }static inline void cxl_rch_enable_rcec (struct pci_dev *rcec) { } +static inline bool is_cxl_error (struct pci_dev *pdev,struct aer_err_info *info) {return false; } +static inline bool cxl_forward_error (struct pci_dev *pdev,struct aer_err_info *info) {return false; } +static inline void cxl_proto_err_wait_for_empty (void ) { }#endif /* CONFIG_CXL_RAS */ #endif /* _PORTDRV_H_ */
include/linux/aer.h +24 -0
@@ -25,6 +25,7 @@#define PCIE_STD_MAX_TLP_HEADERLOG (PCIE_STD_NUM_TLP_HEADERLOG + 10)struct pci_dev ; +struct work_struct ; struct pcie_tlp_log { union {
@@ -66,6 +67,29 @@ static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }static inline void pci_aer_unmask_internal_errors (struct pci_dev *dev) { }#endif +#ifdef CONFIG_CXL_RAS +/** +* struct cxl_proto_err_work_data - Error information used in CXL error handling +* @pdev: PCI device detecting the error +* @severity: AER severity +*/ +struct cxl_proto_err_work_data { +struct pci_dev *pdev; +int severity; +}; + +/** +* Callback for processing a CXL protocol error from the AER-CXL kfifo. +*/ +typedef void (*cxl_proto_err_fn_t )(struct cxl_proto_err_work_data *wd); + +void cxl_register_proto_err_work (struct work_struct *work, +void (*flush)(void )); +void for_each_cxl_proto_err (struct cxl_proto_err_work_data *wd, +cxl_proto_err_fn_t fn); +void cxl_unregister_proto_err_work (void ); +#endif +void pci_print_aer (struct pci_dev *dev,int aer_severity,struct aer_capability_regs *aer);int cper_severity_to_aer (int cper_severity);
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 21 lines
CXL VH RAS handling requires the AER driver to hand off CXL protocol errors to
cxl_corefor logging and recovery before PCIe AER recovery tears down the device. Introducepci/pcie/aer_cxl_vh.cto implement this handoff via a kfifo-backed work item.The producer,
cxl_forward_error(), is gated byis_cxl_error()and enqueues the error source PCI device and severity.cxl_coreregisters a consumer viacxl_register_proto_err_work(); the consumer drains the kfifo withfor_each_cxl_proto_err(). For uncorrectable errors,cxl_proto_err_wait_for_empty()lets the AER path block until the CXL plane has finished so recovery does not race device teardown.A rwsem serializes registration, deregistration, enqueue, and dequeue against concurrent AER IRQ threads; a spinlock serializes concurrent kfifo writers.
is_aer_internal_error()moves into this file and now evaluatesinfo->status& ~info->mask rather than the rawinfo->status, so a masked internal-error bit is treated as not-set. For the RCH RCEC path this is equivalent becausecxl_rch_enable_rcec()first callspci_aer_unmask_internal_errors(), which clears those mask bits in hardware before the AER status is read back.
Quoted 8 lines
A subsequent patch wires
cxl_forward_error()intohandle_error_source().Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
In reply to Terry BowmanQuoted 23 lines · Terry Bowman
CXL VH RAS handling requires the AER driver to hand off CXL protocol errors to
cxl_corefor logging and recovery before PCIe AER recovery tears down the device. Introducepci/pcie/aer_cxl_vh.cto implement this handoff via a kfifo-backed work item.The producer,
cxl_forward_error(), is gated byis_cxl_error()and enqueues the error source PCI device and severity.cxl_coreregisters a consumer viacxl_register_proto_err_work(); the consumer drains the kfifo withfor_each_cxl_proto_err(). For uncorrectable errors,cxl_proto_err_wait_for_empty()lets the AER path block until the CXL plane has finished so recovery does not race device teardown.A rwsem serializes registration, deregistration, enqueue, and dequeue against concurrent AER IRQ threads; a spinlock serializes concurrent kfifo writers.
is_aer_internal_error()moves into this file and now evaluatesinfo->status& ~info->mask rather than the rawinfo->status, so a masked internal-error bit is treated as not-set. For the RCH RCEC path this is equivalent becausecxl_rch_enable_rcec()first callspci_aer_unmask_internal_errors(), which clears those mask bits in hardware before the AER status is read back.A subsequent patch wires
cxl_forward_error()intohandle_error_source().
Quoted 8 lines
Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>---
Just a few nits, but nothing critical so:
Quoted 67 lines
Changes in
v19->v20:
- Drop a correctable error on full kfifo instead of panicking
- Add explicitATOMIC_INIT(0)forflush_inflight
- Changeis_aer_internal_error()to use mask in evaluation.
- Condense commit message (Jonathan)
- Document constraintsfor_each_cxl_proto_err()
- Document the @wd and @fn parameters offor_each_cxl_proto_err()(kernel-doc)Changes in v18 -> v19:
- Renamecxl_proto_err_flush()tocxl_proto_err_wait_for_empty()to better reflect that it waits for the kfifo to drain (Jonathan).Changes in
v17->v18:
- Remove correctable status clear fromcxl_forward_error(); the AER core clears all status bits viapci_aer_handle_error()info->statuswriteback
- Schedule consumer on kfifo overflow so existing entries can be drainedChanges in
v16->v17:
- Reword "kfifo semaphore" to "kfifo spinlock" to matchfifo_lock.
- Defer thehandle_error_source()is_cxl_error()switch to the patch that registers the kfifo consumer to keep each commit bisect-safe.
- Rename rwsema to rwsem
- Change CPER exports to useEXPORT_SYMBOL_FOR_MODULES.
- Add work cancel function.
- Replacekfifo_put()withkfifo_in_spinlocked()for multiple producers
- Addfifo_lockspinlock for concurrent producer serialisation
- Initialize the embedded kfifo withINIT_KFIFO()in asubsys_initcallsokfifo->mask, ->esize and ->data are set before first use.
- ClearPCI_ERR_COR_STATUSincxl_forward_error()after enqueue so the device is acked for correctable events even when the consumer drops the event. Uncorrectable status is left forcxl_do_recovery()to clear after recovery completes, mirroring the AER core convention.
- WARN on double-registration incxl_register_proto_err_work()to make an unintended second consumer visible at runtime.
- Add directrwsem.h,cleanup.handworkqueue.hincludes for symbols used inaer_cxl_vh.c
- AddMAINTAINERSentries fordrivers/pci/pcie/aer_cxl_*.c
- Update message--- MAINTAINERS | 2 + drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/aer.c | 10 -- drivers/pci/pcie/aer_cxl_vh.c | 243 ++++++++++++++++++++++++++++++++++ drivers/pci/pcie/portdrv.h | 6 + include/linux/aer.h | 24 ++++ 6 files changed, 276 insertions(+), 10 deletions(-) create mode 100644 drivers/pci/pcie/aer_cxl_vh.cMAINTAINERS +2
-0@@ -6572,6 +6572,8 @@ S: Maintained F: Documentation/driver-api/cxl F: Documentation/userspace-api/fwctl/fwctl-cxl.rst F: drivers/cxl/ +F: drivers/pci/pcie/aer_cxl_rch.c +F: drivers/pci/pcie/aer_cxl_vh.c F: include/cxl/ F: include/uapi/linux/cxl_mem.h F: tools/testing/cxl/drivers/pci/pcie/Makefile +0
-0
drivers/pci/pcie/Makefile obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o bwctrl.o · line 12
Quoted 4 lines
drivers/pci/pcie/Makefile +1
-0@@ -9,6 +9,7 @@ obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o bwctrl.o obj-y += aspm.o obj-$(CONFIG_PCIEAER) += aer.o err.o tlp.o obj-$(CONFIG_CXL_RAS) += aer_cxl_rch.o +obj-$(CONFIG_CXL_RAS) += aer_cxl_vh.o
This can go on the same line as the obj-$(CONFIG_CXL_RAS) above, i.e.:
obj-$(CONFIG_CXL_RAS) += aer_cxl_rch.o aer_cxl_vh.o
Quoted 53 lines
drivers/pci/pcie/Makefile +0
-0obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o obj-$(CONFIG_PCIE_PME) += pme.o obj-$(CONFIG_PCIE_DPC) += dpc.odrivers/pci/pcie/aer.c +0
-10@@ -1288,16 +1288,6 @@ void pci_aer_unmask_internal_errors(struct pci_dev *dev)*/ EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); -#ifdef CONFIG_CXL_RAS -bool is_aer_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 ; -} -#endif -/** * pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device drivers/pci/pcie/aer_cxl_vh.c new file +23
-0@@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright(c) 2026 AMD Corporation. All rights reserved. */ + +#include <linux/aer.h> +#include <linux/atomic.h> +#include <linux/cleanup.h> +#include <linux/init.h> +#include <linux/kfifo.h> +#include <linux/lockdep.h> +#include <linux/rwsem.h> +#include <linux/spinlock.h> +#include <linux/wait_bit.h> +#include <linux/workqueue.h> +#include "../pci.h" +#include "portdrv.h" + +#define CXL_ERROR_SOURCES_MAX 128 + +struct cxl_proto_err_kfifo { +struct work_struct *work; +void (*flush)(void ); +struct rw_semaphore rwsem; +spinlock_t fifo_lock;/* Serializes kfifo writers */
drivers/pci/pcie/aer_cxl_vh.c line 33
Quoted 10 lines
drivers/pci/pcie/aer_cxl_vh.c new file +10
-0+atomic_t flush_inflight; + DECLARE_KFIFO(fifo, struct cxl_proto_err_work_data, +CXL_ERROR_SOURCES_MAX ); +}; + +static struct cxl_proto_err_kfifo cxl_proto_err_kfifo = { + .rwsem =__RWSEM_INITIALIZER (cxl_proto_err_kfifo.rwsem), + .fifo_lock =__SPIN_LOCK_UNLOCKED (cxl_proto_err_kfifo.fifo_lock), + .flush_inflight =ATOMIC_INIT (0 ), +};
I don't know what the style is for pcie, but I think the above can get shortened to:
static struct cxl_proto_err_kfifo {
...
} cxl_proto_err_kfifo = {
.rwsem = ...
};Quoted 71 lines
drivers/pci/pcie/aer_cxl_vh.c new file +71
-0+ +static int __init cxl_proto_err_kfifo_init (void ) +{ +INIT_KFIFO (cxl_proto_err_kfifo.fifo); +return 0 ; +} +subsys_initcall (cxl_proto_err_kfifo_init); + +bool is_aer_internal_error (struct aer_err_info *info) +{ +u32 status = info->status & ~info->mask; + +if (info->severity ==AER_CORRECTABLE ) +return status &PCI_ERR_COR_INTERNAL ; + +return status &PCI_ERR_UNC_INTN ; +} + +bool is_cxl_error (struct pci_dev *pdev,struct aer_err_info *info) +{ +if (!info || !info->is_cxl) +return false; + +if (pci_pcie_type (pdev) !=PCI_EXP_TYPE_ENDPOINT ) +return false; + +return is_aer_internal_error (info); +} + +/** +* cxl_forward_error - Forward a CXL protocol error to the CXL subsystem via kfifo +* @pdev: PCI device that reported the AER error +* @info: AER error info containing severity and status +* +* Producer side of the AER-CXL kfifo. Enqueues a CXL protocol error work +* item and schedules the consumer workqueue. Takes a reference on @pdev +* that the consumer releases after handling. +* +* Return: true if the consumer workqueue was scheduled and the caller may +* need to drain the kfifo before AER recovery; false if no CXL error +* handling was initiated due to an early return on error (e.g. no kfifo +* consumer registered). Note that on a full kfifo a correctable error is +* dropped but true is still returned; this is harmless because the caller +* only drains the kfifo for non-correctable events. +*/ +bool cxl_forward_error(struct pci_dev *pdev, struct aer_err_info *info) +{ + struct cxl_proto_err_work_data wd = { + .severity = info->severity, + .pdev = pdev, + }; + + guard(rwsem_read)(&cxl_proto_err_kfifo.rwsem); + + if (!cxl_proto_err_kfifo.work) { + dev_err_ratelimited(&pdev->dev, "AER-CXL kfifo reader not registered\n"); + return false; + } + + /* + * Reference discipline: the AER caller (handle_error_source()) holds + * a ref on @pdev for the duration of this call and releases it on + * return. Take a fresh ref here so the pdev stays live while queued + * in the kfifo; the corresponding consumer is for_each_cxl_proto_err() + * and will drop that ref after handling. On enqueue failure below, + * drop the ref we just took to avoid a leak. + */ + pci_dev_get(pdev); + + /* Serialize concurrent kfifo writers: multiple AER threaded IRQs */ + if (!kfifo_in_spinlocked(&cxl_proto_err_kfifo.fifo, &wd, 1,
drivers/pci/pcie/aer_cxl_vh.c line 114
Quoted 10 lines
drivers/pci/pcie/aer_cxl_vh.c new file +10
-0+ &cxl_proto_err_kfifo.fifo_lock)) { + +pci_dev_put (pdev); + +/* +* A correctable error is device-local and recoverable, so a +* dropped CE is safe to log and discard. Never panic on CE +* pressure: a CE storm must not fill the fifo and escalate a +* later event. +*/
I don't think you need this comment when the same info is mentioned in the doc comment above the function. I'd probably keep the doc comment since it's more visible, but that's up to you.
Re: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
In reply to Terry BowmanQuoted 11 lines · On Wed, 2 Sep 2026 08:39:25 -0500 Terry Bowman <[email protected]> wrote:
CXL VH RAS handling requires the AER driver to hand off CXL protocol errors to
cxl_corefor logging and recovery before PCIe AER recovery tears down the device. Introducepci/pcie/aer_cxl_vh.cto implement this handoff via a kfifo-backed work item.The producer,
cxl_forward_error(), is gated byis_cxl_error()and enqueues the error source PCI device and severity.cxl_coreregisters a consumer viacxl_register_proto_err_work(); the consumer drains the kfifo withfor_each_cxl_proto_err(). For uncorrectable errors,cxl_proto_err_wait_for_empty()lets the AER path block until the CXL plane has finished so recovery does not race device teardown.
Do we need most of this last paragraph?
Maybe the bit about letting AER block but the rest smells like implementation details to me with no info on 'why' or anything unexpected.
Quoted 10 lines
A rwsem serializes registration, deregistration, enqueue, and dequeue against concurrent AER IRQ threads; a spinlock serializes concurrent kfifo writers.
is_aer_internal_error()moves into this file and now evaluatesinfo->status& ~info->mask rather than the rawinfo->status, so a masked internal-error bit is treated as not-set. For the RCH RCEC path this is equivalent becausecxl_rch_enable_rcec()first callspci_aer_unmask_internal_errors(), which clears those mask bits in hardware before the AER status is read back.
Quoted 4 lines
A subsequent patch wires
cxl_forward_error()intohandle_error_source().Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.
I couldn't immediately find any discussion about switching away from panic on a kfifo overflow. Was there a reply to an earlier version with a discussion of that? I'm not against the change but a 'why' here would be good to have.
Quoted 4 lines
Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>
One trivial thing inline to add to Ben's nits.
include/linux/aer.h static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; } · line 87
Quoted 7 lines
include/linux/aer.h +7
-0+/** +* Callback for processing a CXL protocol error from the AER-CXL kfifo. +*/ +typedef void (*cxl_proto_err_fn_t )(struct cxl_proto_err_work_data *wd); + +void cxl_register_proto_err_work (struct work_struct *work, +void (*flush)(void ));
Align to after the ( Looks to be 1 space short. If this is a local style thing ignore me ;)
Quoted 10 lines
include/linux/aer.h +5
-0+void for_each_cxl_proto_err (struct cxl_proto_err_work_data *wd, +cxl_proto_err_fn_t fn); +void cxl_unregister_proto_err_work (void ); +#endif +void pci_print_aer (struct pci_dev *dev,int aer_severity,struct aer_capability_regs *aer);int cper_severity_to_aer (int cper_severity);base-commit:
cee9395acd8043be0644b25c34bfa86623f2b935
Re: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
Quoted 15 lines · Jonathan Cameron
Quoted 11 lines · On Wed, 2 Sep 2026 08:39:25 -0500 Terry Bowman <[email protected]> wrote:
CXL VH RAS handling requires the AER driver to hand off CXL protocol errors to
cxl_corefor logging and recovery before PCIe AER recovery tears down the device. Introducepci/pcie/aer_cxl_vh.cto implement this handoff via a kfifo-backed work item.The producer,
cxl_forward_error(), is gated byis_cxl_error()and enqueues the error source PCI device and severity.cxl_coreregisters a consumer viacxl_register_proto_err_work(); the consumer drains the kfifo withfor_each_cxl_proto_err(). For uncorrectable errors,cxl_proto_err_wait_for_empty()lets the AER path block until the CXL plane has finished so recovery does not race device teardown.
Quoted 3 lines
Do we need most of this last paragraph?
Maybe the bit about letting AER block but the rest smells like implementation details to me with no info on 'why' or anything unexpected.
It is implementation centric. This can be reduced.
Quoted 12 lines
Quoted 12 lines
A rwsem serializes registration, deregistration, enqueue, and dequeue against concurrent AER IRQ threads; a spinlock serializes concurrent kfifo writers.
is_aer_internal_error()moves into this file and now evaluatesinfo->status& ~info->mask rather than the rawinfo->status, so a masked internal-error bit is treated as not-set. For the RCH RCEC path this is equivalent becausecxl_rch_enable_rcec()first callspci_aer_unmask_internal_errors(), which clears those mask bits in hardware before the AER status is read back.A subsequent patch wires
cxl_forward_error()intohandle_error_source().
Quoted 8 lines
Quoted 2 lines
Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.I couldn't immediately find any discussion about switching away from panic on a kfifo overflow. Was there a reply to an earlier version with a discussion of that? I'm not against the change but a 'why' here would be good to have.
The driver panics on kfifo full error during UCE enqueue. This was recommended by you and Richard. Changes are at the link below in cxl_forward_error():
https://lore.kernel.org/linux-cxl/[email protected]/
Quoted 7 lines
Quoted 4 lines
Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>One trivial thing inline to add to Ben's nits.
Reviewed-by Jonathan Cameron <[email protected]>
Quoted 11 lines
include/linux/aer.h static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; } · line 87
Quoted 7 lines
include/linux/aer.h +7
-0+/** +* Callback for processing a CXL protocol error from the AER-CXL kfifo. +*/ +typedef void (*cxl_proto_err_fn_t )(struct cxl_proto_err_work_data *wd); + +void cxl_register_proto_err_work (struct work_struct *work, +void (*flush)(void ));Align to after the ( Looks to be 1 space short. If this is a local style thing ignore me ;)
Ok.
-Terry
Quoted 11 lines
Quoted 10 lines
include/linux/aer.h +5
-0+void for_each_cxl_proto_err (struct cxl_proto_err_work_data *wd, +cxl_proto_err_fn_t fn); +void cxl_unregister_proto_err_work (void ); +#endif +void pci_print_aer (struct pci_dev *dev,int aer_severity,struct aer_capability_regs *aer);int cper_severity_to_aer (int cper_severity);base-commit:
cee9395acd8043be0644b25c34bfa86623f2b935
Jonathan Cameron
maintainerRe: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
Hi Terry,
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
A subsequent patch wires
cxl_forward_error()intohandle_error_source().Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.I couldn't immediately find any discussion about switching away from panic on a kfifo overflow. Was there a reply to an earlier version with a discussion of that? I'm not against the change but a 'why' here would be good to have.
Quoted 4 lines
The driver panics on kfifo full error during UCE enqueue. This was recommended by you and Richard. Changes are at the link below in
cxl_forward_error():
https://lore.kernel.org/linux-cxl/[email protected]/
Panic on UCE is a given and correct. I ran the not panic on correctable via some of our folk and they were fine with it (at least so far!). I just saw that you'd stopped panic on this as part of the change log and wondered why.
Not a problem, just following the breadcrumbs!
Jonathan
Re: [PATCH v20 1/9] PCI/AER: Introduce AER-CXL protocol error kfifo
Quoted 18 lines · Jonathan Cameron
Hi Terry,
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
A subsequent patch wires
cxl_forward_error()intohandle_error_source().Add
MAINTAINERSentries foraer_cxl_vh.candaer_cxl_rch.cunder the CXL entry.I couldn't immediately find any discussion about switching away from panic on a kfifo overflow. Was there a reply to an earlier version with a discussion of that? I'm not against the change but a 'why' here would be good to have.
Quoted 4 lines
The driver panics on kfifo full error during UCE enqueue. This was recommended by you and Richard. Changes are at the link below in
cxl_forward_error():
https://lore.kernel.org/linux-cxl/[email protected]/
Quoted 7 lines
Panic on UCE is a given and correct. I ran the not panic on correctable via some of our folk and they were fine with it (at least so far!). I just saw that you'd stopped panic on this as part of the change log and wondered why.
Not a problem, just following the breadcrumbs!
Jonathan
Hi Jonathan,
This area was raised during your and Richard's v18 reviews. The comments:
https://lkml.org/lkml/2026/7/23/446
v19 already implemented the fix from that review: panic on UCE, drop (log) on CE. The v18 code had dropped every severity on overflow without panicking, and you and Richard pointed out a dropped UCE must not be silently lost.
v20 only tidied the CE branch (early return + clearer log message). The panic policy itself is unchanged since v19.
-Terry
PATCH v20 2/9 PCI: Establish common CXL Port protocol error flow
In reply to Terry BowmanEstablish a single CXL protocol error path shared by CXL Virtual Hierarchy (VH) and Restricted CXL Host (RCH) topologies. AER dispatch in handle_error_source() routes CXL protocol errors, gated by is_cxl_error(), through the AER-CXL kfifo to a cxl_core consumer for logging and recovery. Producer and consumer go live together so no CXL error is silently dropped across a bisect.
is_cxl_error() expands from Endpoint-only to also cover Root Port, Upstream Port, and Downstream Port. RCDs report on behalf of an upstream RCH Downstream Port and instead reach the kfifo via cxl_rch_handle_error().
For uncorrectable errors, cxl_proto_err_wait_for_empty() drains the CXL plane (RAS read, panic policy, state clear) before pci_aer_handle_error() drives PCIe recovery, so recovery does not tear down RAS iomaps while the consumer is still reading them. Correctable errors run asynchronously.
Panic policy: cxl_do_recovery() panics on a confirmed UCE, and also when the RAS registers cannot be mapped -- an unconfirmable UCE is treated conservatively as fatal since CXL.mem coherency may be lost. A mapped-but-clear status is logged as spurious with no panic.
to_ras_base() centralizes RAS base lookup (dport->regs.ras for Root/Downstream Ports, port->regs.ras otherwise) and provides an injection point for RAS status simulation during testing. The cxl_cor_error_detected() AER callback is removed; correctable Endpoint errors now route through the kfifo like every other CXL protocol error.
Update cxl_handle_rdport_errors() with locking to prevent dport from being freed and RAS from being unmapped.
At this step cxl_handle_rdport_errors() still dispatches a single severity per pass (matching the pre-series baseline). The following patch, "cxl/ras: Handle RCH correctable and uncorrectable errors in one pass", processes a simultaneously signalled CE and UCE together.
---
Changes in v19->v20:
- Condense commit message (Jonathan)
- Document simultaneous RCH CE+UCE handling in next patch
- Document the cxl_handle_rdport() dport lock
Changes in v18->v19:
- Merge "Establish common CXL Port protocol error flow" and "PCI/CXL: Add RCH support to CXL handlers" into a single patch; route RCD correctable errors through the AER-CXL kfifo and remove cxl_cor_error_detected().
- Rename cxl_proto_err_flush() to cxl_proto_err_wait_for_empty()
- Use guard(device) in __cxl_proto_err_work_fn() instead of scoped_guard
- Reword "silent data corruption" comment; drop "interleaved HDM regions"
- Add blank line after the port lookup in __cxl_proto_err_work_fn()
- Change cxl_do_recovery() to panic if to_ras_base() returns NULL
- Clarify Port driver bound gates RAS access
- Add review-by for DaveJ
Changes in v17->v18:
- Fix pre-existing race: hold memdev device lock around cxl_handle_rdport_errors(), release before port lock
- Fix handle_error_source() to call pci_aer_handle_error() unconditionally so AER handling always runs after cxl_forward_error()
- Add cxl_proto_err_flush() call for CXL UCE to drain kfifo before AER recovery tears down the device
- Fix NULL dereference of dport->dport_dev in cxl_handle_cor_ras() and cxl_handle_ras() for UPSTREAM/ENDPOINT port types: use dport->dport_dev when dport is non-NULL, else fall back to port->uport_dev
- Remove duplicate pcie_clear_device_status() call from cxl_handle_proto_error() CE path; pci_aer_handle_error() already clears it
- Clarify panic policy: panic only on confirmed UCE via RAS status read
- Document kfifo consumer serialization against driver unbind via guard(device)(&port->dev) and port->dev.driver check
Changes in v16->v17:
- get_cxl_port() -> find_cxl_port_by_dev()
- Simplified find_cxl_port_by_dev()
- Replace and remove cxl_serial_number() w/ pci_get_dsn()
- cxl_get_ras_base() -> to_ras_base()
- Drop dependency on PCI_ERS_RESULT_PANIC; cxl_do_recovery() panics directly. (PANIC enum patch dropped from series.)
- Clarify panic semantics: panic on any uncorrectable CXL RAS error, not only AER-FATAL severities.
- Add is_cxl_error() switch in handle_error_source() here, paired with the kfifo consumer registration, to keep each commit bisect-safe.
- Drop pcie_aer_is_native() guard in cxl_do_recovery() (always native).
- Swap order with the "Limit" patch for bisectability w/ cxl_ras_exit()
- Reword for "any uncorrectable" CXL RAS error panics.
- Restore log messages for port-not-found and port-unbound cases.
- Whitespace cleanup (Jonathan)
- Update to get_cxl_port() documentation (Terry)
- Fix __cxl_proto_err_work_fn() to return 0 for transient errors.
- Drop !port check in cxl_do_recovery(), caller already validated
- Fix kerneldoc @pdev -> @dev in find_cxl_port_by_dev()
- Fix missing space in pr_err_ratelimited()
- Made pcie_clear_device_status() and pci_aer_clear_fatal_status() EXPORT_SYMBOL_FOR_MODULES("cxl_core") (Dan)
- Move find_cxl_port_by_dport() and find_cxl_port_by_uport() de-staticisation and core.h declarations from the rename patch to here, where the first cross-file callers in find_cxl_port_by_dev() land.
Changes in v15->v16:
- get_ras_base(), initialize dport to NULL (Jonathan)
- Remove guard(device)(&cxlmd->dev) (Jonathan)
- Fix dev_warns() (Jonathan)
- Remove comment in cxl_port_error_detected() (Dan)
- Update switch-case brackets to follow clang-format (Dan)
- Add PCI_EXP_TYPE_RC_END for cxl_get_ras_base() (Terry)
- Add NULL port check in cxl_serial_number() (Terry)
Changes in v14->v15:
- Update commit message and title. Added Bjorn's ack.
- Move CE and UCE handling logic here
Changes in v13->v14:
- Add Dave Jiang's review-by
- Update commit message & headline (Bjorn)
- Refactor cxl_port_error_detected()/cxl_port_cor_error_detected() to one line (Jonathan)
- Remove cxl_walk_port() (Dan)
- Remove cxl_pci_drv_bound(). Check for 'is_cxl' parent port is sufficient (Dan)
- Remove device_lock_if()
- Combined CE and UCE here (Terry)
Changes in v12->v13:
- Move get_pci_cxl_host_dev() and cxl_handle_proto_error() to Dequeue patch (Terry)
- Remove EP case in cxl_get_ras_base(), not used. (Terry)
- Remove check for dport->dport_dev (Dave)
- Remove whitespace (Terry)
Changes in v11->v12:
- Add call to cxl_pci_drv_bound() in cxl_handle_proto_error() and pci_to_cxl_dev()
- Change cxl_error_detected() -> cxl_cor_error_detected()
- Remove NULL variable assignments
- Replace bus_find_device() with find_cxl_port_by_uport() for upstream port searches.
Changes in v10->v11:
- None
--- drivers/cxl/core/core.h | 17 ++- drivers/cxl/core/port.c | 6 +- drivers/cxl/core/ras.c | 225 +++++++++++++++++++++++++-------- drivers/cxl/core/ras_rch.c | 22 +++- drivers/cxl/cxlpci.h | 3 - drivers/cxl/pci.c | 1 - drivers/pci/pci.h | 1 - drivers/pci/pcie/aer.c | 13 +- drivers/pci/pcie/aer_cxl_rch.c | 39 +++--- drivers/pci/pcie/aer_cxl_vh.c | 16 ++- drivers/pci/pcie/portdrv.h | 4 +- 11 files changed, 249 insertions(+), 98 deletions(-)
drivers/cxl/core/core.h +15 -2
@@ -188,10 +188,13 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)void cxl_ras_init (void );void cxl_ras_exit (void );bool cxl_handle_ras (struct device *dev,void __iomem *ras_base); +void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port, +struct cxl_dport *dport);void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport); -void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds); +void cxl_handle_rdport_errors (struct pci_dev *pdev); +void __iomem *to_ras_base (struct cxl_port *port,struct cxl_dport *dport);void devm_cxl_dport_ras_setup (struct cxl_dport *dport);#else static inline void cxl_ras_init (void ) { }
@@ -200,14 +203,24 @@ static inline bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) {return false; } +static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port, +struct cxl_dport *dport) { }static inline void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { } -static inline void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) { } +static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { } +static inline void __iomem *to_ras_base (struct cxl_port *port, +struct cxl_dport *dport) +{ +return NULL ; +}static inline void devm_cxl_dport_ras_setup (struct cxl_dport *dport) { }#endif /* CONFIG_CXL_RAS */ int cxl_gpf_port_setup (struct cxl_dport *dport); +struct cxl_port *find_cxl_port_by_dport (struct device *dport_dev, +struct cxl_dport **dport); +struct cxl_port *find_cxl_port_by_uport (struct device *uport_dev);struct cxl_hdm ; int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
drivers/cxl/core/port.c +3 -3
@@ -1400,8 +1400,8 @@ static struct cxl_port *__find_cxl_port_by_dport(struct cxl_find_port_ctx *ctx)* Return a 'struct cxl_port' with an elevated reference if found. Use * __free(put_cxl_port) to release. */ -static struct cxl_port *find_cxl_port_by_dport (struct device *dport_dev, -struct cxl_dport **dport) +struct cxl_port *find_cxl_port_by_dport (struct device *dport_dev, +struct cxl_dport **dport) {struct cxl_find_port_ctx ctx = { .dport_dev = dport_dev,
@@ -1596,7 +1596,7 @@ static int match_port_by_uport(struct device *dev, const void *data)* Function takes a device reference on the port device. Caller should do a * put_device() when done. */ -static struct cxl_port *find_cxl_port_by_uport (struct device *uport_dev) +struct cxl_port *find_cxl_port_by_uport (struct device *uport_dev) {struct device *dev;
drivers/cxl/core/ras.c +170 -55
281 lines not on this page · raw message
drivers/cxl/core/ras_rch.c +15 -7
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2025 AMD Corporation. All rights reserved. */ -#include <linux/types.h> #include <linux/aer.h> #include "cxl.h" #include "core.h"
@@ -110,18 +109,27 @@ static bool cxl_rch_get_aer_severity(struct aer_capability_regs *aer_regs,return false; } -void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) +void cxl_handle_rdport_errors (struct pci_dev *pdev) { -struct pci_dev *pdev =to_pci_dev (cxlds->dev);struct aer_capability_regs aer_regs;struct cxl_dport *dport;int severity; - struct cxl_port *port __free(put_cxl_port) = -cxl_pci_find_port (pdev, &dport); + struct cxl_port *port __free(put_cxl_port) = cxl_pci_find_port(pdev, NULL);if (!port)return ; +/* +* The RCH Downstream Port is the Root Port's dport +* (dport free and RAS iomap) is hosted on the CXL Host Bridge +* (port->uport_dev), not &port->dev. Hold that device's lock so the +* dport cannot be freed and its registers unmapped while in use here. +*/ +guard (device)(port->uport_dev); + dport =cxl_find_dport_by_dev (port, pdev->dev.parent); +if (!dport) +return ; +if (!cxl_rch_get_aer_info (dport->regs.dport_aer, &aer_regs))return ;
@@ -130,7 +138,7 @@ void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds)pci_print_aer (pdev, severity, &aer_regs);if (severity ==AER_CORRECTABLE ) -cxl_handle_cor_ras (&cxlds->cxlmd->dev, dport->regs.ras); +cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport));else -cxl_handle_ras (&cxlds->cxlmd->dev, dport->regs.ras); +cxl_do_recovery (pdev, dport->port, dport); }
drivers/cxl/cxlpci.h +0 -3
@@ -79,14 +79,11 @@ struct cxl_dev_state;void read_cdat_data (struct cxl_port *port);#ifdef CONFIG_CXL_RAS -void cxl_cor_error_detected (struct pci_dev *pdev);pci_ers_result_t cxl_error_detected (struct pci_dev *pdev,pci_channel_state_t state);void devm_cxl_dport_rch_ras_setup (struct cxl_dport *dport);void devm_cxl_port_ras_setup (struct cxl_port *port);#else -static inline void cxl_cor_error_detected (struct pci_dev *pdev) { } -static inline pci_ers_result_t cxl_error_detected (struct pci_dev *pdev,pci_channel_state_t state) {
drivers/cxl/pci.c +0 -1
@@ -1002,7 +1002,6 @@ static const struct pci_error_handlers cxl_error_handlers = { .error_detected = cxl_error_detected, .slot_reset = cxl_slot_reset, .resume = cxl_error_resume, - .cor_error_detected = cxl_cor_error_detected, .reset_done = cxl_reset_done, };
drivers/pci/pci.h +0 -1
@@ -1344,7 +1344,6 @@ void pci_restore_aer_state(struct pci_dev *dev);static inline void pci_no_aer (void ) { }static inline void pci_aer_init (struct pci_dev *d) { }static inline void pci_aer_exit (struct pci_dev *d) { } -static inline void pci_aer_clear_fatal_status (struct pci_dev *dev) { }static inline int pci_aer_clear_status (struct pci_dev *dev) {return -EINVAL ; }static inline int pci_aer_raw_clear_status (struct pci_dev *dev) {return -EINVAL ; }static inline void pci_save_aer_state (struct pci_dev *dev) { }
drivers/pci/pcie/aer.c +12 -1
@@ -1328,7 +1328,18 @@ 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); +bool cxl_pending =cxl_rch_handle_error (dev, info); + +if (is_cxl_error (dev, info)) + cxl_pending |=cxl_forward_error (dev, info); + +/* +* Wait for UCE CXL work to complete before AER recovery +* tears down the device. CE can run asynchronously. +*/ +if (cxl_pending && info->severity !=AER_CORRECTABLE ) +cxl_proto_err_wait_for_empty (); +pci_aer_handle_error (dev, info);pci_dev_put (dev); }
drivers/pci/pcie/aer_cxl_rch.c +17 -22
@@ -34,42 +34,37 @@ static bool cxl_error_is_native(struct pci_dev *dev)return (pcie_ports_native || host->native_aer); } +struct cxl_rch_error_ctx { +struct aer_err_info *info; +bool enqueued; +}; +static int cxl_rch_handle_error_iter (struct pci_dev *dev,void *data) { -struct aer_err_info *info = (struct aer_err_info *)data; -const struct pci_error_handlers *err_handler; +struct cxl_rch_error_ctx *ctx = data;if (!is_cxl_mem_dev (dev) || !cxl_error_is_native (dev))return 0 ; -guard (device)(&dev->dev); - - err_handler = dev->driver ? dev->driver->err_handler :NULL ; -if (!err_handler) -return 0 ; - -if (info->severity ==AER_CORRECTABLE ) { -if (err_handler->cor_error_detected) - err_handler->cor_error_detected (dev); - }else if (err_handler->error_detected) { -if (info->severity ==AER_NONFATAL ) - err_handler->error_detected (dev, pci_channel_io_normal); -else if (info->severity ==AER_FATAL ) - err_handler->error_detected (dev, pci_channel_io_frozen); - } +if (cxl_forward_error (dev, ctx->info)) + ctx->enqueued = true;return 0 ; } -void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +bool cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { +struct cxl_rch_error_ctx ctx = { .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. +* An RCEC AER internal error indicates an error in an +* associated RCH Downstream Port or RCD device or both. +* Forward to the cxl_core module for handling. */ if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC &&is_aer_internal_error (info)) -pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, &ctx); + +return ctx.enqueued; }static int handles_cxl_error_iter (struct pci_dev *dev,void *data)
drivers/pci/pcie/aer_cxl_vh.c +15 -1
@@ -54,8 +54,22 @@ bool is_cxl_error(struct pci_dev *pdev, struct aer_err_info *info)if (!info || !info->is_cxl)return false; -if (pci_pcie_type (pdev) !=PCI_EXP_TYPE_ENDPOINT ) +/* +* RCD (PCI_EXP_TYPE_RC_END) is not included here because RCDs +* report errors on behalf of upstream RCH Downstream Port and thus +* require a unique discovery detailed in CXL4.0 spec (12.2.1.1). +* The RCH device error discovery and RCD forwarding flow begins +* in cxl_rch_handle_error(). +*/ +switch (pci_pcie_type (pdev)) { +case PCI_EXP_TYPE_ENDPOINT : +case PCI_EXP_TYPE_ROOT_PORT : +case PCI_EXP_TYPE_UPSTREAM : +case PCI_EXP_TYPE_DOWNSTREAM : +break ; +default :return false; + }return is_aer_internal_error (info); }
drivers/pci/pcie/portdrv.h +2 -2
@@ -128,14 +128,14 @@ struct aer_err_info;#ifdef CONFIG_CXL_RAS bool is_aer_internal_error (struct aer_err_info *info); -void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info); +bool cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info);void cxl_rch_enable_rcec (struct pci_dev *rcec);bool is_cxl_error (struct pci_dev *pdev,struct aer_err_info *info);bool cxl_forward_error (struct pci_dev *pdev,struct aer_err_info *info);void cxl_proto_err_wait_for_empty (void );#else static inline bool is_aer_internal_error (struct aer_err_info *info) {return false; } -static inline void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { } +static inline bool cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) {return false; }static inline void cxl_rch_enable_rcec (struct pci_dev *rcec) { }static inline bool is_cxl_error (struct pci_dev *pdev,struct aer_err_info *info) {return false; }static inline bool cxl_forward_error (struct pci_dev *pdev,struct aer_err_info *info) {return false; }
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] CXL protocol errors on RCD Endpoints bypass the AER-CXL kfifo, leading to dropped correctable…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] CXL protocol errors on RCD Endpoints bypass the AER-CXL kfifo, leading to dropped correctable errors and UCE race conditions. --
commit 6e514f9fb46669ba2eab05ced2511b382df00bce
Author: Terry Bowman <[email protected]>
PCI: Establish common CXL Port protocol error flow
This commit establishes a single CXL protocol error path shared by Virtual Hierarchy and Restricted CXL Host topologies. It routes CXL protocol errors, gated by is_cxl_error(), through an AER-CXL kfifo to a core consumer for logging and recovery to ensure synchronization.
Quoted 3 lines
drivers/pci/pcie/aer_cxl_rch.c +0
-0
[ ... ]
Quoted 10 lines
drivers/pci/pcie/aer_cxl_rch.c +4
-4-void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +bool cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { +struct cxl_rch_error_ctx ctx = { .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. +* An RCEC AER internal error indicates an error in an
drivers/pci/pcie/aer_cxl_rch.c static bool cxl_error_is_native(struct pci_dev *dev) · line 68
Quoted 10 lines
drivers/pci/pcie/aer_cxl_rch.c +5
-1+* associated RCH Downstream Port or RCD device or both. +* Forward to the cxl_core module for handling. */ if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC &&is_aer_internal_error (info)) -pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, &ctx); + +return ctx.enqueued; }
[Severity: High]
Does this check accidentally skip errors logged directly by the RCD itself?
When an RCD detects an error, it logs it in its own AER capability and the RCEC raises the interrupt. The AER driver's find_source_device() then walks the RCEC's children, finds the RCD with the set AER status, and calls handle_error_source() with the RCD device.
Because this condition strictly checks for PCI_EXP_TYPE_RC_EC, it intercepts errors from the RCEC itself (like RCH Downstream Port errors), but bypasses handling when the RCD device itself is passed in.
Quoted 3 lines
drivers/pci/pcie/aer_cxl_vh.c +0
-0
[ ... ]
Quoted 14 lines
drivers/pci/pcie/aer_cxl_vh.c +9
-1@@ -54,8 +54,22 @@ bool is_cxl_error(struct pci_dev *pdev, struct aer_err_info *info)if (!info || !info->is_cxl)return false; -if (pci_pcie_type (pdev) !=PCI_EXP_TYPE_ENDPOINT ) +/* +* RCD (PCI_EXP_TYPE_RC_END) is not included here because RCDs +* report errors on behalf of upstream RCH Downstream Port and thus +* require a unique discovery detailed in CXL4.0 spec (12.2.1.1). +* The RCH device error discovery and RCD forwarding flow begins +* in cxl_rch_handle_error(). +*/ +switch (pci_pcie_type (pdev)) { +case PCI_EXP_TYPE_ENDPOINT :
drivers/pci/pcie/aer_cxl_vh.c bool is_cxl_error(struct pci_dev *pdev, struct aer_err_info *info) · line 75
Quoted 10 lines
drivers/pci/pcie/aer_cxl_vh.c +6
-0+case PCI_EXP_TYPE_ROOT_PORT : +case PCI_EXP_TYPE_UPSTREAM : +case PCI_EXP_TYPE_DOWNSTREAM : +break ; +default :return false; + }return is_aer_internal_error (info); }
[Severity: High]
Since RCDs are excluded here, does this bypass the AER-CXL kfifo entirely for RCD protocol errors?
As noted above, cxl_rch_handle_error() skips the RCD device. With the RCD also falling through to the default case here and returning false, these errors are never enqueued.
This results in correctable errors being silently dropped without being traced or cleared (as the legacy cor_error_detected fallback was removed). For uncorrectable errors, it bypasses the kfifo's synchronization, defeating the race-condition fix and leaving the system vulnerable to teardown races.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow
Quoted 33 lines · On 9/2/2026 8:57 AM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] CXL protocol errors on RCD Endpoints bypass the AER-CXL kfifo, leading to dropped correctable errors and UCE race conditions. --commit
6e514f9fb46669ba2eab05ced2511b382df00bce
Author: Terry Bowman <[email protected]>PCI: Establish common CXL Port protocol error flow
This commit establishes a single CXL protocol error path shared by Virtual Hierarchy and Restricted CXL Host topologies. It routes CXL protocol errors, gated by
is_cxl_error(), through an AER-CXL kfifo to a core consumer for logging and recovery to ensure synchronization.Quoted 3 lines
drivers/pci/pcie/aer_cxl_rch.c +0
-0[ ... ]
Quoted 15 lines
drivers/pci/pcie/aer_cxl_rch.c +6
-4-void cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) +bool cxl_rch_handle_error (struct pci_dev *dev,struct aer_err_info *info) { +struct cxl_rch_error_ctx ctx = { .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. +* An RCEC AER internal error indicates an error in an +* associated RCH Downstream Port or RCD device or both. +* Forward to the cxl_core module for handling. */ if (pci_pcie_type (dev) ==PCI_EXP_TYPE_RC_EC &&is_aer_internal_error (info))
Quoted 9 lines
drivers/pci/pcie/aer_cxl_rch.c static bool cxl_error_is_native(struct pci_dev *dev) · line 68
Quoted 5 lines
drivers/pci/pcie/aer_cxl_rch.c +3
-1-pcie_walk_rcec (dev, cxl_rch_handle_error_iter, info); +pcie_walk_rcec (dev, cxl_rch_handle_error_iter, &ctx); + +return ctx.enqueued; }[Severity: High]
Does this check accidentally skip errors logged directly by the RCD itself?
No. RCH and RCD errors are reported by the platform to the AER agent using RCECs. SW must 'discover' which RCiEP(s) managed by the RCEC have an error.
Quoted 35 lines
When an RCD detects an error, it logs it in its own AER capability and the RCEC raises the interrupt. The AER driver's
find_source_device()then walks the RCEC's children, finds the RCD with the set AER status, and callshandle_error_source()with the RCD device.Because this condition strictly checks for
PCI_EXP_TYPE_RC_EC, it intercepts errors from the RCEC itself (like RCH Downstream Port errors), but bypasses handling when the RCD device itself is passed in.Quoted 3 lines
drivers/pci/pcie/aer_cxl_vh.c +0
-0[ ... ]
Quoted 22 lines
drivers/pci/pcie/aer_cxl_vh.c +15
-1@@ -54,8 +54,22 @@ bool is_cxl_error(struct pci_dev *pdev, struct aer_err_info *info)if (!info || !info->is_cxl)return false; -if (pci_pcie_type (pdev) !=PCI_EXP_TYPE_ENDPOINT ) +/* +* RCD (PCI_EXP_TYPE_RC_END) is not included here because RCDs +* report errors on behalf of upstream RCH Downstream Port and thus +* require a unique discovery detailed in CXL4.0 spec (12.2.1.1). +* The RCH device error discovery and RCD forwarding flow begins +* in cxl_rch_handle_error(). +*/ +switch (pci_pcie_type (pdev)) { +case PCI_EXP_TYPE_ENDPOINT : +case PCI_EXP_TYPE_ROOT_PORT : +case PCI_EXP_TYPE_UPSTREAM : +case PCI_EXP_TYPE_DOWNSTREAM : +break ; +default :return false; + }
Quoted 7 lines
drivers/pci/pcie/aer_cxl_vh.c bool is_cxl_error(struct pci_dev *pdev, struct aer_err_info *info) · line 75
Quoted 2 lines
drivers/pci/pcie/aer_cxl_vh.c +0
-0return is_aer_internal_error (info); }[Severity: High]
Since RCDs are excluded here, does this bypass the AER-CXL kfifo entirely for RCD protocol errors?
is_cxl_error() is used to verify VH devices and is intentionally not used for RCH/RCDs. Below is the flow for RCH/RCDs:
RCEC internal error → cxl_rch_handle_error(RC_EC)
→ pcie_walk_rcec() → cxl_rch_handle_error_iter(RCD)
→ is_cxl_mem_dev(RCD) && cxl_error_is_native(RCD)
→ cxl_forward_error(RCD, info) ← ENQUEUED to the kfifo
CXL r4.0 12.2.1.1 addresses RCH/RCD error handling and provides contrast to VH mode.
-Terry
Quoted 9 lines
As noted above,
cxl_rch_handle_error()skips the RCD device. With the RCD also falling through to the default case here and returning false, these errors are never enqueued.This results in correctable errors being silently dropped without being traced or cleared (as the legacy
cor_error_detectedfallback was removed). For uncorrectable errors, it bypasses the kfifo's synchronization, defeating the race-condition fix and leaving the system vulnerable to teardown races.
Re: [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow
In reply to Terry BowmanQuoted 36 lines · Terry Bowman
Establish a single CXL protocol error path shared by CXL Virtual Hierarchy (VH) and Restricted CXL Host (RCH) topologies. AER dispatch in
handle_error_source()routes CXL protocol errors, gated byis_cxl_error(), through the AER-CXL kfifo to acxl_coreconsumer for logging and recovery. Producer and consumer go live together so no CXL error is silently dropped across a bisect.
is_cxl_error()expands from Endpoint-only to also cover Root Port, Upstream Port, and Downstream Port. RCDs report on behalf of an upstream RCH Downstream Port and instead reach the kfifo viacxl_rch_handle_error().For uncorrectable errors,
cxl_proto_err_wait_for_empty()drains the CXL plane (RAS read, panic policy, state clear) beforepci_aer_handle_error()drives PCIe recovery, so recovery does not tear down RAS iomaps while the consumer is still reading them. Correctable errors run asynchronously.Panic policy:
cxl_do_recovery()panics on a confirmed UCE, and also when the RAS registers cannot be mapped -- an unconfirmable UCE is treated conservatively as fatal since CXL.mem coherency may be lost. A mapped-but-clear status is logged as spurious with no panic.
to_ras_base()centralizes RAS base lookup (dport->regs.rasfor Root/Downstream Ports,port->regs.rasotherwise) and provides an injection point for RAS status simulation during testing. Thecxl_cor_error_detected()AER callback is removed; correctable Endpoint errors now route through the kfifo like every other CXL protocol error.Update
cxl_handle_rdport_errors()with locking to prevent dport from being freed and RAS from being unmapped.At this step
cxl_handle_rdport_errors()still dispatches a single severity per pass (matching the pre-series baseline). The following patch, "cxl/ras: Handle RCH correctable and uncorrectable errors in one pass", processes a simultaneously signalled CE and UCE together.
Quoted 6 lines
Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>---
One small nit, but otherwise LGTM:
...
Quoted 39 lines
pci_ers_result_tcxl_error_detected(structpci_dev*pdev,drivers/cxl/core/ras.c +16
-14pci_channel_state_t state) { -struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); -struct cxl_memdev *cxlmd = cxlds->cxlmd; -struct device *dev = &cxlmd->dev; -bool ue; + struct cxl_port *port __free(put_cxl_port) = find_cxl_port_by_uport(&pdev->dev); +bool ue = false; + +if (!port) +return PCI_ERS_RESULT_DISCONNECT ; + +if (is_cxl_restricted (pdev)) +cxl_handle_rdport_errors (pdev); - scoped_guard(device, dev) { -if (!dev->driver) { + scoped_guard(device, &port->dev) { +if (!port->dev.driver) {dev_warn (&pdev->dev, -"%s: memdev disabled, abort error handling\n" , -dev_name (dev)); +"%s: port disabled, abort error handling\n" , +dev_name (&port->dev));return PCI_ERS_RESULT_DISCONNECT ; } -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds);/* -* A frozen channel indicates an impending reset which is fatal to -* CXL.mem operation, and will likely crash the system. On the off -* chance the situation is recoverable dump the status of the RAS -* capability registers and bounce the active state of the memdev. +* The CXL RAS read is unconditional regardless of channel +* state. Any uncorrectable error bit set in the CXL RAS +* status register triggers a panic below because CXL.mem +* cache coherency is already lost; continuing risks silent
drivers/cxl/core/ras.c bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) · line 353
Quoted 10 lines
drivers/cxl/core/ras.c +6
-1+* data corruption. */ - ue =cxl_handle_ras (&cxlds->cxlmd->dev, cxlmd->endpoint->regs.ras); + ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); } +/* +* CXL.mem UCE means cache coherency is lost. Continuing risks +* silent data corruption. +*/
Don't need this comment and the last sentence in the comment above.
Quoted 24 lines
drivers/cxl/core/ras.c +5
-6+if (ue) +panic ("CXL cachemem error" ); +switch (state) {case pci_channel_io_normal: -if (ue) { -device_release_driver (dev); -return PCI_ERS_RESULT_NEED_RESET ; - }return PCI_ERS_RESULT_CAN_RECOVER ;case pci_channel_io_frozen:dev_warn (&pdev->dev,"%s: frozen state error detected, disable CXL.mem\n" , -dev_name (dev)); -device_release_driver (dev); +dev_name (port->uport_dev)); +device_release_driver (port->uport_dev);return PCI_ERS_RESULT_NEED_RESET ;case pci_channel_io_perm_failure: dev_warn(&pdev->dev,@@ -335,3 +371,82 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,return PCI_ERS_RESULT_NEED_RESET ; }EXPORT_SYMBOL_NS_GPL (cxl_error_detected,"CXL" );
Re: [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow
Quoted 94 lines · Benjamin
Quoted 36 lines · Terry Bowman
Establish a single CXL protocol error path shared by CXL Virtual Hierarchy (VH) and Restricted CXL Host (RCH) topologies. AER dispatch in
handle_error_source()routes CXL protocol errors, gated byis_cxl_error(), through the AER-CXL kfifo to acxl_coreconsumer for logging and recovery. Producer and consumer go live together so no CXL error is silently dropped across a bisect.
is_cxl_error()expands from Endpoint-only to also cover Root Port, Upstream Port, and Downstream Port. RCDs report on behalf of an upstream RCH Downstream Port and instead reach the kfifo viacxl_rch_handle_error().For uncorrectable errors,
cxl_proto_err_wait_for_empty()drains the CXL plane (RAS read, panic policy, state clear) beforepci_aer_handle_error()drives PCIe recovery, so recovery does not tear down RAS iomaps while the consumer is still reading them. Correctable errors run asynchronously.Panic policy:
cxl_do_recovery()panics on a confirmed UCE, and also when the RAS registers cannot be mapped -- an unconfirmable UCE is treated conservatively as fatal since CXL.mem coherency may be lost. A mapped-but-clear status is logged as spurious with no panic.
to_ras_base()centralizes RAS base lookup (dport->regs.rasfor Root/Downstream Ports,port->regs.rasotherwise) and provides an injection point for RAS status simulation during testing. Thecxl_cor_error_detected()AER callback is removed; correctable Endpoint errors now route through the kfifo like every other CXL protocol error.Update
cxl_handle_rdport_errors()with locking to prevent dport from being freed and RAS from being unmapped.At this step
cxl_handle_rdport_errors()still dispatches a single severity per pass (matching the pre-series baseline). The following patch, "cxl/ras: Handle RCH correctable and uncorrectable errors in one pass", processes a simultaneously signalled CE and UCE together.Quoted 6 lines
Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>---
One small nit, but otherwise LGTM:
Reviewed-by Ben Cheatham <[email protected]>...
Quoted 45 lines
pci_ers_result_tcxl_error_detected(structpci_dev*pdev,drivers/cxl/core/ras.c +18
-15pci_channel_state_t state) { -struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); -struct cxl_memdev *cxlmd = cxlds->cxlmd; -struct device *dev = &cxlmd->dev; -bool ue; + struct cxl_port *port __free(put_cxl_port) = find_cxl_port_by_uport(&pdev->dev); +bool ue = false; + +if (!port) +return PCI_ERS_RESULT_DISCONNECT ; + +if (is_cxl_restricted (pdev)) +cxl_handle_rdport_errors (pdev); - scoped_guard(device, dev) { -if (!dev->driver) { + scoped_guard(device, &port->dev) { +if (!port->dev.driver) {dev_warn (&pdev->dev, -"%s: memdev disabled, abort error handling\n" , -dev_name (dev)); +"%s: port disabled, abort error handling\n" , +dev_name (&port->dev));return PCI_ERS_RESULT_DISCONNECT ; } -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds);/* -* A frozen channel indicates an impending reset which is fatal to -* CXL.mem operation, and will likely crash the system. On the off -* chance the situation is recoverable dump the status of the RAS -* capability registers and bounce the active state of the memdev. +* The CXL RAS read is unconditional regardless of channel +* state. Any uncorrectable error bit set in the CXL RAS +* status register triggers a panic below because CXL.mem +* cache coherency is already lost; continuing risks silent +* data corruption. */ - ue =cxl_handle_ras (&cxlds->cxlmd->dev, cxlmd->endpoint->regs.ras); + ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); }
Quoted 6 lines
drivers/cxl/core/ras.c bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) · line 353
Quoted 4 lines
drivers/cxl/core/ras.c +4
-0+/* +* CXL.mem UCE means cache coherency is lost. Continuing risks +* silent data corruption. +*/ Don't need this comment and the last sentence in the comment above.
I'll keep the panic-site comment (it's the "why" at the point of consequence) and will remove the duplicated coherency/corruption sentence from the block comment above (done in 2/9) so there's no duplication at any point in the series.
-Terry
Quoted 24 lines
Quoted 24 lines
drivers/cxl/core/ras.c +5
-6+if (ue) +panic ("CXL cachemem error" ); +switch (state) {case pci_channel_io_normal: -if (ue) { -device_release_driver (dev); -return PCI_ERS_RESULT_NEED_RESET ; - }return PCI_ERS_RESULT_CAN_RECOVER ;case pci_channel_io_frozen:dev_warn (&pdev->dev,"%s: frozen state error detected, disable CXL.mem\n" , -dev_name (dev)); -device_release_driver (dev); +dev_name (port->uport_dev)); +device_release_driver (port->uport_dev);return PCI_ERS_RESULT_NEED_RESET ;case pci_channel_io_perm_failure: dev_warn(&pdev->dev,@@ -335,3 +371,82 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,return PCI_ERS_RESULT_NEED_RESET ; }EXPORT_SYMBOL_NS_GPL (cxl_error_detected,"CXL" );
Re: [PATCH v20 2/9] PCI: Establish common CXL Port protocol error flow
In reply to Terry BowmanQuoted 31 lines · On Wed, 2 Sep 2026 08:39:26 -0500 Terry Bowman <[email protected]> wrote:
Establish a single CXL protocol error path shared by CXL Virtual Hierarchy (VH) and Restricted CXL Host (RCH) topologies. AER dispatch in
handle_error_source()routes CXL protocol errors, gated byis_cxl_error(), through the AER-CXL kfifo to acxl_coreconsumer for logging and recovery. Producer and consumer go live together so no CXL error is silently dropped across a bisect.
is_cxl_error()expands from Endpoint-only to also cover Root Port, Upstream Port, and Downstream Port. RCDs report on behalf of an upstream RCH Downstream Port and instead reach the kfifo viacxl_rch_handle_error().For uncorrectable errors,
cxl_proto_err_wait_for_empty()drains the CXL plane (RAS read, panic policy, state clear) beforepci_aer_handle_error()drives PCIe recovery, so recovery does not tear down RAS iomaps while the consumer is still reading them. Correctable errors run asynchronously.Panic policy:
cxl_do_recovery()panics on a confirmed UCE, and also when the RAS registers cannot be mapped -- an unconfirmable UCE is treated conservatively as fatal since CXL.mem coherency may be lost. A mapped-but-clear status is logged as spurious with no panic.
to_ras_base()centralizes RAS base lookup (dport->regs.rasfor Root/Downstream Ports,port->regs.rasotherwise) and provides an injection point for RAS status simulation during testing. Thecxl_cor_error_detected()AER callback is removed; correctable Endpoint errors now route through the kfifo like every other CXL protocol error.Update
cxl_handle_rdport_errors()with locking to prevent dport from being freed and RAS from being unmapped.
Quoted 9 lines
At this step
cxl_handle_rdport_errors()still dispatches a single severity per pass (matching the pre-series baseline). The following patch, "cxl/ras: Handle RCH correctable and uncorrectable errors in one pass", processes a simultaneously signalled CE and UCE together.Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>
PATCH v20 3/9 cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
In reply to Terry Bowmancxl_rch_get_aer_info() reads and clears both the correctable and uncorrectable AER status registers in a single pass. The previous severity decode returned after the first matching class, so when a correctable and an uncorrectable error were logged simultaneously the correctable event was cleared in hardware but never traced or handled.
Handle both classes independently: dispatch cxl_handle_cor_ras() when correctable status is set and cxl_do_recovery() when uncorrectable status is set. Remove the now-unused cxl_rch_get_aer_severity() helper and decode the uncorrectable severity inline.
Log the uncorrectable status unconditionally. __pci_print_aer() only logs it via ANFE recursion when aer_compute_anfe_status() is non-zero. A conditional skip could drop a fatal or non-ANFE record once the hardware status is cleared.
---
Changes in v19 -> v20:
- Add snapshot of aer_regs before the correctable pci_print_aer(). (Sashiko)
- Log the UCE status unconditionally instead of skipping on PCI_ERR_COR_ADV_NFAT
Changes in v18 -> v19:
- New patch to process correctable and uncorrectable RCH errors in the same call so a co-logged correctable event is not lost.
--- drivers/cxl/core/ras_rch.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)
drivers/cxl/core/ras_rch.c +32 -32
@@ -89,42 +89,15 @@ static bool cxl_rch_get_aer_info(void __iomem *aer_base,return true; } -/* Get AER severity. Return false if there is no error. */ -static bool cxl_rch_get_aer_severity (struct aer_capability_regs *aer_regs, -int *severity) -{ -u32 uncor_status = aer_regs->uncor_status & ~aer_regs->uncor_mask; - -if (uncor_status) { - *severity = (uncor_status & aer_regs->uncor_severity) ? -AER_FATAL :AER_NONFATAL ; -return true; - } - -if (aer_regs->cor_status & ~aer_regs->cor_mask) { - *severity =AER_CORRECTABLE ; -return true; - } - -return false; -} -void cxl_handle_rdport_errors (struct pci_dev *pdev) {struct aer_capability_regs aer_regs;struct cxl_dport *dport; -int severity; struct cxl_port *port __free(put_cxl_port) = cxl_pci_find_port(pdev, NULL);if (!port)return ; -/* -* The RCH Downstream Port is the Root Port's dport -* (dport free and RAS iomap) is hosted on the CXL Host Bridge -* (port->uport_dev), not &port->dev. Hold that device's lock so the -* dport cannot be freed and its registers unmapped while in use here. -*/ guard (device)(port->uport_dev); dport =cxl_find_dport_by_dev (port, pdev->dev.parent);if (!dport)
@@ -133,12 +106,39 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)if (!cxl_rch_get_aer_info (dport->regs.dport_aer, &aer_regs))return ; -if (!cxl_rch_get_aer_severity (&aer_regs, &severity)) -return ; +/* +* Snapshot aer_regs before handling the correctable error: +* pci_print_aer() takes it by pointer and rewrites uncor_status/ +* uncor_mask in place on the Advisory Non-Fatal Error path. Use the +* copy for the uncorrectable dispatch and logging below so neither is +* corrupted by the correctable pci_print_aer() call. +*/ +struct aer_capability_regs uncor_regs = aer_regs; +u32 uncor_status = uncor_regs.uncor_status & ~uncor_regs.uncor_mask; -pci_print_aer (pdev, severity, &aer_regs); -if (severity ==AER_CORRECTABLE ) +/* +* Handle correctable and uncorrectable errors independently; both +* may be set in the same pass and cxl_rch_get_aer_info() has already +* cleared both status registers. +*/ +if (aer_regs.cor_status & ~aer_regs.cor_mask) { +pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs);cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); -else + } + +if (uncor_status) { +int severity = (uncor_status & uncor_regs.uncor_severity) ? +AER_FATAL :AER_NONFATAL ; + +/* +* Log unconditionally. The correctable pci_print_aer() only +* logs this via ANFE recursion when aer_compute_anfe_status() +* is non-zero. Testing PCI_ERR_COR_ADV_NFAT alone cannot tell +* whether it fired, and the HW status is already cleared. A +* duplicate line beats a lost error. +*/ +pci_print_aer (pdev, severity, &uncor_regs); +cxl_do_recovery (pdev, dport->port, dport); + } }
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 3/9] cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
cxl_rch_get_aer_info()reads and clears both the correctable and uncorrectable AER status registers in a single pass. The previous severity decode returned after the first matching class, so when a correctable and an uncorrectable error were logged simultaneously the correctable event was cleared in hardware but never traced or handled.Handle both classes independently: dispatch
cxl_handle_cor_ras()when correctable status is set andcxl_do_recovery()when uncorrectable status is set. Remove the now-unusedcxl_rch_get_aer_severity()helper and decode the uncorrectable severity inline.
Quoted 8 lines
Log the uncorrectable status unconditionally.
__pci_print_aer()only logs it via ANFE recursion whenaer_compute_anfe_status()is non-zero. A conditional skip could drop a fatal or non-ANFE record once the hardware status is cleared.Reported-by Sashiko <[email protected]>Signed-off-by Terry Bowman <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v20 3/9] cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
In reply to Terry BowmanQuoted 16 lines · Terry Bowman
cxl_rch_get_aer_info()reads and clears both the correctable and uncorrectable AER status registers in a single pass. The previous severity decode returned after the first matching class, so when a correctable and an uncorrectable error were logged simultaneously the correctable event was cleared in hardware but never traced or handled.Handle both classes independently: dispatch
cxl_handle_cor_ras()when correctable status is set andcxl_do_recovery()when uncorrectable status is set. Remove the now-unusedcxl_rch_get_aer_severity()helper and decode the uncorrectable severity inline.Log the uncorrectable status unconditionally.
__pci_print_aer()only logs it via ANFE recursion whenaer_compute_anfe_status()is non-zero. A conditional skip could drop a fatal or non-ANFE record once the hardware status is cleared.
Quoted 5 lines
Reported-by Sashiko <[email protected]>Signed-off-by Terry Bowman <[email protected]>---
LGTM:
Jonathan Cameron
maintainerRe: [PATCH v20 3/9] cxl/ras: Handle RCH correctable and uncorrectable errors in one pass
In reply to Terry BowmanQuoted 11 lines · On Wed, 2 Sep 2026 08:39:27 -0500 Terry Bowman <[email protected]> wrote:
cxl_rch_get_aer_info()reads and clears both the correctable and uncorrectable AER status registers in a single pass. The previous severity decode returned after the first matching class, so when a correctable and an uncorrectable error were logged simultaneously the correctable event was cleared in hardware but never traced or handled.Handle both classes independently: dispatch
cxl_handle_cor_ras()when correctable status is set andcxl_do_recovery()when uncorrectable status is set. Remove the now-unusedcxl_rch_get_aer_severity()helper and decode the uncorrectable severity inline.
Quoted 8 lines
Log the uncorrectable status unconditionally.
__pci_print_aer()only logs it via ANFE recursion whenaer_compute_anfe_status()is non-zero. A conditional skip could drop a fatal or non-ANFE record once the hardware status is cleared.Reported-by Sashiko <[email protected]>Signed-off-by Terry Bowman <[email protected]>
Request for Lukas to look at interactions with pci_print_aer() changes that went in this cycle. To me it feels like this 'fixing' things up in the wrong place (maybe!)
Quoted 64 lines
---
Changes in v19 -> v20:
- Add snapshot ofaer_regsbefore the correctablepci_print_aer(). (Sashiko)
- Log the UCE status unconditionally instead of skipping onPCI_ERR_COR_ADV_NFATChanges in v18 -> v19:
- New patch to process correctable and uncorrectable RCH errors in the same call so a co-logged correctable event is not lost.--- drivers/cxl/core/ras_rch.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/cxl/core/ras_rch.c +0
-27@@ -89,42 +89,15 @@ static bool cxl_rch_get_aer_info(void __iomem *aer_base,return true; } -/* Get AER severity. Return false if there is no error. */ -static bool cxl_rch_get_aer_severity (struct aer_capability_regs *aer_regs, -int *severity) -{ -u32 uncor_status = aer_regs->uncor_status & ~aer_regs->uncor_mask; - -if (uncor_status) { - *severity = (uncor_status & aer_regs->uncor_severity) ? -AER_FATAL :AER_NONFATAL ; -return true; - } - -if (aer_regs->cor_status & ~aer_regs->cor_mask) { - *severity =AER_CORRECTABLE ; -return true; - } - -return false; -} -void cxl_handle_rdport_errors (struct pci_dev *pdev) {struct aer_capability_regs aer_regs;struct cxl_dport *dport; -int severity; struct cxl_port *port __free(put_cxl_port) = cxl_pci_find_port(pdev, NULL);if (!port)return ; -/* -* The RCH Downstream Port is the Root Port's dport -* (dport free and RAS iomap) is hosted on the CXL Host Bridge -* (port->uport_dev), not &port->dev. Hold that device's lock so the -* dport cannot be freed and its registers unmapped while in use here. -*/ guard (device)(port->uport_dev); dport =cxl_find_dport_by_dev (port, pdev->dev.parent);if (!dport)@@ -133,12 +106,39 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)if (!cxl_rch_get_aer_info (dport->regs.dport_aer, &aer_regs))return ;
drivers/cxl/core/ras_rch.c void cxl_handle_rdport_errors(struct pci_dev *pdev) · line 115
Quoted 10 lines
drivers/cxl/core/ras_rch.c +7
-2-if (!cxl_rch_get_aer_severity (&aer_regs, &severity)) -return ; +/* +* Snapshot aer_regs before handling the correctable error: +* pci_print_aer() takes it by pointer and rewrites uncor_status/ +* uncor_mask in place on the Advisory Non-Fatal Error path. Use the +* copy for the uncorrectable dispatch and logging below so neither is +* corrupted by the correctable pci_print_aer() call. +*/
I want input from Lukas on this. Seems like we are papering over the cracks. Maybe pci_print_aer() should be using a copy rather than forcing us to do it out here.
Quoted 32 lines
drivers/cxl/core/ras_rch.c +25
-3+struct aer_capability_regs uncor_regs = aer_regs; +u32 uncor_status = uncor_regs.uncor_status & ~uncor_regs.uncor_mask; -pci_print_aer (pdev, severity, &aer_regs); -if (severity ==AER_CORRECTABLE ) +/* +* Handle correctable and uncorrectable errors independently; both +* may be set in the same pass and cxl_rch_get_aer_info() has already +* cleared both status registers. +*/ +if (aer_regs.cor_status & ~aer_regs.cor_mask) { +pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs);cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); -else + } + +if (uncor_status) { +int severity = (uncor_status & uncor_regs.uncor_severity) ? +AER_FATAL :AER_NONFATAL ; + +/* +* Log unconditionally. The correctable pci_print_aer() only +* logs this via ANFE recursion when aer_compute_anfe_status() +* is non-zero. Testing PCI_ERR_COR_ADV_NFAT alone cannot tell +* whether it fired, and the HW status is already cleared. A +* duplicate line beats a lost error. +*/ +pci_print_aer (pdev, severity, &uncor_regs); +cxl_do_recovery (pdev, dport->port, dport); + } }
PATCH v20 4/9 cxl/pci: Thread port and dport through RAS handling helpers
In reply to Terry BowmanFrom: Dan Williams <[email protected]>
The callers of cxl_handle_ras() and cxl_handle_cor_ras() already hold a struct cxl_port * and optionally a struct cxl_dport * for the device being handled. Passing a generic struct device * requires is_cxl_memdev() to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enables is_cxl_endpoint() and explicit dport/port branching for cleaner trace dispatch.
Refactor cxl_handle_ras() and cxl_handle_cor_ras() to accept struct cxl_port * and struct cxl_dport * directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified via is_cxl_endpoint() and emit with the memdev, dport events emit with dport->dport_dev, and Upstream Port events fall back to port->uport_dev. This branching is transitional: the follow-on patch ("cxl: Add port and dport identifiers to CXL AER trace events") unifies the trace events on port/dport and removes it.
Update cxl_handle_rdport_errors() and cxl_handle_proto_error() to pass Port and Downstream Port to the refactored functions.
RCH Downstream Port correctable trace events now report the dport device (dport->dport_dev) as a consequence of threading Port and Downstream Port through the RAS helpers. The following trace event rework ("cxl: Add port and dport identifiers to CXL AER trace events") adds explicit memdev, Port, Downstream Port, and host fields that provide full context for all device types.
---
Changes in v19 -> v20:
- None
Changes in v18 -> v19:
- Added review-by for DaveJ
- Update commit message that three-way trace branching is transitional and removed by the following trace-event unification patch
Changes in v17 -> v18:
- New patch.
--- drivers/cxl/core/core.h | 12 ++++++++---- drivers/cxl/core/ras.c | 29 +++++++++++++++-------------- drivers/cxl/core/ras_rch.c | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-)
drivers/cxl/core/core.h +8 -4
@@ -187,10 +187,12 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)#ifdef CONFIG_CXL_RAS void cxl_ras_init (void );void cxl_ras_exit (void ); -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base); +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport); -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base); +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport);void cxl_handle_rdport_errors (struct pci_dev *pdev);
@@ -199,13 +201,15 @@ void devm_cxl_dport_ras_setup(struct cxl_dport *dport);#else static inline void cxl_ras_init (void ) { }static inline void cxl_ras_exit (void ) { } -static inline bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +static inline bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) {return false; }static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { } -static inline void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) { } +static inline void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { }
drivers/cxl/core/ras.c +15 -14
@@ -227,20 +227,19 @@ void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport)void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev;void __iomem *ras_base =to_ras_base (port, dport);if (!ras_base)panic ("CXL: UCE with unmapped RAS registers" ); -if (cxl_handle_ras (dev, ras_base)) +if (cxl_handle_ras (port, dport, ras_base))panic ("CXL cachemem error" );dev_dbg (&pdev->dev,"CXL UCE signaled but no CXL RAS status bits set\n" ); } -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {void __iomem *addr;u32 status;
@@ -252,10 +251,12 @@ void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base) status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); -if (is_cxl_memdev (dev)) -trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); +if (is_cxl_endpoint (port)) +trace_cxl_aer_correctable_error (to_cxl_memdev (port->uport_dev), status); +else if (dport) +trace_cxl_port_aer_correctable_error (dport->dport_dev, status);else -trace_cxl_port_aer_correctable_error (dev, status); +trace_cxl_port_aer_correctable_error (port->uport_dev, status); } }
@@ -280,7 +281,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. */ -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_TRACE_SIZE_U32 ] = {};void __iomem *addr;
@@ -307,10 +308,12 @@ bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) }header_log_copy (ras_base, hl); -if (is_cxl_memdev (dev)) -trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +if (is_cxl_endpoint (port)) +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (port->uport_dev), status, fe, hl); +else if (dport) +trace_cxl_port_aer_uncorrectable_error (dport->dport_dev, status, fe, hl);else -trace_cxl_port_aer_uncorrectable_error (dev, status, fe, hl); +trace_cxl_port_aer_uncorrectable_error (port->uport_dev, status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);
@@ -344,7 +347,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,* cache coherency is already lost; continuing risks silent * data corruption. */ - ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); }/*
@@ -375,10 +378,8 @@ EXPORT_SYMBOL_NS_GPL(cxl_error_detected, "CXL");static void cxl_handle_proto_error (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport,int severity) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev; -if (severity ==AER_CORRECTABLE ) -cxl_handle_cor_ras (dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport));else cxl_do_recovery (pdev, port, dport); }
drivers/cxl/core/ras_rch.c +1 -1
@@ -123,7 +123,7 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)*/ if (aer_regs.cor_status & ~aer_regs.cor_mask) {pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs); -cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport)); }if (uncor_status) {
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 18 lines
From: Dan Williams <[email protected]>
The callers of
cxl_handle_ras()andcxl_handle_cor_ras()already hold a structcxl_port* and optionally a structcxl_dport* for the device being handled. Passing a generic struct device * requiresis_cxl_memdev()to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enablesis_cxl_endpoint()and explicit dport/port branching for cleaner trace dispatch.Refactor
cxl_handle_ras()andcxl_handle_cor_ras()to accept structcxl_port* and structcxl_dport* directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified viais_cxl_endpoint()and emit with the memdev, dport events emit withdport->dport_dev, and Upstream Port events fall back toport->uport_dev. This branching is transitional: the follow-on patch [ ... ]
device types.
Quoted 3 lines
Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers
In reply to Terry BowmanQuoted 95 lines · Terry Bowman
From: Dan Williams <[email protected]>
The callers of
cxl_handle_ras()andcxl_handle_cor_ras()already hold a structcxl_port* and optionally a structcxl_dport* for the device being handled. Passing a generic struct device * requiresis_cxl_memdev()to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enablesis_cxl_endpoint()and explicit dport/port branching for cleaner trace dispatch.Refactor
cxl_handle_ras()andcxl_handle_cor_ras()to accept structcxl_port* and structcxl_dport* directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified viais_cxl_endpoint()and emit with the memdev, dport events emit withdport->dport_dev, and Upstream Port events fall back toport->uport_dev. This branching is transitional: the follow-on patch ("cxl: Add port and dport identifiers to CXL AER trace events") unifies the trace events on port/dport and removes it.Update
cxl_handle_rdport_errors()andcxl_handle_proto_error()to pass Port and Downstream Port to the refactored functions.RCH Downstream Port correctable trace events now report the dport device (
dport->dport_dev) as a consequence of threading Port and Downstream Port through the RAS helpers. The following trace event rework ("cxl: Add port and dport identifiers to CXL AER trace events") adds explicit memdev, Port, Downstream Port, and host fields that provide full context for all device types.Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Changes in v19 -> v20:
- NoneChanges in v18 -> v19:
- Added review-by for DaveJ
- Update commit message that three-way trace branching is transitional and removed by the following trace-event unification patchChanges in v17 -> v18:
- New patch.--- drivers/cxl/core/core.h | 12 ++++++++---- drivers/cxl/core/ras.c | 29 +++++++++++++++-------------- drivers/cxl/core/ras_rch.c | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-)drivers/cxl/core/core.h +8
-4@@ -187,10 +187,12 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)#ifdef CONFIG_CXL_RAS void cxl_ras_init (void );void cxl_ras_exit (void ); -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base); +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport); -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base); +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport);void cxl_handle_rdport_errors (struct pci_dev *pdev);@@ -199,13 +201,15 @@ void devm_cxl_dport_ras_setup(struct cxl_dport *dport);#else static inline void cxl_ras_init (void ) { }static inline void cxl_ras_exit (void ) { } -static inline bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +static inline bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) {return false; }static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { } -static inline void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) { } +static inline void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { }drivers/cxl/core/ras.c +0
-0@@ -227,20 +227,19 @@ void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport)
drivers/cxl/core/ras.c void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport) · line 235
Quoted 10 lines
drivers/cxl/core/ras.c +1
-2void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev;void __iomem *ras_base =to_ras_base (port, dport);if (!ras_base)panic ("CXL: UCE with unmapped RAS registers" ); -if (cxl_handle_ras (dev, ras_base)) +if (cxl_handle_ras (port, dport, ras_base))
I haven't looked ahead, and maybe I'm missing something, but why not have cxl_handle_ras() just take the port & dport and call to_ras_base() internally? It's not a big deal, but it would make the call in cxl_error_detected() a lot prettier.
Either way:
Quoted 86 lines
drivers/cxl/core/ras.c +14
-12panic ("CXL cachemem error" );dev_dbg (&pdev->dev,"CXL UCE signaled but no CXL RAS status bits set\n" ); } -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {void __iomem *addr;u32 status;@@ -252,10 +251,12 @@ void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base) status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); -if (is_cxl_memdev (dev)) -trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); +if (is_cxl_endpoint (port)) +trace_cxl_aer_correctable_error (to_cxl_memdev (port->uport_dev), status); +else if (dport) +trace_cxl_port_aer_correctable_error (dport->dport_dev, status);else -trace_cxl_port_aer_correctable_error (dev, status); +trace_cxl_port_aer_correctable_error (port->uport_dev, status); } }@@ -280,7 +281,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. */ -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_TRACE_SIZE_U32 ] = {};void __iomem *addr;@@ -307,10 +308,12 @@ bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) }header_log_copy (ras_base, hl); -if (is_cxl_memdev (dev)) -trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +if (is_cxl_endpoint (port)) +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (port->uport_dev), status, fe, hl); +else if (dport) +trace_cxl_port_aer_uncorrectable_error (dport->dport_dev, status, fe, hl);else -trace_cxl_port_aer_uncorrectable_error (dev, status, fe, hl); +trace_cxl_port_aer_uncorrectable_error (port->uport_dev, status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);@@ -344,7 +347,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,* cache coherency is already lost; continuing risks silent * data corruption. */ - ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); }/* @@ -375,10 +378,8 @@ EXPORT_SYMBOL_NS_GPL(cxl_error_detected, "CXL");static void cxl_handle_proto_error (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport,int severity) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev; -if (severity ==AER_CORRECTABLE ) -cxl_handle_cor_ras (dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport));else cxl_do_recovery (pdev, port, dport); }drivers/cxl/core/ras_rch.c +1
-1@@ -123,7 +123,7 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)*/ if (aer_regs.cor_status & ~aer_regs.cor_mask) {pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs); -cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport)); }if (uncor_status) {
Re: [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers
Quoted 104 lines · Benjamin
Quoted 103 lines · Terry Bowman
From: Dan Williams <[email protected]>
The callers of
cxl_handle_ras()andcxl_handle_cor_ras()already hold a structcxl_port* and optionally a structcxl_dport* for the device being handled. Passing a generic struct device * requiresis_cxl_memdev()to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enablesis_cxl_endpoint()and explicit dport/port branching for cleaner trace dispatch.Refactor
cxl_handle_ras()andcxl_handle_cor_ras()to accept structcxl_port* and structcxl_dport* directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified viais_cxl_endpoint()and emit with the memdev, dport events emit withdport->dport_dev, and Upstream Port events fall back toport->uport_dev. This branching is transitional: the follow-on patch ("cxl: Add port and dport identifiers to CXL AER trace events") unifies the trace events on port/dport and removes it.Update
cxl_handle_rdport_errors()andcxl_handle_proto_error()to pass Port and Downstream Port to the refactored functions.RCH Downstream Port correctable trace events now report the dport device (
dport->dport_dev) as a consequence of threading Port and Downstream Port through the RAS helpers. The following trace event rework ("cxl: Add port and dport identifiers to CXL AER trace events") adds explicit memdev, Port, Downstream Port, and host fields that provide full context for all device types.Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Changes in v19 -> v20:
- NoneChanges in v18 -> v19:
- Added review-by for DaveJ
- Update commit message that three-way trace branching is transitional and removed by the following trace-event unification patchChanges in v17 -> v18:
- New patch.--- drivers/cxl/core/core.h | 12 ++++++++---- drivers/cxl/core/ras.c | 29 +++++++++++++++-------------- drivers/cxl/core/ras_rch.c | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-)drivers/cxl/core/core.h +8
-4@@ -187,10 +187,12 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)#ifdef CONFIG_CXL_RAS void cxl_ras_init (void );void cxl_ras_exit (void ); -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base); +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport); -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base); +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport);void cxl_handle_rdport_errors (struct pci_dev *pdev);@@ -199,13 +201,15 @@ void devm_cxl_dport_ras_setup(struct cxl_dport *dport);#else static inline void cxl_ras_init (void ) { }static inline void cxl_ras_exit (void ) { } -static inline bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +static inline bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) {return false; }static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { } -static inline void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) { } +static inline void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { }drivers/cxl/core/ras.c +0
-1@@ -227,20 +227,19 @@ void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport)void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev;void __iomem *ras_base =to_ras_base (port, dport);if (!ras_base)panic ("CXL: UCE with unmapped RAS registers" );
Quoted 7 lines
drivers/cxl/core/ras.c void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport) · line 235
Quoted 2 lines
drivers/cxl/core/ras.c +1
-1-if (cxl_handle_ras (dev, ras_base)) +if (cxl_handle_ras (port, dport, ras_base))I haven't looked ahead, and maybe I'm missing something, but why not have
cxl_handle_ras()just take the port & dport and callto_ras_base()internally? It's not a big deal, but it would make the call incxl_error_detected()a lot prettier.
This would break for the CPER case which uses GHES/CPER buffer instead of a MMIO RAS block.
Quoted 2 lines
Either way:
Reviewed-by Ben Cheatham <[email protected]>
Thanks Ben.
-Terry
Quoted 87 lines
Quoted 86 lines
drivers/cxl/core/ras.c +14
-12panic ("CXL cachemem error" );dev_dbg (&pdev->dev,"CXL UCE signaled but no CXL RAS status bits set\n" ); } -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {void __iomem *addr;u32 status;@@ -252,10 +251,12 @@ void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base) status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); -if (is_cxl_memdev (dev)) -trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); +if (is_cxl_endpoint (port)) +trace_cxl_aer_correctable_error (to_cxl_memdev (port->uport_dev), status); +else if (dport) +trace_cxl_port_aer_correctable_error (dport->dport_dev, status);else -trace_cxl_port_aer_correctable_error (dev, status); +trace_cxl_port_aer_correctable_error (port->uport_dev, status); } }@@ -280,7 +281,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. */ -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_TRACE_SIZE_U32 ] = {};void __iomem *addr;@@ -307,10 +308,12 @@ bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) }header_log_copy (ras_base, hl); -if (is_cxl_memdev (dev)) -trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +if (is_cxl_endpoint (port)) +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (port->uport_dev), status, fe, hl); +else if (dport) +trace_cxl_port_aer_uncorrectable_error (dport->dport_dev, status, fe, hl);else -trace_cxl_port_aer_uncorrectable_error (dev, status, fe, hl); +trace_cxl_port_aer_uncorrectable_error (port->uport_dev, status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);@@ -344,7 +347,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,* cache coherency is already lost; continuing risks silent * data corruption. */ - ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); }/* @@ -375,10 +378,8 @@ EXPORT_SYMBOL_NS_GPL(cxl_error_detected, "CXL");static void cxl_handle_proto_error (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport,int severity) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev; -if (severity ==AER_CORRECTABLE ) -cxl_handle_cor_ras (dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport));else cxl_do_recovery (pdev, port, dport); }drivers/cxl/core/ras_rch.c +1
-1@@ -123,7 +123,7 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)*/ if (aer_regs.cor_status & ~aer_regs.cor_mask) {pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs); -cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport)); }if (uncor_status) {
Re: [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers
In reply to Cheatham, BenjaminQuoted 104 lines · Benjamin
Quoted 103 lines · Terry Bowman
From: Dan Williams <[email protected]>
The callers of
cxl_handle_ras()andcxl_handle_cor_ras()already hold a structcxl_port* and optionally a structcxl_dport* for the device being handled. Passing a generic struct device * requiresis_cxl_memdev()to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enablesis_cxl_endpoint()and explicit dport/port branching for cleaner trace dispatch.Refactor
cxl_handle_ras()andcxl_handle_cor_ras()to accept structcxl_port* and structcxl_dport* directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified viais_cxl_endpoint()and emit with the memdev, dport events emit withdport->dport_dev, and Upstream Port events fall back toport->uport_dev. This branching is transitional: the follow-on patch ("cxl: Add port and dport identifiers to CXL AER trace events") unifies the trace events on port/dport and removes it.Update
cxl_handle_rdport_errors()andcxl_handle_proto_error()to pass Port and Downstream Port to the refactored functions.RCH Downstream Port correctable trace events now report the dport device (
dport->dport_dev) as a consequence of threading Port and Downstream Port through the RAS helpers. The following trace event rework ("cxl: Add port and dport identifiers to CXL AER trace events") adds explicit memdev, Port, Downstream Port, and host fields that provide full context for all device types.Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Changes in v19 -> v20:
- NoneChanges in v18 -> v19:
- Added review-by for DaveJ
- Update commit message that three-way trace branching is transitional and removed by the following trace-event unification patchChanges in v17 -> v18:
- New patch.--- drivers/cxl/core/core.h | 12 ++++++++---- drivers/cxl/core/ras.c | 29 +++++++++++++++-------------- drivers/cxl/core/ras_rch.c | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-)drivers/cxl/core/core.h +8
-4@@ -187,10 +187,12 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)#ifdef CONFIG_CXL_RAS void cxl_ras_init (void );void cxl_ras_exit (void ); -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base); +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport); -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base); +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport);void cxl_handle_rdport_errors (struct pci_dev *pdev);@@ -199,13 +201,15 @@ void devm_cxl_dport_ras_setup(struct cxl_dport *dport);#else static inline void cxl_ras_init (void ) { }static inline void cxl_ras_exit (void ) { } -static inline bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +static inline bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) {return false; }static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { } -static inline void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) { } +static inline void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, +void __iomem *ras_base) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { }drivers/cxl/core/ras.c +0
-1@@ -227,20 +227,19 @@ void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport)void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev;void __iomem *ras_base =to_ras_base (port, dport);if (!ras_base)panic ("CXL: UCE with unmapped RAS registers" );
Quoted 7 lines
drivers/cxl/core/ras.c void __iomem *to_ras_base(struct cxl_port *port, struct cxl_dport *dport) · line 235
Quoted 2 lines
drivers/cxl/core/ras.c +1
-1-if (cxl_handle_ras (dev, ras_base)) +if (cxl_handle_ras (port, dport, ras_base))I haven't looked ahead, and maybe I'm missing something, but why not have
cxl_handle_ras()just take the port & dport and callto_ras_base()internally? It's not a big deal, but it would make the call incxl_error_detected()a lot prettier.
There are currently 2 callers to cxl_handle_ras() and they manage a NULL RAS block differently.
- cxl_do_recovery(): For non-EP and non-USP CXL devices the AER UCE internal error bit has been confirmed present and panics in cxl_do_recovery() even when the RAS register block is missing.
- cxl_pci_error_detected() (Endpoint AER path): For EP UCEs the cxl_pci_error_detected() is called and does not panic on missing RAS block because the error was not confirmed as a CXL RAS error. The error could be a an AER error instead of CXL RAS.
I agree the cxl_error_detected() call site would read more nicely. I kept the split for the above reasons.
Quoted 2 lines
Either way:
Reviewed-by Ben Cheatham <[email protected]>
Thanks for reviewing.
-Terry
Quoted 87 lines
Quoted 86 lines
drivers/cxl/core/ras.c +14
-12panic ("CXL cachemem error" );dev_dbg (&pdev->dev,"CXL UCE signaled but no CXL RAS status bits set\n" ); } -void cxl_handle_cor_ras (struct device *dev,void __iomem *ras_base) +void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {void __iomem *addr;u32 status;@@ -252,10 +251,12 @@ void cxl_handle_cor_ras(struct device *dev, void __iomem *ras_base) status =readl (addr);if (status &CXL_RAS_CORRECTABLE_STATUS_MASK ) {writel (status &CXL_RAS_CORRECTABLE_STATUS_MASK , addr); -if (is_cxl_memdev (dev)) -trace_cxl_aer_correctable_error (to_cxl_memdev (dev), status); +if (is_cxl_endpoint (port)) +trace_cxl_aer_correctable_error (to_cxl_memdev (port->uport_dev), status); +else if (dport) +trace_cxl_port_aer_correctable_error (dport->dport_dev, status);else -trace_cxl_port_aer_correctable_error (dev, status); +trace_cxl_port_aer_correctable_error (port->uport_dev, status); } }@@ -280,7 +281,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. */ -bool cxl_handle_ras (struct device *dev,void __iomem *ras_base) +bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport,void __iomem *ras_base) {u32 hl[CXL_HEADERLOG_TRACE_SIZE_U32 ] = {};void __iomem *addr;@@ -307,10 +308,12 @@ bool cxl_handle_ras(struct device *dev, void __iomem *ras_base) }header_log_copy (ras_base, hl); -if (is_cxl_memdev (dev)) -trace_cxl_aer_uncorrectable_error (to_cxl_memdev (dev), status, fe, hl); +if (is_cxl_endpoint (port)) +trace_cxl_aer_uncorrectable_error (to_cxl_memdev (port->uport_dev), status, fe, hl); +else if (dport) +trace_cxl_port_aer_uncorrectable_error (dport->dport_dev, status, fe, hl);else -trace_cxl_port_aer_uncorrectable_error (dev, status, fe, hl); +trace_cxl_port_aer_uncorrectable_error (port->uport_dev, status, fe, hl);writel (status &CXL_RAS_UNCORRECTABLE_STATUS_MASK , addr);@@ -344,7 +347,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev,* cache coherency is already lost; continuing risks silent * data corruption. */ - ue =cxl_handle_ras (port->uport_dev,to_ras_base (port,NULL )); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); }/* @@ -375,10 +378,8 @@ EXPORT_SYMBOL_NS_GPL(cxl_error_detected, "CXL");static void cxl_handle_proto_error (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport,int severity) { -struct device *dev = dport ? dport->dport_dev : port->uport_dev; -if (severity ==AER_CORRECTABLE ) -cxl_handle_cor_ras (dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport));else cxl_do_recovery (pdev, port, dport); }drivers/cxl/core/ras_rch.c +1
-1@@ -123,7 +123,7 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)*/ if (aer_regs.cor_status & ~aer_regs.cor_mask) {pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs); -cxl_handle_cor_ras (dport->dport_dev,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport)); }if (uncor_status) {
Re: [PATCH v20 4/9] cxl/pci: Thread port and dport through RAS handling helpers
In reply to Terry BowmanQuoted 28 lines · On Wed, 2 Sep 2026 08:39:28 -0500 Terry Bowman <[email protected]> wrote:
From: Dan Williams <[email protected]>
The callers of
cxl_handle_ras()andcxl_handle_cor_ras()already hold a structcxl_port* and optionally a structcxl_dport* for the device being handled. Passing a generic struct device * requiresis_cxl_memdev()to distinguish Endpoints from Ports at trace emission time. Threading Port and Downstream Port directly enablesis_cxl_endpoint()and explicit dport/port branching for cleaner trace dispatch.Refactor
cxl_handle_ras()andcxl_handle_cor_ras()to accept structcxl_port* and structcxl_dport* directly. The CXL RAS trace event emission logic is split into three branches: Endpoint events are identified viais_cxl_endpoint()and emit with the memdev, dport events emit withdport->dport_dev, and Upstream Port events fall back toport->uport_dev. This branching is transitional: the follow-on patch ("cxl: Add port and dport identifiers to CXL AER trace events") unifies the trace events on port/dport and removes it.Update
cxl_handle_rdport_errors()andcxl_handle_proto_error()to pass Port and Downstream Port to the refactored functions.RCH Downstream Port correctable trace events now report the dport device (
dport->dport_dev) as a consequence of threading Port and Downstream Port through the RAS helpers. The following trace event rework ("cxl: Add port and dport identifiers to CXL AER trace events") adds explicit memdev, Port, Downstream Port, and host fields that provide full context for all device types.
Quoted 5 lines
Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Alison Schofield <[email protected]>
Subject to Ben's question getting a reasonable answer,
PATCH v20 5/9 cxl: Update CXL Endpoint AER handler
In reply to Terry BowmanRename cxl_error_detected() to cxl_pci_error_detected() and rename the struct pci_error_handlers instance from cxl_error_handlers to cxl_pci_error_handlers for consistency with the cxl_pci_ prefix used by the renamed handler and the rest of the PCI-facing entry points.
Document the unconditional CXL RAS read policy: on a dead link, readl() returns 0xFFFFFFFF which is interpreted as UCE bits set and triggers a panic. If RAS registers are not mapped the read is skipped and the frozen/perm_failure switch cases defer to AER recovery for devices without active CXL.mem traffic.
---
Changes in v19->v20:
- Expand the comment block in cxl_pci_error_detected().
- Clarify commit message's first paragraph. cxl_error_handlers is a variable
- Clarify AER handling in cxl_pci_error_detected() block comment
Changes in v18->v19:
- Add review-by for DaveJ and Jonathan
- Remove reindent introduced in v18 at cxl_error_handlers definition.
Changes in v17->v18:
- Fix cxl_pci_error_detected() to use find_cxl_port_by_uport() and port->uport_dev
- Read CXL RAS unconditionally; panic on UCE regardless of channel state
- Document unconditional read policy and 0xFFFFFFFF behavior in comment
- Drop guard removal paragraph from commit message (not in this diff)
- Drop Reviewed-by tags pending re-review after message change
Changes in v16->v17:
- Rename pci_error_handlers struct instance to cxl_pci_error_handlers for cxl_pci_ naming consistency.
- Restore scoped_guard(device) and dev->driver check around AER read.
- NULL-check find_cxl_port_by_dev() before deref of port->uport_dev.
- Updated commit message. (Terry)
- Add scope cleanup for port variable in cxl_pci_error_detected() (Terry)
- Drop cxl_uncor_aer_present(), rely on AER state
Changes in v15->v16:
- Update commit message (DaveJ)
- s/cxl_handle_aer()/cxl_uncor_aer_present()/g (Jonathan)
- cxl_uncor_aer_present(): Leave original result calculation based on if a UCE is present and the provided state (Terry)
- Add call to pci_print_aer(). AER fails to log because is upstream link (Terry)
Changes in v14->v15:
- Update commit message and title. Added Bjorn's ack.
- Move CE and UCE handling logic here
Changes in v13->v14:
- Add Dave Jiang's review-by
- Update commit message & headline (Bjorn)
- Refactor cxl_port_error_detected()/cxl_port_cor_error_detected() to one line (Jonathan)
- Remove cxl_walk_port() (Dan)
- Remove cxl_pci_drv_bound(). Check for 'is_cxl' parent port is sufficient (Dan)
- Remove device_lock_if()
- Combined CE and UCE here (Terry)
Changes in v12->v13:
- Move get_pci_cxl_host_dev() and cxl_handle_proto_error() to Dequeue patch (Terry)
- Remove EP case in cxl_get_ras_base(), not used. (Terry)
- Remove check for dport->dport_dev (Dave)
- Remove whitespace (Terry)
Changes in v11->v12:
- Add call to cxl_pci_drv_bound() in cxl_handle_proto_error() and pci_to_cxl_dev()
- Change cxl_error_detected() -> cxl_cor_error_detected()
- Remove NULL variable assignments
- Replace bus_find_device() with find_cxl_port_by_uport() for upstream port searches.
Changes in v10->v11:
- None
--- drivers/cxl/core/ras.c | 25 ++++++++++++++++--------- drivers/cxl/cxlpci.h | 8 ++++---- drivers/cxl/pci.c | 6 +++--- 3 files changed, 23 insertions(+), 16 deletions(-)
drivers/cxl/core/ras.c +16 -9
@@ -61,7 +61,7 @@ cxl_cper_trace_uncorr_prot_err(struct cxl_memdev *cxlmd,/* * ras_cap.header_log[] holds CXL_HEADERLOG_SIZE_U32 (16) hardware -* dwords. Copy them into the front of a zero-filled +* dwords. Copy them into the front of a zero-filled * CXL_HEADERLOG_TRACE_SIZE_U32 (128) u32 staging buffer so the trace * event memcpy sees a full 512-byte source and the userspace ABI * (rasdaemon) is preserved.
@@ -320,8 +320,8 @@ bool cxl_handle_ras(struct cxl_port *port, struct cxl_dport *dport, void __iomemreturn true; } -pci_ers_result_t cxl_error_detected (struct pci_dev *pdev, -pci_channel_state_t state) +pci_ers_result_t cxl_pci_error_detected (struct pci_dev *pdev, +pci_channel_state_t state) { struct cxl_port *port __free(put_cxl_port) = find_cxl_port_by_uport(&pdev->dev);bool ue = false;
@@ -341,11 +341,18 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, }/* -* The CXL RAS read is unconditional regardless of channel -* state. Any uncorrectable error bit set in the CXL RAS -* status register triggers a panic below because CXL.mem -* cache coherency is already lost; continuing risks silent -* data corruption. +* The CXL RAS uncorrectable status is the only signal here +* that the error is a CXL internal (protocol) error. A set +* UCE bit confirms it and triggers the panic below. On a dead +* link readl() returns 0xFFFFFFFF, which sets all UCE bits and +* triggers the panic intentionally. +* +* If RAS is not mapped the read is skipped. Unlike +* cxl_do_recovery(), which is reached only after +* is_aer_internal_error() has already confirmed a CXL internal +* UCE, this path has no such confirmation, so an unmapped RAS +* block cannot attribute the error to CXL and must not panic. +* The switch cases below then handle AER recovery. */ ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); }
@@ -373,7 +380,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, }return PCI_ERS_RESULT_NEED_RESET ; } -EXPORT_SYMBOL_NS_GPL (cxl_error_detected,"CXL" ); +EXPORT_SYMBOL_NS_GPL (cxl_pci_error_detected,"CXL" );static void cxl_handle_proto_error (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport,int severity)
drivers/cxl/cxlpci.h +4 -4
@@ -79,13 +79,13 @@ struct cxl_dev_state;void read_cdat_data (struct cxl_port *port);#ifdef CONFIG_CXL_RAS -pci_ers_result_t cxl_error_detected (struct pci_dev *pdev, -pci_channel_state_t state); +pci_ers_result_t cxl_pci_error_detected (struct pci_dev *pdev, +pci_channel_state_t state);void devm_cxl_dport_rch_ras_setup (struct cxl_dport *dport);void devm_cxl_port_ras_setup (struct cxl_port *port);#else -static inline pci_ers_result_t cxl_error_detected (struct pci_dev *pdev, -pci_channel_state_t state) +static inline pci_ers_result_t cxl_pci_error_detected (struct pci_dev *pdev, +pci_channel_state_t state) {return PCI_ERS_RESULT_NONE ; }
drivers/cxl/pci.c +3 -3
@@ -998,8 +998,8 @@ static void cxl_reset_done(struct pci_dev *pdev) } } -static const struct pci_error_handlers cxl_error_handlers = { - .error_detected = cxl_error_detected, +static const struct pci_error_handlers cxl_pci_error_handlers = { + .error_detected = cxl_pci_error_detected, .slot_reset = cxl_slot_reset, .resume = cxl_error_resume, .reset_done = cxl_reset_done,
@@ -1009,7 +1009,7 @@ static struct pci_driver cxl_pci_driver = { .name = KBUILD_MODNAME, .id_table = cxl_mem_pci_tbl, .probe = cxl_pci_probe, - .err_handler = &cxl_error_handlers, + .err_handler = &cxl_pci_error_handlers, .dev_groups = cxl_rcd_groups, .driver = { .probe_type = PROBE_PREFER_ASYNCHRONOUS,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 5/9] cxl: Update CXL Endpoint AER handler
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Self-deadlock with PCI AER core via device_release_driver()
- [High] AB-BA lock inversion between PCI AER core and CXL port uport_dev
Pre-existing issues:
- [High] Undefined behavior and truncation on BIT(63) during dead link RAS handling --
commit 2f0ed965e221155153683db0b8960c5aeb8afd4e
Author: Terry Bowman <[email protected]>
cxl: Update CXL Endpoint AER handler
This patch renames cxl_error_detected() to cxl_pci_error_detected() and aligns error handler names. It also modifies the RAS read policy to be unconditional and documents the behavior on dead links.
Quoted 4 lines
drivers/cxl/core/ras.c +0
-0
[ ... ]
Quoted 28 lines
drivers/cxl/core/ras.c +5
-19-pci_ers_result_t cxl_error_detected (struct pci_dev *pdev, -pci_channel_state_t state) -{ -struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); -struct cxl_memdev *cxlmd = cxlds->cxlmd; -struct device *dev = &cxlmd->dev; -bool ue; - - scoped_guard(device, dev) { -if (!dev->driver) { -dev_warn (&pdev->dev, -"%s: memdev disabled, abort error handling\n" , -dev_name (dev)); +"%s: port disabled, abort error handling\n" , + dev_name(&port->dev));return PCI_ERS_RESULT_DISCONNECT ; } -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds);/* -* A frozen channel indicates an impending reset which is fatal to -* CXL.mem operation, and will likely crash the system. On the off -* chance the situation is recoverable dump the status of the RAS -* capability registers and bounce the active state of the memdev. +* The CXL RAS uncorrectable status is the only signal here +* that the error is a CXL internal (protocol) error. A set +* UCE bit confirms it and triggers the panic below. On a dead
drivers/cxl/core/ras.c
Quoted 10 lines
drivers/cxl/core/ras.c +9
-0+* link readl() returns 0xFFFFFFFF, which sets all UCE bits and +* triggers the panic intentionally. +* +* If RAS is not mapped the read is skipped. Unlike +* cxl_do_recovery(), which is reached only after +* is_aer_internal_error() has already confirmed a CXL internal +* UCE, this path has no such confirmation, so an unmapped RAS +* block cannot attribute the error to CXL and must not panic. +* The switch cases below then handle AER recovery. */
[Severity: High]
This is a pre-existing issue, but this patch explicitly documents that reading the RAS registers on a dead link returning 0xFFFFFFFF is intentional.
If readl() returns 0xFFFFFFFF, inside cxl_handle_ras(), hweight32(status) > 1 is true, so it evaluates:
fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK,
readl(rcc_addr)));
Since the dead link causes readl() to return 0xFFFFFFFF, FIELD_GET will extract bits 0-5 and yield 63. Will evaluating BIT(63) trigger undefined behavior on 32-bit platforms and silent truncation on 64-bit platforms?
Quoted 15 lines
drivers/cxl/core/ras.c +8
-3- ue =cxl_handle_ras (&cxlds->cxlmd->dev, cxlmd->endpoint->regs.ras); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); } +/* +* CXL.mem UCE means cache coherency is lost. Continuing risks +* silent data corruption. +*/ +if (ue) +panic ("CXL cachemem error" ); +switch (state) {case pci_channel_io_normal: -if (ue) { -device_release_driver (dev);
drivers/cxl/core/ras.c
Quoted 10 lines
drivers/cxl/core/ras.c +2
-4-return PCI_ERS_RESULT_NEED_RESET ; - }return PCI_ERS_RESULT_CAN_RECOVER ;case pci_channel_io_frozen:dev_warn (&pdev->dev,"%s: frozen state error detected, disable CXL.mem\n" , -dev_name (dev)); -device_release_driver (dev); +dev_name (port->uport_dev)); +device_release_driver (port->uport_dev);
[Severity: High]
The AER core calls report_error_detected() which acquires device_lock(&pdev->dev) before invoking this driver callback.
Because port is resolved via find_cxl_port_by_uport(&pdev->dev), port->uport_dev is identical to &pdev->dev. Will calling device_release_driver(port->uport_dev) here unconditionally attempt to acquire the exact lock that the AER thread is already holding, resulting in a self-deadlock?
Quoted 1 line
return
PCI_ERS_RESULT_NEED_RESET;
[ ... ]
Quoted 4 lines
drivers/cxl/core/ras_rch.c +0
-0
[ ... ]
Quoted 4 lines
drivers/cxl/core/ras_rch.c +0
-3-void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) -{ -struct pci_dev *pdev =to_pci_dev (cxlds->dev);struct aer_capability_regs aer_regs;
drivers/cxl/core/ras_rch.c
Quoted 10 lines
drivers/cxl/core/ras_rch.c +2
-3struct cxl_dport *dport; -int severity; - struct cxl_port *port __free(put_cxl_port) = -cxl_pci_find_port (pdev, &dport); + struct cxl_port *port __free(put_cxl_port) = cxl_pci_find_port(pdev, NULL);if (!port)return ; +guard (device)(port->uport_dev);
[Severity: High]
The AER core executes cxl_pci_error_detected() with device_lock(&pdev->dev) already held, which synchronously calls this function for an RCD.
For an RCD, port->uport_dev resolves to the ACPI root or host bridge, which is an ancestor of pdev. Will locking this ancestor device while holding a descendant's lock create an AB-BA deadlock with concurrent device removal operations that lock from parent to child?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v20 5/9] cxl: Update CXL Endpoint AER handler
Quoted 2 lines · On 9/2/2026 9:05 AM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
The following 2 "new" issues are invalid with reasoning provided further below.
Quoted 4 lines
New issues:
- [High] Self-deadlock with PCI AER core viadevice_release_driver()
- [High] AB-BA lock inversion between PCI AER core and CXL portuport_dev
The next issue is valid but "prior-existing" and I recommend this is addressed later in a separate follow-up submission.
Quoted 67 lines
Pre-existing issues:
- [High] Undefined behavior and truncation on BIT(63) during dead link RAS handling --commit
2f0ed965e221155153683db0b8960c5aeb8afd4e
Author: Terry Bowman <[email protected]>cxl: Update CXL Endpoint AER handler
This patch renames
cxl_error_detected()tocxl_pci_error_detected()and aligns error handler names. It also modifies the RAS read policy to be unconditional and documents the behavior on dead links.Quoted 4 lines
drivers/cxl/core/ras.c +0
-0[ ... ]
Quoted 28 lines
drivers/cxl/core/ras.c +5
-19-pci_ers_result_t cxl_error_detected (struct pci_dev *pdev, -pci_channel_state_t state) -{ -struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); -struct cxl_memdev *cxlmd = cxlds->cxlmd; -struct device *dev = &cxlmd->dev; -bool ue; - - scoped_guard(device, dev) { -if (!dev->driver) { -dev_warn (&pdev->dev, -"%s: memdev disabled, abort error handling\n" , -dev_name (dev)); +"%s: port disabled, abort error handling\n" , + dev_name(&port->dev));return PCI_ERS_RESULT_DISCONNECT ; } -if (cxlds->rcd) -cxl_handle_rdport_errors (cxlds);/* -* A frozen channel indicates an impending reset which is fatal to -* CXL.mem operation, and will likely crash the system. On the off -* chance the situation is recoverable dump the status of the RAS -* capability registers and bounce the active state of the memdev. +* The CXL RAS uncorrectable status is the only signal here +* that the error is a CXL internal (protocol) error. A set +* UCE bit confirms it and triggers the panic below. On a dead drivers/cxl/core/ras.c
Quoted 10 lines
drivers/cxl/core/ras.c +9
-0+* link readl() returns 0xFFFFFFFF, which sets all UCE bits and +* triggers the panic intentionally. +* +* If RAS is not mapped the read is skipped. Unlike +* cxl_do_recovery(), which is reached only after +* is_aer_internal_error() has already confirmed a CXL internal +* UCE, this path has no such confirmation, so an unmapped RAS +* block cannot attribute the error to CXL and must not panic. +* The switch cases below then handle AER recovery. */ [Severity: High]
This is a pre-existing issue, but this patch explicitly documents that reading the RAS registers on a dead link returning0xFFFFFFFFis intentional.If
readl()returns0xFFFFFFFF, insidecxl_handle_ras(), hweight32(status) > 1 is true, so it evaluates:
Quoted 7 lines
fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK,
readl(rcc_addr)));Since the dead link causes
readl()to return0xFFFFFFFF,FIELD_GETwill extract bits 0-5 and yield 63. Will evaluating BIT(63) trigger undefined behavior on 32-bit platforms and silent truncation on 64-bit platforms?
I agree, the analysis is correct. On a dead link the First Error Pointer field reads 0x3F (63), and BIT(63) is undefined on 32-bit and truncates to 0 when stored into the u32 fe on 64-bit.
This is pre-existing: the fe = BIT(FIELD_GET(...)) encoding in cxl_handle_ras() is unchanged by this patch, which only reworks the surrounding comment. It's also diagnostic-only - fe feeds the trace first_error field and has no bearing on the panic or recovery decision (that is driven by the UCE status mask, not fe), so the dead-link path documented here still behaves correctly.
I'd prefer to fix this properly in a follow-up submission rather than fold an unrelated fix into this rename patch. Something like:
u32 fe_bit = FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK, readl(rcc_addr));
/* First Error Pointer is only valid within the UCE status field */
fe = (fe_bit < 32) ? BIT(fe_bit) : 0;Quoted 30 lines
Quoted 15 lines
drivers/cxl/core/ras.c +8
-3- ue =cxl_handle_ras (&cxlds->cxlmd->dev, cxlmd->endpoint->regs.ras); + ue =cxl_handle_ras (port,NULL ,to_ras_base (port,NULL )); } +/* +* CXL.mem UCE means cache coherency is lost. Continuing risks +* silent data corruption. +*/ +if (ue) +panic ("CXL cachemem error" ); +switch (state) {case pci_channel_io_normal: -if (ue) { -device_release_driver (dev);drivers/cxl/core/ras.c
Quoted 10 lines
drivers/cxl/core/ras.c +2
-4-return PCI_ERS_RESULT_NEED_RESET ; - }return PCI_ERS_RESULT_CAN_RECOVER ;case pci_channel_io_frozen:dev_warn (&pdev->dev,"%s: frozen state error detected, disable CXL.mem\n" , -dev_name (dev)); -device_release_driver (dev); +dev_name (port->uport_dev)); +device_release_driver (port->uport_dev);[Severity: High]
The AER core callsreport_error_detected()which acquiresdevice_lock(&pdev->dev)before invoking this driver callback.
Quoted 6 lines
Because port is resolved via
find_cxl_port_by_uport(&pdev->dev),port->uport_devis identical to&pdev->dev. Will callingdevice_release_driver(port->uport_dev)here unconditionally attempt to acquire the exact lock that the AER thread is already holding, resulting in a self-deadlock?
No. For a CXL Endpoint, port->uport_dev is the CXL memory device (struct cxl_memdev), not the PCI device the AER core has locked.
The AER thread holds device_lock(&pdev->dev). The Endpoint Port is hosted on a different device (a child of &pdev->dev), so port->uport_dev != &pdev->dev and device_release_driver(port->uport_dev) acquires a different lock. This is true for both VH Endpoints and RCDs.
Quoted 30 lines
Quoted 1 line
return
PCI_ERS_RESULT_NEED_RESET;[ ... ]
Quoted 4 lines
drivers/cxl/core/ras_rch.c +0
-0[ ... ]
Quoted 4 lines
drivers/cxl/core/ras_rch.c +0
-3-void cxl_handle_rdport_errors (struct cxl_dev_state *cxlds) -{ -struct pci_dev *pdev =to_pci_dev (cxlds->dev);struct aer_capability_regs aer_regs;drivers/cxl/core/ras_rch.c
Quoted 10 lines
drivers/cxl/core/ras_rch.c +2
-3struct cxl_dport *dport; -int severity; - struct cxl_port *port __free(put_cxl_port) = -cxl_pci_find_port (pdev, &dport); + struct cxl_port *port __free(put_cxl_port) = cxl_pci_find_port(pdev, NULL);if (!port)return ; +guard (device)(port->uport_dev);[Severity: High]
The AER core executescxl_pci_error_detected()withdevice_lock(&pdev->dev)already held, which synchronously calls this function for an RCD.
Quoted 5 lines
For an RCD,
port->uport_devresolves to the ACPI root or host bridge, which is an ancestor of pdev. Will locking this ancestor device while holding a descendant's lock create an AB-BA deadlock with concurrent device removal operations that lock from parent to child?
To begin, RCD doesn't support hotplug, so the concurrent removal this describes doesn't happen in practice.
Beyond that, I think this is looking at the wrong pair of locks. The concern assumes an established parent->child device-core lock order, but the RCD pci_dev is not a device-core child of port->uport_dev (the Host Bridge). They're in different device hierarchies, PCI bus vs. CXL bus. So there is no parent/child lock relationship between these two to invert on removal.
For a real AB-BA we'd need a path that holds the Host Bridge lock and then blocks on the RCD's lock, and there isn't one. The Host Bridge lock is also unavoidable here, since the RCH Downstream Port's RAS/AER registers live on the Host Bridge, not the RCD.
-Terry
Re: [PATCH v20 5/9] cxl: Update CXL Endpoint AER handler
In reply to Terry BowmanQuoted 94 lines · Terry Bowman
Rename
cxl_error_detected()tocxl_pci_error_detected()and rename the structpci_error_handlersinstance fromcxl_error_handlerstocxl_pci_error_handlersfor consistency with thecxl_pci_prefix used by the renamed handler and the rest of the PCI-facing entry points.Document the unconditional CXL RAS read policy: on a dead link,
readl()returns0xFFFFFFFFwhich is interpreted as UCE bits set and triggers a panic. If RAS registers are not mapped the read is skipped and the frozen/perm_failure switch cases defer to AER recovery for devices without active CXL.mem traffic.Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Changes in
v19->v20:
- Expand the comment block incxl_pci_error_detected().
- Clarify commit message's first paragraph.cxl_error_handlersis a variable
- Clarify AER handling incxl_pci_error_detected()block commentChanges in
v18->v19:
- Add review-by for DaveJ and Jonathan
- Remove reindent introduced in v18 atcxl_error_handlersdefinition.Changes in
v17->v18:
- Fixcxl_pci_error_detected()to usefind_cxl_port_by_uport()andport->uport_dev
- Read CXL RAS unconditionally; panic on UCE regardless of channel state
- Document unconditional read policy and0xFFFFFFFFbehavior in comment
- Drop guard removal paragraph from commit message (not in this diff)
- Drop Reviewed-by tags pending re-review after message changeChanges in
v16->v17:
- Renamepci_error_handlersstruct instance tocxl_pci_error_handlersforcxl_pci_naming consistency.
- Restorescoped_guard(device)anddev->drivercheck around AER read.
- NULL-checkfind_cxl_port_by_dev()before deref ofport->uport_dev.
- Updated commit message. (Terry)
- Add scope cleanup for port variable incxl_pci_error_detected()(Terry)
- Dropcxl_uncor_aer_present(), rely on AER stateChanges in
v15->v16:
- Update commit message (DaveJ)
- s/cxl_handle_aer()/cxl_uncor_aer_present()/g (Jonathan)
-cxl_uncor_aer_present(): Leave original result calculation based on if a UCE is present and the provided state (Terry)
- Add call topci_print_aer(). AER fails to log because is upstream link (Terry)Changes in
v14->v15:
- Update commit message and title. Added Bjorn's ack.
- Move CE and UCE handling logic hereChanges in
v13->v14:
- Add Dave Jiang's review-by
- Update commit message & headline (Bjorn)
- Refactor cxl_port_error_detected()/cxl_port_cor_error_detected() to one line (Jonathan)
- Removecxl_walk_port()(Dan)
- Removecxl_pci_drv_bound(). Check for 'is_cxl' parent port is sufficient (Dan)
- Removedevice_lock_if()
- Combined CE and UCE here (Terry)Changes in
v12->v13:
- Moveget_pci_cxl_host_dev()andcxl_handle_proto_error()to Dequeue patch (Terry)
- Remove EP case incxl_get_ras_base(), not used. (Terry)
- Remove check fordport->dport_dev(Dave)
- Remove whitespace (Terry)Changes in
v11->v12:
- Add call tocxl_pci_drv_bound()incxl_handle_proto_error()andpci_to_cxl_dev()
- Changecxl_error_detected()->cxl_cor_error_detected()
- Remove NULL variable assignments
- Replacebus_find_device()withfind_cxl_port_by_uport()for upstream port searches.Changes in
v10->v11:
- None--- drivers/cxl/core/ras.c | 25 ++++++++++++++++--------- drivers/cxl/cxlpci.h | 8 ++++---- drivers/cxl/pci.c | 6 +++--- 3 files changed, 23 insertions(+), 16 deletions(-)drivers/cxl/core/ras.c +0
-0
drivers/cxl/core/ras.c cxl_cper_trace_uncorr_prot_err(struct cxl_memdev *cxlmd, · line 64
Quoted 5 lines
drivers/cxl/core/ras.c +1
-1@@ -61,7 +61,7 @@ cxl_cper_trace_uncorr_prot_err(struct cxl_memdev *cxlmd,/* * ras_cap.header_log[] holds CXL_HEADERLOG_SIZE_U32 (16) hardware -* dwords. Copy them into the front of a zero-filled +* dwords. Copy them into the front of a zero-filled
Stray whitespace fix? Doesn't matter much to me, so:
PATCH v20 6/9 PCI: Cache PCI DSN into pci_dev->dsn during probe
In reply to Terry BowmanSubsequent CXL error-reporting code paths need to log the PCI Device Serial Number (DSN) as part of trace events emitted from interrupt or panic context. Computing the DSN there via pci_get_dsn() requires PCI configuration space reads, which are slow, can fail when the link is down or frozen, and may not be safe in some contexts.
Add a u64 dsn field to struct pci_dev and populate it from pci_get_dsn() during pci_init_capabilities() at probe time via pci_dsn_init(). Only write dev->dsn when the read succeeds. The zero initial value from pci_dev allocation already represents 'no DSN available.'
Remove the now-redundant dsn member from the pciehp struct controller along with its kernel-doc. Drop the pci_get_slot()/pci_dev_put() pairs in pciehp_configure_device() and pcie_init() that existed solely to read the DSN into ctrl->dsn. Use pdev->dsn in pciehp_device_replaced() for the device-replacement comparison.
pci_get_dsn() is not modified because it remains a pure config-space read with no side effects on pci_dev. The cache is written exclusively by pci_dsn_init() at probe time.
---
Changes in v19 -> v20:
- Change 2 space to 1 space in comment block in pci_dsn_init
- Add Reviewed-by from Alison Schofield
Changes in v18 -> v19:
- Update pciehp hotplug to use cached DSN.
- Swapped order in series with
("cxl: Add port and dport identifiers to CXL AER trace events ")
- Update function documentation for pci_dsn_init()
Changes in v17->v18:
- New commit.
--- drivers/cxl/pci.c | 2 +- drivers/pci/hotplug/pciehp.h | 4 ---- drivers/pci/hotplug/pciehp_hpc.c | 7 +------ drivers/pci/hotplug/pciehp_pci.c | 4 ---- drivers/pci/probe.c | 17 +++++++++++++++++ include/linux/pci.h | 1 + 6 files changed, 20 insertions(+), 15 deletions(-)
drivers/cxl/pci.c +1 -1
@@ -802,7 +802,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (!dvsec)pci_warn (pdev,"Device DVSEC not present, skip CXL.mem init\n" ); - mds =cxl_memdev_state_create (&pdev->dev,pci_get_dsn (pdev), dvsec); + mds =cxl_memdev_state_create (&pdev->dev, pdev->dsn, dvsec);if (IS_ERR (mds))return PTR_ERR (mds); cxlds = &mds->cxlds;
drivers/pci/hotplug/pciehp.h +0 -4
@@ -46,9 +46,6 @@ extern int pciehp_poll_time;/** * struct controller - PCIe hotplug controller * @pcie: pointer to the controller's PCIe port service device -* @dsn: cached copy of Device Serial Number of Function 0 in the hotplug slot -* (PCIe r6.2 sec 7.9.3); used to determine whether a hotplugged device -* was replaced with a different one during system sleep * @slot_cap: cached copy of the Slot Capabilities register * @inband_presence_disabled: In-Band Presence Detect Disable supported by * controller and disabled per spec recommendation (PCIe r5.0, appendix I
@@ -90,7 +87,6 @@ extern int pciehp_poll_time;*/ struct controller {struct pcie_device *pcie; -u64 dsn;u32 slot_cap;/* capabilities and quirks */ unsigned int inband_presence_disabled:1 ;
drivers/pci/hotplug/pciehp_hpc.c +1 -6
@@ -587,7 +587,7 @@ bool pciehp_device_replaced(struct controller *ctrl) reg != (pdev->subsystem_vendor | (pdev->subsystem_device << 16))))return true; -if (pci_get_dsn (pdev) != ctrl->dsn) +if (pci_get_dsn (pdev) != pdev->dsn)return true;return false;
@@ -1085,11 +1085,6 @@ struct controller *pcie_init(struct pcie_device *dev) } } - pdev =pci_get_slot (subordinate,PCI_DEVFN (0 ,0 )); -if (pdev) - ctrl->dsn =pci_get_dsn (pdev); -pci_dev_put (pdev); -return ctrl; }
drivers/pci/hotplug/pciehp_pci.c +0 -4
@@ -72,10 +72,6 @@ int pciehp_configure_device(struct controller *ctrl)pci_bus_add_devices (parent);down_read_nested (&ctrl->reset_lock, ctrl->depth); - dev =pci_get_slot (parent,PCI_DEVFN (0 ,0 )); - ctrl->dsn =pci_get_dsn (dev); -pci_dev_put (dev); - out:pci_unlock_rescan_remove ();return ret;
drivers/pci/probe.c +17 -0
@@ -2638,6 +2638,22 @@ void pcie_report_downtraining(struct pci_dev *dev)__pcie_print_link_status (dev, false); } +/* +* Cache the Device Serial Number for use in contexts where config-space reads +* are unsafe (interrupt, panic). Process-context callers that need a fresh +* value (e.g. hotplug device replacement) call pci_get_dsn() and compare it +* against this cached pdev->dsn to detect a changed device. Note pdev->dsn +* is 0 for devices without the DSN capability, so such a comparison cannot +* distinguish a replacement. +*/ +static void pci_dsn_init (struct pci_dev *dev) +{ +u64 dsn =pci_get_dsn (dev); + +if (dsn) + dev->dsn = dsn; +} +static void pci_imm_ready_init (struct pci_dev *dev) {u16 status;
@@ -2674,6 +2690,7 @@ static void pci_init_capabilities(struct pci_dev *dev)pci_rebar_init (dev);/* Resizable BAR */ pci_dev3_init (dev);/* Device 3 capabilities */ pci_ide_init (dev);/* Link Integrity and Data Encryption */ +pci_dsn_init (dev);/* Serial number */ pcie_report_downtraining (dev);pci_init_reset_methods (dev);
include/linux/pci.h +1 -0
@@ -390,6 +390,7 @@ struct pci_dev {unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ struct pci_driver *driver;/* Driver bound to this device */ +u64 dsn;/* PCI Device Serial Number */ u64 dma_mask;/* Mask of the bits of bus address this device implements. Normally this is 0xffffffff. You only need to change
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 6/9] PCI: Cache PCI DSN into pci_dev->dsn during probe
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 17 lines
Subsequent CXL error-reporting code paths need to log the PCI Device Serial Number (DSN) as part of trace events emitted from interrupt or panic context. Computing the DSN there via
pci_get_dsn()requires PCI configuration space reads, which are slow, can fail when the link is down or frozen, and may not be safe in some contexts.Add a u64 dsn field to struct
pci_devand populate it frompci_get_dsn()duringpci_init_capabilities()at probe time viapci_dsn_init(). Only writedev->dsnwhen the read succeeds. The zero initial value frompci_devallocation already represents 'no DSN available.'Remove the now-redundant dsn member from the pciehp struct controller along with its kernel-doc. Drop the pci_get_slot()/pci_dev_put() pairs in
pciehp_configure_device()andpcie_init()that existed solely to read the DSN intoctrl->dsn. Usepdev->dsninpciehp_device_replaced()for the device-replacement comparison.
Quoted 5 lines
pci_get_dsn()is not modified because it remains a pure config-space read with no side effects onpci_dev. The cache is written exclusively bypci_dsn_init()at probe time.Signed-off-by Terry Bowman <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v20 6/9] PCI: Cache PCI DSN into pci_dev->dsn during probe
In reply to Terry BowmanQuoted 21 lines · Terry Bowman
Subsequent CXL error-reporting code paths need to log the PCI Device Serial Number (DSN) as part of trace events emitted from interrupt or panic context. Computing the DSN there via
pci_get_dsn()requires PCI configuration space reads, which are slow, can fail when the link is down or frozen, and may not be safe in some contexts.Add a u64 dsn field to struct
pci_devand populate it frompci_get_dsn()duringpci_init_capabilities()at probe time viapci_dsn_init(). Only writedev->dsnwhen the read succeeds. The zero initial value frompci_devallocation already represents 'no DSN available.'Remove the now-redundant dsn member from the pciehp struct controller along with its kernel-doc. Drop the pci_get_slot()/pci_dev_put() pairs in
pciehp_configure_device()andpcie_init()that existed solely to read the DSN intoctrl->dsn. Usepdev->dsninpciehp_device_replaced()for the device-replacement comparison.
pci_get_dsn()is not modified because it remains a pure config-space read with no side effects onpci_dev. The cache is written exclusively bypci_dsn_init()at probe time.
Quoted 6 lines
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Re: [PATCH v20 6/9] PCI: Cache PCI DSN into pci_dev->dsn during probe
In reply to Terry BowmanQuoted 10 lines · Terry Bowman
Subsequent CXL error-reporting code paths need to log the PCI Device Serial Number (DSN) as part of trace events emitted from interrupt or panic context. Computing the DSN there via
pci_get_dsn()requires PCI configuration space reads, which are slow, can fail when the link is down or frozen, and may not be safe in some contexts.Add a u64 dsn field to struct
pci_devand populate it frompci_get_dsn()duringpci_init_capabilities()at probe time viapci_dsn_init(). Only writedev->dsnwhen the read succeeds. The zero initial value frompci_devallocation already represents 'no DSN available.'
[...]
Quoted 4 lines
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>
drivers/pci/probe.c void pcie_report_downtraining(struct pci_dev *dev) · line 2648
Quoted 13 lines
+++
b/drivers/pci/probe.cdrivers/pci/probe.c +8
-0@@ -2638,6 +2638,22 @@ void pcie_report_downtraining(struct pci_dev *dev)__pcie_print_link_status (dev, false); } +/* +* Cache the Device Serial Number for use in contexts where config-space reads +* are unsafe (interrupt, panic). Process-context callers that need a fresh +* value (e.g. hotplug device replacement) call pci_get_dsn() and compare it +* against this cached pdev->dsn to detect a changed device. Note pdev->dsn +* is 0 for devices without the DSN capability, so such a comparison cannot +* distinguish a replacement. +*/
A value of 0 is not a valid serial number in the first place:
PCIe r7.0 sec 7.9.3.2 defines the Device Serial Number as an EUI-64.
In the corresponding IEEE spec on EUIs on page 11 in section "Unassigned and NULL EUI values", it says:
"Many applications have found it useful to define a distinct null
identifier, most often indicating the absence of a valid EUI-48 or EUI-64 value. As an example, a null value might be the power-on state for an integrated circuit register, until the hardware or firmware initializes the register with a valid EUI.
[...]
The all-zeros EUI-48 value (00-00-00-00-00-00) and EUI-64 value (00-00-00-00-00-00-00-00), though assigned to an organization, have not been and will not be used by that assignee as an EUI. (They can be considered as assigned to the IEEE Registration Authority.)"
https://standards.ieee.org/content/dam/ieee-standards/standards/web/documents/tutorials/eui.pdf
Thanks,
Lukas
PATCH v20 7/9 cxl: Add port and dport identifiers to CXL AER trace events
In reply to Terry BowmanFrom: Dan Williams <[email protected]>
Pass struct cxl_port * and struct cxl_dport * to the cxl_aer_* trace events instead of a plain struct device * derived at the caller. The trace event helpers then derive the right strings for Endpoints, Switch Ports, Root Ports, and RCH Downstream Ports consistently across the CPER and native AER paths.
The unified cxl_aer_* events keep "memdev" as the legacy field (Endpoint events populate it with the memdev name; non-Endpoint events emit memdev="") and add new "port" and "dport" string fields populated for all CXL device classes. Updated userspace can key off "port" and "dport" without a parallel set of events.
Remove the separate cxl_port_aer_uncorrectable_error and cxl_port_aer_correctable_error trace events. All CXL AER events now use the unified cxl_aer_* events with port and dport fields.
Rework cxl_cper_handle_prot_err() to use find_cxl_port_by_dev() and the unified trace helpers, replacing the per-port-type branching and bus_find_device() memdev lookup.
The TP_printk format string places "port=%s dport=%s" between "memdev=%s" and "host=%s", changing the text-mode field order from the pre-patch output. This does not affect consumers such as rasdaemon that use libtraceevent to parse fields by name rather than by fixed text position.
For non-Endpoint events (Switch Port, Root Port, RCH Dport), "memdev" is empty and "port"/"dport" carry the topology information.
CPER: trace firmware-supplied protocol errors even when the host device is unbound; the record is self-contained in ras_cap and reads no MMIO. Keep the host lock only to serialize the dport lookup against teardown.
Below are examples of the different CXL devices' error trace logs after this patch:
---------------------
| CXL RP - 0C:00.0 |
---------------------
|
---------------------
| CXL USP - 0D:00.0 |
---------------------
|
--------------------
| CXL DSP - 0E:00.0 |
--------------------
|
---------------------
| CXL EP - 0F:00.0 |
---------------------Root Port:cxl_aer_correctable_error: memdev= port=port1 dport=0000:0c:00.0 \
host=pci0000:0c serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=port1 dport=0000:0c:00.0 \
host=pci0000:0c serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'
Upstream Switch Port:cxl_aer_correctable_error: memdev= port=port2 dport= host=0000:0d:00.0 \
serial=0: status: 'Memory Data ECC Error'
UCE NA - Upstream Switch Port UCE's are handled in the portdrv driver's PCI AER callbacks that are not CXL aware.
Downstream Switch Port:cxl_aer_correctable_error: memdev= port=port2 dport=0000:0e:00.0 \
host=0000:0d:00.0 serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=port2 dport=0000:0e:00.0 \
host=0000:0d:00.0 serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'
RCH Downstream Port (RCD attached under a host bridge, no switch):cxl_aer_correctable_error: memdev= port=root0 dport=pci0000:0c \
host=pci0000:0c serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=root0 dport=pci0000:0c \
host=pci0000:0c serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'
For RCH topologies, both correctable and uncorrectable protocol errors were previously traced against the memdev via the cxl_aer_* events with memdev populated. They now emit memdev="" with the RCH Downstream Port carried in the "dport" field (dport->dport_dev, the host bridge) and the host bridge in "host". Consumers that keyed RCH errors off "memdev" must key off "dport" instead.
Endpoint:cxl_aer_uncorrectable_error: memdev=mem1 port=endpoint4 dport= \
host=0000:0f:00.0 serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'
cxl_aer_correctable_error: memdev=mem1 port=endpoint4 dport= host=0000:0f:00.0 \
serial=0: status: 'Memory Data ECC Error'
---
Changes in v19->v20:
- Remove host->driver gate. Not required for dev_name() call
Changes in v18->v19:
- Drop redundant device lock in cxl_cper_handle_prot_err(); the port reference already keeps the object alive and no RAS iomap is accessed.
- Swap order in series with ("PCI: Cache PCI DSN into pci_dev->dsn during probe")
- Add review-by for DaveJ
Changes in v17->v18:
- Consolidate double find_cxl_port_by_dev() in cxl_cper_handle_prot_err()
- Add comment noting dport is NULL for Endpoint and Upstream Port devices
- Add cxl_trace_* helpers
- Add CPER refactor
Changes in v16->v17:
- Replace cxlds->serial with pci_get_dsn()
- Change 'memdev' to 'device' (Dan)
- Updated Commit message
Changes in v15->v16:
- Add Dan's review-by
- Incorporate Dan's comment into commit message:
"Add the serial number at the end to preserve compatibility with libtraceevent parsing of the parameters."
Changes in v14->v15:
- Update commit message.
- Moved cxl_handle_ras/cxl_handle_cor_ras() changes to future patch (terry)
Changes in v13->v14:
- Update commit headline (Bjorn)
Changes in v12->v13:
- Added Dave Jiang's review-by
Changes in v11 -> v12:
- Correct parameters to call trace_cxl_aer_correctable_error()
- Add reviewed-by for Jonathan and Shiju
Changes in v10->v11:
- Updated CE and UCE trace routines to maintain consistent TP_Struct ABI and unchanged TP_printk() logging.
--- drivers/cxl/core/core.h | 8 +-- drivers/cxl/core/ras.c | 137 +++++++++++++------------------------ drivers/cxl/core/ras_rch.c | 3 +- drivers/cxl/core/trace.c | 35 ++++++++++ drivers/cxl/core/trace.h | 91 +++++++----------------- drivers/cxl/cxlmem.h | 7 ++ 6 files changed, 122 insertions(+), 159 deletions(-)
drivers/cxl/core/core.h +4 -4
@@ -188,11 +188,11 @@ static inline struct device *dport_to_host(struct cxl_dport *dport)void cxl_ras_init (void );void cxl_ras_exit (void );bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, -void __iomem *ras_base); +void __iomem *ras_base,u64 serial);void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport);void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, -void __iomem *ras_base); +void __iomem *ras_base,u64 serial);void cxl_dport_map_rch_aer (struct cxl_dport *dport);void cxl_disable_rch_root_ints (struct cxl_dport *dport);void cxl_handle_rdport_errors (struct pci_dev *pdev);
@@ -202,14 +202,14 @@ void devm_cxl_dport_ras_setup(struct cxl_dport *dport);static inline void cxl_ras_init (void ) { }static inline void cxl_ras_exit (void ) { }static inline bool cxl_handle_ras (struct cxl_port *port,struct cxl_dport *dport, -void __iomem *ras_base) +void __iomem *ras_base,u64 serial) {return false; }static inline void cxl_do_recovery (struct pci_dev *pdev,struct cxl_port *port,struct cxl_dport *dport) { }static inline void cxl_handle_cor_ras (struct cxl_port *port,struct cxl_dport *dport, -void __iomem *ras_base) { } +void __iomem *ras_base,u64 serial) { }static inline void cxl_dport_map_rch_aer (struct cxl_dport *dport) { }static inline void cxl_disable_rch_root_ints (struct cxl_dport *dport) { }static inline void cxl_handle_rdport_errors (struct pci_dev *pdev) { }
drivers/cxl/core/ras.c +48 -89
220 lines not on this page · raw message
drivers/cxl/core/ras_rch.c +2 -1
@@ -123,7 +123,8 @@ void cxl_handle_rdport_errors(struct pci_dev *pdev)*/ if (aer_regs.cor_status & ~aer_regs.cor_mask) {pci_print_aer (pdev,AER_CORRECTABLE , &aer_regs); -cxl_handle_cor_ras (port, dport,to_ras_base (port, dport)); +cxl_handle_cor_ras (port, dport,to_ras_base (port, dport), + pdev->dsn); }if (uncor_status) {
drivers/cxl/core/trace.c +35 -0
@@ -2,7 +2,42 @@/* Copyright(c) 2022 Intel Corporation. All rights reserved. */ #include <cxl.h> +#include <cxlmem.h> #include "core.h" +const char *cxl_trace_memdev_name (struct cxl_port *port) +{ +if (is_cxl_endpoint (port)) { +struct cxl_memdev *cxlmd =to_cxl_memdev (port->uport_dev); + +return dev_name (&cxlmd->dev); + } + +return "" ; +} + +const char *cxl_trace_host_name (struct cxl_port *port) +{ +if (is_cxl_endpoint (port)) { +struct cxl_memdev *cxlmd =to_cxl_memdev (port->uport_dev); + +return dev_name (cxlmd->dev.parent); + } + +return dev_name (port->uport_dev); +} + +const char *cxl_trace_port_name (struct cxl_port *port) +{ +return dev_name (&port->dev); +} + +const char *cxl_trace_dport_name (struct cxl_dport *dport) +{ +if (dport) +return dev_name (dport->dport_dev); +return "" ; +} +#define CREATE_TRACE_POINTS #include "trace.h"
drivers/cxl/core/trace.h +26 -65
128 lines not on this page · raw message
drivers/cxl/cxlmem.h +7 -0
@@ -125,6 +125,13 @@ static inline int cxl_memdev_attach_region(struct cxl_memdev *cxlmd)#endif struct cxl_memdev *devm_cxl_add_classdev (struct cxl_dev_state *cxlds); + +/* trace-event helpers */ +const char *cxl_trace_memdev_name (struct cxl_port *port); +const char *cxl_trace_host_name (struct cxl_port *port); +const char *cxl_trace_port_name (struct cxl_port *port); +const char *cxl_trace_dport_name (struct cxl_dport *dport); +struct cxl_memdev *__devm_cxl_add_memdev (struct cxl_dev_state *cxlds,const struct cxl_memdev_attach *attach); int devm_cxl_sanitize_setup_notifier(struct device *host,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 7/9] cxl: Add port and dport identifiers to CXL AER trace events
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines
From: Dan Williams <[email protected]>
Pass struct
cxl_port* and structcxl_dport* to the cxl_aer_* trace events instead of a plain struct device * derived at the caller. The trace event helpers then derive the right strings for Endpoints, Switch Ports, Root Ports, and RCH Downstream Ports consistently across the CPER and native AER paths.The unified cxl_aer_* events keep "memdev" as the legacy field (Endpoint events populate it with the memdev name; non-Endpoint events emit memdev="") and add new "port" and "dport" string fields populated for all CXL device classes. Updated userspace can key off "port" and "dport" without a parallel set of events.
Quoted 7 lines
Remove the separate
cxl_port_aer_uncorrectable_errorand [ ... ]
serial=0: status: 'Memory Data ECC Error'Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Re: [PATCH v20 7/9] cxl: Add port and dport identifiers to CXL AER trace events
In reply to Terry BowmanQuoted 96 lines · On Wed, 2 Sep 2026 08:39:31 -0500 Terry Bowman <[email protected]> wrote:
From: Dan Williams <[email protected]>
Pass struct
cxl_port* and structcxl_dport* to the cxl_aer_* trace events instead of a plain struct device * derived at the caller. The trace event helpers then derive the right strings for Endpoints, Switch Ports, Root Ports, and RCH Downstream Ports consistently across the CPER and native AER paths.The unified cxl_aer_* events keep "memdev" as the legacy field (Endpoint events populate it with the memdev name; non-Endpoint events emit memdev="") and add new "port" and "dport" string fields populated for all CXL device classes. Updated userspace can key off "port" and "dport" without a parallel set of events.
Remove the separate
cxl_port_aer_uncorrectable_errorandcxl_port_aer_correctable_errortrace events. All CXL AER events now use the unified cxl_aer_* events with port and dport fields.Rework
cxl_cper_handle_prot_err()to usefind_cxl_port_by_dev()and the unified trace helpers, replacing the per-port-type branching andbus_find_device()memdev lookup.The
TP_printkformat string places "port=%s dport=%s" between "memdev=%s" and "host=%s", changing the text-mode field order from the pre-patch output. This does not affect consumers such as rasdaemon that use libtraceevent to parse fields by name rather than by fixed text position.For non-Endpoint events (Switch Port, Root Port, RCH Dport), "memdev" is empty and "port"/"dport" carry the topology information.
CPER: trace firmware-supplied protocol errors even when the host device is unbound; the record is self-contained in
ras_capand reads no MMIO. Keep the host lock only to serialize the dport lookup against teardown.Below are examples of the different CXL devices' error trace logs after this patch:
--------------------- | CXL RP - 0C:00.0 | --------------------- | --------------------- | CXL USP - 0D:00.0 | --------------------- | -------------------- | CXL DSP - 0E:00.0 | -------------------- | --------------------- | CXL EP - 0F:00.0 | ---------------------Root Port:
cxl_aer_correctable_error: memdev= port=port1 dport=0000:0c:00.0 \
host=pci0000:0c serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=port1 dport=0000:0c:00.0 \
host=pci0000:0c serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'Upstream Switch Port:
cxl_aer_correctable_error: memdev= port=port2 dport= host=0000:0d:00.0 \
serial=0: status: 'Memory Data ECC Error'UCE NA - Upstream Switch Port UCE's are handled in the portdrv driver's PCI AER callbacks that are not CXL aware.
Downstream Switch Port:
cxl_aer_correctable_error: memdev= port=port2 dport=0000:0e:00.0 \
host=0000:0d:00.0 serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=port2 dport=0000:0e:00.0 \
host=0000:0d:00.0 serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'RCH Downstream Port (RCD attached under a host bridge, no switch):
cxl_aer_correctable_error: memdev= port=root0 dport=pci0000:0c \
host=pci0000:0c serial=0: status: 'Memory Data ECC Error'
cxl_aer_uncorrectable_error: memdev= port=root0 dport=pci0000:0c \
host=pci0000:0c serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'For RCH topologies, both correctable and uncorrectable protocol errors were previously traced against the memdev via the cxl_aer_* events with memdev populated. They now emit memdev="" with the RCH Downstream Port carried in the "dport" field (
dport->dport_dev, the host bridge) and the host bridge in "host". Consumers that keyed RCH errors off "memdev" must key off "dport" instead.Endpoint:
cxl_aer_uncorrectable_error: memdev=mem1 port=endpoint4 dport= \
host=0000:0f:00.0 serial=0: status: 'Cache Address Parity Error' \
first_error: 'Cache Address Parity Error'
Quoted 6 lines
cxl_aer_correctable_error: memdev=mem1 port=endpoint4 dport= host=0000:0f:00.0 \
serial=0: status: 'Memory Data ECC Error'Co-developed-by Terry Bowman <[email protected]>Signed-off-by Terry Bowman <[email protected]>Signed-off-by Dan Williams <[email protected]>
A trivial 'maybe it looks nicer like this' suggestion inline. Feel free to ignore.
Quoted 7 lines
drivers/cxl/core/trace.c +0
-0@@ -2,7 +2,42 @@/* Copyright(c) 2022 Intel Corporation. All rights reserved. */
drivers/cxl/core/trace.c line 13
Quoted 10 lines
drivers/cxl/core/trace.c +7
-0#include <cxl.h> +#include <cxlmem.h> #include "core.h" +const char *cxl_trace_memdev_name (struct cxl_port *port) +{ +if (is_cxl_endpoint (port)) { +struct cxl_memdev *cxlmd =to_cxl_memdev (port->uport_dev); + +return dev_name (&cxlmd->dev);
Similar to below if you make that change.
drivers/cxl/core/trace.c line 24
Quoted 11 lines
drivers/cxl/core/trace.c +11
-0+ } + +return "" ; +} + +const char *cxl_trace_host_name (struct cxl_port *port) +{ +if (is_cxl_endpoint (port)) { +struct cxl_memdev *cxlmd =to_cxl_memdev (port->uport_dev); + +return dev_name (cxlmd->dev.parent);
return dev_name(to_cxl_memdev(port->uport_dev)->dev.parent);
Maybe that's too ugly though.
Quoted 4 lines
drivers/cxl/core/trace.c +4
-0+ } + +return dev_name (port->uport_dev); +}
PATCH v20 8/9 PCI/CXL: Mask/Unmask CXL protocol errors
In reply to Terry BowmanCXL protocol errors must be unmasked to be reported. Add pci_aer_mask_internal_errors() as the symmetric counterpart to pci_aer_unmask_internal_errors() and export both for cxl_core.
Unmask CXL internal errors in cxl_dport_map_ras() and devm_cxl_port_ras_setup() after the RAS register block is successfully mapped. Register a devm action to restore the mask on teardown. The unmask/mask helpers gate on dev_is_pci() and pcie_aer_is_native() internally so callers need no special-casing.
Remove the dev_is_pci(dport->dport_dev) guard in devm_cxl_dport_rch_ras_setup(). On RCH systems dport->dport_dev is the pci_host_bridge device which is not on pci_bus_type, so this guard blocked real hardware. The caller already gates on dport->rch.
---
Changes in v19 -> v20:
- None
Changes in v18 -> v19:
- Reworded commit message to be more concise.
- Use pci_clear_and_set_config_dword() in pci_aer_mask_internal_errors()
- Add review-by for DaveJ and Jonathan
Changes in v17->v18:
- Make cxl_unmask_proto_interrupts() and cxl_mask_proto_interrupts() static
- Remove dev_is_pci() guard from devm_cxl_dport_rch_ras_setup(); the guard blocked real RCH hardware because pci_host_bridge is not on pci_bus_type
Changes in v16->v17:
- Drop redundant cxl_mask_proto_interrupts() calls from unregister_port() and cxl_dport_remove(); the devres action registered alongside the unmask is the sole mask path.
- Update title
- Remove unnecessary check for aer_capabilities
- Gate cxl_unmask_proto_interrupts() on pcie_aer_is_native()
- Add pci_aer_mask_internal_errors() and cxl_mask_proto_interrupts()
- Only unmask on successful cxl_map_component_regs()
- NULL-check @dev in cxl_{un,}mask_proto_interrupts()
- Drop static and declare in core/core.h
Change in v15 -> v16:
- None
Change in v14 -> v15:
- None
Changes in v13->v14:
- Update commit title's prefix (Bjorn)
Changes in v12->v13:
- Add dev and dev_is_pci() NULL checks in cxl_unmask_proto_interrupts() (Terry)
- Add Dave Jiang's and Ben's review-by
Changes in v11->v12:
- None
--- drivers/cxl/core/ras.c | 73 +++++++++++++++++++++++++++++++---- drivers/pci/pcie/aer.c | 22 +++++++++-- include/linux/aer.h | 2 + tools/testing/cxl/Kbuild | 1 + tools/testing/cxl/test/mock.c | 12 ++++++ 5 files changed, 99 insertions(+), 11 deletions(-)
drivers/cxl/core/ras.c +66 -7
@@ -124,16 +124,64 @@ static void cxl_cper_prot_err_work_fn(struct work_struct *work) } static DECLARE_WORK(cxl_cper_prot_err_work, cxl_cper_prot_err_work_fn); +static void cxl_unmask_proto_interrupts (struct device *dev) +{ +struct pci_dev *pdev; + +if (!dev || !dev_is_pci (dev)) +return ; + + pdev =to_pci_dev (dev); +if (!pcie_aer_is_native (pdev)) +return ; + +pci_aer_unmask_internal_errors (pdev); +} + +static void cxl_mask_proto_interrupts (struct device *dev) +{ +struct pci_dev *pdev; + +if (!dev || !dev_is_pci (dev)) +return ; + + pdev =to_pci_dev (dev); +if (!pcie_aer_is_native (pdev)) +return ; + +pci_aer_mask_internal_errors (pdev); +} + +static void cxl_mask_proto_irqs (void *dev) +{ +cxl_mask_proto_interrupts (dev); +} +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) +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 ))) +return ; + } + +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" ); +return ; + } + +if (!dev_is_pci (dev)) +return ; + +cxl_unmask_proto_interrupts (dev); +if (devm_add_action_or_reset (dport_to_host (dport), + cxl_mask_proto_irqs, dev)) { +dev_warn (dev,"failed to defer CXL proto-irq mask; CXL protocol error reporting disabled\n" ); + dport->regs.component.ras =NULL ; + } }/**
@@ -150,9 +198,6 @@ void devm_cxl_dport_rch_ras_setup(struct cxl_dport *dport) {struct pci_host_bridge *host_bridge; -if (!dev_is_pci (dport->dport_dev)) -return ; -devm_cxl_dport_ras_setup (dport); host_bridge =to_pci_host_bridge (dport->dport_dev);
@@ -167,6 +212,7 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_dport_rch_ras_setup, "CXL");void devm_cxl_port_ras_setup (struct cxl_port *port) {struct cxl_register_map *map = &port->reg_map; +struct device *dev;if (!map->component_map.ras.valid) {dev_dbg (&port->dev,"RAS registers not found\n" );
@@ -175,8 +221,21 @@ void devm_cxl_port_ras_setup(struct cxl_port *port) map->host = &port->dev;if (cxl_map_component_regs (map, &port->regs, -BIT (CXL_CM_CAP_CAP_ID_RAS ))) +BIT (CXL_CM_CAP_CAP_ID_RAS ))) {dev_dbg (&port->dev,"Failed to map RAS capability\n" ); +return ; + } + + dev =is_cxl_endpoint (port) ? port->uport_dev->parent : port->uport_dev; +if (!dev_is_pci (dev)) +return ; + +cxl_unmask_proto_interrupts (dev); +if (devm_add_action_or_reset (&port->dev, cxl_mask_proto_irqs, dev)) { +dev_warn (&port->dev, +"failed to defer CXL proto-irq mask; CXL protocol error reporting disabled\n" ); + port->regs.ras =NULL ; + } }EXPORT_SYMBOL_NS_GPL (devm_cxl_port_ras_setup,"CXL" );
drivers/pci/pcie/aer.c +18 -4
@@ -1281,12 +1281,26 @@ 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_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); -/* -* Internal errors are too device-specific to enable generally, however for CXL -* their behavior is standardized for conveying CXL protocol errors. +/** +* pci_aer_mask_internal_errors - mask internal errors +* @dev: pointer to the pci_dev data structure +* +* Mask internal errors in the Uncorrectable and Correctable Error +* Mask registers. +* +* Note: AER must be enabled and supported by the device which must be +* checked in advance, e.g. with pcie_aer_is_native(). */ -EXPORT_SYMBOL_FOR_MODULES (pci_aer_unmask_internal_errors,"cxl_core" ); +void pci_aer_mask_internal_errors (struct pci_dev *dev) +{ +pci_clear_and_set_config_dword (dev, dev->aer_cap +PCI_ERR_UNCOR_MASK , +0 ,PCI_ERR_UNC_INTN ); +pci_clear_and_set_config_dword (dev, dev->aer_cap +PCI_ERR_COR_MASK , +0 ,PCI_ERR_COR_INTERNAL ); +} +EXPORT_SYMBOL_FOR_MODULES (pci_aer_mask_internal_errors,"cxl_core" );/** * pci_aer_handle_error - handle logging error into an event log
include/linux/aer.h +2 -0
@@ -58,6 +58,7 @@ struct aer_capability_regs {int pci_aer_clear_nonfatal_status (struct pci_dev *dev);int pcie_aer_is_native (struct pci_dev *dev);void pci_aer_unmask_internal_errors (struct pci_dev *dev); +void pci_aer_mask_internal_errors (struct pci_dev *dev);#else static inline int pci_aer_clear_nonfatal_status (struct pci_dev *dev) {
@@ -65,6 +66,7 @@ static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev) }static inline int pcie_aer_is_native (struct pci_dev *dev) {return 0 ; }static inline void pci_aer_unmask_internal_errors (struct pci_dev *dev) { } +static inline void pci_aer_mask_internal_errors (struct pci_dev *dev) { }#endif #ifdef CONFIG_CXL_RAS
tools/testing/cxl/Kbuild +1 -0
@@ -6,6 +6,7 @@ ldflags-y += --wrap=acpi_pci_find_root ldflags-y += --wrap=nvdimm_bus_register ldflags-y += --wrap=cxl_await_media_ready ldflags-y += --wrap=devm_cxl_add_rch_dport +ldflags-y += --wrap=devm_cxl_dport_rch_ras_setup ldflags-y += --wrap=cxl_endpoint_parse_cdat ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup ldflags-y += --wrap=hmat_get_extended_linear_cache_size
tools/testing/cxl/test/mock.c +12 -0
@@ -220,6 +220,18 @@ struct cxl_dport *__wrap_devm_cxl_add_rch_dport(struct cxl_port *port, }EXPORT_SYMBOL_NS_GPL (__wrap_devm_cxl_add_rch_dport,"CXL" ); +void __wrap_devm_cxl_dport_rch_ras_setup (struct cxl_dport *dport) +{ +int index; +struct cxl_mock_ops *ops =get_cxl_mock_ops (&index); + +if (!ops || !ops->is_mock_port (dport->dport_dev)) +devm_cxl_dport_rch_ras_setup (dport); + +put_cxl_mock_ops (index); +} +EXPORT_SYMBOL_NS_GPL (__wrap_devm_cxl_dport_rch_ras_setup,"CXL" ); +void __wrap_cxl_endpoint_parse_cdat (struct cxl_port *port) {int index;
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 8/9] PCI/CXL: Mask/Unmask CXL protocol errors
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Devres memory and action leak on CXL endpoint port unbind/rebind for RCH topologies. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Devres memory and action leak on CXL endpoint port unbind/rebind for RCH topologies. --
commit 6742f1a341d88bb57310da7468fadf1a3f3b4556
Author: Terry Bowman <[email protected]>
PCI/CXL: Mask/Unmask CXL protocol errors
This commit introduces helpers to mask and unmask CXL protocol errors. It unmasks internal errors in cxl_dport_map_ras() and devm_cxl_port_ras_setup() after the RAS register block is successfully mapped, and adds a devm action to restore the mask on teardown.
Quoted 4 lines
drivers/cxl/core/ras.c +0
-0
[ ... ]
Quoted 3 lines
drivers/cxl/core/ras.c +0
-0@@ -124,16 +124,64 @@ static void cxl_cper_prot_err_work_fn(struct work_struct *work) } static DECLARE_WORK(cxl_cper_prot_err_work, cxl_cper_prot_err_work_fn);
[ ... ]
Quoted 15 lines
static void
cxl_dport_map_ras(struct cxl_dport *dport){drivers/cxl/core/ras.c +6
-3struct cxl_register_map *map = &dport->reg_map;struct device *dev = dport->dport_dev; -if (!map->component_map.ras.valid) +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 ))) +return ; + } + +if (cxl_map_component_regs (map, &dport->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS ))) {
drivers/cxl/core/ras.c static void cxl_cper_prot_err_work_fn(struct work_struct *work) · line 181
Quoted 10 lines
drivers/cxl/core/ras.c +9
-0dev_dbg (dev,"Failed to map RAS capability.\n" ); +return ; + } + +if (!dev_is_pci (dev)) +return ; + +cxl_unmask_proto_interrupts (dev); +if (devm_add_action_or_reset (dport_to_host (dport), + cxl_mask_proto_irqs, dev)) {
[Severity: High]
Does this devres action cause an unbounded memory and action leak when a CXL endpoint port is unbound and rebound in RCH topologies?
In cxl_endpoint_port_probe() in drivers/cxl/port.c, when dport->rch is true, it calls devm_cxl_dport_rch_ras_setup(dport). This executes repeatedly across unbind/bind cycles of the endpoint port.
That setup path eventually calls cxl_dport_map_ras(dport), which registers the cxl_mask_proto_irqs action on the device returned by dport_to_host(dport).
For RCH topologies, dport_to_host(dport) evaluates to the parent root port's host device (the ACPI host bridge), not the endpoint port being probed.
Because the action is tied to the parent host device instead of the endpoint port, unbinding and rebinding the endpoint port does not free the devres action. This leaves a leaked action on the parent host device each time the endpoint port is probed.
Quoted 4 lines
drivers/cxl/core/ras.c +3
-0+dev_warn (dev,"failed to defer CXL proto-irq mask; CXL protocol error reporting disabled\n" ); + dport->regs.component.ras =NULL ; + } }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Re: [PATCH v20 8/9] PCI/CXL: Mask/Unmask CXL protocol errors
Quoted 48 lines · On 9/2/2026 9:03 AM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Devres memory and action leak on CXL endpoint port unbind/rebind for RCH topologies. --commit
6742f1a341d88bb57310da7468fadf1a3f3b4556
Author: Terry Bowman <[email protected]>PCI/CXL: Mask/Unmask CXL protocol errors
This commit introduces helpers to mask and unmask CXL protocol errors. It unmasks internal errors in
cxl_dport_map_ras()anddevm_cxl_port_ras_setup()after the RAS register block is successfully mapped, and adds a devm action to restore the mask on teardown.Quoted 4 lines
drivers/cxl/core/ras.c +0
-0[ ... ]
Quoted 3 lines
drivers/cxl/core/ras.c +0
-0@@ -124,16 +124,64 @@ static void cxl_cper_prot_err_work_fn(struct work_struct *work) } static DECLARE_WORK(cxl_cper_prot_err_work, cxl_cper_prot_err_work_fn);[ ... ]
Quoted 21 lines
static void
cxl_dport_map_ras(struct cxl_dport *dport){drivers/cxl/core/ras.c +11
-3struct cxl_register_map *map = &dport->reg_map;struct device *dev = dport->dport_dev; -if (!map->component_map.ras.valid) +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 ))) +return ; + } + +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" ); +return ; + } + +if (!dev_is_pci (dev)) +return ;
Quoted 9 lines
drivers/cxl/core/ras.c static void cxl_cper_prot_err_work_fn(struct work_struct *work) · line 181
Quoted 4 lines
drivers/cxl/core/ras.c +4
-0+ +cxl_unmask_proto_interrupts (dev); +if (devm_add_action_or_reset (dport_to_host (dport), + cxl_mask_proto_irqs, dev)) {[Severity: High]
Does this devres action cause an unbounded memory and action leak when a CXL endpoint port is unbound and rebound in RCH topologies?
No. CXL 1.1 RCD/RCH is not hotpluggable — the RCH Downstream Port and RCD are enumerated once by platform firmware and are never hot-removed or rebound. The unbind/rebind cycle this accumulation depends on does not occur, so the action is registered once, not repeatedly.
CXL4.0 - 9.9 Hot-Plug
"By definition, RCDs and RCHs do not support Hot-Plug."*
Terry
Quoted 21 lines
In
cxl_endpoint_port_probe()indrivers/cxl/port.c, whendport->rchis true, it callsdevm_cxl_dport_rch_ras_setup(dport). This executes repeatedly across unbind/bind cycles of the endpoint port.That setup path eventually calls
cxl_dport_map_ras(dport), which registers thecxl_mask_proto_irqsaction on the device returned bydport_to_host(dport).For RCH topologies,
dport_to_host(dport)evaluates to the parent root port's host device (the ACPI host bridge), not the endpoint port being probed.Because the action is tied to the parent host device instead of the endpoint port, unbinding and rebinding the endpoint port does not free the devres action. This leaves a leaked action on the parent host device each time the endpoint port is probed.
Quoted 4 lines
drivers/cxl/core/ras.c +3
-0+dev_warn (dev,"failed to defer CXL proto-irq mask; CXL protocol error reporting disabled\n" ); + dport->regs.component.ras =NULL ; + } }
Re: [PATCH v20 8/9] PCI/CXL: Mask/Unmask CXL protocol errors
In reply to Terry BowmanQuoted 16 lines · Terry Bowman
CXL protocol errors must be unmasked to be reported. Add
pci_aer_mask_internal_errors()as the symmetric counterpart topci_aer_unmask_internal_errors()and export both forcxl_core.Unmask CXL internal errors in
cxl_dport_map_ras()anddevm_cxl_port_ras_setup()after the RAS register block is successfully mapped. Register a devm action to restore the mask on teardown. The unmask/mask helpers gate ondev_is_pci()andpcie_aer_is_native()internally so callers need no special-casing.Remove the
dev_is_pci(dport->dport_dev)guard indevm_cxl_dport_rch_ras_setup(). On RCH systemsdport->dport_devis thepci_host_bridgedevice which is not onpci_bus_type, so this guard blocked real hardware. The caller already gates ondport->rch.
Quoted 8 lines
Co-developed-by Dan Williams <[email protected]>Signed-off-by Dan Williams <[email protected]>Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>---
Thanks,
Ben
PATCH v20 9/9 Documentation: cxl: Document CXL protocol error handling
In reply to Terry BowmanAdd Documentation/driver-api/cxl/linux/protocol-error-handling.rst describing the end-to-end CXL protocol error path: AER ingress, the AER-CXL kfifo handoff, the cxl_core consumer worker, RCD/RCH special cases, severity policy, trace events, and a source code map.
This documents the architecture introduced by the preceding patches in this series.
---
Changes in v19 -> v20:
- Document the kfifo-overflow panic policy
- Name the CXL Host Bridge device lock (port->uport_dev) in RCH case
- Reword the cxl_do_recovery() no-UE-bits path
- Fix CPER path description: firmware-first is trace-only, no panic
- Diagram: EP RAS read is channel-state independent, not "unconditional"
- Fix cxl_handle_ras() argument count in the fatal-UCE diagram
- Clarify .error_detected skips RAS read without panic when unmapped
Changes in v18->v19:
- Alignment fixes
- Add RC_END/RCiEP to diagram
- Wrap past 80 columns.
- Update cxl_forward_error() return-value behavior
- Add review-by for Jonathan Cameron
- Document the CPER/firmware-first flow (GHES + ext-log producers, CPER-CXL kfifo, trace-only consumer)
- Document the fatal EP/RCD UCE flow via the .error_detected (cxl_pci_error_detected) RAS path, including channel-state handling
- Add an "AER handlers vs RAS handlers" section clarifying the two handler layers and their relationship
Changes in v17->v18:
- Simplify document for readability (Jonathan)
- Drop historical context that goes stale (Jonathan)
- Shorten ASCII flow diagram (Jonathan)
- Drop manual backtick markup, use automarkup (Jonathan)
- Clarify USP/DSP as single switch component (Dave)
- Fix line wrapping to 80 chars (Jonathan)
--- Documentation/driver-api/cxl/index.rst | 1 + .../cxl/linux/protocol-error-handling.rst | 441 ++++++++++++++++++ 2 files changed, 442 insertions(+) create mode 100644 Documentation/driver-api/cxl/linux/protocol-error-handling.rst
Documentation/driver-api/cxl/index.rst +1 -0
@@ -42,6 +42,7 @@ that have impacts on each other. The docs here break up configurations steps. linux/dax-driver linux/memory-hotplug linux/access-coordinates + linux/protocol-error-handling .. toctree:: :maxdepth: 2
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +441 -0
441 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v20 9/9] Documentation: cxl: Document CXL protocol error handling
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Add
Documentation/driver-api/cxl/linux/protocol-error-handling.rstdescribing the end-to-end CXL protocol error path: AER ingress, the AER-CXL kfifo handoff, thecxl_coreconsumer worker, RCD/RCH special cases, severity policy, trace events, and a source code map.This documents the architecture introduced by the preceding patches in this series.
Assisted-by Claude:claude-opus-4.8Signed-off-by Terry Bowman <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Re: [PATCH v20 9/9] Documentation: cxl: Document CXL protocol error handling
In reply to Terry BowmanQuoted 9 lines · On Wed, 2 Sep 2026 08:39:33 -0500 Terry Bowman <[email protected]> wrote:
Add
Documentation/driver-api/cxl/linux/protocol-error-handling.rstdescribing the end-to-end CXL protocol error path: AER ingress, the AER-CXL kfifo handoff, thecxl_coreconsumer worker, RCD/RCH special cases, severity policy, trace events, and a source code map.This documents the architecture introduced by the preceding patches in this series.
Assisted-by Claude:claude-opus-4.8
Assited-by: LLM
for all of these (kernel documentation was recently changed on this).
Quoted 4 lines
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>
...
Quoted 54 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +48
-0@@ -0,0 +1,441 @@ +Error flow +========== + +.. code-block:: text + + CXL device raises AER Internal Error + (PCI_ERR_COR_INTERNAL or PCI_ERR_UNC_INTN) + | + v + +--------------------------------------+ + | AER core (aer.c) | + | aer_irq() -> aer_isr() | + | -> find_source_device() | + | -> handle_error_source(dev, info) | + +--------------------------------------+ + | + v + +--------------------------------------+ + | handle_error_source() dispatch | + | | + | 1. cxl_rch_handle_error() | + | [always; filters internally. | + | RC_END enters the kfifo here | + | via pcie_walk_rcec(), NOT via | + | is_cxl_error() below] | + | | + | 2. if is_cxl_error(): | + | cxl_forward_error() | + | [enqueue to kfifo; EP/RP/USP/ | + | DSP only, RC_END excluded] | + | | + | 3. if cxl_pending && non-CE: | + | cxl_proto_err_wait_for_empty() | + | [sync drain before recovery] | + | | + | 4. pci_aer_handle_error() [always] | + +--------------------------------------+ + | + (kfifo -> workqueue) + | + v + +--------------------------------------+ + | __cxl_proto_err_work_fn() consumer | + | | + | if is_cxl_restricted(pdev): | + | cxl_handle_rdport_errors() | + | [RCH dport RAS first] | + | |
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 58
Quoted 10 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +10
-0+ | cxl_handle_proto_error() | + +--------------------------------------+ + | | + v v + +-----------------+ +--------------------+ + | CE | | UCE | + | cxl_handle_ | | cxl_do_recovery() | + | cor_ras() | | read RAS status | + | trace + clear | | trace + panic | + +-----------------+ +--------------------+
Why so narrow. Seems like bits of this diag would be more readable if you use the whole 80 chars?
Quoted 34 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +34
-0+ +.. code-block:: text + + Fatal UCE on Endpoint (VH Endpoint or RCD; link down, no AER status) + | + v + +--------------------------------------+ + | PCIe core error recovery | + | pcie_do_recovery() | + | -> report_error_detected() | + | -> cxl_pci_error_detected() | + | [pci_error_handlers callback in | + | cxl_core/ras.c; the RAS handler,| + | NOT the AER kfifo path] | + +--------------------------------------+ + | + v + +--------------------------------------+ + | cxl_pci_error_detected() | + | | + | if is_cxl_restricted(pdev): | + | cxl_handle_rdport_errors() | + | [RCD-only: RCH Dport RAS first] | + | | + | if port->dev.driver == NULL: | + | return DISCONNECT [port unbound] | + | | + | cxl_handle_ras(port, NULL, | + | to_ras_base(...), | + | pdev->dsn) | + | [EP RAS read, independent of | + | channel state (not skipped for | + | io_normal); dead link | + | readl()==0xFFFFFFFF sets all UE |
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 260
Quoted 10 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +10
-0+ | bits -> panic] | + | | + | if ue: panic("CXL cachemem error") | + | | + | else switch (channel state): | + | io_normal -> CAN_RECOVER | + | io_frozen -> release driver, | + | NEED_RESET | + | perm_failure -> DISCONNECT | + +--------------------------------------+
Similar. I have a new favourite irritation - overly narrow LLM (I guess) generated diagrams!
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 303
Quoted 13 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +13
-0+.. code-block:: text + + Platform firmware CPER record (CPER_SEC_CXL_PROT_ERR) + | + v + +----------------------+ + | GHES/APEI (ghes.c) | + | ghes_do_proc() | + | cxl_cper_post_ | + | prot_err() | + | kfifo_put(CPER-CXL) | + | schedule_work() | + +----------------------+
Ouch. Definitely wider here too to avoid splitting those function names.
Quoted 31 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +29
-0+ | + v + +----------------------+ + | CPER-CXL kfifo | + | + work_struct | + +----------------------+ + | + v + +----------------------+ + | cxl_cper_prot_err_ | + | work_fn() consumer | + | (cxl_core/ras.c) | + | drain kfifo -> | + +----------------------+ + | + v + +--------------------------------+ + | cxl_cper_handle_prot_err() | + | pci_get_domain_bus_and_slot() | + | find_cxl_port_by_dev() | + | cxl_find_dport_by_dev() | + | | + | if CE: trace correctable | + | else: trace uncorrectable | + | [trace-only; no panic, | + | no cxl_do_recovery()] | + +--------------------------------+ +Severity policy +===============
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 374
Quoted 10 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +10
-0+**Fatal UCE on EP/USP** - A fatal event brings the link down, so the AER +core reads no AER status and is_cxl_error() cannot enqueue the event to the +kfifo. Endpoints and RCDs are instead handled through the +pci_error_handlers .error_detected callback (cxl_pci_error_detected()), +which reads the CXL RAS registers when they are mapped and panics on any UE +bit. If the RAS registers are unmapped the read is skipped without a panic, +because this path has no prior confirmation that the error is CXL internal. +Upstream Ports bound to portdrv fall back to standard AER recovery - a known +limitation. See "Fatal UCE flow for Endpoints and RCDs" above for the full +path and channel-state handling.
This 'known limitation' language kind of implies there is a solution. I'm curious, do you have one in mind? I can sort of see maybe that the class of UCE that leaves CXL.io up is larger than that for PCIe so maybe it would be worth logic to probe the device and see if we can get to it's registers? Anyhow, job for another day.
This looks good to me and even the diag things is just a 'make it prettier' so
Re: [PATCH v20 9/9] Documentation: cxl: Document CXL protocol error handling
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 2 Sep 2026 08:39:33 -0500 Terry Bowman <[email protected]> wrote:
Add
Documentation/driver-api/cxl/linux/protocol-error-handling.rstdescribing the end-to-end CXL protocol error path: AER ingress, the AER-CXL kfifo handoff, thecxl_coreconsumer worker, RCD/RCH special cases, severity policy, trace events, and a source code map.
Quoted 5 lines
Quoted 4 lines
This documents the architecture introduced by the preceding patches in this series.
Assisted-by Claude:claude-opus-4.8Assited-by: LLM
Ok, will switch to "Assisted-by: LLM" across the series.
Quoted 68 lines
for all of these (kernel documentation was recently changed on this).
Quoted 4 lines
Signed-off-by Terry Bowman <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Alison Schofield <[email protected]>...
Quoted 59 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +53
-0@@ -0,0 +1,441 @@ +Error flow +========== + +.. code-block:: text + + CXL device raises AER Internal Error + (PCI_ERR_COR_INTERNAL or PCI_ERR_UNC_INTN) + | + v + +--------------------------------------+ + | AER core (aer.c) | + | aer_irq() -> aer_isr() | + | -> find_source_device() | + | -> handle_error_source(dev, info) | + +--------------------------------------+ + | + v + +--------------------------------------+ + | handle_error_source() dispatch | + | | + | 1. cxl_rch_handle_error() | + | [always; filters internally. | + | RC_END enters the kfifo here | + | via pcie_walk_rcec(), NOT via | + | is_cxl_error() below] | + | | + | 2. if is_cxl_error(): | + | cxl_forward_error() | + | [enqueue to kfifo; EP/RP/USP/ | + | DSP only, RC_END excluded] | + | | + | 3. if cxl_pending && non-CE: | + | cxl_proto_err_wait_for_empty() | + | [sync drain before recovery] | + | | + | 4. pci_aer_handle_error() [always] | + +--------------------------------------+ + | + (kfifo -> workqueue) + | + v + +--------------------------------------+ + | __cxl_proto_err_work_fn() consumer | + | | + | if is_cxl_restricted(pdev): | + | cxl_handle_rdport_errors() | + | [RCH dport RAS first] | + | | + | cxl_handle_proto_error() | + +--------------------------------------+ + | | + v v + +-----------------+ +--------------------+
Quoted 9 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 180
Quoted 5 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +5
-0+ | CE | | UCE | + | cxl_handle_ | | cxl_do_recovery() | + | cor_ras() | | read RAS status | + | trace + clear | | trace + panic | + +-----------------+ +--------------------+Why so narrow. Seems like bits of this diag would be more readable if you use the whole 80 chars?
Yes, would be more readable with wider boxes. I'll make all wider.
Quoted 97 lines
Quoted 35 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +34
-0+ +.. code-block:: text + + Fatal UCE on Endpoint (VH Endpoint or RCD; link down, no AER status) + | + v + +--------------------------------------+ + | PCIe core error recovery | + | pcie_do_recovery() | + | -> report_error_detected() | + | -> cxl_pci_error_detected() | + | [pci_error_handlers callback in | + | cxl_core/ras.c; the RAS handler,| + | NOT the AER kfifo path] | + +--------------------------------------+ + | + v + +--------------------------------------+ + | cxl_pci_error_detected() | + | | + | if is_cxl_restricted(pdev): | + | cxl_handle_rdport_errors() | + | [RCD-only: RCH Dport RAS first] | + | | + | if port->dev.driver == NULL: | + | return DISCONNECT [port unbound] | + | | + | cxl_handle_ras(port, NULL, | + | to_ras_base(...), | + | pdev->dsn) | + | [EP RAS read, independent of | + | channel state (not skipped for | + | io_normal); dead link | + | readl()==0xFFFFFFFF sets all UE |Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 260
Quoted 10 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +10
-0+ | bits -> panic] | + | | + | if ue: panic("CXL cachemem error") | + | | + | else switch (channel state): | + | io_normal -> CAN_RECOVER | + | io_frozen -> release driver, | + | NEED_RESET | + | perm_failure -> DISCONNECT | + +--------------------------------------+Similar. I have a new favourite irritation - overly narrow LLM (I guess) generated diagrams!
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 303
Quoted 13 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +13
-0+.. code-block:: text + + Platform firmware CPER record (CPER_SEC_CXL_PROT_ERR) + | + v + +----------------------+ + | GHES/APEI (ghes.c) | + | ghes_do_proc() | + | cxl_cper_post_ | + | prot_err() | + | kfifo_put(CPER-CXL) | + | schedule_work() | + +----------------------+Ouch. Definitely wider here too to avoid splitting those function names.
Quoted 30 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +29
-0+ | + v + +----------------------+ + | CPER-CXL kfifo | + | + work_struct | + +----------------------+ + | + v + +----------------------+ + | cxl_cper_prot_err_ | + | work_fn() consumer | + | (cxl_core/ras.c) | + | drain kfifo -> | + +----------------------+ + | + v + +--------------------------------+ + | cxl_cper_handle_prot_err() | + | pci_get_domain_bus_and_slot() | + | find_cxl_port_by_dev() | + | cxl_find_dport_by_dev() | + | | + | if CE: trace correctable | + | else: trace uncorrectable | + | [trace-only; no panic, | + | no cxl_do_recovery()] | + +--------------------------------+ +Severity policy +===============
Quoted 16 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst line 374
Quoted 10 lines
Documentation/driver-api/cxl/linux/protocol-error-handling.rst new file +10
-0+**Fatal UCE on EP/USP** - A fatal event brings the link down, so the AER +core reads no AER status and is_cxl_error() cannot enqueue the event to the +kfifo. Endpoints and RCDs are instead handled through the +pci_error_handlers .error_detected callback (cxl_pci_error_detected()), +which reads the CXL RAS registers when they are mapped and panics on any UE +bit. If the RAS registers are unmapped the read is skipped without a panic, +because this path has no prior confirmation that the error is CXL internal. +Upstream Ports bound to portdrv fall back to standard AER recovery - a known +limitation. See "Fatal UCE flow for Endpoints and RCDs" above for the full +path and channel-state handling.This 'known limitation' language kind of implies there is a solution. I'm curious, do you have one in mind? I can sort of see maybe that the class of UCE that leaves CXL.io up is larger than that for PCIe so maybe it would be worth logic to probe the device and see if we can get to it's registers? Anyhow, job for another day.
Yes, we may be able to update aer_get_device_error_info() to check for upstream link health and if its intact then can possibly read the AER registers. I was leaving this for future improvement.
Quoted 3 lines
This looks good to me and even the diag things is just a 'make it prettier' so
Reviewed-by Jonathan Cameron <[email protected]>
Thanks
-Terry
Quoted 5 lines · Terry Bowman
Today the kernel handles native CXL.cachemem RAS only for Endpoints and Restricted CXL Host (RCH) Downstream Ports. Root Ports, Upstream Switch Ports, and Downstream Switch Ports are uncovered. This series introduces a unified CXL protocol error path for all CXL device types, in both VH and RCH topologies.
I'm trying to make sense of the existing code. I know this wasn't introduced by you (but by Robert in 0a867568bb0d), but you've moved this code around recently and are extending it in this series.
Errors of the RCH downstream port are signaled as internal errors of an RCEC on the root bus. Their handling was plumbed into:
aer_process_err_devices()
handle_error_source()
cxl_rch_handle_error()
First of all, handle_error_source() calls pci_aer_handle_error(), which (for Fatal Errors) will issue an FLR of the RCEC. Note that Uncorrectable Internal Errors have Fatal severity by default (PCIe r7.0 sec 7.8.4.4).
If the Uncorrectable Internal Error was the only error, then why is the RCEC being reset? It's just serving as a conduit to inform that there are CXL errors at the downstream port. There's no reason at all to issue an FLR to the RCEC in that case.
Second, cxl_rch_handle_error() then walks all the RCiEPs reporting to the RCEC. This also looks weird to me. Can there ever be more than one RCiEP? I think not, but maybe I'm missing something. If there's only ever a single RCiEP reporting to the RCEC, why perform a walk?
What we actually want to do is retrieve the CXL errors from the downstream port's RCRB, but this is done in a fairly roundabout way:cxl_rch_handle_error() walks the RCiEPs (aka RCDs), invokes the ->error_detected() callback for each, which is cxl_error_detected(). That will then call cxl_handle_rdport_errors() to find the RCH downstream port to which the RCD is attached.
Isn't there a simpler way to find the RCH downstream port from which the error originated? Why do we have to go through the RCDs?
Also, putting this in cxl_error_detected() has a weird side effect:
The function is also invoked when the RCD upstream port experienced an error. But because the retrieval, reporting and handling of RCH downstream port errors was put into this function, those errors are reported and handled as a side effect of RCD upstream port errors. What sense does this make?
The commit message of 0a867568bb0d provides the following hint as to why this approach was chosen:
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time.
So I think the point may have been to make this work even if the cxl module is not loaded? Is that all? Is that the only reason? We have try_module_get() and symbol_get() helpers. You could just call those prior to invoking functions implemented by the cxl module from the AER driver. There's plenty of precedent for that in the kernel.
The problem is that the present approach is fairly complex and has side effects which make it difficult to understand and reason about the error handling. In my view, this should be cleaned up first before bolting more functionality on top of it.
Thanks,
Lukas
Quoted 11 lines · Lukas Wunner
Quoted 5 lines · Terry Bowman
Today the kernel handles native CXL.cachemem RAS only for Endpoints and Restricted CXL Host (RCH) Downstream Ports. Root Ports, Upstream Switch Ports, and Downstream Switch Ports are uncovered. This series introduces a unified CXL protocol error path for all CXL device types, in both VH and RCH topologies.
I'm trying to make sense of the existing code. I know this wasn't introduced by you (but by Robert in
0a867568bb0d), but you've moved this code around recently and are extending it in this series.
Quoted 7 lines
Errors of the RCH downstream port are signaled as internal errors of an RCEC on the root bus. Their handling was plumbed into:
aer_process_err_devices()
handle_error_source()
cxl_rch_handle_error()
cxl_rch_handle_error() is used in the RCH and RCD error handling path. VH errors are handled through the call to cxl_forward_errors(). Both, RCH/RCD and VH errors use the kfifo for handling in cxl_core.
Quoted 10 lines
First of all,
handle_error_source()callspci_aer_handle_error(), which (for Fatal Errors) will issue an FLR of the RCEC. Note that Uncorrectable Internal Errors have Fatal severity by default (PCIe r7.0 sec 7.8.4.4).If the Uncorrectable Internal Error was the only error, then why is the RCEC being reset? It's just serving as a conduit to inform that there are CXL errors at the downstream port. There's no reason at all to issue an FLR to the RCEC in that case.
RCEC FLR doesn't serve a purpose here. This likely needs a check to skip the FLR if the device is a CXL RCEC and the error is internal, indicating a CXL RAS error at the downstream CXL device.
Quoted 5 lines
Second,
cxl_rch_handle_error()then walks all the RCiEPs reporting to the RCEC. This also looks weird to me. Can there ever be more than one RCiEP? I think not, but maybe I'm missing something. If there's only ever a single RCiEP reporting to the RCEC, why perform a walk?
The RCEC can have more than one associated RCiEP. The associated set is carried in the RCEC Endpoint Association DVSEC, which is what pcie_walk_rcec() iterates.
Quoted 10 lines
What we actually want to do is retrieve the CXL errors from the downstream port's RCRB, but this is done in a fairly roundabout way:
cxl_rch_handle_error()walks the RCiEPs (aka RCDs), invokes the ->error_detected() callback for each, which iscxl_error_detected(). That will then callcxl_handle_rdport_errors()to find the RCH downstream port to which the RCD is attached.Isn't there a simpler way to find the RCH downstream port from which the error originated? Why do we have to go through the RCDs?
Unfortunately there isn't a better approach. The CXL spec (Chapter 12) outlines 2 procedures for RCH/RCD protocol error reporting. The standard approach is implemented and follows the logic of searching all CXL RCiEP's (RCDs) associated with the reporting RCEC.
A second approach defined by the CXL spec named the RCEC Downstream Port Association Structure (RDPAS) was submitted for review by Dave Jiang but did not offer obvious improvement as it didn't eliminate the search iterations. Also, its an optionally supported platform device hardware making it "not required".
https://lore.kernel.org/linux-cxl/[email protected]/
Quoted 7 lines
Also, putting this in
cxl_error_detected()has a weird side effect:
The function is also invoked when the RCD upstream port experienced an error. But because the retrieval, reporting and handling of RCH downstream port errors was put into this function, those errors are reported and handled as a side effect of RCD upstream port errors. What sense does this make?
The side effect stems from the RCH Downstream Port being implemented as an RCRB with no BDF or PCI visibility. Because the DP cannot be addressed directly, software discovers it via the downstream RCD.
Per CXL r4.0 §12.2.1.1, an RCH Downstream Port has no BDF of its own. The RCEC Error Source Identification register logs the RCEC's own BDF "because the RCH Downstream Port is not associated with one," and the spec states outright that "the RCEC Error Source Identification register is insufficient for identifying the error source." Software must therefore either follow PCIe rules to inspect the RCEC-associated RCiEPs, or use the optional RDPAS structure (§9.18.1.5) "if present." Because RDPAS is optional, the RCiEP walk is the baseline discovery path, and it is why the DP is reached via its associated RCD rather than addressed directly.
Quoted 9 lines
The commit message of
0a867568bb0dprovides the following hint as to why this approach was chosen:The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time.
Quoted 6 lines
So I think the point may have been to make this work even if the cxl module is not loaded? Is that all? Is that the only reason? We have
try_module_get()andsymbol_get()helpers. You could just call those prior to invoking functions implemented by the cxl module from the AER driver. There's plenty of precedent for that in the kernel.
We we were looking for a callback that fit the current PCI error handling but also supported handling errors detected in the RCH RCRB. The move to use the kfifo removes the module dependency and timing constraint. I'd prefer that over symbol_get()/try_module_get() here: it avoids a per-error symbol lookup in the error path and gives explicit ordering against AER recovery via cxl_proto_err_wait_for_empty(). But, I'm open to it if you see a concrete advantage.
Quoted 8 lines
The problem is that the present approach is fairly complex and has side effects which make it difficult to understand and reason about the error handling. In my view, this should be cleaned up first before bolting more functionality on top of it.
Thanks,
Lukas
I understand the concern. The RCEC-reset-on-conduit-error issue is self-contained and worth fixing. I'll post it as a standalone patch.
For the broader restructuring, this is already on the serie's coversheet TODO list ("Move RCH traversing for handling from AER driver into CXL driver"): the plan is to move the RCH/RCD searching into cxl_core, after the error is forwarded via the kfifo, so discovery lives in the CXL subsystem rather than the AER driver. I'd like to keep this series focused on landing the unified CXL protocol-error path and take that up as follow-up work. Is that acceptable, or is there a specific change you'd want to see land first?
Thanks,
Terry