Skip to content

Commit 38dd7c4

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3-its: Drop chunk allocation compatibility
The chunk allocation system is now officially dead, so let's remove it. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 147c8f3 commit 38dd7c4

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,12 +1440,6 @@ static struct irq_chip its_irq_chip = {
14401440
* freeing is expensive. We assumes that freeing rarely occurs.
14411441
*/
14421442

1443-
/*
1444-
* Compatibility defines until we fully refactor the allocator
1445-
*/
1446-
#define IRQS_PER_CHUNK_SHIFT 5
1447-
#define IRQS_PER_CHUNK (1UL << IRQS_PER_CHUNK_SHIFT)
1448-
14491443
static DEFINE_MUTEX(lpi_range_lock);
14501444
static LIST_HEAD(lpi_range_list);
14511445

@@ -1558,30 +1552,27 @@ static int __init its_lpi_init(u32 id_bits)
15581552
return err;
15591553
}
15601554

1561-
static unsigned long *its_lpi_alloc_chunks(int nr_irqs, u32 *base, int *nr_ids)
1555+
static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)
15621556
{
15631557
unsigned long *bitmap = NULL;
15641558
int err = 0;
1565-
int nr_lpis;
1566-
1567-
nr_lpis = round_up(nr_irqs, IRQS_PER_CHUNK);
15681559

15691560
do {
1570-
err = alloc_lpi_range(nr_lpis, base);
1561+
err = alloc_lpi_range(nr_irqs, base);
15711562
if (!err)
15721563
break;
15731564

1574-
nr_lpis -= IRQS_PER_CHUNK;
1575-
} while (nr_lpis > 0);
1565+
nr_irqs /= 2;
1566+
} while (nr_irqs > 0);
15761567

15771568
if (err)
15781569
goto out;
15791570

1580-
bitmap = kcalloc(BITS_TO_LONGS(nr_lpis), sizeof (long), GFP_ATOMIC);
1571+
bitmap = kcalloc(BITS_TO_LONGS(nr_irqs), sizeof (long), GFP_ATOMIC);
15811572
if (!bitmap)
15821573
goto out;
15831574

1584-
*nr_ids = nr_lpis;
1575+
*nr_ids = nr_irqs;
15851576

15861577
out:
15871578
if (!bitmap)
@@ -1590,7 +1581,7 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, u32 *base, int *nr_ids)
15901581
return bitmap;
15911582
}
15921583

1593-
static void its_lpi_free_chunks(unsigned long *bitmap, u32 base, u32 nr_ids)
1584+
static void its_lpi_free(unsigned long *bitmap, u32 base, u32 nr_ids)
15941585
{
15951586
WARN_ON(free_lpi_range(base, nr_ids));
15961587
kfree(bitmap);
@@ -2213,7 +2204,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
22132204
sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
22142205
itt = kzalloc(sz, GFP_KERNEL);
22152206
if (alloc_lpis) {
2216-
lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis);
2207+
lpi_map = its_lpi_alloc(nvecs, &lpi_base, &nr_lpis);
22172208
if (lpi_map)
22182209
col_map = kcalloc(nr_lpis, sizeof(*col_map),
22192210
GFP_KERNEL);
@@ -2448,9 +2439,9 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,
24482439
/* If all interrupts have been freed, start mopping the floor */
24492440
if (bitmap_empty(its_dev->event_map.lpi_map,
24502441
its_dev->event_map.nr_lpis)) {
2451-
its_lpi_free_chunks(its_dev->event_map.lpi_map,
2452-
its_dev->event_map.lpi_base,
2453-
its_dev->event_map.nr_lpis);
2442+
its_lpi_free(its_dev->event_map.lpi_map,
2443+
its_dev->event_map.lpi_base,
2444+
its_dev->event_map.nr_lpis);
24542445
kfree(its_dev->event_map.col_map);
24552446

24562447
/* Unmap device/itt */
@@ -2849,7 +2840,7 @@ static void its_vpe_irq_domain_free(struct irq_domain *domain,
28492840
}
28502841

28512842
if (bitmap_empty(vm->db_bitmap, vm->nr_db_lpis)) {
2852-
its_lpi_free_chunks(vm->db_bitmap, vm->db_lpi_base, vm->nr_db_lpis);
2843+
its_lpi_free(vm->db_bitmap, vm->db_lpi_base, vm->nr_db_lpis);
28532844
its_free_prop_table(vm->vprop_page);
28542845
}
28552846
}
@@ -2864,18 +2855,18 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
28642855

28652856
BUG_ON(!vm);
28662857

2867-
bitmap = its_lpi_alloc_chunks(roundup_pow_of_two(nr_irqs), &base, &nr_ids);
2858+
bitmap = its_lpi_alloc(roundup_pow_of_two(nr_irqs), &base, &nr_ids);
28682859
if (!bitmap)
28692860
return -ENOMEM;
28702861

28712862
if (nr_ids < nr_irqs) {
2872-
its_lpi_free_chunks(bitmap, base, nr_ids);
2863+
its_lpi_free(bitmap, base, nr_ids);
28732864
return -ENOMEM;
28742865
}
28752866

28762867
vprop_page = its_allocate_prop_table(GFP_KERNEL);
28772868
if (!vprop_page) {
2878-
its_lpi_free_chunks(bitmap, base, nr_ids);
2869+
its_lpi_free(bitmap, base, nr_ids);
28792870
return -ENOMEM;
28802871
}
28812872

@@ -2902,7 +2893,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
29022893
if (i > 0)
29032894
its_vpe_irq_domain_free(domain, virq, i - 1);
29042895

2905-
its_lpi_free_chunks(bitmap, base, nr_ids);
2896+
its_lpi_free(bitmap, base, nr_ids);
29062897
its_free_prop_table(vprop_page);
29072898
}
29082899

0 commit comments

Comments
 (0)