[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a37f80a55eeb4b2eb125e3340320032e@hihonor.com>
Date: Mon, 15 May 2023 06:59:31 +0000
From: gaoxu <gaoxu2@...onor.com>
To: "hch@....de" <hch@....de>,
"m.szyprowski@...sung.com" <m.szyprowski@...sung.com>
CC: "robin.murphy@....com" <robin.murphy@....com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"surenb@...gle.com" <surenb@...gle.com>,
yipengxiang <yipengxiang@...onor.com>,
wangbintian 00013160 <bintian.wang@...onor.com>
Subject: RE: [PATCH] dma-remap: Use kvmalloc_array/kvfree for larger dma
memory remap
Please help to review, thanks.
-----Original Message-----
From: gaoxu 00016977
Sent: 2023年5月6日 15:34
To: 'hch@....de' <hch@....de>; 'm.szyprowski@...sung.com' <m.szyprowski@...sung.com>
Cc: 'robin.murphy@....com' <robin.murphy@....com>; 'iommu@...ts.linux.dev' <iommu@...ts.linux.dev>; 'linux-kernel@...r.kernel.org' <linux-kernel@...r.kernel.org>; 'surenb@...gle.com' <surenb@...gle.com>; yipengxiang 00013268 <yipengxiang@...onor.com>; wangbintian 00013160 <bintian.wang@...onor.com>; hanfeng 00012985 <feng.han@...onor.com>
Subject: [PATCH] dma-remap: Use kvmalloc_array/kvfree for larger dma memory remap
If dma_direct_alloc() alloc memory in size of 64MB, the inner function
dma_common_contiguous_remap() will allocate 128KB memory by invoking the function kmalloc_array(). and the kmalloc_array seems to fail to try to allocate 128KB mem. work around by doing kvmalloc_array instead.
Signed-off-by: Gao Xu <gaoxu2@...onor.com>
---
kernel/dma/remap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c index b45266680..27596f3b4 100644
--- a/kernel/dma/remap.c
+++ b/kernel/dma/remap.c
@@ -43,13 +43,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
void *vaddr;
int i;
- pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
+ pages = kvmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
if (!pages)
return NULL;
for (i = 0; i < count; i++)
pages[i] = nth_page(page, i);
vaddr = vmap(pages, count, VM_DMA_COHERENT, prot);
- kfree(pages);
+ kvfree(pages);
return vaddr;
}
--
2.17.1
Powered by blists - more mailing lists