Subject: Re: [PATCH v8 27/27] sfc: support pio mapping based on cxl

From: Simon Horman <[email-masked]>
Date: Tue, 17 Dec 2024 10:47:26 +0000

On Mon, Dec 16, 2024 at 04:10:42PM +0000, [email-masked] wrote:
> From: Alejandro Lucero <[email-masked]>
> 
> With a device supporting CXL and successfully initialised, use the cxl
> region to map the memory range and use this mapping for PIO buffers.
> 
> Signed-off-by: Alejandro Lucero <[email-masked]>
> Acked-by: Edward Cree <[email-masked]>

...

> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
> index 7367ba28a40f..6eab6dfd7ebd 100644
> --- a/drivers/net/ethernet/sfc/efx_cxl.c
> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
> @@ -27,6 +27,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  	struct pci_dev *pci_dev;
>  	struct efx_cxl *cxl;
>  	struct resource res;
> +	struct range range;
>  	u16 dvsec;
>  	int rc;
>  
> @@ -136,10 +137,25 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  		goto err_region;
>  	}
>  
> +	rc = cxl_get_region_range(cxl->efx_region, &range);
> +	if (rc) {
> +		pci_err(pci_dev, "CXL getting regions params failed");
> +		goto err_region_params;
> +	}
> +
> +	cxl->ctpio_cxl = ioremap(range.start, range.end - range.start);

nit: Smatch suggests that resource_size() may be used here.

> +	if (!cxl->ctpio_cxl) {
> +		pci_err(pci_dev, "CXL ioremap region (%pra) pfailed", &range);

I think rc should be be set to an error value here.

Also flagged by Smatch.

> +		goto err_region_params;
> +	}
> +
>  	probe_data->cxl = cxl;
> +	probe_data->cxl_pio_initialised = true;
>  
>  	return 0;
>  
> +err_region_params:
> +	cxl_accel_region_detach(cxl->cxled);
>  err_region:
>  	cxl_dpa_free(cxl->cxled);
>  err_memdev:

...