[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <327e32f1-fba8-4b5a-b7a2-9fc875017521@intel.com>
Date: Mon, 6 Oct 2025 09:02:47 -0700
From: Dave Jiang <dave.jiang@...el.com>
To: Neeraj Kumar <s.neeraj@...sung.com>
Cc: linux-cxl@...r.kernel.org, nvdimm@...ts.linux.dev,
linux-kernel@...r.kernel.org, gost.dev@...sung.com,
a.manzanares@...sung.com, vishak.g@...sung.com, neeraj.kernel@...il.com,
cpgs@...sung.com
Subject: Re: [PATCH V3 15/20] cxl: Add a routine to find cxl root decoder on
cxl bus using cxl port
On 9/29/25 6:40 AM, Neeraj Kumar wrote:
> On 24/09/25 11:11AM, Dave Jiang wrote:
>>
>>> +struct cxl_root_decoder *cxl_find_root_decoder_by_port(struct cxl_port *port)
>>> +{
>>> + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port);
>>> + struct device *dev;
>>> +
>>> + if (!cxl_root)
>>> + return NULL;
>>> +
>>> + dev = device_find_child(&cxl_root->port.dev, NULL, match_root_decoder);
>>> + if (!dev)
>>> + return NULL;
>>> +
>>> + /* Release device ref taken via device_find_child() */
>>> + put_device(dev);
>>
>> Should the caller release the device reference instead?
>>
>> DJ
>
> Actually caller of this function wants to find root decoder information from cxl_port.
> So in order to find root decoder we have used device_find_child() which internally
> takes device ref. Therefore, just after finding the appropriate dev, I am releasing
> device ref.
> Its like taking device ref temporarly and releasing it then and there after finding
> proper root decoder.
> I believe, Releasing device ref from caller would make it look little out of context.
With the caller acquiring the root decoder, it should hold a reference until it is done with it. See usages of cxl_find_root_decoder(). i.e. core/region.c:cxl_add_to_region(). cxl_find_root_decoder_by_port() should do something similar.
DJ
>
>
> Regards,
> Neeraj
>
Powered by blists - more mailing lists