From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: Dan Williams <djbw@kernel.org>, <dave.jiang@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<alejandro.lucero-palau@amd.com>, <lukas@wunner.de>
Subject: Re: [RFC PATCH 4/4] cxl/region: Introduce cxl_memdev_attach_region
Date: Mon, 13 Apr 2026 09:25:02 -0500 [thread overview]
Message-ID: <c5487f86-f9ed-4d54-b420-4ef451be558e@amd.com> (raw)
In-Reply-To: <69dad30a614d7_fdcb41008c@djbw-dev.notmuch>
On 4/11/2026 6:02 PM, Dan Williams wrote:
[snip]
>>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>>> index 11bc0b88b05f..090f52392b20 100644
>>> --- a/drivers/cxl/core/region.c
>>> +++ b/drivers/cxl/core/region.c
>>> @@ -1123,6 +1123,19 @@ static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region *cxlr,
>>> static void cxl_region_setup_flags(struct cxl_region *cxlr,
>>> struct cxl_decoder *cxld)
>>> {
>>> + if (is_endpoint_decoder(&cxld->dev)) {
>>> + struct cxl_endpoint_decoder *cxled = to_cxl_endpoint_decoder(&cxld->dev);
>>> + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
>>> +
>>> + /*
>>> + * When a region's memdevs specify an @attach method the attach
>>> + * provider is responsible for dispositioning the region for
>>> + * both probe and userspace management
>>> + */
>>> + if (cxlmd->attach)
>>> + set_bit(CXL_REGION_F_LOCK, &cxlr->flags);
>>> + }
>>> +
>>
>> It seems unfortunate that you set the region lock bit here and then
>> immediately do a check to set the bit again.
>
> There are 2 different cases to lock the region here, presence of attach, or
> presence of hardware locked decoder.
>
>> I can't think of a way to leverage cxld->flags for type 2 in an
>> ergonomic way though, so I guess it's fine.
>
> The flags are just caching hardware state, I do not want to have drivers
> play games with the flags that dilute that "cached hardware value"
> meaning.
>
Didn't realize that, makes sense.
> [..]
>>> +/*
>>> + * The presence of an attach method indicates that the region is designated for
>>> + * a purpose outside of CXL core memory expansion defaults.
>>> + */
>>> +static bool cxl_region_has_memdev_attach(struct cxl_region *cxlr)
>>> +{
>>
>> I think this should be renamed to something like "cxl_region_is_private()"; it
>> better matches the intended use of the function while lessening the burden on
>> a non-type 2 educated reader. Also has the added benefit of being one less
>> change site if the mechanism for determining if a region belongs to an accelerator
>> changes in the future.
>
> Why does the CXL core naming need to cater to accelerator vs expansion
> use case naming? CXL core developer needs to understand all the use
> cases and wants to make them unified as much as possible.
It doesn't. I agree that developers that are going to touch this code should
understand all the use cases but the naming here doesn't accurately convey
the intended use case. memdev_attach is only used by accelerator drivers, so
this function is checking the device type/driver.
That does somewhat go against unifying the use cases but the use cases
definitely do diverge here. It's really more about clearly delineating where
the cases diverge to someone who is less knowledgeable about accelerators
(which is most people in my experience).
> "cxl_region_is_private()" says nothing about what "private" means and
> where to look next. It also muddies the namespace for when CXL regions
> start becoming the backing store for "private" nodes. Is that a
> "private" region?
Bad naming suggestion on my part, I forgot about the private nodes set.
I was about to suggest changing it to "cxl_region_is_reserved()" but that's
an even more overloaded term :/. Going along the lines of what I said above,
maybe something like "cxl_region_reserved_by_acclerator()"? Kind of long, but
gets to the point.
Thanks,
Ben
prev parent reply other threads:[~2026-04-13 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 21:00 [RFC PATCH 0/4] cxl: Region attach for accelerators Dan Williams
2026-04-03 21:00 ` [RFC PATCH 1/4] cxl/mem: Add support to cleanly continue after attach Dan Williams
2026-04-09 22:02 ` Cheatham, Benjamin
2026-04-11 22:33 ` Dan Williams
2026-04-03 21:00 ` [RFC PATCH 2/4] cxl/region: Move region lock error code to -EBUSY Dan Williams
2026-04-03 21:00 ` [RFC PATCH 3/4] cxl/region: Block region delete for locked regions Dan Williams
2026-04-03 21:00 ` [RFC PATCH 4/4] cxl/region: Introduce cxl_memdev_attach_region Dan Williams
2026-04-07 10:25 ` Alejandro Lucero Palau
2026-04-11 21:42 ` Dan Williams
2026-04-14 15:41 ` Alejandro Lucero Palau
2026-04-15 12:57 ` Alejandro Lucero Palau
2026-04-09 22:02 ` Cheatham, Benjamin
2026-04-11 23:02 ` Dan Williams
2026-04-12 8:57 ` Lukas Wunner
2026-04-13 14:25 ` Cheatham, Benjamin [this message]
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=c5487f86-f9ed-4d54-b420-4ef451be558e@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=alejandro.lucero-palau@amd.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
/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
all inboxes | Powered by JetHome®