]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ACPI: PRM: Add PRM handler direct call support
authorJohn Allen <john.allen@amd.com>
Tue, 30 Jul 2024 15:17:30 +0000 (15:17 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Thu, 1 Aug 2024 12:23:39 +0000 (14:23 +0200)
Platform Runtime Mechanism (PRM) handlers can be invoked from either the AML
interpreter or directly by an OS driver. Implement the latter.

  [ bp: Massage commit message. ]

Signed-off-by: John Allen <john.allen@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20240730151731.15363-2-john.allen@amd.com
drivers/acpi/prmt.c
include/linux/prmt.h

index c78453c74ef5aa6cb30485901f0ee127fddebed4..1cfaa5957ac4d860babeb05460a7c7d020caa659 100644 (file)
@@ -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
index 24da8364b91977fcd8c9c3372d8cd26a3cb6d578..9c094294403ff488a03f50d90bab3ddc8254575f 100644 (file)
@@ -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