Re: [PATCH v20 22/22] sfc: support pio mapping based on cxl

Jonathan Cameron
2025-11-12T16:24:43Z

On Mon, 10 Nov 2025 15:36:57 +0000
alejandro.lucero-palau@amd.com wrote:

> From: Alejandro Lucero <alucerop@amd.com>
>
> A PIO buffer is a region of device memory to which the driver can write a
> packet for TX, with the device handling the transmit doorbell without
> requiring a DMA for getting the packet data, which helps reducing latency
> in certain exchanges. With CXL mem protocol this latency can be lowered
> further.
>
> With a device supporting CXL and successfully initialised, use the cxl
> region to map the memory range and use this mapping for PIO buffers.
>
> Add the disabling of those CXL-based PIO buffers if the callback for
> potential cxl endpoint removal by the CXL code happens.
>
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
One comment on something I thought you meant you were changing for v20
but haven't. Not important, so either way:
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
> index 79fe99d83f9f..a84ce45398c1 100644
> --- a/drivers/net/ethernet/sfc/efx_cxl.c
> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
> @@ -11,6 +11,7 @@
> #include <cxl/pci.h>
> #include "net_driver.h"
> #include "efx_cxl.h"
> +#include "efx.h"
>
> #define EFX_CTPIO_BUFFER_SIZE SZ_256M
>
> @@ -20,6 +21,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
> struct pci_dev *pci_dev = efx->pci_dev;
> resource_size_t max_size;
> struct efx_cxl *cxl;
> + struct range range;
> u16 dvsec;
> int rc;
>
> @@ -119,19 +121,40 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
> cxl->efx_region = cxl_create_region(cxl->cxlrd, &cxl->cxled, 1);
> if (IS_ERR(cxl->efx_region)) {
> pci_err(pci_dev, "CXL accel create region failed");
> - cxl_put_root_decoder(cxl->cxlrd);
> - cxl_dpa_free(cxl->cxled);
> - return PTR_ERR(cxl->efx_region);
> + rc = PTR_ERR(cxl->efx_region);
> + goto err_dpa;

I thought you agreed with moving this err_dpa path into the earlier patch to
reduce churn. Maybe you already had v20 ready when you replied to the late
v19 feedback on this. I don't mind much either way as its just a really
minor patch churn thing.

> + }
> +
> + rc = cxl_get_region_range(cxl->efx_region, &range);
> + if (rc) {
> + pci_err(pci_dev, "CXL getting regions params failed");
> + goto err_detach;
> + }
> +
> + cxl->ctpio_cxl = ioremap(range.start, range.end - range.start + 1);
> + if (!cxl->ctpio_cxl) {
> + pci_err(pci_dev, "CXL ioremap region (%pra) failed", &range);
> + rc = -ENOMEM;
> + goto err_detach;
> }
>
> probe_data->cxl = cxl;
> + probe_data->cxl_pio_initialised = true;
>
> return 0;
> +
> +err_detach:
> + cxl_decoder_detach(NULL, cxl->cxled, 0, DETACH_INVALIDATE);
> +err_dpa:
> + cxl_put_root_decoder(cxl->cxlrd);
> + cxl_dpa_free(cxl->cxled);
> + return rc;
> }