irqchip/gic-v3-its: Rework LPI freeing

Rework LPI deallocation so that it can be reused by the v4 support
code.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+7 -6
+7 -6
drivers/irqchip/irq-gic-v3-its.c
··· 881 881 return bitmap; 882 882 } 883 883 884 - static void its_lpi_free(struct event_lpi_map *map) 884 + static void its_lpi_free_chunks(unsigned long *bitmap, int base, int nr_ids) 885 885 { 886 - int base = map->lpi_base; 887 - int nr_ids = map->nr_lpis; 888 886 int lpi; 889 887 890 888 spin_lock(&lpi_lock); 891 889 892 890 for (lpi = base; lpi < (base + nr_ids); lpi += IRQS_PER_CHUNK) { 893 891 int chunk = its_lpi_to_chunk(lpi); 892 + 894 893 BUG_ON(chunk > lpi_chunks); 895 894 if (test_bit(chunk, lpi_bitmap)) { 896 895 clear_bit(chunk, lpi_bitmap); ··· 900 901 901 902 spin_unlock(&lpi_lock); 902 903 903 - kfree(map->lpi_map); 904 - kfree(map->col_map); 904 + kfree(bitmap); 905 905 } 906 906 907 907 static struct page *its_allocate_prop_table(gfp_t gfp_flags) ··· 1672 1674 /* If all interrupts have been freed, start mopping the floor */ 1673 1675 if (bitmap_empty(its_dev->event_map.lpi_map, 1674 1676 its_dev->event_map.nr_lpis)) { 1675 - its_lpi_free(&its_dev->event_map); 1677 + its_lpi_free_chunks(its_dev->event_map.lpi_map, 1678 + its_dev->event_map.lpi_base, 1679 + its_dev->event_map.nr_lpis); 1680 + kfree(its_dev->event_map.col_map); 1676 1681 1677 1682 /* Unmap device/itt */ 1678 1683 its_send_mapd(its_dev, 0);