From: Alison Schofield <alison.schofield@intel.com>
To: Richard Cheng <icheng@nvidia.com>
Cc: <jic23@kernel.org>, <dave@stgolabs.net>, <dave.jiang@intel.com>,
<vishal.l.verma@intel.com>, <djbw@kernel.org>,
<danwilliams@nvidia.com>, <iweiny@kernel.org>,
<ming.li@zohomail.com>, <kaihengf@nvidia.com>, <kobak@nvidia.com>,
<vaslot@nvidia.com>, <mochs@nvidia.com>, <newtonl@nvidia.com>,
<kristinc@nvidia.com>, <linux-cxl@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v9 2/3] cxl/hdm: Allow zero sized HDM decoders
Date: Fri, 4 Sep 2026 09:53:32 -0700 [thread overview]
Message-ID: <apr3jMIDDqYeZdK5@aschofie-mobl2.lan> (raw)
In-Reply-To: <20260805055524.22311-3-icheng@nvidia.com>
On Wed, Aug 05, 2026 at 01:55:23PM +0800, Richard Cheng wrote:
> CXL r4.0 §8.2.4.20.12 ("Committing Decoder Programming") and §14.13.10
> ("CXL HDM Decoder Zero Size Commit") permit committing an HDM decoder
> with size 0. BIOS may commit and lock such decoders so the OS cannot
> program regions through them, this is a design choice rather than a spec
> requirement.
>
> The kernel rejected these with -ENXIO during port enumeration and
> aborted the whole port, so affected systems showed nothing under "cxl
> list".
>
> Treat empty decoders as first class instead of special casing them, back
> them with a kmalloc'd resource, since the resource tree can't represent
> an empty range, and keep the skip and hdm_end accounting intact. Guard
> the paths an empty decoder can't serve, e.g. region attach, DPA free,
> and poison queries.
Hi Richard,
I applied this set to 7.3-rc1 and retested w the new test case in
cxl-topology.sh - all good.
I do have some comments though - see below
snip...
I'm snipping past a bunch of Reviewed-by tags a bit sheepishly.
Maybe you'll quickly dispute my feedback?
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 0c80b76a5f9b..3b3cfa0f2507 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -240,6 +240,18 @@ static resource_size_t __adjust_skip(struct cxl_dev_state *cxlds,
> }
> #define release_skip(c, b, l) __adjust_skip((c), (b), (l), NULL)
>
> +static void cxl_dpa_release_region(struct resource *parent,
> + struct resource *res)
> +{
> + /* zero sized decoders are not tracked in the resource tree */
> + if (resource_size(res) == 0) {
> + kfree(res);
> + return;
> + }
> +
> + __release_region(parent, res->start, resource_size(res));
> +}
> +
> /*
> * Must be called in a context that synchronizes against this decoder's
> * port ->remove() callback (like an endpoint decoder sysfs attribute)
> @@ -256,7 +268,7 @@ static void __cxl_dpa_release(struct cxl_endpoint_decoder *cxled)
>
> /* save @skip_start, before @res is released */
> skip_start = res->start - cxled->skip;
> - __release_region(&cxlds->dpa_res, res->start, resource_size(res));
> + cxl_dpa_release_region(&cxlds->dpa_res, res);
> if (cxled->skip)
> release_skip(cxlds, skip_start, cxled->skip);
> cxled->skip = 0;
> @@ -336,6 +348,26 @@ static int request_skip(struct cxl_dev_state *cxlds,
> return -EBUSY;
> }
>
> +static struct resource *cxl_dpa_request_region(struct resource *parent,
> + resource_size_t start,
> + resource_size_t n,
> + const char *name)
> +{
> + if (!n) {
> + struct resource *res;
> +
> + res = kmalloc_obj(*res);
> + if (!res)
> + return NULL;
> +
> + *res = DEFINE_RES_NAMED(start, 0, name, IORESOURCE_MEM);
> +
> + return res;
> + }
> +
> + return __request_region(parent, start, n, name, 0);
> +}
> +
2 failures are now collapsing into one -EBUSY
1) __request_region() returning NULL is a resource conflict.
2) kmalloc_obj() returning NULL is -ENOMEM
Can this preserve the -ENONMEM? Maybe using ERR_PTR() or handle the
zero size alloc in __cxl_dpa_reserve()?
snip
>
> @@ -545,7 +572,7 @@ int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)
> struct device *dev = &cxled->cxld.dev;
>
> guard(rwsem_write)(&cxl_rwsem.dpa);
> - if (!cxled->dpa_res)
> + if (cxled_empty(cxled))
> return 0;
> if (cxled->cxld.region) {
> dev_dbg(dev, "decoder assigned to: %s\n",
Is cxled_empty() the right test above?
The old check only returns early when there is no DPA resource.
cxled_empty() also returns true for a zero-sized decoder that does
have a resource, so this can return success before reaching the
CXL_DECODER_F_ENABLE check.
For a committed zero-sized decoder, that means echo 0 > dpa_size can
report success even though the decoder can't actually be freed.
Can the original !cxled->dpa_res check should remain, or the empty
case be handled after the existing state checks.
This also means I don't think "DPA free" belongs in the commit message's
list of paths that need to be guarded.
-- Alison
snip
next prev parent reply other threads:[~2026-09-04 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 5:55 [PATCH v9 0/3] Support zero-sized " Richard Cheng
2026-08-05 5:55 ` [PATCH v9 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
2026-09-22 1:14 ` Jonathan Cameron
2026-08-05 5:55 ` [PATCH v9 2/3] cxl/hdm: Allow zero sized HDM decoders Richard Cheng
2026-09-04 16:53 ` Alison Schofield [this message]
2026-09-14 3:36 ` Richard Cheng
2026-08-05 5:55 ` [PATCH v9 3/3] tools/testing/cxl: Enable zero sized decoders under hb0 Richard Cheng
2026-08-27 9:33 ` [PATCH v9 0/3] Support zero-sized HDM decoders Richard Cheng
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=apr3jMIDDqYeZdK5@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=danwilliams@nvidia.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=icheng@nvidia.com \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=kaihengf@nvidia.com \
--cc=kobak@nvidia.com \
--cc=kristinc@nvidia.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=mochs@nvidia.com \
--cc=newtonl@nvidia.com \
--cc=vaslot@nvidia.com \
--cc=vishal.l.verma@intel.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
all inboxes | Powered by JetHome®