]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: MRRM: Minimal parse of ACPI MRRM table
authorTony Luck <tony.luck@intel.com>
Mon, 5 May 2025 17:38:17 +0000 (10:38 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 12 May 2025 13:43:16 +0000 (15:43 +0200)
The resctrl file system code needs to know how many region tags
are supported. Parse the ACPI MRRM table and save the max_mem_region
value.

Provide a function for resctrl to collect that value.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://patch.msgid.link/20250505173819.419271-2-tony.luck@intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
arch/x86/Kconfig
drivers/acpi/Kconfig
drivers/acpi/Makefile
drivers/acpi/acpi_mrrm.c [new file with mode: 0644]
include/linux/acpi.h

index 4b9f378e05f6be9f0c90a722c4fba66ff96f073f..0e43069082dfa7f9209a4a8efbc337d171ee30aa 100644 (file)
@@ -38,6 +38,7 @@ config X86_64
        select ARCH_HAS_ELFCORE_COMPAT
        select ZONE_DMA32
        select EXECMEM if DYNAMIC_FTRACE
+       select ACPI_MRRM if ACPI
 
 config FORCE_DYNAMIC_FTRACE
        def_bool y
index 7f10aa38269d2189e14c716d44ef5d0b8e53a3d1..7bc40c2735ac0dfe18834e8ec7df686779e8586f 100644 (file)
@@ -576,6 +576,9 @@ config ACPI_FFH
          Enable this feature if you want to set up and install the FFH Address
          Space handler to handle FFH OpRegion in the firmware.
 
+config ACPI_MRRM
+       bool
+
 source "drivers/acpi/pmic/Kconfig"
 
 config ACPI_VIOT
index 797070fc9a3f42ad9be166a6d96051572ae6593e..d1b0affb844f05a9d3f12d7f8af51cd2c3fe7317 100644 (file)
@@ -66,6 +66,7 @@ acpi-$(CONFIG_ACPI_WATCHDOG)  += acpi_watchdog.o
 acpi-$(CONFIG_ACPI_PRMT)       += prmt.o
 acpi-$(CONFIG_ACPI_PCC)                += acpi_pcc.o
 acpi-$(CONFIG_ACPI_FFH)                += acpi_ffh.o
+acpi-$(CONFIG_ACPI_MRRM)       += acpi_mrrm.o
 
 # Address translation
 acpi-$(CONFIG_ACPI_ADXL)       += acpi_adxl.o
diff --git a/drivers/acpi/acpi_mrrm.c b/drivers/acpi/acpi_mrrm.c
new file mode 100644 (file)
index 0000000..ab8022e
--- /dev/null
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2025, Intel Corporation.
+ *
+ * Memory Range and Region Mapping (MRRM) structure
+ */
+
+#define pr_fmt(fmt) "acpi/mrrm: " fmt
+
+#include <linux/acpi.h>
+#include <linux/init.h>
+
+static int max_mem_region = -ENOENT;
+
+/* Access for use by resctrl file system */
+int acpi_mrrm_max_mem_region(void)
+{
+       return max_mem_region;
+}
+
+static __init int acpi_parse_mrrm(struct acpi_table_header *table)
+{
+       struct acpi_table_mrrm *mrrm;
+
+       mrrm = (struct acpi_table_mrrm *)table;
+       if (!mrrm)
+               return -ENODEV;
+
+       max_mem_region = mrrm->max_mem_region;
+
+       return 0;
+}
+
+static __init int mrrm_init(void)
+{
+       int ret;
+
+       ret = acpi_table_parse(ACPI_SIG_MRRM, acpi_parse_mrrm);
+
+       return ret;
+}
+device_initcall(mrrm_init);
index 3f2e93ed9730160c1090ff86fd94fe5413676a20..c409f4cecb09026335c718b8bb0e0f5945be3b34 100644 (file)
@@ -772,6 +772,10 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr);
 int acpi_get_local_address(acpi_handle handle, u32 *addr);
 const char *acpi_get_subsystem_id(acpi_handle handle);
 
+#ifdef CONFIG_ACPI_MRRM
+int acpi_mrrm_max_mem_region(void);
+#endif
+
 #else  /* !CONFIG_ACPI */
 
 #define acpi_disabled 1
@@ -1092,6 +1096,11 @@ static inline acpi_handle acpi_get_processor_handle(int cpu)
        return NULL;
 }
 
+static inline int acpi_mrrm_max_mem_region(void)
+{
+       return -ENOENT;
+}
+
 #endif /* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI_HMAT