[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <468b818c-fc16-4b26-3c40-99205d10323b@amd.com>
Date: Fri, 27 Dec 2024 08:06:05 +0000
From: Alejandro Lucero Palau <alucerop@....com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>,
alejandro.lucero-palau@....com
Cc: linux-cxl@...r.kernel.org, netdev@...r.kernel.org,
dan.j.williams@...el.com, martin.habets@...inx.com, edward.cree@....com,
davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, dave.jiang@...el.com
Subject: Re: [PATCH v8 08/27] cxl: add functions for resource request/release
by a driver
On 12/24/24 17:25, Jonathan Cameron wrote:
> On Mon, 16 Dec 2024 16:10:23 +0000
> alejandro.lucero-palau@....com wrote:
>
>> From: Alejandro Lucero <alucerop@....com>
>>
>> Create accessors for an accel driver requesting and releasing a resource.
>>
>> Signed-off-by: Alejandro Lucero <alucerop@....com>
>> Reviewed-by: Ben Cheatham <benjamin.cheatham@....com>
>> Reviewed-by: Zhi Wang <zhi@...dia.com>
>> Reviewed-by: Fan Ni <fan.ni@...sung.com>
> Hi Alejandro,
>
> Minor comment inline. Either way
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
>
>> ---
>> drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++++++++++++++++
>> include/cxl/cxl.h | 2 ++
>> 2 files changed, 47 insertions(+)
>>
>> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
>> index 99f533caae1e..c414b0fbbead 100644
>> --- a/drivers/cxl/core/memdev.c
>> +++ b/drivers/cxl/core/memdev.c
>> @@ -744,6 +744,51 @@ int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res,
>> }
>> EXPORT_SYMBOL_NS_GPL(cxl_set_resource, "CXL");
>>
>> +int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type)
>> +{
>> + switch (type) {
>> + case CXL_RES_RAM:
>> + if (!resource_size(&cxlds->ram_res)) {
>> + dev_err(cxlds->dev,
>> + "resource request for ram with size 0\n");
>> + return -EINVAL;
>> + }
>> +
>> + return request_resource(&cxlds->dpa_res, &cxlds->ram_res);
>> + case CXL_RES_PMEM:
>> + if (!resource_size(&cxlds->pmem_res)) {
>> + dev_err(cxlds->dev,
>> + "resource request for pmem with size 0\n");
>> + return -EINVAL;
>> + }
>> + return request_resource(&cxlds->dpa_res, &cxlds->pmem_res);
>> + default:
>> + dev_err(cxlds->dev, "unsupported resource type (%u)\n", type);
>> + return -EINVAL;
>> + }
>> +}
>> +EXPORT_SYMBOL_NS_GPL(cxl_request_resource, "CXL");
>> +
>> +int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type)
>> +{
>> + int rc;
>> +
>> + switch (type) {
>> + case CXL_RES_RAM:
>> + rc = release_resource(&cxlds->ram_res);
> return release_resource() unless a later
> patch add something that happens after this...
>
>> + break;
>> + case CXL_RES_PMEM:
>> + rc = release_resource(&cxlds->pmem_res);
> same
>
>> + break;
>> + default:
>> + dev_err(cxlds->dev, "unknown resource type (%u)\n", type);
>> + return -EINVAL;
>> + }
>> +
>> + return rc;
> With above, this isn't needed.
It is cleaner. I'll do.
Thanks
>> +}
>> +EXPORT_SYMBOL_NS_GPL(cxl_release_resource, "CXL");
>> +
>> static int cxl_memdev_release_file(struct inode *inode, struct file *file)
>> {
>> struct cxl_memdev *cxlmd =
>> diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
>> index 18fb01adcf19..44664c9928a4 100644
>> --- a/include/cxl/cxl.h
>> +++ b/include/cxl/cxl.h
>> @@ -42,4 +42,6 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds,
>> unsigned long *expected_caps,
>> unsigned long *current_caps);
>> int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds);
>> +int cxl_request_resource(struct cxl_dev_state *cxlds, enum cxl_resource type);
>> +int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type);
>> #endif
Powered by blists - more mailing lists