Linux ACPI
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	Hanjun Guo <guohanjun@huawei.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shuai Xue <xueshuai@linux.alibaba.com>,
	Len Brown <lenb@kernel.org>,
	Ben Cheatham <benjamin.cheatham@amd.com>
Cc: Alison Schofield <alison.schofield@intel.com>,
	linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org,
	Pei Gao <pei.gao@intel.com>
Subject: [PATCH] EINJ, CXL: Use PCI domain for CXL root port error injection
Date: Thu,  5 Nov 2026 10:46:41 -0800	[thread overview]
Message-ID: <20261105184643.907678-1-alison.schofield@intel.com> (raw)

CXL protocol error injection identifies the target root port to firmware
using its PCI segment, bus, device, and function (SBDF).

The segment is taken from the PCI host bridge's domain_nr, which is
only populated for emulated PCI domains. On ACPI systems, firmware
receives segment 0 even when the target root port belongs to a nonzero
segment, identifying the wrong PCI device for error injection.

Use the PCI domain of the target root port to obtain the correct segment.
With the host bridge lookup removed, cxl_dport_get_sbdf() can return the
SBDF directly.

Reported-by: Pei Gao <pei.gao@intel.com>
Fixes: 12fb28ea6b1c ("EINJ: Add CXL error type support")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

The ACPI EINJ SBDF field limits the PCI segment to 8 bits, while PCI
segment numbers can be 16 bits. A segment greater than 0xff would be
silently truncated, potentially targeting the wrong device.

I'm unsure how likely systems are to use segments above 0xff. Is this
a practical concern? Would a range check to enforce the ACPI limit
be warranted in a follow-up patch?
---
 drivers/acpi/apei/einj-cxl.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/acpi/apei/einj-cxl.c b/drivers/acpi/apei/einj-cxl.c
index e70a416ec925..4c8f014378bc 100644
--- a/drivers/acpi/apei/einj-cxl.c
+++ b/drivers/acpi/apei/einj-cxl.c
@@ -47,25 +47,12 @@ int einj_cxl_available_error_type_show(struct seq_file *m, void *v)
 }
 EXPORT_SYMBOL_NS_GPL(einj_cxl_available_error_type_show, "CXL");
 
-static int cxl_dport_get_sbdf(struct pci_dev *dport_dev, u64 *sbdf)
+static u64 cxl_dport_get_sbdf(struct pci_dev *dport_dev)
 {
-	struct pci_bus *pbus;
-	struct pci_host_bridge *bridge;
-	u64 seg = 0, bus;
+	u64 seg = pci_domain_nr(dport_dev->bus);
+	u64 bus = dport_dev->bus->number;
 
-	pbus = dport_dev->bus;
-	bridge = pci_find_host_bridge(pbus);
-
-	if (!bridge)
-		return -ENODEV;
-
-	if (bridge->domain_nr != PCI_DOMAIN_NR_NOT_SET)
-		seg = bridge->domain_nr;
-
-	bus = pbus->number;
-	*sbdf = (seg << 24) | (bus << 16) | (dport_dev->devfn << 8);
-
-	return 0;
+	return (seg << 24) | (bus << 16) | (dport_dev->devfn << 8);
 }
 
 int einj_cxl_inject_rch_error(u64 rcrb, u64 type)
@@ -87,7 +74,7 @@ EXPORT_SYMBOL_NS_GPL(einj_cxl_inject_rch_error, "CXL");
 
 int einj_cxl_inject_error(struct pci_dev *dport, u64 type)
 {
-	u64 param4 = 0;
+	u64 sbdf;
 	int rc;
 
 	/* Only CXL error types can be specified */
@@ -98,11 +85,9 @@ int einj_cxl_inject_error(struct pci_dev *dport, u64 type)
 	if (rc)
 		return rc;
 
-	rc = cxl_dport_get_sbdf(dport, &param4);
-	if (rc)
-		return rc;
+	sbdf = cxl_dport_get_sbdf(dport);
 
-	return einj_error_inject(type, 0x4, 0, 0, 0, param4);
+	return einj_error_inject(type, 0x4, 0, 0, 0, sbdf);
 }
 EXPORT_SYMBOL_NS_GPL(einj_cxl_inject_error, "CXL");
 

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.37.3


             reply	other threads:[~2026-11-05 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 18:46 Alison Schofield [this message]
2026-11-06 17:29 ` [PATCH] EINJ, CXL: Use PCI domain for CXL root port error injection Cheatham, Benjamin

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=20261105184643.907678-1-alison.schofield@intel.com \
    --to=alison.schofield@intel.com \
    --cc=benjamin.cheatham@amd.com \
    --cc=bp@alien8.de \
    --cc=guohanjun@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=pei.gao@intel.com \
    --cc=rafael@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=xueshuai@linux.alibaba.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