From: Dave Jiang <dave.jiang@intel.com>
To: penn <engguopeng@buaa.edu.cn>, linux-cxl@vger.kernel.org
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
bhelgaas@google.com, dave@stgolabs.net, jic23@kernel.org,
alison.schofield@intel.com, vishal.l.verma@intel.com,
ira.weiny@intel.com, djbw@kernel.org, johnny.li@montage-tech.com,
peng.guo@montage-tech.com, jingzhong.yang@montage-tech.com
Subject: Re: [PATCH v2 2/2] cxl/core: Skip non-CXL capabilities in MCAP
Date: Tue, 18 Aug 2026 15:43:29 -0700 [thread overview]
Message-ID: <c01709c9-4c3b-4ced-9635-72947807c301@intel.com> (raw)
In-Reply-To: <20260817075854.17207-3-engguopeng@buaa.edu.cn>
On 8/17/26 12:58 AM, penn wrote:
> From: Penn <engguopeng@buaa.edu.cn>
>
> When MMPT is enabled, a CXL device may expose CXL-defined capabilities
> and PCIe Management Message Passthrough (MMPT) capabilities in the same
> MMIO Capabilities Register Block (MCAP).
>
> The CXL capability parser currently identifies entries using only the
> capability ID. Since capability IDs are scoped by Vendor ID, a
> PCI-SIG-defined capability may have the same ID as a CXL-defined
> capability. This causes non-CXL entries, including MMPT and MMIO Mailbox,
> to be interpreted as CXL register blocks.
>
> The MMPT register block may be interpreted as a CXL mailbox. This
> causes mailbox initialization to fail with:
>
> cxl_pci 0000:3b:00.0: Mailbox is too small (64b)
>
> Check the MCAP Vendor ID before interpreting an entry as a CXL-defined
> capability. Skip capabilities with a non-zero Vendor ID other than
> PCI_VENDOR_ID_CXL.
>
> In legacy CXL capability headers, the field now used for the MCAP
> Vendor ID was reserved and reads as zero. Continue to accept zero to
> preserve compatibility with those devices.
>
> The fix has been tested on CXL 1.1 and CXL 3.0 devices. On the
> MMPT-enabled device, it prevents both Mailbox and Status capabilities
> from being misidentified.
>
> Fixes: 8adaf747c9f0 ("cxl/mem: Find device capabilities")
> Suggested-by: Johnny <johnny.li@montage-tech.com>
> Signed-off-by: Penn <engguopeng@buaa.edu.cn>
After addressing Lukas's comment,
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Given that you are utilizing the new PCIe MMIO MBOX feature, have you considered migrate the CXL MBOX block parsing code to a PCI lib and shared between PCI and CXL? I did attempted something [1] like that a while back but never upstreamed the code due to no hardware to test on.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git/log/?h=pci-mbox
DJ
> ---
> Changes in v2:
> - Accept a zero Vendor ID for compatibility with legacy CXL capability
> headers.
> - Move the u16 declaration above the u32 declaration to follow the
> reverse Christmas tree convention.
> - Document testing on CXL 1.1 and CXL 3.0 devices.
>
> drivers/cxl/core/regs.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c
> index 93710cf4f0a6..c7c14089f2c6 100644
> --- a/drivers/cxl/core/regs.c
> +++ b/drivers/cxl/core/regs.c
> @@ -133,8 +133,18 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,
>
> for (cap = 1; cap <= cap_count; cap++) {
> struct cxl_reg_map *rmap;
> + u16 cap_id, vendor_id;
> u32 offset, length;
> - u16 cap_id;
> +
> + vendor_id = FIELD_GET(PCI_MCAP_HDR_VENDOR_ID,
> + readl(base + PCI_MCAP_HDR_BASE(cap) +
> + PCI_MCAP_HDR_REG_4));
> + /*
> + * The Vendor ID field is reserved and reads as zero in legacy
> + * CXL capability headers. See CXL r3.2, Table 8-44.
> + */
> + if (vendor_id && vendor_id != PCI_VENDOR_ID_CXL)
> + continue;
>
> cap_id = FIELD_GET(CXLDEV_CAP_HDR_CAP_ID_MASK,
> readl(base + cap * 0x10));
next prev parent reply other threads:[~2026-08-18 22:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 7:58 [PATCH v2 0/2] PCI/CXL: Distinguish CXL capabilities in MCAP penn
2026-08-17 7:58 ` [PATCH v2 1/2] PCI: Add MMIO Capabilities Register Block definitions penn
2026-08-17 8:07 ` sashiko-bot
2026-08-18 22:37 ` Dave Jiang
2026-08-17 7:58 ` [PATCH v2 2/2] cxl/core: Skip non-CXL capabilities in MCAP penn
2026-08-17 8:10 ` sashiko-bot
2026-08-18 22:43 ` Dave Jiang [this message]
2026-08-19 1:28 ` engguopeng
2026-08-19 15:09 ` Dave Jiang
2026-08-20 2:36 ` engguopeng
2026-08-21 18:01 ` Jonathan Cameron
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=c01709c9-4c3b-4ced-9635-72947807c301@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=bhelgaas@google.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=engguopeng@buaa.edu.cn \
--cc=ira.weiny@intel.com \
--cc=jic23@kernel.org \
--cc=jingzhong.yang@montage-tech.com \
--cc=johnny.li@montage-tech.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=peng.guo@montage-tech.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