Re: [PATCH v11 21/23] CXL/PCI: Introduce CXL uncorrectable protocol error recovery

Jonathan Cameron
2025-09-10T13:33:18Z

On Tue, 26 Aug 2025 20:35:36 -0500
Terry Bowman <terry.bowman@amd.com> wrote:

> Populate the cxl_do_recovery() function with uncorrectable protocol error (UCE)
> handling. Follow similar design as found in PCIe error driver,
> pcie_do_recovery(). One difference is cxl_do_recovery() will treat all UCEs
> as fatal with a kernel panic. This is to prevent corruption on CXL memory.
>
> Introduce cxl_walk_port(). Make this analogous to pci_walk_bridge() but walking
> CXL ports instead. This will iterate through the CXL topology from the
> erroring device through the downstream CXL Ports and Endpoints.
>
> Export pci_aer_clear_fatal_status() for CXL to use if a UCE is not found.
>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>
> ---
> Changes in v10->v11:
> - pci_ers_merge_results() - Move to earlier patch

One trivial formatting thing below.

> diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
> index 536ca9c815ce..3da675f72616 100644
> --- a/drivers/cxl/core/ras.c
> +++ b/drivers/cxl/core/ras.c

> +static void cxl_walk_port(struct device *port_dev,
> + int (*cb)(struct device *, void *),
> + void *userdata)
> +{
> + struct cxl_dport *dport = NULL;
> + struct cxl_port *port;
> + unsigned long index;
> +
> + if (!port_dev)
> + return;
> +
> + port = to_cxl_port(port_dev);
> + if (port->uport_dev && dev_is_pci(port->uport_dev))
> + cb(port->uport_dev, userdata);
> +
> + xa_for_each(&port->dports, index, dport)
> + {

xa_for_each(&port->dports, index, dport) {

as it's just a fancy for loop.

> + struct device *child_port_dev __free(put_device) =
> + bus_find_device(&cxl_bus_type, &port->dev, dport,
> + match_port_by_parent_dport);
> +
> + cb(dport->dport_dev, userdata);
> +
> + cxl_walk_port(child_port_dev, cxl_report_error_detected, userdata);
> + }
> +
> + if (is_cxl_endpoint(port))
> + cb(port->uport_dev->parent, userdata);
> +}