Netdev List
 help / color / mirror / Atom feed
From: "Lucero Palau, Alejandro" <alejandro.lucero-palau@amd.com>
To: Richard Cheng <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org, netdev@vger.kernel.org,
	edward.cree@amd.com, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, edumazet@google.com, dave.jiang@intel.com,
	Alejandro Lucero <alucerop@amd.com>
Subject: Re: [RFC 1/2] cxl/memdev: add support for mutipf device
Date: Thu, 27 Aug 2026 18:44:42 +0100	[thread overview]
Message-ID: <2a7d2d8c-ff02-4f2f-94d8-21d64dd77f82@amd.com> (raw)
In-Reply-To: <a313b340-9263-4204-b0b2-bc492cf746a4@amd.com>


On 25/08/2026 08:37, Lucero Palau, Alejandro wrote:
>
> On 24/08/2026 09:33, Richard Cheng wrote:
>> On Fri, Aug 21, 2026 at 04:51:33PM 
>> +0800,alejandro.lucero-palau@amd.com wrote:
>>> From: Alejandro Lucero<alucerop@amd.com>
>>>
>>> A PCI device can present multiple Physical Functions(PFs) but the CXL
>>> specs restrict to the first one, PF0, the discovery and management of
>>> CXL capabilities accessed through a PF0 BAR. Other non-PF0 PFs need to
>>> obtain the CXL.mem range to work with somehow.
>>>
>>> Although this could be handled internally by an accelerator/Type2
>>> driver, it requires to properly handle changes to the CXL mem device,
>>> mainly its release by the CXL core, but also potential CXL device
>>> resets. When this release happens, those other PFs need to be told 
>>> about
>>> it.
>>>
>>> Implement a way for non-PF0 PFs to register/unregister to the memdev
>>> linked to the PF0 device. At memdev release, trigger the release of
>>> those non-PF0 PFs devices registered to such memdev from the driver 
>>> they
>>> are bound to.
>>>

<snip>

>> I suggest replacing cxl_get_pf0_memdev() and cxl_put_pf0_memdev() 
>> with another
>> helper, e.g.:
>>
>> int cxl_memdev_link_consumer(struct device *pf0, struct device 
>> *consumer, struct range *range);
>>   It should live in cxl/core/memdev.c , and the behavior is something 
>> like
>>
>> 1. Find PF0's memdev and take a temp ref.
>> 2. Lock the memdev
>> 3. Verify that the memdev is still registered, driver-bound, 
>> attached, and has a valid HPA range
>> 4. Create a managed devce link via device_link_add(consumer, 
>> &cxlmd->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
>
>
> Interesting approach.
>
>
> Not sure this could do the proper thing though. 
> DL_FLAG_AUTOREMOVE_CONSUMER seems to remove the link, cxlmd->dev in 
> your case, when consume driver unbinds ... but it is the other way 
> what we need. Maybe I do not understand well all the implications with 
> this approach, so let me study it.


I'm having problems just trying to implement the supposedly basic 
functionality linking the cxlmd device with the non-PF0 device, I mean 
without thinking about potential races with this approach (I think it 
has less problems in this regard than my approach).


I can use DL_FLAG_AUTOREMOVE_SUPPLIER with the supplier being 
cxlmd->dev, so at device unbinding it can trigger the non-PF0 device 
unbinding as well. But it seems all this link code is quite related to 
PM, so some checks at link creation fail. I have tried using 
DL_FLAGS_SYNC_STATE_ONLY along with the previous one, but another check 
precludes the link creation if both are used (See 
device_link_flag_is_sync_state_only() ).


Do you have any advice here?


>
> Thanks!
>
>> 5. Copy the HPA range
>> 6. Unlock the memdev and drop the temp ref
>>
>> This helper can return only an error code and the range. The sfc 
>> driver doesn't need the cxl_memdev pointer then, and
>> no put helper would be needed.
>>
>> And driver core would unbind the non-PF0 consumer before unbinding or 
>> removing the supplier ( memdev ).
>>
>> I think this can remove the sibling xarray , raw device pointers and 
>> mutex_trylock() context check.
>>
>> Would this modle work for your teardown requirements ?
>>
>> Best regards,
>> Richard Cheng.

  reply	other threads:[~2026-08-27 17:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 15:51 [RFC 0/2] Type2 multipf support alejandro.lucero-palau
2026-08-21 15:51 ` [RFC 1/2] cxl/memdev: add support for mutipf device alejandro.lucero-palau
2026-08-24  8:33   ` Richard Cheng
2026-08-25  7:37     ` Lucero Palau, Alejandro
2026-08-27 17:44       ` Lucero Palau, Alejandro [this message]
2026-08-28  8:15         ` Richard Cheng
2026-08-21 15:51 ` [RFC 2/2] sfc: add multipf support alejandro.lucero-palau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a7d2d8c-ff02-4f2f-94d8-21d64dd77f82@amd.com \
    --to=alejandro.lucero-palau@amd.com \
    --cc=alucerop@amd.com \
    --cc=dave.jiang@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=edward.cree@amd.com \
    --cc=icheng@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox