acpi: add support for CXL _OSC
Subsystems (3)
v2 cover acpi: add support for CXL _OSC
Changes since v1[1]:
- Reword commit message (Dan)
- Move the OSC capability size definition and usage into patch 1 (Davidlohr)
- Clean up some unnecessary parens (Rafael)
- Avoid repetitive strcmp()'s in is_pcie()/is_cxl() helpers (Rafael)
- Clean up some pointer math (Rafael)
- Fix a copy-paste error in updating the saved OSC mask (Rafael)
- Fix a bug where we'd try to print missing OSC bits when we should've been printing missing PCI bits.
Add support for using the CXL definition of _OSC where applicable, and negotiating CXL specific support and control bits.
Patch 1 adds the new CXL _OSC UUID, and uses it instead of the PCI UUID when a root port is CXL enabled. It provides a fallback method for CXL-1.1 platforms that may not implement the CXL-2.0 _OSC.
Patch 2 performs negotiation for the CXL specific _OSC support and control bits.
I've tested these against a custom qemu[2], which adds the CXL _OSC (in addition to other CXL support). Specifically, _OSC support is added here[3].
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://gitlab.com/jic23/qemu/-/tree/cxl-v8-draft
[3]: https://gitlab.com/jic23/qemu/-/commit/1d67df6b6e3716c27462873f3451956f5c0673a3
Dan Williams (1):
PCI/ACPI: Use CXL _OSC instead of PCIe _OSC
Vishal Verma (1):
acpi/pci_root: negotiate CXL _OSC
include/linux/acpi.h | 20 +++- include/acpi/acpi_bus.h | 12 ++- drivers/acpi/pci_root.c | 225 ++++++++++++++++++++++++++++++++++------ 3 files changed, 224 insertions(+), 33 deletions(-)
base-commit: 05e815539f3f161585c13a9ab023341bade2c52f
Signature · 1 line
2.35.1
PATCH v2 1/2 PCI/ACPI: Use CXL _OSC instead of PCIe _OSC
From: Dan Williams <[email protected]>
OB In preparation for negotiating OS control of CXL _OSC features, do the minimal enabling to use CXL _OSC to handle the base PCIe feature negotiation. Recall that CXL _OSC is a super-set of PCIe _OSC and the CXL 2.0 specification mandates: "If a CXL Host Bridge device exposes CXL _OSC, CXL aware OSPM shall evaluate CXL _OSC and not evaluate PCIe _OSC."
Rather than pass a boolean flag alongside @root to all the helper functions that need to consider PCIe specifics, add is_pcie() and is_cxl() helper functions to check the flavor of @root. This also allows for dynamic fallback to PCIe _OSC in cases where an attempt to use CXL _OXC fails. This can happen on CXL 1.1 platforms that publish ACPI0016 devices to indicate CXL host bridges, but do not publish the optional CXL _OSC method. CXL _OSC is mandatory for CXL 2.0 hosts.
--- include/linux/acpi.h | 4 +++ include/acpi/acpi_bus.h | 6 ++++ drivers/acpi/pci_root.c | 74 ++++++++++++++++++++++++++++++++--------- 3 files changed, 69 insertions(+), 15 deletions(-)
include/linux/acpi.h +4 -0
@@ -550,6 +550,10 @@ struct acpi_osc_context {acpi_status acpi_run_osc (acpi_handle handle,struct acpi_osc_context *context); +/* Number of _OSC capability DWORDS depends on bridge type */ +#define OSC_PCI_CAPABILITY_DWORDS 3 +#define OSC_CXL_CAPABILITY_DWORDS 5 +/* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */ #define OSC_QUERY_DWORD 0/* DWORD 1 */ #define OSC_SUPPORT_DWORD 1/* DWORD 2 */
include/acpi/acpi_bus.h +6 -0
@@ -581,10 +581,16 @@ int unregister_acpi_bus_type(struct acpi_bus_type *);int acpi_bind_one (struct device *dev,struct acpi_device *adev);int acpi_unbind_one (struct device *dev); +enum acpi_bridge_type { +ACPI_BRIDGE_TYPE_PCIE =1 , +ACPI_BRIDGE_TYPE_CXL , +}; +struct acpi_pci_root {struct acpi_device * device;struct pci_bus *bus;u16 segment; +int bridge_type;struct resource secondary;/* downstream bus range */ u32 osc_support_set;/* _OSC state of support bits */
drivers/acpi/pci_root.c +59 -15
140 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH v2 1/2] PCI/ACPI: Use CXL _OSC instead of PCIe _OSC
Quoted 4 lines · Vishal Verma
drivers/acpi/pci_root.c +4
-0+static bool is_pcie (struct acpi_pci_root *root) +{ +if (root->bridge_type ==ACPI_BRIDGE_TYPE_PCIE ) +return true;
drivers/acpi/pci_root.c static void decode_osc_control(struct acpi_pci_root *root, char *msg, u32 word) · line 185
Quoted 10 lines
drivers/acpi/pci_root.c +8
-1+return false; +} -static acpi_status acpi_pci_run_osc(acpi_handle handle, +static bool is_cxl (struct acpi_pci_root *root) +{ +if (root->bridge_type ==ACPI_BRIDGE_TYPE_CXL ) +return true; +return false; +}
return root->bridge_type == TYPE
Re: [PATCH v2 1/2] PCI/ACPI: Use CXL _OSC instead of PCIe _OSC
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Vishal Verma
drivers/acpi/pci_root.c +6
-0+static bool is_pcie (struct acpi_pci_root *root) +{ + if (root->bridge_type == ACPI_BRIDGE_TYPE_PCIE) + return true; + return false; +}
Quoted 9 lines
drivers/acpi/pci_root.c static void decode_osc_control(struct acpi_pci_root *root, char *msg, u32 word) · line 185
Quoted 7 lines
drivers/acpi/pci_root.c +6
-1-static acpi_status acpi_pci_run_osc(acpi_handle handle, +static bool is_cxl (struct acpi_pci_root *root) +{ + if (root->bridge_type == ACPI_BRIDGE_TYPE_CXL) + return true; + return false; +}return
root->bridge_type== TYPE
Oh, yes, of course - I'll fix up!
PATCH v2 2/2 acpi/pci_root: negotiate CXL _OSC
In reply to Vishal VermaAdd full support for negotiating _OSC as defined in the CXL 2.0 spec, as applicable to CXL-enabled platforms. Advertise support for the CXL features we support - 'CXL 2.0 port/device register access', 'Protocol Error Reporting', and 'CL Native Hot Plug'. Request control for 'CXL Memory Error Reporting'. The requests are dependent on CONFIG_* based pre-requisites, and prior PCI enabling, similar to how the standard PCI _OSC bits are determined.
The CXL specification does not define any additional constraints on the hotplug flow beyond PCIe native hotplug, so a kernel that supports native PCIe hotplug, supports CXL hotplug. For error handling protocol and link errors just use PCIe AER. There is nascent support for amending AER events with CXL specific status [1], but there's otherwise no additional OS responsibility for CXL errors beyond PCIe AER. CXL Memory Errors behave the same as typical memory errors so CONFIG_MEMORY_FAILURE is sufficient to indicate support to platform firmware.
--- include/linux/acpi.h | 16 +++- include/acpi/acpi_bus.h | 6 +- drivers/acpi/pci_root.c | 159 +++++++++++++++++++++++++++++++++++----- 3 files changed, 159 insertions(+), 22 deletions(-)
include/linux/acpi.h +15 -1
@@ -554,10 +554,15 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);#define OSC_PCI_CAPABILITY_DWORDS 3#define OSC_CXL_CAPABILITY_DWORDS 5 -/* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */ +/* +* Indexes into _OSC Capabilities Buffer +* DWORDs 2 & 3 are device-specific, and 4 & 5 are specific to CXL platforms +*/ #define OSC_QUERY_DWORD 0/* DWORD 1 */ #define OSC_SUPPORT_DWORD 1/* DWORD 2 */ #define OSC_CONTROL_DWORD 2/* DWORD 3 */ +#define OSC_CXL_SUPPORT_DWORD 3/* DWORD 4 */ +#define OSC_CXL_CONTROL_DWORD 4/* DWORD 5 */ /* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */ #define OSC_QUERY_ENABLE 0x00000001/* input */
@@ -611,6 +616,15 @@ extern u32 osc_sb_native_usb4_control;#define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020#define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 +/* CXL _OSC: Capabilities DWORD 4: Support Field */ +#define OSC_CXL_1_1_PORT_REG_ACCESS_SUPPORT 0x00000001 +#define OSC_CXL_2_0_PORT_DEV_REG_ACCESS_SUPPORT 0x00000002 +#define OSC_CXL_PROTOCOL_ERR_REPORTING_SUPPORT 0x00000004 +#define OSC_CXL_NATIVE_HP_SUPPORT 0x00000008 + +/* CXL _OSC: Capabilities DWORD 5: Control Field */ +#define OSC_CXL_ERROR_REPORTING_CONTROL 0x00000001 +#define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004#define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
include/acpi/acpi_bus.h +4 -2
@@ -593,8 +593,10 @@ struct acpi_pci_root {int bridge_type;struct resource secondary;/* downstream bus range */ -u32 osc_support_set;/* _OSC state of support bits */ -u32 osc_control_set;/* _OSC state of control bits */ +u32 osc_support_set;/* _OSC state of support bits */ +u32 osc_control_set;/* _OSC state of control bits */ +u32 cxl_osc_support_set;/* _OSC state of CXL support bits */ +u32 cxl_osc_control_set;/* _OSC state of CXL control bits */ phys_addr_t mcfg_addr; };
drivers/acpi/pci_root.c +140 -19
272 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH v2 2/2] acpi/pci_root: negotiate CXL _OSC
Hi Vishal,
A few small comments below, but overall I like this series.
drivers/acpi/pci_root.c static int cap_length(struct acpi_pci_root *root) · line 232
Quoted 6 lines · Vishal Verma
drivers/acpi/pci_root.c +6
-0+static u32 acpi_osc_ctx_get_pci_control (struct acpi_osc_context *context) +{ +u32 *ret = context->ret.pointer; + +return ret[OSC_CONTROL_DWORD ]; +}
Should this one go into a more generic acpi.h? For example, another user could be acpi_bus_osc_negotiate_usb_control().
drivers/acpi/pci_root.c static int cap_length(struct acpi_pci_root *root) · line 239
Quoted 7 lines
drivers/acpi/pci_root.c +7
-0+ +static u32 acpi_osc_ctx_get_cxl_control (struct acpi_osc_context *context) +{ +u32 *ret = context->ret.pointer; + +return ret[OSC_CXL_CONTROL_DWORD ]; +}
... and perhaps this one too? But just for symmetry with the pci one, as there are no users out side of pci_root.c. Both helpers want to be inline too. Btw this probably also goes for the is_pci/cxl() helpers.
Thanks,
Davidlohr
Re: [PATCH v2 2/2] acpi/pci_root: negotiate CXL _OSC
In reply to Vishal Vermadrivers/acpi/pci_root.c static acpi_status acpi_pci_run_osc(struct acpi_pci_root *root, · line 268
Quoted 7 lines · Vishal Verma
drivers/acpi/pci_root.c +3
-0+static acpi_status acpi_pci_query_osc (struct acpi_pci_root *root,u32 support, +u32 *control,u32 cxl_support, +u32 *cxl_control){ acpi_status status;drivers/acpi/pci_root.c +1
-1-u32 result, capbuf[OSC_CXL_CAPABILITY_DWORDS ]; +u32 pci_result, cxl_result, capbuf[OSC_CXL_CAPABILITY_DWORDS ];
While the wasted stack is hardly an issue, I do find it annoying that capbuf will be bigger than necessary when is_cxl() == F, cap's pointer.length being capped at 12 bytes. Doing capbuf dynamically and allocating memory would obviously not be worth it. Bleh :/
Thanks,
Davidlohr