[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <63353dd3-6527-6165-533e-90787a1ebea4@amd.com>
Date: Wed, 27 Nov 2024 17:18:06 +0000
From: Alejandro Lucero Palau <alucerop@....com>
To: Alison Schofield <alison.schofield@...el.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
Subject: Re: [PATCH v5 26/27] cxl: add function for obtaining params from a
region
On 11/21/24 02:56, Alison Schofield wrote:
> On Mon, Nov 18, 2024 at 04:44:33PM +0000, alejandro.lucero-palau@....com wrote:
>> From: Alejandro Lucero <alucerop@....com>
>>
>> A CXL region struct contains the physical address to work with.
>>
>> Add a function for given a opaque cxl region struct returns the params
>> to be used for mapping such memory range.
> I may not be understanding what needs to be opaque here.
The driver can not access cxl_region struct just using it in calls, what
requires this patch as other in this patchset as an API for accel drivers.
Apologies if mentioning that here creates confusion.
> Why not just 'add function to get a region resource'
> and then add 'cxl_get_region_resource().
>
> Region params usually refers to the member of struct cxl_region
> that is called 'params' and that includes more than the resource.
I did not realize using params could be problematic, but I agree it is
not how we should refer to what we are returning to the caller.
I think using Dave suggestion for using range instead should solve the
problem.
Thanks
> --Alison
>
>> Signed-off-by: Alejandro Lucero <alucerop@....com>
>> ---
>> drivers/cxl/core/region.c | 16 ++++++++++++++++
>> drivers/cxl/cxl.h | 2 ++
>> include/cxl/cxl.h | 2 ++
>> 3 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>> index eff3ad788077..fa44a60549f7 100644
>> --- a/drivers/cxl/core/region.c
>> +++ b/drivers/cxl/core/region.c
>> @@ -2663,6 +2663,22 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd,
>> return ERR_PTR(rc);
>> }
>>
>> +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start,
>> + resource_size_t *end)
>> +{
>> + if (!region)
>> + return -ENODEV;
>> +
>> + if (!region->params.res)
>> + return -ENOSPC;
>> +
>> + *start = region->params.res->start;
>> + *end = region->params.res->end;
>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_NS_GPL(cxl_get_region_params, CXL);
>> +
>> static ssize_t __create_region_show(struct cxl_root_decoder *cxlrd, char *buf)
>> {
>> return sysfs_emit(buf, "region%u\n", atomic_read(&cxlrd->region_id));
>> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
>> index ee3385db5663..7b46d313e581 100644
>> --- a/drivers/cxl/cxl.h
>> +++ b/drivers/cxl/cxl.h
>> @@ -913,6 +913,8 @@ void cxl_coordinates_combine(struct access_coordinate *out,
>>
>> bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port);
>>
>> +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start,
>> + resource_size_t *end);
>> /*
>> * Unit test builds overrides this to __weak, find the 'strong' version
>> * of these symbols in tools/testing/cxl/.
>> diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
>> index 2a8ebabfc1dd..f14a3f292ad8 100644
>> --- a/include/cxl/cxl.h
>> +++ b/include/cxl/cxl.h
>> @@ -77,4 +77,6 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd,
>> bool avoid_dax);
>>
>> int cxl_accel_region_detach(struct cxl_endpoint_decoder *cxled);
>> +int cxl_get_region_params(struct cxl_region *region, resource_size_t *start,
>> + resource_size_t *end);
>> #endif
>> --
>> 2.17.1
>>
>>
Powered by blists - more mailing lists