From: g.liakhovetski@gmx.de (Guennadi Liakhovetski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/5] DMA: reduce the number of memory allocations
Date: Thu, 19 Aug 2010 16:40:15 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.64.1008191634160.26145@axis700.grange> (raw)
In-Reply-To: <Pine.LNX.4.64.1008191623580.26145@axis700.grange>
Allocate the bitmap in dma_declare_coherent_memory() together with the struct
dma_coherent_mem object.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/base/dma-coherent.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index f369e27..8efdfd4 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -11,7 +11,7 @@ struct dma_coherent_mem {
dma_addr_t device_base;
int size;
int flags;
- unsigned long *bitmap;
+ unsigned long bitmap[0];
};
int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
@@ -34,12 +34,10 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
if (!mem_base)
goto out;
- dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
+ dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem) + bitmap_size,
+ GFP_KERNEL);
if (!dev->dma_mem)
goto out;
- dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
- if (!dev->dma_mem->bitmap)
- goto free1_out;
dev->dma_mem->virt_base = mem_base;
dev->dma_mem->device_base = device_addr;
@@ -51,8 +49,6 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
return DMA_MEMORY_IO;
- free1_out:
- kfree(dev->dma_mem);
out:
if (mem_base)
iounmap(mem_base);
@@ -68,7 +64,6 @@ void dma_release_declared_memory(struct device *dev)
return;
dev->dma_mem = NULL;
iounmap(mem->virt_base);
- kfree(mem->bitmap);
kfree(mem);
}
EXPORT_SYMBOL(dma_release_declared_memory);
--
1.7.2
next prev parent reply other threads:[~2010-08-19 14:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-19 14:39 [PATCH 0/5] Add API for DMA memory reservation for devices Guennadi Liakhovetski
2010-08-19 14:40 ` [PATCH 1/5] DMA: Remove unneeded "extern" from function declarations Guennadi Liakhovetski
2010-08-19 14:40 ` [PATCH 2/5] DMA: dma_declare_coherent_memory() should return an error if unsupported Guennadi Liakhovetski
2010-08-19 14:40 ` Guennadi Liakhovetski [this message]
2010-08-19 15:35 ` [PATCH 3/5] DMA: reduce the number of memory allocations Greg KH
2010-08-19 15:46 ` Guennadi Liakhovetski
2010-08-19 16:02 ` Greg KH
2010-09-14 8:52 ` Paul Mundt
2010-09-15 7:23 ` Guennadi Liakhovetski
2010-09-16 2:58 ` FUJITA Tomonori
2010-09-16 7:04 ` Russell King - ARM Linux
2010-09-16 7:08 ` FUJITA Tomonori
2010-09-16 4:22 ` Paul Mundt
2010-08-20 1:15 ` Michał Nazarewicz
2010-08-19 14:40 ` [PATCH 4/5] DMA: Add functions to preallocate DMA memory dor devices Guennadi Liakhovetski
2010-09-02 10:50 ` Russell King - ARM Linux
2010-09-15 7:28 ` Uwe Kleine-König
2010-08-19 14:40 ` [PATCH 5/5] SH: use dma_preallocate_coherent_memory() for platform device memory Guennadi Liakhovetski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.1008191634160.26145@axis700.grange \
--to=g.liakhovetski@gmx.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox