From: sashiko-bot@kernel.org
To: "Srirangan Madhavan" <smadhavan@nvidia.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v6 3/9] cxl: Add reset-idle and cache flush helpers
Date: Thu, 28 May 2026 10:09:00 +0000 [thread overview]
Message-ID: <20260528100900.784D31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260528083154.137979-4-smadhavan@nvidia.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Dereferencing an ERR_PTR as a device pointer leads to a kernel panic.
- [Medium] Using a pointer address as an XArray index creates an unnecessarily deep radix tree, wasting memory.
- [Low] Silent truncation of region size when calling cpu_cache_invalidate_memregion() on 32-bit systems.
--
commit 87c5409ded1cea23c3df266a42ac4769f6e16636
Author: Srirangan Madhavan <smadhavan@nvidia.com>
cxl: Add reset-idle and cache flush helpers
This commit adds helpers to collect CXL regions affected by a memdev
reset, verify they are idle, and invalidate CPU caches for those regions.
These helpers use an xarray to track regions and prepare the data path
for the actual reset orchestration.
> diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> index d1f487b3d809a..318744695f628 100644
> --- a/drivers/cxl/core/pci.c
> +++ b/drivers/cxl/core/pci.c
[ ... ]
> @@ -926,3 +928,171 @@ int cxl_port_get_possible_dports(struct cxl_port *port)
[ ... ]
> +static int cxl_reset_add_region(struct cxl_reset_region_context *ctx,
> + struct cxl_region *cxlr)
> +{
> + int rc;
> +
> + if (!cxlr || !cxlr->params.res)
> + return 0;
> +
> + rc = xa_insert(&ctx->regions, (unsigned long)cxlr, cxlr, GFP_KERNEL);
[Severity: Medium]
Since kernel pointers have their highest bits set on 64-bit systems, won't
using the pointer address as the XArray index force the radix tree to its
maximum depth and unnecessarily waste memory?
Could cxlr->id be used as the index instead to deduplicate regions more
efficiently?
> +
> + /* A region may be referenced by multiple affected endpoint decoders. */
> + return rc == -EBUSY ? 0 : rc;
> +}
[ ... ]
> +static int __maybe_unused
> +cxl_reset_collect_memdev_regions(struct cxl_reset_region_context *ctx,
> + struct cxl_memdev *cxlmd)
> +{
> + struct cxl_port *endpoint;
> +
> + if (!cxlmd || !cxlmd->cxlds)
> + return -ENODEV;
> +
> + endpoint = cxlmd->endpoint;
> + if (!endpoint)
[Severity: High]
If cxlmd->endpoint hasn't been successfully probed and attached yet, it
holds an ERR_PTR value rather than NULL. Will this check fail to catch the
error pointer, allowing it to be passed into device_for_each_child()?
If so, dereferencing &endpoint->dev would cause a kernel panic. Should this
check use IS_ERR(endpoint) instead?
> + return 0;
> +
> + return device_for_each_child(&endpoint->dev, ctx,
> + cxl_reset_collect_region);
> +}
[ ... ]
> +static int cxl_reset_flush_region_cache(struct cxl_region *cxlr)
> +{
> + struct resource *res = cxlr->params.res;
> + int rc;
> +
> + if (!res)
> + return 0;
> +
> + rc = cpu_cache_invalidate_memregion(res->start, resource_size(res));
[Severity: Low]
Can this silently truncate the region size on 32-bit systems?
The function cpu_cache_invalidate_memregion() takes a size_t for its length
parameter, while resource_size() returns a resource_size_t. On 32-bit
systems with PAE enabled, resource_size_t is 64-bit while size_t is 32-bit,
which could cause regions larger than 4GB to be partially skipped.
> + if (rc)
> + dev_err(&cxlr->dev, "Failed to invalidate CPU cache [%pr]: %d\n",
> + res, rc);
> +
> + return rc;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260528083154.137979-1-smadhavan@nvidia.com?part=3
next prev parent reply other threads:[~2026-05-28 10:09 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 8:31 [PATCH v6 0/9] cxl: Add cxl_reset sysfs attribute for memdevs Srirangan Madhavan
2026-05-28 8:31 ` [PATCH v6 1/9] cxl/hdm: Add helpers to restore and commit memdev decoders Srirangan Madhavan
2026-05-28 9:12 ` sashiko-bot
2026-05-28 11:06 ` Richard Cheng
2026-06-02 18:12 ` Dave Jiang
2026-06-02 18:31 ` Dave Jiang
2026-06-02 20:34 ` Cheatham, Benjamin
2026-06-03 22:35 ` Dan Williams (nvidia)
2026-05-28 8:31 ` [PATCH v6 2/9] PCI: Export pci_dev_save_and_disable() and pci_dev_restore() Srirangan Madhavan
2026-06-02 20:18 ` Dave Jiang
2026-06-03 22:36 ` Dan Williams (nvidia)
2026-05-28 8:31 ` [PATCH v6 3/9] cxl: Add reset-idle and cache flush helpers Srirangan Madhavan
2026-05-28 10:09 ` sashiko-bot [this message]
2026-06-02 20:34 ` Cheatham, Benjamin
2026-06-02 20:36 ` Dave Jiang
2026-06-04 2:49 ` Dan Williams (nvidia)
2026-05-28 8:31 ` [PATCH v6 4/9] PCI/CXL: Add sibling function coordination for reset Srirangan Madhavan
2026-05-28 10:41 ` sashiko-bot
2026-05-28 11:15 ` Richard Cheng
2026-06-02 22:10 ` Dave Jiang
2026-06-04 3:13 ` Dan Williams (nvidia)
2026-05-28 8:31 ` [PATCH v6 5/9] cxl/pci: Add CXL DVSEC reset helper Srirangan Madhavan
2026-05-28 11:05 ` sashiko-bot
2026-06-02 20:34 ` Cheatham, Benjamin
2026-05-28 8:31 ` [PATCH v6 6/9] cxl/pci: Track memdevs affected by CXL reset Srirangan Madhavan
2026-05-28 11:36 ` sashiko-bot
2026-06-02 20:34 ` Cheatham, Benjamin
2026-05-28 8:31 ` [PATCH v6 7/9] cxl/pci: Orchestrate CXL reset for affected memdevs Srirangan Madhavan
2026-05-28 12:25 ` sashiko-bot
2026-06-02 20:34 ` Cheatham, Benjamin
2026-06-04 3:25 ` Dan Williams (nvidia)
2026-05-28 8:31 ` [PATCH v6 8/9] cxl/memdev: Add cxl_reset sysfs attribute Srirangan Madhavan
2026-05-28 13:03 ` sashiko-bot
2026-06-02 21:35 ` Cheatham, Benjamin
2026-06-02 23:50 ` Dave Jiang
2026-05-28 8:31 ` [PATCH v6 9/9] Documentation/ABI: Document CXL memdev cxl_reset Srirangan Madhavan
2026-06-03 0:11 ` Dave Jiang
2026-06-02 20:34 ` [PATCH v6 0/9] cxl: Add cxl_reset sysfs attribute for memdevs Cheatham, Benjamin
2026-06-02 21:42 ` Dan Williams (nvidia)
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=20260528100900.784D31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=smadhavan@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.