iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory()
@ 2020-05-16 10:09 Yunfeng Ye
  2020-07-16 14:47 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Yunfeng Ye @ 2020-05-16 10:09 UTC (permalink / raw)
  To: Christoph Hellwig, m.szyprowski, robin.murphy, iommu, linux-kernel
  Cc: Shiyuan Hu, Hewenliang

Switch to bitmap_zalloc() to show clearly in dma_init_coherent_memory().

No functional change.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 kernel/dma/coherent.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index 2a0c4985f38e..794b31e61ca0 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -44,7 +44,6 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr,
 	struct dma_coherent_mem *dma_mem = NULL;
 	void *mem_base = NULL;
 	int pages = size >> PAGE_SHIFT;
-	int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
 	int ret;

 	if (!size) {
@@ -62,7 +61,7 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr,
 		ret = -ENOMEM;
 		goto out;
 	}
-	dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+	dma_mem->bitmap = bitmap_zalloc(pages, GFP_KERNEL);
 	if (!dma_mem->bitmap) {
 		ret = -ENOMEM;
 		goto out;
@@ -90,7 +89,7 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
 		return;

 	memunmap(mem->virt_base);
-	kfree(mem->bitmap);
+	bitmap_free(mem->bitmap);
 	kfree(mem);
 }

-- 
1.8.3.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory()
  2020-05-16 10:09 [PATCH] dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory() Yunfeng Ye
@ 2020-07-16 14:47 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2020-07-16 14:47 UTC (permalink / raw)
  To: Yunfeng Ye
  Cc: Hewenliang, Shiyuan Hu, linux-kernel, iommu, robin.murphy,
	Christoph Hellwig

Applied to nvme-5.9.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-16 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 10:09 [PATCH] dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory() Yunfeng Ye
2020-07-16 14:47 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).