ACPI: Keep sub-table parsing infrastructure available for modules
authorDan Williams <dan.j.williams@intel.com>
Fri, 29 Oct 2021 19:51:32 +0000 (12:51 -0700)
committerDan Williams <dan.j.williams@intel.com>
Mon, 15 Nov 2021 19:02:59 +0000 (11:02 -0800)
The NFIT driver and now the CXL ACPI driver have both open-coded ACPI
table parsing. Before another instance is added arrange for the core
ACPI sub-table parsing to be optionally available to drivers via the
CONFIG_ACPI_TABLE_LIB symbol. If no drivers select the symbol then the
infrastructure reverts back to being tagged __init via the
__init_or_acpilib annotation.

For now, only tag the core sub-table routines and data that the CEDT parsing in
the cxl_acpi driver would want to reuse, a CEDT parsing helper is added
in a later change.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Alison Schofield <alison.schofield@intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/163553709227.2509508.8215196520233473814.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/acpi/Kconfig
drivers/acpi/tables.c
include/linux/acpi.h

index cdbdf68bd98f5ce3e7ef485580e102fd16694e67..c97ee0cfe26ea3fcd5fec7bf44c9fad60ae89127 100644 (file)
@@ -59,6 +59,9 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
 config ACPI_CCA_REQUIRED
        bool
 
+config ACPI_TABLE_LIB
+       bool
+
 config ACPI_DEBUGGER
        bool "AML debugger interface"
        select ACPI_DEBUG
index 71419eb16e09fab1fe18e7cb6d46fc2930d0763d..b80a3de655d79c0dbc340c4609a24df52c44b7fa 100644 (file)
@@ -35,7 +35,7 @@ static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
 
 static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
 
-static int acpi_apic_instance __initdata;
+static int acpi_apic_instance __initdata_or_acpilib;
 
 enum acpi_subtable_type {
        ACPI_SUBTABLE_COMMON,
@@ -52,7 +52,7 @@ struct acpi_subtable_entry {
  * Disable table checksum verification for the early stage due to the size
  * limitation of the current x86 early mapping implementation.
  */
-static bool acpi_verify_table_checksum __initdata = false;
+static bool acpi_verify_table_checksum __initdata_or_acpilib = false;
 
 void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 {
@@ -216,7 +216,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
        }
 }
 
-static unsigned long __init
+static unsigned long __init_or_acpilib
 acpi_get_entry_type(struct acpi_subtable_entry *entry)
 {
        switch (entry->type) {
@@ -230,7 +230,7 @@ acpi_get_entry_type(struct acpi_subtable_entry *entry)
        return 0;
 }
 
-static unsigned long __init
+static unsigned long __init_or_acpilib
 acpi_get_entry_length(struct acpi_subtable_entry *entry)
 {
        switch (entry->type) {
@@ -244,7 +244,7 @@ acpi_get_entry_length(struct acpi_subtable_entry *entry)
        return 0;
 }
 
-static unsigned long __init
+static unsigned long __init_or_acpilib
 acpi_get_subtable_header_length(struct acpi_subtable_entry *entry)
 {
        switch (entry->type) {
@@ -258,7 +258,7 @@ acpi_get_subtable_header_length(struct acpi_subtable_entry *entry)
        return 0;
 }
 
-static enum acpi_subtable_type __init
+static enum acpi_subtable_type __init_or_acpilib
 acpi_get_subtable_type(char *id)
 {
        if (strncmp(id, ACPI_SIG_HMAT, 4) == 0)
@@ -291,10 +291,10 @@ acpi_get_subtable_type(char *id)
  * On success returns sum of all matching entries for all proc handlers.
  * Otherwise, -ENODEV or -EINVAL is returned.
  */
-static int __init acpi_parse_entries_array(char *id, unsigned long table_size,
-               struct acpi_table_header *table_header,
-               struct acpi_subtable_proc *proc, int proc_num,
-               unsigned int max_entries)
+static int __init_or_acpilib acpi_parse_entries_array(
+       char *id, unsigned long table_size,
+       struct acpi_table_header *table_header, struct acpi_subtable_proc *proc,
+       int proc_num, unsigned int max_entries)
 {
        struct acpi_subtable_entry entry;
        unsigned long table_end, subtable_len, entry_len;
@@ -352,10 +352,9 @@ static int __init acpi_parse_entries_array(char *id, unsigned long table_size,
        return errs ? -EINVAL : count;
 }
 
-int __init acpi_table_parse_entries_array(char *id,
-                        unsigned long table_size,
-                        struct acpi_subtable_proc *proc, int proc_num,
-                        unsigned int max_entries)
+int __init_or_acpilib acpi_table_parse_entries_array(
+       char *id, unsigned long table_size, struct acpi_subtable_proc *proc,
+       int proc_num, unsigned int max_entries)
 {
        struct acpi_table_header *table_header = NULL;
        int count;
index 143ce7e0bee130a56eda16b5862cd82e5bcddf4b..edfa3c8f356245b7e84c29df2301cf2e62b77757 100644 (file)
@@ -232,14 +232,22 @@ int acpi_locate_initial_tables (void);
 void acpi_reserve_initial_tables (void);
 void acpi_table_init_complete (void);
 int acpi_table_init (void);
+
+#ifdef CONFIG_ACPI_TABLE_LIB
+#define __init_or_acpilib
+#define __initdata_or_acpilib
+#else
+#define __init_or_acpilib __init
+#define __initdata_or_acpilib __initdata
+#endif
+
 int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
-int __init acpi_table_parse_entries(char *id, unsigned long table_size,
-                             int entry_id,
-                             acpi_tbl_entry_handler handler,
-                             unsigned int max_entries);
-int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
-                             struct acpi_subtable_proc *proc, int proc_num,
-                             unsigned int max_entries);
+int __init_or_acpilib acpi_table_parse_entries(char *id,
+               unsigned long table_size, int entry_id,
+               acpi_tbl_entry_handler handler, unsigned int max_entries);
+int __init_or_acpilib acpi_table_parse_entries_array(char *id,
+               unsigned long table_size, struct acpi_subtable_proc *proc,
+               int proc_num, unsigned int max_entries);
 int acpi_table_parse_madt(enum acpi_madt_type id,
                          acpi_tbl_entry_handler handler,
                          unsigned int max_entries);