From 9895357a71205ea7d92d7608bd5ea40cef38e4c1 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 21 Jun 2012 10:25:29 +0200 Subject: block: use dma_alloc to allocate buffers Drivers may use dma to transfer blocks, so put them into dma save memory. Signed-off-by: Sascha Hauer --- common/block.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/block.c b/common/block.c index 71ecfd5ab7..f3bcdc8181 100644 --- a/common/block.c +++ b/common/block.c @@ -24,6 +24,7 @@ #include #include #include +#include #define BLOCKSIZE(blk) (1 << blk->blockbits) @@ -357,7 +358,7 @@ int blockdevice_register(struct block_device *blk) for (i = 0; i < 8; i++) { struct chunk *chunk = xzalloc(sizeof(*chunk)); - chunk->data = xmalloc(BUFSIZE); + chunk->data = dma_alloc(BUFSIZE); chunk->num = i; list_add_tail(&chunk->list, &blk->idle_blocks); } @@ -376,12 +377,12 @@ int blockdevice_unregister(struct block_device *blk) writebuffer_flush(blk); list_for_each_entry_safe(chunk, tmp, &blk->buffered_blocks, list) { - free(chunk->data); + dma_free(chunk->data); free(chunk); } list_for_each_entry_safe(chunk, tmp, &blk->idle_blocks, list) { - free(chunk->data); + dma_free(chunk->data); free(chunk); } -- cgit v1.2.3 From 527772ca0ea0447d8c5394e9d6bc1581bdf06835 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 21 Jun 2012 10:27:20 +0200 Subject: partition: Use dma_alloc for allocating buffers Drivers may use dma to transfer blocks, so put them into dma save memory. Signed-off-by: Sascha Hauer --- common/partitions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/partitions.c b/common/partitions.c index 74b4f1201a..3d92838948 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -31,6 +31,7 @@ #include #include #include +#include struct partition { uint64_t first_sec; @@ -102,7 +103,7 @@ static void __maybe_unused try_dos_partition(struct block_device *blk, struct partition pentry; int i, rc; - buffer = xmalloc(SECTOR_SIZE); + buffer = dma_alloc(SECTOR_SIZE); /* read in the MBR to get the partition table */ rc = blk->ops->read(blk, buffer, 0, 1); @@ -142,7 +143,7 @@ static void __maybe_unused try_dos_partition(struct block_device *blk, } on_error: - free(buffer); + dma_free(buffer); } /** -- cgit v1.2.3