Re: [PATCH v19 14/22] sfc: get endpoint decoder

Alejandro Lucero Palau
2025-11-10T12:08:30Z

On 10/15/25 21:15, Dave Jiang wrote:
>
> On 10/6/25 3:01 AM, alejandro.lucero-palau@amd.com wrote:
>> From: Alejandro Lucero <alucerop@amd.com>
>>
>> Use cxl api for getting DPA (Device Physical Address) to use through an
>> endpoint decoder.
>>
>> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
>> Reviewed-by: Martin Habets <habetsm.xilinx@gmail.com>
>> Acked-by: Edward Cree <ecree.xilinx@gmail.com>
>> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>> Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
>> ---
>> drivers/net/ethernet/sfc/efx_cxl.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/sfc/efx_cxl.c b/drivers/net/ethernet/sfc/efx_cxl.c
>> index d7c34c978434..1a50bb2c0913 100644
>> --- a/drivers/net/ethernet/sfc/efx_cxl.c
>> +++ b/drivers/net/ethernet/sfc/efx_cxl.c
>> @@ -108,6 +108,14 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>> return -ENOSPC;
>> }
>>
>> + cxl->cxled = cxl_request_dpa(cxl->cxlmd, CXL_PARTMODE_RAM,
>> + EFX_CTPIO_BUFFER_SIZE);
>> + if (IS_ERR(cxl->cxled)) {
>> + pci_err(pci_dev, "CXL accel request DPA failed");
>> + cxl_put_root_decoder(cxl->cxlrd);
> Might be good to create a __free() macro for freeing the root decoder instead of having to do this for every error path in this function.

We are in netdev territory here and this is not recommended, so I have
tried to avoid other uses of this kernel releasing functionality here
since the RFC.

Thanks

> DJ
>
>> + return PTR_ERR(cxl->cxled);
>> + }
>> +
>> probe_data->cxl = cxl;
>>
>> return 0;
>> @@ -115,8 +123,10 @@ int efx_cxl_init(struct efx_probe_data *probe_data)
>>
>> void efx_cxl_exit(struct efx_probe_data *probe_data)
>> {
>> - if (probe_data->cxl)
>> + if (probe_data->cxl) {
>> + cxl_dpa_free(probe_data->cxl->cxled);
>> cxl_put_root_decoder(probe_data->cxl->cxlrd);
>> + }
>> }
>>
>> MODULE_IMPORT_NS("CXL");