Skip to content

Commit

Permalink
acpi: Create subtable parsing infrastructure
Browse files Browse the repository at this point in the history
Parsing entries in an ACPI table had assumed a generic header
structure. There is no standard ACPI header, though, so less common
layouts with different field sizes required custom parsers to go through
their subtable entry list.

Create the infrastructure for adding different table types so parsing
the entries array may be more reused for all ACPI system tables and
the common code doesn't need to be duplicated.

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Tested-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Keith Busch authored and Greg Kroah-Hartman committed Apr 4, 2019
1 parent c03a0fd commit 60574d1
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 63 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kernel/acpi_numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
return -EINVAL;
}

static int __init acpi_parse_gicc_pxm(struct acpi_subtable_header *header,
static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_srat_gicc_affinity *pa;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
}

static int __init
acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
acpi_parse_gic_cpu_interface(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_madt_generic_interrupt *processor;
Expand All @@ -595,7 +595,7 @@ acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
if (BAD_MADT_GICC_ENTRY(processor, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

acpi_map_gic_cpu_interface(processor);

Expand Down
14 changes: 7 additions & 7 deletions arch/ia64/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ struct acpi_table_madt *acpi_madt __initdata;
static u8 has_8259;

static int __init
acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_madt_local_apic_override *lapic;
Expand All @@ -195,7 +195,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
}

static int __init
acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_lsapic(union acpi_subtable_headers *header, const unsigned long end)
{
struct acpi_madt_local_sapic *lsapic;

Expand All @@ -216,7 +216,7 @@ acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end)
}

static int __init
acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_local_apic_nmi *lacpi_nmi;

Expand All @@ -230,7 +230,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
}

static int __init
acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_iosapic(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_io_sapic *iosapic;

Expand All @@ -245,7 +245,7 @@ acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end
static unsigned int __initdata acpi_madt_rev;

static int __init
acpi_parse_plat_int_src(struct acpi_subtable_header * header,
acpi_parse_plat_int_src(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_madt_interrupt_source *plintsrc;
Expand Down Expand Up @@ -329,7 +329,7 @@ unsigned int get_cpei_target_cpu(void)
}

static int __init
acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_madt_interrupt_override *p;
Expand All @@ -350,7 +350,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
}

static int __init
acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_nmi_source *nmi_src;

Expand Down
36 changes: 18 additions & 18 deletions arch/x86/kernel/acpi/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
}

static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
{
struct acpi_madt_local_x2apic *processor = NULL;
#ifdef CONFIG_X86_X2APIC
Expand All @@ -210,7 +210,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

#ifdef CONFIG_X86_X2APIC
apic_id = processor->local_apic_id;
Expand Down Expand Up @@ -242,7 +242,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
}

static int __init
acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_local_apic *processor = NULL;

Expand All @@ -251,7 +251,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

/* Ignore invalid ID */
if (processor->id == 0xff)
Expand All @@ -272,7 +272,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
}

static int __init
acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
{
struct acpi_madt_local_sapic *processor = NULL;

Expand All @@ -281,7 +281,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
processor->processor_id, /* ACPI ID */
Expand All @@ -291,7 +291,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
}

static int __init
acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
Expand All @@ -301,15 +301,15 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

acpi_lapic_addr = lapic_addr_ovr->address;

return 0;
}

static int __init
acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
Expand All @@ -319,7 +319,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
if (BAD_MADT_ENTRY(x2apic_nmi, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

if (x2apic_nmi->lint != 1)
printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
Expand All @@ -328,7 +328,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
}

static int __init
acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;

Expand All @@ -337,7 +337,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
if (BAD_MADT_ENTRY(lapic_nmi, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

if (lapic_nmi->lint != 1)
printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
Expand Down Expand Up @@ -449,7 +449,7 @@ static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
}

static int __init
acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_io_apic *ioapic = NULL;
struct ioapic_domain_cfg cfg = {
Expand All @@ -462,7 +462,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
if (BAD_MADT_ENTRY(ioapic, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

/* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
if (ioapic->global_irq_base < nr_legacy_irqs())
Expand Down Expand Up @@ -508,7 +508,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
}

static int __init
acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_madt_interrupt_override *intsrc = NULL;
Expand All @@ -518,7 +518,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
if (BAD_MADT_ENTRY(intsrc, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
acpi_sci_ioapic_setup(intsrc->source_irq,
Expand Down Expand Up @@ -550,7 +550,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
}

static int __init
acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
{
struct acpi_madt_nmi_source *nmi_src = NULL;

Expand All @@ -559,7 +559,7 @@ acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end
if (BAD_MADT_ENTRY(nmi_src, end))
return -EINVAL;

acpi_table_print_madt_entry(header);
acpi_table_print_madt_entry(&header->common);

/* TBD: Support nimsrc entries? */

Expand Down
16 changes: 8 additions & 8 deletions drivers/acpi/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
}

static int __init
acpi_parse_x2apic_affinity(struct acpi_subtable_header *header,
acpi_parse_x2apic_affinity(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_srat_x2apic_cpu_affinity *processor_affinity;
Expand All @@ -348,7 +348,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header,
if (!processor_affinity)
return -EINVAL;

acpi_table_print_srat_entry(header);
acpi_table_print_srat_entry(&header->common);

/* let architecture-dependent part to do it */
acpi_numa_x2apic_affinity_init(processor_affinity);
Expand All @@ -357,7 +357,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header,
}

static int __init
acpi_parse_processor_affinity(struct acpi_subtable_header *header,
acpi_parse_processor_affinity(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_srat_cpu_affinity *processor_affinity;
Expand All @@ -366,7 +366,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header,
if (!processor_affinity)
return -EINVAL;

acpi_table_print_srat_entry(header);
acpi_table_print_srat_entry(&header->common);

/* let architecture-dependent part to do it */
acpi_numa_processor_affinity_init(processor_affinity);
Expand All @@ -375,7 +375,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header,
}

static int __init
acpi_parse_gicc_affinity(struct acpi_subtable_header *header,
acpi_parse_gicc_affinity(union acpi_subtable_headers *header,
const unsigned long end)
{
struct acpi_srat_gicc_affinity *processor_affinity;
Expand All @@ -384,7 +384,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header,
if (!processor_affinity)
return -EINVAL;

acpi_table_print_srat_entry(header);
acpi_table_print_srat_entry(&header->common);

/* let architecture-dependent part to do it */
acpi_numa_gicc_affinity_init(processor_affinity);
Expand All @@ -395,7 +395,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header,
static int __initdata parsed_numa_memblks;

static int __init
acpi_parse_memory_affinity(struct acpi_subtable_header * header,
acpi_parse_memory_affinity(union acpi_subtable_headers * header,
const unsigned long end)
{
struct acpi_srat_mem_affinity *memory_affinity;
Expand All @@ -404,7 +404,7 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header,
if (!memory_affinity)
return -EINVAL;

acpi_table_print_srat_entry(header);
acpi_table_print_srat_entry(&header->common);

/* let architecture-dependent part to do it */
if (!acpi_numa_memory_affinity_init(memory_affinity))
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,10 +2241,10 @@ static struct acpi_probe_entry *ape;
static int acpi_probe_count;
static DEFINE_MUTEX(acpi_probe_mutex);

static int __init acpi_match_madt(struct acpi_subtable_header *header,
static int __init acpi_match_madt(union acpi_subtable_headers *header,
const unsigned long end)
{
if (!ape->subtable_valid || ape->subtable_valid(header, ape))
if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape))
if (!ape->probe_subtbl(header, end))
acpi_probe_count++;

Expand Down
Loading

0 comments on commit 60574d1

Please sign in to comment.