Subject: Re: [PATCH v24 09/11] sfc: obtain decoder and region if committed by firmware

From: Jonathan Cameron <[email-masked]>
Date: Tue, 24 Mar 2026 16:56:55 +0000

On Mon, 23 Mar 2026 11:31:15 +0000
[email-masked] wrote:

> From: Alejandro Lucero <[email-masked]>
> 
> Check if device HDM is already committed during firmware/BIOS
> initialization.
> 
> A CXL region should exist if so after memdev allocation/initialization.
> Get HPA from region and map it.
> 
> Signed-off-by: Alejandro Lucero <[email-masked]>
> Acked-by: Edward Cree <[email-masked]>
> ---
>  drivers/net/ethernet/sfc/efx_cxl.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
> index 22a7d1d95425..78f926300943 100644
> --- a/drivers/net/ethernet/sfc/efx_cxl.c
> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
> @@ -19,6 +19,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  	struct efx_nic *efx = &probe_data->efx;
>  	struct pci_dev *pci_dev = efx->pci_dev;
>  	struct efx_cxl *cxl;
> +	struct range range;
>  	u16 dvsec;
>  	int rc;
>  
> @@ -82,6 +83,24 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  		return PTR_ERR(cxl->cxlmd);
>  	}
>  
> +	cxl->cxled = cxl_get_committed_decoder(cxl->cxlmd, &cxl->efx_region);
> +	if (!cxl->cxled || !cxl->efx_region)
> +		return -ENODEV;
> +
> +	rc = cxl_get_region_range(cxl->efx_region, &range);
> +	if (rc) {
> +		pci_err(pci_dev,
> +			"CXL getting regions params from a committed decoder failed");
> +		return rc;
> +	}
> +
> +	cxl->ctpio_cxl = ioremap(range.start, range_len(&range));
> +	if (!cxl->ctpio_cxl) {
> +		pci_err(pci_dev, "CXL ioremap region (%pra) failed", &range);
> +		return -ENOMEM;
> +	}
> +
> +
>  	probe_data->cxl = cxl;
>  
>  	return 0;
> @@ -89,6 +108,11 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>  
>  void efx_cxl_exit(struct efx_probe_data *probe_data)
>  {
> +	if (!probe_data->cxl)
> +		return;
> +
> +	iounmap(probe_data->cxl->ctpio_cxl);
> +	cxl_unregister_region(probe_data->cxl->efx_region);

When something called cxl_unregister_region() is called in exit() I look for
where cxl_register_region() is....  and I can't find it (more than possible
I'm failing to search the code though!  What is this undoing?

>  }
>  MODULE_IMPORT_NS("CXL");