Skip to content

Commit

Permalink
HSD#15016865391: irqchip: gic-v3-its: add 32bit addressing dma quirk
Browse files Browse the repository at this point in the history
Added quirk to configure gfp flags to allocate buffers within 32bit
addressable range.

Signed-off-by: Adrian Ng Ho Yin <[email protected]>
  • Loading branch information
hoyin0722 committed Oct 14, 2024
1 parent 12a12c6 commit cf7b837
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions drivers/irqchip/irq-gic-v3-its.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define RD_LOCAL_MEMRESERVE_DONE BIT(2)

static u32 lpi_id_bits;
static bool dma_32bit_flag;

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

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

page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, order);
if (dma_32bit_flag)
flags |= GFP_DMA32;

page = alloc_pages_node(its->numa_node, flags, order);
if (!page)
return -ENOMEM;

Expand Down Expand Up @@ -3293,6 +3298,7 @@ static bool its_alloc_table_entry(struct its_node *its,
struct page *page;
u32 esz, idx;
__le64 *table;
gfp_t flags = GFP_KERNEL | __GFP_ZERO;

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

table = baser->base;

if (dma_32bit_flag)
flags |= GFP_DMA32;

/* Allocate memory for 2nd level table */
if (!table[idx]) {
page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,
page = alloc_pages_node(its->numa_node, flags,
get_order(baser->psz));
if (!page)
return false;
Expand Down Expand Up @@ -5069,8 +5078,11 @@ static int __init its_probe_one(struct its_node *its)
struct page *page;
u32 ctlr;
int err;
gfp_t flags = GFP_KERNEL | __GFP_ZERO;

its_enable_quirks(its);
if (dma_32bit_flag)
flags |= GFP_DMA32;

if (is_v4(its)) {
if (!(its->typer & GITS_TYPER_VMOVP)) {
Expand Down Expand Up @@ -5102,7 +5114,7 @@ static int __init its_probe_one(struct its_node *its)
}
}

page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,
page = alloc_pages_node(its->numa_node, flags,
get_order(ITS_CMD_QUEUE_SZ));
if (!page) {
err = -ENOMEM;
Expand Down Expand Up @@ -5418,6 +5430,8 @@ static int __init its_of_probe(struct device_node *node)
continue;
}

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

its = its_node_init(&res, &np->fwnode, of_node_to_nid(np));
if (!its)
Expand Down Expand Up @@ -5648,6 +5662,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,
bool has_v4 = false;
bool has_v4_1 = false;
int err;
dma_32bit_flag = false;

gic_rdists = rdists;

Expand Down

0 comments on commit cf7b837

Please sign in to comment.