Re: [PATCH v2 03/15] cxl: add function for type2 resource request

Alejandro Lucero Palau
2024-08-23T09:31:12Z

On 8/22/24 14:07, Zhi Wang wrote:
> On Mon, 15 Jul 2024 18:28:23 +0100
> <alejandro.lucero-palau@amd.com> wrote:
>
>> From: Alejandro Lucero <alucerop@amd.com>
>>
>> Create a new function for a type2 device requesting a resource
>> passing the opaque struct to work with.
>>
>> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
>> ---
>> drivers/cxl/core/memdev.c | 13 +++++++++++++
>> drivers/net/ethernet/sfc/efx_cxl.c | 7 ++++++-
>> include/linux/cxl_accel_mem.h | 1 +
>> 3 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
>> index 61b5d35b49e7..04c3a0f8bc2e 100644
>> --- a/drivers/cxl/core/memdev.c
>> +++ b/drivers/cxl/core/memdev.c
>> @@ -744,6 +744,19 @@ void cxl_accel_set_resource(struct cxl_dev_state
>> *cxlds, struct resource res, }
>> EXPORT_SYMBOL_NS_GPL(cxl_accel_set_resource, CXL);
>>
>> +int cxl_accel_request_resource(struct cxl_dev_state *cxlds, bool
>> is_ram) +{
>> + int rc;
>> +
>> + if (is_ram)
>> + rc = request_resource(&cxlds->dpa_res,
>> &cxlds->ram_res);
>> + else
>> + rc = request_resource(&cxlds->dpa_res,
>> &cxlds->pmem_res); +
>> + return rc;
>> +}
>> +EXPORT_SYMBOL_NS_GPL(cxl_accel_request_resource, CXL);
>> +
> Hi Alejandro:
>
> Since we only have cxl_accel_request_resource() here, how is
> the resource going to be released? e.g. in an error handling path.
>
> Thanks,
> Zhi.
>

Right. I will use devm_request_resource in v3 using cxlds->dev and the
owner.

Thanks