Skip to content

Commit

Permalink
irqchip/gic-v3: Dynamically allocate PPI partition descriptors
Browse files Browse the repository at this point in the history
Again, PPIs are becoming a variable set. Let's hack the PPI partition
code to make the top-level array dynamically allocated.

Signed-off-by: Marc Zyngier <maz@kernel.org>
  • Loading branch information
Marc Zyngier committed Aug 20, 2019
1 parent 81a4327 commit 52085d3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drivers/irqchip/irq-gic-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct gic_chip_data {
u64 flags;
bool has_rss;
unsigned int ppi_nr;
struct partition_desc *ppi_descs[16];
struct partition_desc **ppi_descs;
};

static struct gic_chip_data gic_data __read_mostly;
Expand Down Expand Up @@ -1354,7 +1354,8 @@ static int gic_irq_domain_select(struct irq_domain *d,
* then we need to match the partition domain.
*/
if (fwspec->param_count >= 4 &&
fwspec->param[0] == 1 && fwspec->param[3] != 0)
fwspec->param[0] == 1 && fwspec->param[3] != 0 &&
gic_data.ppi_descs)
return d == partition_get_domain(gic_data.ppi_descs[fwspec->param[1]]);

return d == gic_data.domain;
Expand All @@ -1375,6 +1376,9 @@ static int partition_domain_translate(struct irq_domain *d,
struct device_node *np;
int ret;

if (!gic_data.ppi_descs)
return -ENOMEM;

np = of_find_node_by_phandle(fwspec->param[3]);
if (WARN_ON(!np))
return -EINVAL;
Expand Down Expand Up @@ -1531,6 +1535,10 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
if (!parts_node)
return;

gic_data.ppi_descs = kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_descs), GFP_KERNEL);
if (!gic_data.ppi_descs)
return;

nr_parts = of_get_child_count(parts_node);

if (!nr_parts)
Expand Down Expand Up @@ -1582,7 +1590,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
part_idx++;
}

for (i = 0; i < 16; i++) {
for (i = 0; i < gic_data.ppi_nr; i++) {
unsigned int irq;
struct partition_desc *desc;
struct irq_fwspec ppi_fwspec = {
Expand Down

0 comments on commit 52085d3

Please sign in to comment.