Skip to content

Commit 18aa60c

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
irqchip/gic-v3-its: Recompute the number of pages on page size change
When the programming of a GITS_BASERn register fails because of an unsupported ITS page size, we retry it with a smaller page size. Unfortunately, we don't recompute the number of allocated ITS pages, indicating the wrong value computed in the original allocation. A convenient fix is to free the pages we allocated, update the page size, and restart the allocation. This will ensure that we always allocate the right amount in the case of a device table, specially if we have to reduce the allocation order to stay within the boundaries of the ITS maximum allocation. Reported-and-tested-by: Ma Jun <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] Cc: Jason Cooper <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent bb1a793 commit 18aa60c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
875875
}
876876

877877
alloc_size = (1 << order) * PAGE_SIZE;
878+
retry_alloc_baser:
878879
alloc_pages = (alloc_size / psz);
879880
if (alloc_pages > GITS_BASER_PAGES_MAX) {
880881
alloc_pages = GITS_BASER_PAGES_MAX;
@@ -938,13 +939,16 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
938939
* size and retry. If we reach 4K, then
939940
* something is horribly wrong...
940941
*/
942+
free_pages((unsigned long)base, order);
943+
its->tables[i] = NULL;
944+
941945
switch (psz) {
942946
case SZ_16K:
943947
psz = SZ_4K;
944-
goto retry_baser;
948+
goto retry_alloc_baser;
945949
case SZ_64K:
946950
psz = SZ_16K;
947-
goto retry_baser;
951+
goto retry_alloc_baser;
948952
}
949953
}
950954

0 commit comments

Comments
 (0)