[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <34d7b634-0a4f-4cbe-a96f-cd1a8cea72ef@amd.com>
Date: Tue, 1 Jul 2025 17:07:50 +0100
From: Alejandro Lucero Palau <alucerop@....com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Dave Jiang <dave.jiang@...el.com>
Cc: alejandro.lucero-palau@....com, linux-cxl@...r.kernel.org,
netdev@...r.kernel.org, dan.j.williams@...el.com, edward.cree@....com,
davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com, edumazet@...gle.com
Subject: Re: [PATCH v17 10/22] cx/memdev: Indicate probe deferral
On 6/30/25 17:20, Jonathan Cameron wrote:
> Hi Dave,
>
>>> +/*
>>> + * Try to get a locked reference on a memdev's CXL port topology
>>> + * connection. Be careful to observe when cxl_mem_probe() has deposited
>>> + * a probe deferral awaiting the arrival of the CXL root driver.
>>> + */
>>> +struct cxl_port *cxl_acquire_endpoint(struct cxl_memdev *cxlmd)
> Just focusing on this part.
>
>> Annotation of __acquires() is needed here to annotate that this function is taking multiple locks and keeping the locks.
> Messy because it's a conditional case and on error we never have
> a call marked __releases() so sparse may moan.
>
> In theory we have __cond_acquires() but I think the sparse tooling
> is still missing for that.
>
> One option is to hike the thing into a header as inline and use __acquire()
> in the appropriate places. Then sparse can see the markings
> without problems.
>
> https://lore.kernel.org/all/20250305161652.GA18280@noisy.programming.kicks-ass.net/
>
> has some discussion on fixing the annotation issues around conditional locks
> for LLVM but for now I think we are still stuck.
>
> For the original __cond_acquires()
> https://lore.kernel.org/all/CAHk-=wjZfO9hGqJ2_hGQG3U_XzSh9_XaXze=HgPdvJbgrvASfA@mail.gmail.com/
>
> Linus posted sparse and kernel support but I think only the kernel bit merged
> as sparse is currently (I think) unmaintained.
>
Not sure what is the conclusion to this: should I do it or not?
I can not see the __acquires being used yet by cxl core so I wonder if
this needs to be introduced only when new code is added or it should
require a core revision for adding all required. I mean, those locks
being used in other code parts but not "advertised" by __acquires, is
not that a problem?
>>> +{
>>> + struct cxl_port *endpoint;
>>> + int rc = -ENXIO;
>>> +
>>> + device_lock(&cxlmd->dev);
>>> +> + endpoint = cxlmd->endpoint;
>>> + if (!endpoint)
>>> + goto err;
>>> +
>>> + if (IS_ERR(endpoint)) {
>>> + rc = PTR_ERR(endpoint);
>>> + goto err;
>>> + }
>>> +
>>> + device_lock(&endpoint->dev);
>>> + if (!endpoint->dev.driver)> + goto err_endpoint;
>>> +
>>> + return endpoint;
>>> +
>>> +err_endpoint:
>>> + device_unlock(&endpoint->dev);
>>> +err:
>>> + device_unlock(&cxlmd->dev);
>>> + return ERR_PTR(rc);
>>> +}
>>> +EXPORT_SYMBOL_NS_GPL(cxl_acquire_endpoint, "CXL");
>>> +
>>> +void cxl_release_endpoint(struct cxl_memdev *cxlmd, struct cxl_port *endpoint)
>> And __releases() here to release the lock annotations
>>> +{
>>> + device_unlock(&endpoint->dev);
>>> + device_unlock(&cxlmd->dev);
>>> +}
>>> +EXPORT_SYMBOL_NS_GPL(cxl_release_endpoint, "CXL");
>
Powered by blists - more mailing lists