Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dave Jiang" <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2] cxl/pci: Honor -EPROBE_DEFER from component register setup
Date: Mon, 06 Jul 2026 22:56:48 +0000	[thread overview]
Message-ID: <20260706225648.C6C031F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706224322.714934-1-dave.jiang@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] cxl_pci_type3_init_mailbox() incorrectly evaluates component_map.ras.valid instead of device_map.mbox.valid to check mailbox presence, leading to kernel panics or functional regressions.
--

--- Patch [1]: [PATCH v2] cxl/pci: Honor -EPROBE_DEFER from component register setup ---
commit 04637d8b82b95fbc354ce623ffbeb09e3d57ae3e
Author: Dave Jiang <dave.jiang@intel.com>

cxl/pci: Honor -EPROBE_DEFER from component register setup

cxl_pci_setup_regs() can return -EPROBE_DEFER on a Restricted CXL Host (RCD)
when the upstream port has not yet been enumerated. This patch ensures that
cxl_pci_probe() returns -EPROBE_DEFER instead of continuing so the probe is
retried once the upstream port is available.

Link: https://lore.kernel.org/linux-cxl/ajzhsubot_PSYtHQ@MWDK4CY14F/T/#m063bbf76b1c9c293ade52ab311018ae6bba11a44

> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 267c679b0b3c2..6a132a6c4c5b3 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -829,10 +829,13 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	 */
>  	rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT,
>  				&cxlds->reg_map);
> -	if (rc)
> +	if (rc) {
> +		if (rc == -EPROBE_DEFER)
> +			return rc;
>  		dev_warn(&pdev->dev, "No component registers (%d)\n", rc);
> -	else if (!cxlds->reg_map.component_map.ras.valid)
> +	} else if (!cxlds->reg_map.component_map.ras.valid) {
>  		dev_dbg(&pdev->dev, "RAS registers not found\n");
> +	}
>  
>  	rc = cxl_pci_type3_init_mailbox(cxlds);
>  	if (rc)

[Severity: High]
This isn't a bug introduced by this patch, but looking at the mailbox
initialization, cxl_pci_type3_init_mailbox() checks the mbox valid flag:

drivers/cxl/pci.c:cxl_pci_type3_init_mailbox() {
    if (!cxlds->reg_map.device_map.mbox.valid)
        return -ENODEV;
    ...
}

Since cxl_pci_setup_regs() was just called above with
CXL_REGLOC_RBI_COMPONENT and populated cxlds->reg_map, does this mailbox
check inadvertently evaluate component_map.ras.valid due to the union
in struct cxl_register_map?

If a device lacks a mailbox but has RAS registers, could the presence
check incorrectly pass?

drivers/cxl/pci.c:cxl_pci_setup_mailbox() {
    ...
    const int cap = readl(cxlds->regs.mbox + CXLDEV_MBOX_CAPS_OFFSET);
    ...
}

Would this lead to a null pointer dereference in cxl_pci_setup_mailbox()
because cxlds->regs.mbox is null?

Conversely, if a device has a valid mailbox but no RAS registers,
would cxl_pci_type3_init_mailbox() incorrectly return -ENODEV and fail the
probe of a functional device?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706224322.714934-1-dave.jiang@intel.com?part=1

      reply	other threads:[~2026-07-06 22:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 22:43 [PATCH v2] cxl/pci: Honor -EPROBE_DEFER from component register setup Dave Jiang
2026-07-06 22:56 ` sashiko-bot [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=20260706225648.C6C031F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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