From a9d1129997cf016b24a33a822659abd13b686323 Mon Sep 17 00:00:00 2001 From: XiaoDong Huang Date: Wed, 2 Dec 2020 17:30:47 +0800 Subject: [PATCH] irqchip/gic-v3-its: add GFP_DMA32 flag for memory allocated for ITS in rk356x Change-Id: Ic1d866733b348b86bbfdf2df4c0416a68eb422b7 Signed-off-by: XiaoDong Huang --- drivers/irqchip/irq-gic-v3-its.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 34391b00c546..1fdf88885730 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2167,6 +2167,8 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags) { struct page *prop_page; + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; prop_page = alloc_pages(gfp_flags, get_order(LPI_PROPBASE_SZ)); if (!prop_page) return NULL; @@ -2290,6 +2292,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 gfp_flags; psz = baser->psz; alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz); @@ -2301,7 +2304,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); + gfp_flags = GFP_KERNEL | __GFP_ZERO; + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; + page = alloc_pages_node(its->numa_node, gfp_flags, order); if (!page) return -ENOMEM; @@ -2930,6 +2936,8 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags) { struct page *pend_page; + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; pend_page = alloc_pages(gfp_flags | __GFP_ZERO, get_order(LPI_PENDBASE_SZ)); if (!pend_page) @@ -3263,7 +3271,11 @@ static bool its_alloc_table_entry(struct its_node *its, /* Allocate memory for 2nd level table */ if (!table[idx]) { - page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, + gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO; + + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; + page = alloc_pages_node(its->numa_node, gfp_flags, get_order(baser->psz)); if (!page) return false; @@ -3352,6 +3364,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, int nr_lpis; int nr_ites; int sz; + gfp_t gfp_flags; if (!its_alloc_device_table(its, dev_id)) return NULL; @@ -3367,7 +3380,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, nr_ites = max(2, nvecs); sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1); sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; - itt = kzalloc_node(sz, GFP_KERNEL, its->numa_node); + gfp_flags = GFP_KERNEL; + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; + itt = kzalloc_node(sz, gfp_flags, its->numa_node); if (alloc_lpis) { lpi_map = its_lpi_alloc(nvecs, &lpi_base, &nr_lpis); if (lpi_map) @@ -4949,6 +4965,7 @@ static int __init its_probe_one(struct resource *res, u64 baser, tmp, typer; struct page *page; int err; + gfp_t gfp_flags; its_base = ioremap(res->start, SZ_64K); if (!its_base) { @@ -5017,7 +5034,10 @@ static int __init its_probe_one(struct resource *res, its->numa_node = numa_node; - page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, + gfp_flags = GFP_KERNEL | __GFP_ZERO; + if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566")) + gfp_flags |= GFP_DMA32; + page = alloc_pages_node(its->numa_node, gfp_flags, get_order(ITS_CMD_QUEUE_SZ)); if (!page) { err = -ENOMEM;