Skip to content

Commit b9020bd

Browse files
aeglrafaeljw
authored andcommitted
ACPI: MRRM: Minimal parse of ACPI MRRM table
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>
1 parent fec2686 commit b9020bd

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config X86_64
3838
select ARCH_HAS_ELFCORE_COMPAT
3939
select ZONE_DMA32
4040
select EXECMEM if DYNAMIC_FTRACE
41+
select ACPI_MRRM if ACPI
4142

4243
config FORCE_DYNAMIC_FTRACE
4344
def_bool y

drivers/acpi/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ config ACPI_FFH
576576
Enable this feature if you want to set up and install the FFH Address
577577
Space handler to handle FFH OpRegion in the firmware.
578578

579+
config ACPI_MRRM
580+
bool
581+
579582
source "drivers/acpi/pmic/Kconfig"
580583

581584
config ACPI_VIOT

drivers/acpi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o
6666
acpi-$(CONFIG_ACPI_PRMT) += prmt.o
6767
acpi-$(CONFIG_ACPI_PCC) += acpi_pcc.o
6868
acpi-$(CONFIG_ACPI_FFH) += acpi_ffh.o
69+
acpi-$(CONFIG_ACPI_MRRM) += acpi_mrrm.o
6970

7071
# Address translation
7172
acpi-$(CONFIG_ACPI_ADXL) += acpi_adxl.o

drivers/acpi/acpi_mrrm.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2025, Intel Corporation.
4+
*
5+
* Memory Range and Region Mapping (MRRM) structure
6+
*/
7+
8+
#define pr_fmt(fmt) "acpi/mrrm: " fmt
9+
10+
#include <linux/acpi.h>
11+
#include <linux/init.h>
12+
13+
static int max_mem_region = -ENOENT;
14+
15+
/* Access for use by resctrl file system */
16+
int acpi_mrrm_max_mem_region(void)
17+
{
18+
return max_mem_region;
19+
}
20+
21+
static __init int acpi_parse_mrrm(struct acpi_table_header *table)
22+
{
23+
struct acpi_table_mrrm *mrrm;
24+
25+
mrrm = (struct acpi_table_mrrm *)table;
26+
if (!mrrm)
27+
return -ENODEV;
28+
29+
max_mem_region = mrrm->max_mem_region;
30+
31+
return 0;
32+
}
33+
34+
static __init int mrrm_init(void)
35+
{
36+
int ret;
37+
38+
ret = acpi_table_parse(ACPI_SIG_MRRM, acpi_parse_mrrm);
39+
40+
return ret;
41+
}
42+
device_initcall(mrrm_init);

include/linux/acpi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr);
772772
int acpi_get_local_address(acpi_handle handle, u32 *addr);
773773
const char *acpi_get_subsystem_id(acpi_handle handle);
774774

775+
#ifdef CONFIG_ACPI_MRRM
776+
int acpi_mrrm_max_mem_region(void);
777+
#endif
778+
775779
#else /* !CONFIG_ACPI */
776780

777781
#define acpi_disabled 1
@@ -1092,6 +1096,11 @@ static inline acpi_handle acpi_get_processor_handle(int cpu)
10921096
return NULL;
10931097
}
10941098

1099+
static inline int acpi_mrrm_max_mem_region(void)
1100+
{
1101+
return -ENOENT;
1102+
}
1103+
10951104
#endif /* !CONFIG_ACPI */
10961105

10971106
#ifdef CONFIG_ACPI_HMAT

0 commit comments

Comments
 (0)