diff options
-rw-r--r-- | drivers/irqchip/irq-gic-v3-its.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 63cd0f2b8707..fed99c55e2f4 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
@@ -691,9 +691,11 @@ static struct irq_chip its_irq_chip = { | |||
691 | */ | 691 | */ |
692 | #define IRQS_PER_CHUNK_SHIFT 5 | 692 | #define IRQS_PER_CHUNK_SHIFT 5 |
693 | #define IRQS_PER_CHUNK (1 << IRQS_PER_CHUNK_SHIFT) | 693 | #define IRQS_PER_CHUNK (1 << IRQS_PER_CHUNK_SHIFT) |
694 | #define ITS_MAX_LPI_NRBITS 16 /* 64K LPIs */ | ||
694 | 695 | ||
695 | static unsigned long *lpi_bitmap; | 696 | static unsigned long *lpi_bitmap; |
696 | static u32 lpi_chunks; | 697 | static u32 lpi_chunks; |
698 | static u32 lpi_id_bits; | ||
697 | static DEFINE_SPINLOCK(lpi_lock); | 699 | static DEFINE_SPINLOCK(lpi_lock); |
698 | 700 | ||
699 | static int its_lpi_to_chunk(int lpi) | 701 | static int its_lpi_to_chunk(int lpi) |
@@ -789,17 +791,13 @@ static void its_lpi_free(struct event_lpi_map *map) | |||
789 | } | 791 | } |
790 | 792 | ||
791 | /* | 793 | /* |
792 | * We allocate 64kB for PROPBASE. That gives us at most 64K LPIs to | 794 | * We allocate memory for PROPBASE to cover 2 ^ lpi_id_bits LPIs to |
793 | * deal with (one configuration byte per interrupt). PENDBASE has to | 795 | * deal with (one configuration byte per interrupt). PENDBASE has to |
794 | * be 64kB aligned (one bit per LPI, plus 8192 bits for SPI/PPI/SGI). | 796 | * be 64kB aligned (one bit per LPI, plus 8192 bits for SPI/PPI/SGI). |
795 | */ | 797 | */ |
796 | #define LPI_PROPBASE_SZ SZ_64K | 798 | #define LPI_NRBITS lpi_id_bits |
797 | #define LPI_PENDBASE_SZ (LPI_PROPBASE_SZ / 8 + SZ_1K) | 799 | #define LPI_PROPBASE_SZ ALIGN(BIT(LPI_NRBITS), SZ_64K) |
798 | 800 | #define LPI_PENDBASE_SZ ALIGN(BIT(LPI_NRBITS) / 8, SZ_64K) | |
799 | /* | ||
800 | * This is how many bits of ID we need, including the useless ones. | ||
801 | */ | ||
802 | #define LPI_NRBITS ilog2(LPI_PROPBASE_SZ + SZ_8K) | ||
803 | 801 | ||
804 | #define LPI_PROP_DEFAULT_PRIO 0xa0 | 802 | #define LPI_PROP_DEFAULT_PRIO 0xa0 |
805 | 803 | ||
@@ -807,6 +805,7 @@ static int __init its_alloc_lpi_tables(void) | |||
807 | { | 805 | { |
808 | phys_addr_t paddr; | 806 | phys_addr_t paddr; |
809 | 807 | ||
808 | lpi_id_bits = min_t(u32, gic_rdists->id_bits, ITS_MAX_LPI_NRBITS); | ||
810 | gic_rdists->prop_page = alloc_pages(GFP_NOWAIT, | 809 | gic_rdists->prop_page = alloc_pages(GFP_NOWAIT, |
811 | get_order(LPI_PROPBASE_SZ)); | 810 | get_order(LPI_PROPBASE_SZ)); |
812 | if (!gic_rdists->prop_page) { | 811 | if (!gic_rdists->prop_page) { |
@@ -825,7 +824,7 @@ static int __init its_alloc_lpi_tables(void) | |||
825 | /* Make sure the GIC will observe the written configuration */ | 824 | /* Make sure the GIC will observe the written configuration */ |
826 | gic_flush_dcache_to_poc(page_address(gic_rdists->prop_page), LPI_PROPBASE_SZ); | 825 | gic_flush_dcache_to_poc(page_address(gic_rdists->prop_page), LPI_PROPBASE_SZ); |
827 | 826 | ||
828 | return 0; | 827 | return its_lpi_init(lpi_id_bits); |
829 | } | 828 | } |
830 | 829 | ||
831 | static const char *its_base_type_string[] = { | 830 | static const char *its_base_type_string[] = { |
@@ -1100,7 +1099,7 @@ static void its_cpu_init_lpis(void) | |||
1100 | * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below. | 1099 | * hence the 'max(LPI_PENDBASE_SZ, SZ_64K)' below. |
1101 | */ | 1100 | */ |
1102 | pend_page = alloc_pages(GFP_NOWAIT | __GFP_ZERO, | 1101 | pend_page = alloc_pages(GFP_NOWAIT | __GFP_ZERO, |
1103 | get_order(max(LPI_PENDBASE_SZ, SZ_64K))); | 1102 | get_order(max_t(u32, LPI_PENDBASE_SZ, SZ_64K))); |
1104 | if (!pend_page) { | 1103 | if (!pend_page) { |
1105 | pr_err("Failed to allocate PENDBASE for CPU%d\n", | 1104 | pr_err("Failed to allocate PENDBASE for CPU%d\n", |
1106 | smp_processor_id()); | 1105 | smp_processor_id()); |
@@ -1975,8 +1974,5 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, | |||
1975 | } | 1974 | } |
1976 | 1975 | ||
1977 | gic_rdists = rdists; | 1976 | gic_rdists = rdists; |
1978 | its_alloc_lpi_tables(); | 1977 | return its_alloc_lpi_tables(); |
1979 | its_lpi_init(rdists->id_bits); | ||
1980 | |||
1981 | return 0; | ||
1982 | } | 1978 | } |