[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5ba7516c-2856-4bd1-9d5b-0e33ea91addc@zohomail.com>
Date: Wed, 12 Feb 2025 14:36:16 +0800
From: Li Ming <ming.li@...omail.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: dave@...olabs.net, dave.jiang@...el.com, alison.schofield@...el.com,
vishal.l.verma@...el.com, ira.weiny@...el.com, dan.j.williams@...el.com,
linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 1/7] cxl/core: Use guard() to replace open-coded
down_read/write()
On 2/12/2025 1:26 AM, Jonathan Cameron wrote:
> On Tue, 11 Feb 2025 15:57:21 +0800
> Li Ming <ming.li@...omail.com> wrote:
>
>> Some down/up_read() and down/up_write() cases can be replaced by a
>> guard() simply to drop explicit unlock invoked. It helps to align coding
>> style with current CXL subsystem's.
>>
>> Signed-off-by: Li Ming <ming.li@...omail.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
>
> I wondered if it was worth doing some early returns and dropping
> local variables, but on balance think it isn't worth doing.
>
>
>> @@ -364,10 +362,9 @@ resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled)
>> {
>> resource_size_t size = 0;
>>
>> - down_read(&cxl_dpa_rwsem);
>> + guard(rwsem_read)(&cxl_dpa_rwsem);
>> if (cxled->dpa_res)
>> size = resource_size(cxled->dpa_res);
> Could return resource_size() here and return 0 below.
> I'm not sure it gains us much though.
Right, I will do it in V2.
>> - up_read(&cxl_dpa_rwsem);
>>
>> return size;
>> }
>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>> index e8d11a988fd9..e3bb33109ced 100644
>> --- a/drivers/cxl/core/region.c
>> +++ b/drivers/cxl/core/region.c
>> @@ -3216,10 +3216,9 @@ static int match_region_by_range(struct device *dev, const void *data)
>> cxlr = to_cxl_region(dev);
>> p = &cxlr->params;
>>
>> - down_read(&cxl_region_rwsem);
>> + guard(rwsem_read)(&cxl_region_rwsem);
>> if (p->res && p->res->start == r->start && p->res->end == r->end)
>> rc = 1;
> could do return 1 here and return 0 but it doesn't gain us much.
Will do it in V2. thanks for review.
Ming
>
>> - up_read(&cxl_region_rwsem);
>>
>> return rc;
>> }
>
Powered by blists - more mailing lists