Commit 611f039f authored by Julien Grall's avatar Julien Grall Committed by Christoffer Dall

irqchip/gic-v3: Gather all ACPI specific data in a single structure

The ACPI code requires to use global variables in order to collect
information from the tables.

To make clear those variables are ACPI specific, gather all of them in a
single structure.

Furthermore, even if some of the variables are not marked with
__initdata, they are all only used during the initialization. Therefore,
the new variable, which hold the structure, can be marked with
__initdata.
Signed-off-by: default avatarJulien Grall <julien.grall@arm.com>
Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: default avatarHanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent 68628bb8
...@@ -970,19 +970,22 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare ...@@ -970,19 +970,22 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare
IRQCHIP_DECLARE(gic_v3, "arm,gic-v3", gic_of_init); IRQCHIP_DECLARE(gic_v3, "arm,gic-v3", gic_of_init);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static void __iomem *dist_base; static struct
static struct redist_region *redist_regs __initdata; {
static u32 nr_redist_regions __initdata; void __iomem *dist_base;
static bool single_redist; struct redist_region *redist_regs;
u32 nr_redist_regions;
bool single_redist;
} acpi_data __initdata;
static void __init static void __init
gic_acpi_register_redist(phys_addr_t phys_base, void __iomem *redist_base) gic_acpi_register_redist(phys_addr_t phys_base, void __iomem *redist_base)
{ {
static int count = 0; static int count = 0;
redist_regs[count].phys_base = phys_base; acpi_data.redist_regs[count].phys_base = phys_base;
redist_regs[count].redist_base = redist_base; acpi_data.redist_regs[count].redist_base = redist_base;
redist_regs[count].single_redist = single_redist; acpi_data.redist_regs[count].single_redist = acpi_data.single_redist;
count++; count++;
} }
...@@ -1010,7 +1013,7 @@ gic_acpi_parse_madt_gicc(struct acpi_subtable_header *header, ...@@ -1010,7 +1013,7 @@ gic_acpi_parse_madt_gicc(struct acpi_subtable_header *header,
{ {
struct acpi_madt_generic_interrupt *gicc = struct acpi_madt_generic_interrupt *gicc =
(struct acpi_madt_generic_interrupt *)header; (struct acpi_madt_generic_interrupt *)header;
u32 reg = readl_relaxed(dist_base + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK; u32 reg = readl_relaxed(acpi_data.dist_base + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK;
u32 size = reg == GIC_PIDR2_ARCH_GICv4 ? SZ_64K * 4 : SZ_64K * 2; u32 size = reg == GIC_PIDR2_ARCH_GICv4 ? SZ_64K * 4 : SZ_64K * 2;
void __iomem *redist_base; void __iomem *redist_base;
...@@ -1027,7 +1030,7 @@ static int __init gic_acpi_collect_gicr_base(void) ...@@ -1027,7 +1030,7 @@ static int __init gic_acpi_collect_gicr_base(void)
acpi_tbl_entry_handler redist_parser; acpi_tbl_entry_handler redist_parser;
enum acpi_madt_type type; enum acpi_madt_type type;
if (single_redist) { if (acpi_data.single_redist) {
type = ACPI_MADT_TYPE_GENERIC_INTERRUPT; type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
redist_parser = gic_acpi_parse_madt_gicc; redist_parser = gic_acpi_parse_madt_gicc;
} else { } else {
...@@ -1078,14 +1081,14 @@ static int __init gic_acpi_count_gicr_regions(void) ...@@ -1078,14 +1081,14 @@ static int __init gic_acpi_count_gicr_regions(void)
count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
gic_acpi_match_gicr, 0); gic_acpi_match_gicr, 0);
if (count > 0) { if (count > 0) {
single_redist = false; acpi_data.single_redist = false;
return count; return count;
} }
count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
gic_acpi_match_gicc, 0); gic_acpi_match_gicc, 0);
if (count > 0) if (count > 0)
single_redist = true; acpi_data.single_redist = true;
return count; return count;
} }
...@@ -1105,7 +1108,7 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header, ...@@ -1105,7 +1108,7 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header,
if (count <= 0) if (count <= 0)
return false; return false;
nr_redist_regions = count; acpi_data.nr_redist_regions = count;
return true; return true;
} }
...@@ -1116,25 +1119,28 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end) ...@@ -1116,25 +1119,28 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end)
{ {
struct acpi_madt_generic_distributor *dist; struct acpi_madt_generic_distributor *dist;
struct fwnode_handle *domain_handle; struct fwnode_handle *domain_handle;
size_t size;
int i, err; int i, err;
/* Get distributor base address */ /* Get distributor base address */
dist = (struct acpi_madt_generic_distributor *)header; dist = (struct acpi_madt_generic_distributor *)header;
dist_base = ioremap(dist->base_address, ACPI_GICV3_DIST_MEM_SIZE); acpi_data.dist_base = ioremap(dist->base_address,
if (!dist_base) { ACPI_GICV3_DIST_MEM_SIZE);
if (!acpi_data.dist_base) {
pr_err("Unable to map GICD registers\n"); pr_err("Unable to map GICD registers\n");
return -ENOMEM; return -ENOMEM;
} }
err = gic_validate_dist_version(dist_base); err = gic_validate_dist_version(acpi_data.dist_base);
if (err) { if (err) {
pr_err("No distributor detected at @%p, giving up", dist_base); pr_err("No distributor detected at @%p, giving up",
acpi_data.dist_base);
goto out_dist_unmap; goto out_dist_unmap;
} }
redist_regs = kzalloc(sizeof(*redist_regs) * nr_redist_regions, size = sizeof(*acpi_data.redist_regs) * acpi_data.nr_redist_regions;
GFP_KERNEL); acpi_data.redist_regs = kzalloc(size, GFP_KERNEL);
if (!redist_regs) { if (!acpi_data.redist_regs) {
err = -ENOMEM; err = -ENOMEM;
goto out_dist_unmap; goto out_dist_unmap;
} }
...@@ -1143,14 +1149,14 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end) ...@@ -1143,14 +1149,14 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end)
if (err) if (err)
goto out_redist_unmap; goto out_redist_unmap;
domain_handle = irq_domain_alloc_fwnode(dist_base); domain_handle = irq_domain_alloc_fwnode(acpi_data.dist_base);
if (!domain_handle) { if (!domain_handle) {
err = -ENOMEM; err = -ENOMEM;
goto out_redist_unmap; goto out_redist_unmap;
} }
err = gic_init_bases(dist_base, redist_regs, nr_redist_regions, 0, err = gic_init_bases(acpi_data.dist_base, acpi_data.redist_regs,
domain_handle); acpi_data.nr_redist_regions, 0, domain_handle);
if (err) if (err)
goto out_fwhandle_free; goto out_fwhandle_free;
...@@ -1160,12 +1166,12 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end) ...@@ -1160,12 +1166,12 @@ gic_acpi_init(struct acpi_subtable_header *header, const unsigned long end)
out_fwhandle_free: out_fwhandle_free:
irq_domain_free_fwnode(domain_handle); irq_domain_free_fwnode(domain_handle);
out_redist_unmap: out_redist_unmap:
for (i = 0; i < nr_redist_regions; i++) for (i = 0; i < acpi_data.nr_redist_regions; i++)
if (redist_regs[i].redist_base) if (acpi_data.redist_regs[i].redist_base)
iounmap(redist_regs[i].redist_base); iounmap(acpi_data.redist_regs[i].redist_base);
kfree(redist_regs); kfree(acpi_data.redist_regs);
out_dist_unmap: out_dist_unmap:
iounmap(dist_base); iounmap(acpi_data.dist_base);
return err; return err;
} }
IRQCHIP_ACPI_DECLARE(gic_v3, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, IRQCHIP_ACPI_DECLARE(gic_v3, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment