@@ -1440,12 +1440,6 @@ static struct irq_chip its_irq_chip = {
1440
1440
* freeing is expensive. We assumes that freeing rarely occurs.
1441
1441
*/
1442
1442
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
-
1449
1443
static DEFINE_MUTEX (lpi_range_lock );
1450
1444
static LIST_HEAD (lpi_range_list );
1451
1445
@@ -1558,30 +1552,27 @@ static int __init its_lpi_init(u32 id_bits)
1558
1552
return err ;
1559
1553
}
1560
1554
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 )
1562
1556
{
1563
1557
unsigned long * bitmap = NULL ;
1564
1558
int err = 0 ;
1565
- int nr_lpis ;
1566
-
1567
- nr_lpis = round_up (nr_irqs , IRQS_PER_CHUNK );
1568
1559
1569
1560
do {
1570
- err = alloc_lpi_range (nr_lpis , base );
1561
+ err = alloc_lpi_range (nr_irqs , base );
1571
1562
if (!err )
1572
1563
break ;
1573
1564
1574
- nr_lpis -= IRQS_PER_CHUNK ;
1575
- } while (nr_lpis > 0 );
1565
+ nr_irqs /= 2 ;
1566
+ } while (nr_irqs > 0 );
1576
1567
1577
1568
if (err )
1578
1569
goto out ;
1579
1570
1580
- bitmap = kcalloc (BITS_TO_LONGS (nr_lpis ), sizeof (long ), GFP_ATOMIC );
1571
+ bitmap = kcalloc (BITS_TO_LONGS (nr_irqs ), sizeof (long ), GFP_ATOMIC );
1581
1572
if (!bitmap )
1582
1573
goto out ;
1583
1574
1584
- * nr_ids = nr_lpis ;
1575
+ * nr_ids = nr_irqs ;
1585
1576
1586
1577
out :
1587
1578
if (!bitmap )
@@ -1590,7 +1581,7 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, u32 *base, int *nr_ids)
1590
1581
return bitmap ;
1591
1582
}
1592
1583
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 )
1594
1585
{
1595
1586
WARN_ON (free_lpi_range (base , nr_ids ));
1596
1587
kfree (bitmap );
@@ -2213,7 +2204,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
2213
2204
sz = max (sz , ITS_ITT_ALIGN ) + ITS_ITT_ALIGN - 1 ;
2214
2205
itt = kzalloc (sz , GFP_KERNEL );
2215
2206
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 );
2217
2208
if (lpi_map )
2218
2209
col_map = kcalloc (nr_lpis , sizeof (* col_map ),
2219
2210
GFP_KERNEL );
@@ -2448,9 +2439,9 @@ static void its_irq_domain_free(struct irq_domain *domain, unsigned int virq,
2448
2439
/* If all interrupts have been freed, start mopping the floor */
2449
2440
if (bitmap_empty (its_dev -> event_map .lpi_map ,
2450
2441
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 );
2454
2445
kfree (its_dev -> event_map .col_map );
2455
2446
2456
2447
/* Unmap device/itt */
@@ -2849,7 +2840,7 @@ static void its_vpe_irq_domain_free(struct irq_domain *domain,
2849
2840
}
2850
2841
2851
2842
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 );
2853
2844
its_free_prop_table (vm -> vprop_page );
2854
2845
}
2855
2846
}
@@ -2864,18 +2855,18 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
2864
2855
2865
2856
BUG_ON (!vm );
2866
2857
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 );
2868
2859
if (!bitmap )
2869
2860
return - ENOMEM ;
2870
2861
2871
2862
if (nr_ids < nr_irqs ) {
2872
- its_lpi_free_chunks (bitmap , base , nr_ids );
2863
+ its_lpi_free (bitmap , base , nr_ids );
2873
2864
return - ENOMEM ;
2874
2865
}
2875
2866
2876
2867
vprop_page = its_allocate_prop_table (GFP_KERNEL );
2877
2868
if (!vprop_page ) {
2878
- its_lpi_free_chunks (bitmap , base , nr_ids );
2869
+ its_lpi_free (bitmap , base , nr_ids );
2879
2870
return - ENOMEM ;
2880
2871
}
2881
2872
@@ -2902,7 +2893,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
2902
2893
if (i > 0 )
2903
2894
its_vpe_irq_domain_free (domain , virq , i - 1 );
2904
2895
2905
- its_lpi_free_chunks (bitmap , base , nr_ids );
2896
+ its_lpi_free (bitmap , base , nr_ids );
2906
2897
its_free_prop_table (vprop_page );
2907
2898
}
2908
2899
0 commit comments