From: Ben Cheatham <Benjamin.Cheatham@amd.com>
To: <linux-cxl@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<linux-acpi@vger.kernel.org>
Cc: Ben Cheatham <Benjamin.Cheatham@amd.com>
Subject: [PATCH 15/16] cxl/core, cxl/acpi: Enable CXL isolation based on _OSC handshake
Date: Wed, 30 Jul 2025 16:47:17 -0500 [thread overview]
Message-ID: <20250730214718.10679-16-Benjamin.Cheatham@amd.com> (raw)
In-Reply-To: <20250730214718.10679-1-Benjamin.Cheatham@amd.com>
Enable CXL isolation based on the result of _OSC handshake, if
applicable. In the absence of a _OSC interpretation callback (i.e.
platform is non-ACPI), assume that we have control of all features.
A link for the ECN (expected in CXL 4.0 spec) that introduces the
relevant parts of the _OSC method (CXL 3.2 9.18.2) can be found below.
spec). This link is only accesible to CXL SSWG members, so here's a brief
overview:
The ECN introduces an _OSC field for controlling whether the OSPM can write
to the CXL.mem Isolation Enable bit in the CXL isolation control
register (CXL 3.2 8.2.4.24.2). If the firmware reserves control, the
OSPM is expected to not modify the isolation enable bit when writing the
register.
Link: https://members.computeexpresslink.org/wg/software_systems/document/3118
Signed-off-by: Ben Cheatham <Benjamin.Cheatham@amd.com>
---
drivers/cxl/acpi.c | 24 ++++++++++++++++++++++++
drivers/cxl/core/port.c | 17 +++++++++++++++--
drivers/cxl/cxl.h | 5 +++++
include/cxl/isolation.h | 4 ++++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index badaa99ab33a..b964f02fb56b 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -8,6 +8,7 @@
#include <linux/pci.h>
#include <linux/node.h>
#include <asm/div64.h>
+#include <cxl/isolation.h>
#include "cxlpci.h"
#include "cxl.h"
@@ -367,9 +368,32 @@ static int cxl_acpi_setup_hostbridge_uport(struct cxl_root *cxl_root,
return 0;
}
+static void decode_isolation_osc(struct cxl_port *hb, u32 iso_cap)
+{
+ bool err_corr = FIELD_GET(CXL_ISOLATION_CAP_ERR_COR_SUPP, iso_cap);
+ struct acpi_device *adev = ACPI_COMPANION(hb->uport_dev);
+ struct acpi_pci_root *pci_root;
+ u32 osc_ctrl;
+
+ if (!adev)
+ return;
+
+ pci_root = acpi_pci_find_root(adev->handle);
+ if (!pci_root)
+ return;
+
+ osc_ctrl = pci_root->osc_ext_control_set;
+ if (osc_ctrl & OSC_CXL_MEM_ISOLATION_CONTROL)
+ hb->isolation_caps |= CXL_ISOLATION_MEM_ENABLE;
+
+ if (!err_corr || (osc_ctrl & OSC_CXL_ISOLATION_NOTIF_CONTROL))
+ hb->isolation_caps |= CXL_ISOLATION_INTERRUPTS;
+}
+
static const struct cxl_root_ops acpi_root_ops = {
.qos_class = cxl_acpi_qos_class,
.setup_hostbridge_uport = cxl_acpi_setup_hostbridge_uport,
+ .get_isolation_caps = decode_isolation_osc,
};
static void del_cxl_resource(struct resource *res)
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index b5a306341bb2..e9eb7a8a5f72 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -1322,7 +1322,8 @@ static int cxl_dport_setup_interrupts(struct device *host,
static int cxl_dport_enable_timeout_isolation(struct device *host,
struct cxl_dport *dport)
{
- u32 cap;
+ struct cxl_port *port = dport->port;
+ u32 cap, ctrl;
int rc;
if (!dport->reg_map.component_map.isolation.valid)
@@ -1337,11 +1338,23 @@ static int cxl_dport_enable_timeout_isolation(struct device *host,
if (!(cap & CXL_ISOLATION_CAP_MEM_ISO_SUPP))
return 0;
+ struct cxl_root *root __free(put_cxl_root) = find_cxl_root(dport->port);
+ if (root && root->ops && root->ops->get_isolation_caps)
+ root->ops->get_isolation_caps(port, cap);
+ else
+ port->isolation_caps = ~0;
+
+ ctrl = readl(dport->regs.isolation + CXL_ISOLATION_CTRL_OFFSET);
+ if (!(port->isolation_caps & CXL_ISOLATION_MEM_ENABLE) &&
+ !(ctrl & CXL_ISOLATION_CTRL_MEM_ISO_ENABLE))
+ return 0;
+
rc = cxl_dport_setup_interrupts(host, dport);
if (rc)
return rc == -ENXIO ? 0 : rc;
- cxl_enable_isolation(dport);
+ if (port->isolation_caps & CXL_ISOLATION_MEM_ENABLE)
+ cxl_enable_isolation(dport);
if (!(cap & CXL_ISOLATION_CAP_MEM_TIME_SUPP))
cxl_enable_timeout(dport);
diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index 7f9c6bd6e010..aa36eba79181 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -139,6 +139,7 @@ static inline int ways_to_eiw(unsigned int ways, u8 *eiw)
#define CXL_ISOLATION_CAP_MEM_TIME_MASK GENMASK(3, 0)
#define CXL_ISOLATION_CAP_MEM_TIME_SUPP BIT(4)
#define CXL_ISOLATION_CAP_MEM_ISO_SUPP BIT(16)
+#define CXL_ISOLATION_CAP_ERR_COR_SUPP BIT(25)
#define CXL_ISOLATION_CAP_INTR_SUPP BIT(26)
#define CXL_ISOLATION_CAP_INTR_MASK GENMASK(31, 27)
#define CXL_ISOLATION_CTRL_OFFSET 0x8
@@ -629,6 +630,7 @@ struct cxl_dax_region {
* @cdat: Cached CDAT data
* @cdat_available: Should a CDAT attribute be available in sysfs
* @pci_latency: Upstream latency in picoseconds
+ * @isolation_caps: Isolation capabilities given by platform firmware
*/
struct cxl_port {
struct device dev;
@@ -654,6 +656,7 @@ struct cxl_port {
} cdat;
bool cdat_available;
long pci_latency;
+ u32 isolation_caps;
};
/**
@@ -679,6 +682,8 @@ struct cxl_root_ops {
int *qos_class);
int (*setup_hostbridge_uport)(struct cxl_root *cxl_root,
struct device *bridge_dev);
+ void (*get_isolation_caps)(struct cxl_port *hb,
+ u32 iso_cap);
};
static inline struct cxl_dport *
diff --git a/include/cxl/isolation.h b/include/cxl/isolation.h
index f2c4feb5a42b..54b57c42e46e 100644
--- a/include/cxl/isolation.h
+++ b/include/cxl/isolation.h
@@ -4,6 +4,10 @@
#include <linux/pci.h>
+/* CXL Isolation capabilities we have control over */
+#define CXL_ISOLATION_MEM_ENABLE BIT(0)
+#define CXL_ISOLATION_INTERRUPTS BIT(1)
+
/**
* enum cxl_err_results - Possible results of an CXL isolation handler
* @CXL_ERR_NONE: Device can recover without CXL core intervention
--
2.34.1
next prev parent reply other threads:[~2025-07-30 21:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 21:47 [PATCH 00/16] CXL.mem error isolation support Ben Cheatham
2025-07-30 21:47 ` [PATCH 01/16] cxl/regs: Add cxl_unmap_component_regs() Ben Cheatham
2025-09-12 14:46 ` Jonathan Cameron
2025-09-17 17:26 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 02/16] cxl/regs: Add CXL Isolation capability mapping Ben Cheatham
2025-09-12 14:47 ` Jonathan Cameron
2025-07-30 21:47 ` [PATCH 03/16] PCI: PCIe portdrv: Add CXL Isolation service driver Ben Cheatham
2025-09-12 15:14 ` Jonathan Cameron
2025-09-17 17:26 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 04/16] PCI: PCIe portdrv: Allocate CXL isolation MSI/-X vector Ben Cheatham
2025-08-04 21:39 ` Bjorn Helgaas
2025-08-06 17:58 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 05/16] PCI: PCIe portdrv: Add interface for getting CXL isolation IRQ Ben Cheatham
2025-07-31 5:59 ` Lukas Wunner
2025-07-31 13:13 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 06/16] cxl/core: Enable CXL.mem isolation Ben Cheatham
2025-09-12 15:21 ` Jonathan Cameron
2025-09-17 17:26 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 07/16] cxl/core: Set up isolation interrupts Ben Cheatham
2025-09-12 15:25 ` Jonathan Cameron
2025-09-17 17:27 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 08/16] cxl/core: Enable CXL " Ben Cheatham
2025-07-30 21:47 ` [PATCH 09/16] cxl/core: Prevent onlining CXL memory behind isolated ports Ben Cheatham
2025-07-30 21:47 ` [PATCH 10/16] cxl/core: Enable CXL.mem timeout Ben Cheatham
2025-07-30 21:47 ` [PATCH 11/16] cxl/pci: Add isolation handler Ben Cheatham
2025-07-30 21:47 ` [PATCH 12/16] PCI: PCIe portdrv: Add cxl_isolation sysfs attributes Ben Cheatham
2025-09-12 15:33 ` Jonathan Cameron
2025-09-17 17:27 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 13/16] cxl/core, PCI: PCIe portdrv: Add CXL timeout range programming Ben Cheatham
2025-08-04 21:39 ` Bjorn Helgaas
2025-08-06 17:58 ` Cheatham, Benjamin
2025-09-12 15:55 ` Jonathan Cameron
2025-09-17 17:27 ` Cheatham, Benjamin
2025-07-30 21:47 ` [PATCH 14/16] ACPI: Add CXL isolation _OSC fields Ben Cheatham
2025-08-22 19:19 ` Rafael J. Wysocki
2025-07-30 21:47 ` Ben Cheatham [this message]
2025-07-30 21:47 ` [PATCH 16/16] cxl/core, cxl/acpi: Add CXL isolation notify handler Ben Cheatham
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=20250730214718.10679-16-Benjamin.Cheatham@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/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.