Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Unsung Lee" <unsung0317@gmail.com>, linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2 1/2] cxl/region: Fail region creation for a root decoder without a CXL window
Date: Fri, 04 Dec 2026 14:15:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-249945@kernel.org> (raw)
In-Reply-To: <20261204135754.639574-2-unsung0317@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] cxl: data race on cxlrd->res between pair_cxl_resource() and
  __create_region()
--

commit f8ca0af34d0d599d4141c4a1d8c9733e462badf1
Author: Unsung Lee <unsung0317@gmail.com>

cxl/region: Fail region creation for a root decoder without a CXL window

This commit rejects region creation in __create_region() with -ENXIO when
cxlrd->res is NULL and logs unpaired root decoders in pair_cxl_resource().

> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 7573cd115e57d..4a1386ffa43ed 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -3106,7 +3106,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
>  {
>  	int rc;
>  
> -	if (cxlrd->dead)
> +	if (cxlrd->dead || !cxlrd->res)
>  		return ERR_PTR(-ENXIO);
>  
>  	switch (mode) {

[Severity: Medium]
Can this read of cxlrd->res race with pair_cxl_resource() during
cxl_acpi_probe()?

CPU0                                CPU1
cxl_acpi_probe()
  acpi_table_parse_cedt()
    __cxl_parse_cfmws()
      cxl_decoder_add(cxld)
                                    create_region_store()
                                      lock(&cxlrd->regions_lock)
  ...                                 __create_region()
  pair_cxl_resource()                   if (cxlrd->dead || !cxlrd->res)
    cxlrd->res = ...                      <-- data race / spurious -ENXIO

__cxl_parse_cfmws() exposes the root decoder in sysfs via cxl_decoder_add()
before pair_cxl_resource() populates cxlrd->res.  create_region_store()
holds only cxlrd->regions_lock, while pair_cxl_resource() writes cxlrd->res
with a plain store without taking cxlrd->regions_lock.

This introduces a data race on cxlrd->res and can cause valid root decoders
to transiently fail region creation with -ENXIO during probe.

Taking cxlrd->regions_lock around the cxlrd->res store in
pair_cxl_resource() would fix the data race, and deferring cxl_decoder_add()
until after resource pairing would close the probe window.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204135754.639574-1-unsung0317@gmail.com?part=1

  reply	other threads:[~2026-12-04 14:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 13:57 [PATCH v2 0/2] cxl: Fail region creation for a root decoder without a CXL window Unsung Lee
2026-12-04 13:57 ` [PATCH v2 1/2] cxl/region: " Unsung Lee
2026-12-04 14:15   ` sashiko-bot [this message]
2026-12-04 13:57 ` [PATCH v2 2/2] cxl/acpi: Correct the add_cxl_resources() kernel-doc on a trimmed window Unsung Lee

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=sashiko-outbox-249945@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=unsung0317@gmail.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