Skip to content

Commit cf7b837

Browse files
committed
HSD#15016865391: irqchip: gic-v3-its: add 32bit addressing dma quirk
Added quirk to configure gfp flags to allocate buffers within 32bit addressable range. Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@intel.com>
1 parent 12a12c6 commit cf7b837

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define RD_LOCAL_MEMRESERVE_DONE BIT(2)
5050

5151
static u32 lpi_id_bits;
52+
static bool dma_32bit_flag;
5253

5354
/*
5455
* We allocate memory for PROPBASE to cover 2 ^ lpi_id_bits LPIs to
@@ -2309,6 +2310,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
23092310
u32 alloc_pages, psz;
23102311
struct page *page;
23112312
void *base;
2313+
gfp_t flags = GFP_KERNEL | __GFP_ZERO;
23122314

23132315
psz = baser->psz;
23142316
alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
@@ -2320,7 +2322,10 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
23202322
order = get_order(GITS_BASER_PAGES_MAX * psz);
23212323
}
23222324

2323-
page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, order);
2325+
if (dma_32bit_flag)
2326+
flags |= GFP_DMA32;
2327+
2328+
page = alloc_pages_node(its->numa_node, flags, order);
23242329
if (!page)
23252330
return -ENOMEM;
23262331

@@ -3293,6 +3298,7 @@ static bool its_alloc_table_entry(struct its_node *its,
32933298
struct page *page;
32943299
u32 esz, idx;
32953300
__le64 *table;
3301+
gfp_t flags = GFP_KERNEL | __GFP_ZERO;
32963302

32973303
/* Don't allow device id that exceeds single, flat table limit */
32983304
esz = GITS_BASER_ENTRY_SIZE(baser->val);
@@ -3306,9 +3312,12 @@ static bool its_alloc_table_entry(struct its_node *its,
33063312

33073313
table = baser->base;
33083314

3315+
if (dma_32bit_flag)
3316+
flags |= GFP_DMA32;
3317+
33093318
/* Allocate memory for 2nd level table */
33103319
if (!table[idx]) {
3311-
page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,
3320+
page = alloc_pages_node(its->numa_node, flags,
33123321
get_order(baser->psz));
33133322
if (!page)
33143323
return false;
@@ -5069,8 +5078,11 @@ static int __init its_probe_one(struct its_node *its)
50695078
struct page *page;
50705079
u32 ctlr;
50715080
int err;
5081+
gfp_t flags = GFP_KERNEL | __GFP_ZERO;
50725082

50735083
its_enable_quirks(its);
5084+
if (dma_32bit_flag)
5085+
flags |= GFP_DMA32;
50745086

50755087
if (is_v4(its)) {
50765088
if (!(its->typer & GITS_TYPER_VMOVP)) {
@@ -5102,7 +5114,7 @@ static int __init its_probe_one(struct its_node *its)
51025114
}
51035115
}
51045116

5105-
page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,
5117+
page = alloc_pages_node(its->numa_node, flags,
51065118
get_order(ITS_CMD_QUEUE_SZ));
51075119
if (!page) {
51085120
err = -ENOMEM;
@@ -5418,6 +5430,8 @@ static int __init its_of_probe(struct device_node *node)
54185430
continue;
54195431
}
54205432

5433+
if (of_property_read_bool(np, "dma-32bit-quirk"))
5434+
dma_32bit_flag = true;
54215435

54225436
its = its_node_init(&res, &np->fwnode, of_node_to_nid(np));
54235437
if (!its)
@@ -5648,6 +5662,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
56485662
bool has_v4 = false;
56495663
bool has_v4_1 = false;
56505664
int err;
5665+
dma_32bit_flag = false;
56515666

56525667
gic_rdists = rdists;
56535668

0 commit comments

Comments
 (0)