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(-) --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2197,6 +2197,8 @@ static struct page *its_allocate_prop_ta { 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; @@ -2320,6 +2322,7 @@ static int its_setup_baser(struct its_no u32 alloc_pages, psz; struct page *page; void *base; + gfp_t gfp_flags; psz = baser->psz; alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz); @@ -2331,7 +2334,10 @@ static int its_setup_baser(struct its_no 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; @@ -2960,6 +2966,8 @@ static struct page *its_allocate_pending { 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) @@ -3303,7 +3311,11 @@ static bool its_alloc_table_entry(struct /* 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; @@ -3392,6 +3404,7 @@ static struct its_device *its_create_dev int nr_lpis; int nr_ites; int sz; + gfp_t gfp_flags; if (!its_alloc_device_table(its, dev_id)) return NULL; @@ -3407,7 +3420,10 @@ static struct its_device *its_create_dev 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) @@ -4990,6 +5006,7 @@ static int __init its_probe_one(struct r u64 baser, tmp, typer; struct page *page; int err; + gfp_t gfp_flags; its_base = ioremap(res->start, SZ_64K); if (!its_base) { @@ -5058,7 +5075,10 @@ static int __init its_probe_one(struct r 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;