Skip to contentSkip to conversation

PRM handler direct call interface

PATCH Applied John Allen 2 participants 4 messages Jul 30, 2024 – Aug 1, 2024

Subsystems (4)
lore
Share & tools
lore

John Allen

author
#0 lore raw

v3 cover PRM handler direct call interface

Platform Runtime Mechanism (PRM) introduces a means for the AML interpreter and OS drivers to invoke runtime handlers from platform firmware in order to remove the need for certain classes of SMIs. Further details can be seen in the PRM specification[1].

Future AMD platforms will implement a PRM module in firmware that will include handlers for performing various types of address translation. The address translation PRM module is documented in chapter 22 of the publicly available "AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh ACPI v6.5 Porting Guide"[2].

While the kernel currently has support for calling PRM handlers from the AML interpreter, it does not support calling PRM handlers directly from OS drivers. This series implements the direct call interface and uses it for translating normalized addresses to system physical addresses.

Thanks,
John

[1]:
https://uefi.org/sites/default/files/resources/Platform%20Runtime%20Mechanism%20-%20with%20legal%20notice.pdf
[2]:
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/58088-0.75-pub.pdf

Tree: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Base commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

John Allen (2):
ACPI: PRM: Add PRM handler direct call support RAS/AMD/ATL: Translate normalized to system physical addresses using
PRM

 drivers/acpi/prmt.c            | 24 ++++++++++++++
 drivers/ras/amd/atl/Kconfig    |  4 +++
 drivers/ras/amd/atl/Makefile   |  2 ++
 drivers/ras/amd/atl/internal.h | 10 ++++++
 drivers/ras/amd/atl/prm.c      | 57 ++++++++++++++++++++++++++++++++++
 drivers/ras/amd/atl/umc.c      |  5 +++
 include/linux/prmt.h           |  5 +++
 7 files changed, 107 insertions(+)
 create mode 100644 drivers/ras/amd/atl/prm.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/2 ACPI: PRM: Add PRM handler direct call support

Platform Runtime Mechanism (PRM) handlers can be invoked from either the AML interpreter or directly by an OS driver. Implement the direct call method.

Export the symbol as this will be used by modules such as the AMD Address Translation Library and likely others in the future.

---
v2:
- Align statements setting fields in context buffer on '='

---
 drivers/acpi/prmt.c  | 24 ++++++++++++++++++++++++
 include/linux/prmt.h |  5 +++++
 2 files changed, 29 insertions(+)
drivers/acpi/prmt.c +24 -0
index c78453c74ef5..1cfaa5957ac4 100644
@@ -214,6 +214,30 @@ static struct prm_handler_info *find_prm_handler(const guid_t *guid)
 #define UPDATE_LOCK_ALREADY_HELD 	4
 #define UPDATE_UNLOCK_WITHOUT_LOCK 	5
 
+int acpi_call_prm_handler(guid_t handler_guid, void *param_buffer)
+{
+	struct prm_handler_info *handler = find_prm_handler(&handler_guid);
+	struct prm_module_info *module = find_prm_module(&handler_guid);
+	struct prm_context_buffer context;
+	efi_status_t status;
+
+	if (!module || !handler)
+		return -ENODEV;
+
+	memset(&context, 0, sizeof(context));
+	ACPI_COPY_NAMESEG(context.signature, "PRMC");
+	context.identifier         = handler->guid;
+	context.static_data_buffer = handler->static_data_buffer_addr;
+	context.mmio_ranges        = module->mmio_info;
+
+	status = efi_call_acpi_prm_handler(handler->handler_addr,
+					   (u64)param_buffer,
+					   &context);
+
+	return efi_status_to_err(status);
+}
+EXPORT_SYMBOL_GPL(acpi_call_prm_handler);
+
 /*
  * This is the PlatformRtMechanism opregion space handler.
  * @function: indicates the read/write. In fact as the PlatformRtMechanism
include/linux/prmt.h +5 -0
index 24da8364b919..9c094294403f 100644
@@ -2,6 +2,11 @@
 
 #ifdef CONFIG_ACPI_PRMT
 void init_prmt(void);
+int acpi_call_prm_handler(guid_t handler_guid, void *param_buffer);
 #else
 static inline void init_prmt(void) { }
+static inline int acpi_call_prm_handler(guid_t handler_guid, void *param_buffer)
+{
+	return -EOPNOTSUPP;
+}
 #endif
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v3 2/2 RAS/AMD/ATL: Translate normalized to system physical addresses using PRM

In reply to John Allen

Future AMD platforms will provide a UEFI PRM module that implements a number of address translation PRM handlers. This will provide an interface for the OS to call platform specific code without requiring the use of SMM or other heavy firmware operations.

AMD Zen-based systems report memory error addresses through Machine Check banks representing Unified Memory Controllers (UMCs) in the form of UMC relative "normalized" addresses. A normalized address must be converted to a system physical address to be usable by the OS.

Add support for the normalized to system physical address translation PRM handler in the AMD Address Translation Library and prefer it over native code if available. The GUID and parameter buffer structure are specific to the normalized to system physical address handler provided by the address translation PRM module included in future AMD systems.

The address translation PRM module is documented in chapter 22 of the publicly available "AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh ACPI v6.5 Porting Guide".

---
v2:
- Make norm_to_sys_prm_handler_guid static.
- Change pr_info statements to more appropriate pr_debug and pr_info_once statements

v3:
- Add new AMD_ATL_PRM config instead of #if defined(CONFIG_APCI_PRMT) in prm.c
- Shorten variable names
- Update file header to include reference to the ACPI Porting Guide

---
 drivers/ras/amd/atl/Kconfig    |  4 +++
 drivers/ras/amd/atl/Makefile   |  2 ++
 drivers/ras/amd/atl/internal.h | 10 ++++++
 drivers/ras/amd/atl/prm.c      | 57 ++++++++++++++++++++++++++++++++++
 drivers/ras/amd/atl/umc.c      |  5 +++
 5 files changed, 78 insertions(+)
 create mode 100644 drivers/ras/amd/atl/prm.c
drivers/ras/amd/atl/Kconfig +4 -0
index df49c23e7f62..551680073e43 100644
@@ -19,3 +19,7 @@ config AMD_ATL
 
 	  Enable this option if using DRAM ECC on Zen-based systems
 	  and OS-based error handling.
+
+config AMD_ATL_PRM
+	depends on AMD_ATL && ACPI_PRMT
+	def_bool y
drivers/ras/amd/atl/Makefile +2 -0
index 4acd5f05bd9c..b56892c0c0d9 100644
@@ -15,4 +15,6 @@ amd_atl-y		+= map.o
 amd_atl-y		+= system.o
 amd_atl-y		+= umc.o
 
+amd_atl-$(CONFIG_AMD_ATL_PRM) += prm.o
+
 obj-$(CONFIG_AMD_ATL)	+= amd_atl.o
drivers/ras/amd/atl/internal.h +10 -0
index 9de5d53d0568..143d04c779a8 100644
@@ -282,6 +282,16 @@ unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err);
 u64 add_base_and_hole(struct addr_ctx *ctx, u64 addr);
 u64 remove_base_and_hole(struct addr_ctx *ctx, u64 addr);
 
+#ifdef CONFIG_AMD_ATL_PRM
+unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id, unsigned long addr);
+#else
+static inline unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id,
+						     unsigned long addr)
+{
+       return -ENODEV;
+}
+#endif
+
 /*
  * Make a gap in @data that is @num_bits long starting at @bit_num.
  * e.g. data		= 11111111'b
drivers/ras/amd/atl/prm.c new file +57 -0

57 lines not on this page · raw message

drivers/ras/amd/atl/umc.c +5 -0
index a1b4accf7b96..dc8aa12f63c8 100644
@@ -401,9 +401,14 @@ unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err)
 	u8 coh_st_inst_id = get_coh_st_inst_id(err);
 	unsigned long addr = get_addr(err->addr);
 	u8 die_id = get_die_id(err);
+	unsigned long ret_addr;
 
 	pr_debug("socket_id=0x%x die_id=0x%x coh_st_inst_id=0x%x addr=0x%016lx",
 		 socket_id, die_id, coh_st_inst_id, addr);
 
+	ret_addr = prm_umc_norm_to_sys_addr(socket_id, err->ipid, addr);
+	if (!IS_ERR_VALUE(ret_addr))
+		return ret_addr;
+
 	return norm_to_sys_addr(socket_id, die_id, coh_st_inst_id, addr);
 }
Signature · 1 line
2.34.1
maintainer Applied
#3 lore raw
In reply to John Allen
Quoted 32 lines · John Allen

Platform Runtime Mechanism (PRM) introduces a means for the AML interpreter and OS drivers to invoke runtime handlers from platform firmware in order to remove the need for certain classes of SMIs. Further details can be seen in the PRM specification[1].

Future AMD platforms will implement a PRM module in firmware that will include handlers for performing various types of address translation. The address translation PRM module is documented in chapter 22 of the publicly available "AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh ACPI v6.5 Porting Guide"[2].

While the kernel currently has support for calling PRM handlers from the AML interpreter, it does not support calling PRM handlers directly from OS drivers. This series implements the direct call interface and uses it for translating normalized addresses to system physical addresses.

Thanks,
John

[1]:
https://uefi.org/sites/default/files/resources/Platform%20Runtime%20Mechanism%20-%20with%20legal%20notice.pdf
[2]:
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/58088-0.75-pub.pdf

Tree: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Base commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

John Allen (2):
ACPI: PRM: Add PRM handler direct call support RAS/AMD/ATL: Translate normalized to system physical addresses using
PRM

Quoted 11 lines
 drivers/acpi/prmt.c            | 24 ++++++++++++++
 drivers/ras/amd/atl/Kconfig    |  4 +++
 drivers/ras/amd/atl/Makefile   |  2 ++
 drivers/ras/amd/atl/internal.h | 10 ++++++
 drivers/ras/amd/atl/prm.c      | 57 ++++++++++++++++++++++++++++++++++
 drivers/ras/amd/atl/umc.c      |  5 +++
 include/linux/prmt.h           |  5 +++
 7 files changed, 107 insertions(+)
 create mode 100644 drivers/ras/amd/atl/prm.c

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette