From fced80c735941fa518ac67c0b61bbe153fb8c050 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 6 Sep 2008 12:10:45 +0100 Subject: [ARM] Convert asm/io.h to linux/io.h Signed-off-by: Russell King --- arch/arm/common/gic.c | 2 +- arch/arm/common/locomo.c | 2 +- arch/arm/common/sa1111.c | 2 +- arch/arm/common/scoop.c | 2 +- arch/arm/common/time-acorn.c | 2 +- arch/arm/common/uengine.c | 2 +- arch/arm/common/via82c505.c | 2 +- arch/arm/common/vic.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index 0c89bd35e06..7fc9860a97d 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c @@ -27,9 +27,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 283051eaf93..534b23d9586 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c @@ -24,9 +24,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index ec8a5471bf0..fb86f248aab 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -25,10 +25,10 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index ae39553589d..697c6491399 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm/common/time-acorn.c b/arch/arm/common/time-acorn.c index df0983aafe6..deeed561b16 100644 --- a/arch/arm/common/time-acorn.c +++ b/arch/arm/common/time-acorn.c @@ -17,9 +17,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm/common/uengine.c b/arch/arm/common/uengine.c index 7ecd3c0ab01..b520e56216a 100644 --- a/arch/arm/common/uengine.c +++ b/arch/arm/common/uengine.c @@ -16,9 +16,9 @@ #include #include #include +#include #include #include -#include #if defined(CONFIG_ARCH_IXP2000) #define IXP_UENGINE_CSR_VIRT_BASE IXP2000_UENGINE_CSR_VIRT_BASE diff --git a/arch/arm/common/via82c505.c b/arch/arm/common/via82c505.c index 79a8206e62a..8421d39109b 100644 --- a/arch/arm/common/via82c505.c +++ b/arch/arm/common/via82c505.c @@ -4,8 +4,8 @@ #include #include #include +#include -#include #include #include diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c index c026fa2214a..f1e4b8f60ca 100644 --- a/arch/arm/common/vic.c +++ b/arch/arm/common/vic.c @@ -20,8 +20,8 @@ */ #include #include +#include -#include #include #include -- cgit v1.2.3-18-g5258 From afd1a321c49a250dab97cef6f2d3c3c9b9d0174a Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 16:30:57 +0100 Subject: [ARM] Update dma_map_sg()/dma_unmap_sg() API Update the ARM DMA scatter gather APIs for the scatterlist changes. Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index aecc6c3f908..35c72bcf3d0 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -435,6 +435,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -442,14 +443,13 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - struct page *page = sg_page(sg); - unsigned int offset = sg->offset; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + struct page *page = sg_page(s); + unsigned int offset = s->offset; + unsigned int length = s->length; void *ptr = page_address(page) + offset; - sg->dma_address = - map_single(dev, ptr, length, dir); + s->dma_address = map_single(dev, ptr, length, dir); } return nents; @@ -459,6 +459,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -466,9 +467,9 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; unmap_single(dev, dma_addr, length, dir); } @@ -502,6 +503,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -509,9 +511,9 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; sync_single(dev, dma_addr, length, dir); } @@ -521,6 +523,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { + struct scatterlist *s; int i; dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", @@ -528,9 +531,9 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(dir == DMA_NONE); - for (i = 0; i < nents; i++, sg++) { - dma_addr_t dma_addr = sg->dma_address; - unsigned int length = sg->length; + for_each_sg(sg, s, nents, i) { + dma_addr_t dma_addr = s->dma_address; + unsigned int length = s->length; sync_single(dev, dma_addr, length, dir); } -- cgit v1.2.3-18-g5258 From 56f55f8b58a02e95b401cb50df05086cabeaeeb5 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 20:59:12 +0100 Subject: [ARM] dma: provide a better dma_map_page() implementation We can translate a struct page directly to a DMA address using page_to_dma(). No need to use page_address() followed by virt_to_dma(). Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 35c72bcf3d0..c7f23ced0a3 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -412,6 +412,19 @@ dma_map_single(struct device *dev, void *ptr, size_t size, return dma_addr; } +dma_addr_t dma_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction dir) +{ + dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n", + __func__, page, offset, size, dir); + + BUG_ON(dir == DMA_NONE); + + return map_single(dev, page_address(page) + offset, size, dir); +} +EXPORT_SYMBOL(dma_map_page); + /* * see if a mapped address was really a "safe" buffer and if so, copy * the data from the safe buffer back to the unsafe buffer and free up -- cgit v1.2.3-18-g5258 From 01135d92c1a540cd3370f7cf3d1c762320b85034 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 21:05:02 +0100 Subject: [ARM] dma: Reduce to one dma_map_sg()/dma_unmap_sg() implementation No point having two of these; dma_map_page() can do all the work for us. Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 46 --------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index c7f23ced0a3..20d967376fa 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -444,50 +444,6 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, unmap_single(dev, dma_addr, size, dir); } -int -dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, - enum dma_data_direction dir) -{ - struct scatterlist *s; - int i; - - dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", - __func__, sg, nents, dir); - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sg, s, nents, i) { - struct page *page = sg_page(s); - unsigned int offset = s->offset; - unsigned int length = s->length; - void *ptr = page_address(page) + offset; - - s->dma_address = map_single(dev, ptr, length, dir); - } - - return nents; -} - -void -dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, - enum dma_data_direction dir) -{ - struct scatterlist *s; - int i; - - dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", - __func__, sg, nents, dir); - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sg, s, nents, i) { - dma_addr_t dma_addr = s->dma_address; - unsigned int length = s->length; - - unmap_single(dev, dma_addr, length, dir); - } -} - void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, unsigned long offset, size_t size, enum dma_data_direction dir) @@ -662,8 +618,6 @@ dmabounce_unregister_dev(struct device *dev) EXPORT_SYMBOL(dma_map_single); EXPORT_SYMBOL(dma_unmap_single); -EXPORT_SYMBOL(dma_map_sg); -EXPORT_SYMBOL(dma_unmap_sg); EXPORT_SYMBOL(dma_sync_sg_for_cpu); EXPORT_SYMBOL(dma_sync_sg_for_device); EXPORT_SYMBOL(dmabounce_register_dev); -- cgit v1.2.3-18-g5258 From 2638b4dbe768aba023a06acd8e7eba708bb76ee6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 21:38:41 +0100 Subject: [ARM] dma: Reduce to one dma_sync_sg_* implementation Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 48 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 20d967376fa..0a98148279b 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -468,45 +468,23 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr, } EXPORT_SYMBOL(dma_sync_single_range_for_device); -void -dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, - enum dma_data_direction dir) +int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, + unsigned long off, size_t sz, enum dma_data_direction dir) { - struct scatterlist *s; - int i; - - dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", - __func__, sg, nents, dir); - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sg, s, nents, i) { - dma_addr_t dma_addr = s->dma_address; - unsigned int length = s->length; - - sync_single(dev, dma_addr, length, dir); - } + dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n", + __func__, addr, off, sz, dir); + return sync_single(dev, addr, off + sz, dir); } +EXPORT_SYMBOL(dmabounce_sync_for_cpu); -void -dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, - enum dma_data_direction dir) +int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, + unsigned long off, size_t sz, enum dma_data_direction dir) { - struct scatterlist *s; - int i; - - dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", - __func__, sg, nents, dir); - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sg, s, nents, i) { - dma_addr_t dma_addr = s->dma_address; - unsigned int length = s->length; - - sync_single(dev, dma_addr, length, dir); - } + dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n", + __func__, addr, off, sz, dir); + return sync_single(dev, addr, off + sz, dir); } +EXPORT_SYMBOL(dmabounce_sync_for_device); static int dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char *name, @@ -618,8 +596,6 @@ dmabounce_unregister_dev(struct device *dev) EXPORT_SYMBOL(dma_map_single); EXPORT_SYMBOL(dma_unmap_single); -EXPORT_SYMBOL(dma_sync_sg_for_cpu); -EXPORT_SYMBOL(dma_sync_sg_for_device); EXPORT_SYMBOL(dmabounce_register_dev); EXPORT_SYMBOL(dmabounce_unregister_dev); -- cgit v1.2.3-18-g5258 From 8c8a0ec57ee285ff407e9a64b3a5a37eaf800ad8 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 21:52:49 +0100 Subject: [ARM] dma: use new dmabounce_sync_for_xxx() for dma_sync_single_xxx() Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 0a98148279b..1cb880b734d 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -444,30 +444,6 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, unmap_single(dev, dma_addr, size, dir); } -void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, - unsigned long offset, size_t size, - enum dma_data_direction dir) -{ - dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n", - __func__, dma_addr, offset, size, dir); - - if (sync_single(dev, dma_addr, offset + size, dir)) - dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir); -} -EXPORT_SYMBOL(dma_sync_single_range_for_cpu); - -void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr, - unsigned long offset, size_t size, - enum dma_data_direction dir) -{ - dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n", - __func__, dma_addr, offset, size, dir); - - if (sync_single(dev, dma_addr, offset + size, dir)) - dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir); -} -EXPORT_SYMBOL(dma_sync_single_range_for_device); - int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, unsigned long off, size_t sz, enum dma_data_direction dir) { -- cgit v1.2.3-18-g5258 From 125ab12acf64ff86b55d20e14db20becd917b7c4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 22:16:22 +0100 Subject: [ARM] dma: fix dmabounce dma_sync_xxx() implementations The dmabounce dma_sync_xxx() implementation have been broken for quite some time; they all copy data between the DMA buffer and the CPU visible buffer no irrespective of the change of ownership. (IOW, a DMA_FROM_DEVICE mapping copies data from the DMA buffer to the CPU buffer during a call to dma_sync_single_for_device().) Fix it by getting rid of sync_single(), moving the contents into the recently created dmabounce_sync_for_xxx() functions and adjusting appropriately. This also makes it possible to properly support the DMA range sync functions. Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 144 ++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 86 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 1cb880b734d..d4b0c608fde 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -205,6 +205,21 @@ free_safe_buffer(struct dmabounce_device_info *device_info, struct safe_buffer * /* ************************************************** */ +static struct safe_buffer *find_safe_buffer_dev(struct device *dev, + dma_addr_t dma_addr, const char *where) +{ + if (!dev || !dev->archdata.dmabounce) + return NULL; + if (dma_mapping_error(dev, dma_addr)) { + if (dev) + dev_err(dev, "Trying to %s invalid mapping\n", where); + else + pr_err("unknown device: Trying to %s invalid mapping\n", where); + return NULL; + } + return find_safe_buffer(dev->archdata.dmabounce, dma_addr); +} + static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir) @@ -274,19 +289,7 @@ static inline void unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction dir) { - struct dmabounce_device_info *device_info = dev->archdata.dmabounce; - struct safe_buffer *buf = NULL; - - /* - * Trying to unmap an invalid mapping - */ - if (dma_mapping_error(dev, dma_addr)) { - dev_err(dev, "Trying to unmap invalid mapping\n"); - return; - } - - if (device_info) - buf = find_safe_buffer(device_info, dma_addr); + struct safe_buffer *buf = find_safe_buffer_dev(dev, dma_addr, "unmap"); if (buf) { BUG_ON(buf->size != size); @@ -296,7 +299,7 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, __func__, buf->ptr, virt_to_dma(dev, buf->ptr), buf->safe, buf->safe_dma_addr); - DO_STATS ( device_info->bounce_count++ ); + DO_STATS(dev->archdata.dmabounce->bounce_count++); if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) { void *ptr = buf->ptr; @@ -317,74 +320,7 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, dmac_clean_range(ptr, ptr + size); outer_clean_range(__pa(ptr), __pa(ptr) + size); } - free_safe_buffer(device_info, buf); - } -} - -static int sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, - enum dma_data_direction dir) -{ - struct dmabounce_device_info *device_info = dev->archdata.dmabounce; - struct safe_buffer *buf = NULL; - - if (device_info) - buf = find_safe_buffer(device_info, dma_addr); - - if (buf) { - /* - * Both of these checks from original code need to be - * commented out b/c some drivers rely on the following: - * - * 1) Drivers may map a large chunk of memory into DMA space - * but only sync a small portion of it. Good example is - * allocating a large buffer, mapping it, and then - * breaking it up into small descriptors. No point - * in syncing the whole buffer if you only have to - * touch one descriptor. - * - * 2) Buffers that are mapped as DMA_BIDIRECTIONAL are - * usually only synced in one dir at a time. - * - * See drivers/net/eepro100.c for examples of both cases. - * - * -ds - * - * BUG_ON(buf->size != size); - * BUG_ON(buf->direction != dir); - */ - - dev_dbg(dev, - "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", - __func__, buf->ptr, virt_to_dma(dev, buf->ptr), - buf->safe, buf->safe_dma_addr); - - DO_STATS ( device_info->bounce_count++ ); - - switch (dir) { - case DMA_FROM_DEVICE: - dev_dbg(dev, - "%s: copy back safe %p to unsafe %p size %d\n", - __func__, buf->safe, buf->ptr, size); - memcpy(buf->ptr, buf->safe, size); - break; - case DMA_TO_DEVICE: - dev_dbg(dev, - "%s: copy out unsafe %p to safe %p, size %d\n", - __func__,buf->ptr, buf->safe, size); - memcpy(buf->safe, buf->ptr, size); - break; - case DMA_BIDIRECTIONAL: - BUG(); /* is this allowed? what does it mean? */ - default: - BUG(); - } - /* - * No need to sync the safe buffer - it was allocated - * via the coherent allocators. - */ - return 0; - } else { - return 1; + free_safe_buffer(dev->archdata.dmabounce, buf); } } @@ -447,18 +383,54 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, unsigned long off, size_t sz, enum dma_data_direction dir) { - dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n", + struct safe_buffer *buf; + + dev_dbg(dev, "%s(dma=%#x,off=%#lx,sz=%zx,dir=%x)\n", __func__, addr, off, sz, dir); - return sync_single(dev, addr, off + sz, dir); + + buf = find_safe_buffer_dev(dev, addr, __func__); + if (!buf) + return 1; + + dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", + __func__, buf->ptr, virt_to_dma(dev, buf->ptr), + buf->safe, buf->safe_dma_addr); + + DO_STATS(dev->archdata.dmabounce->bounce_count++); + + if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) { + dev_dbg(dev, "%s: copy back safe %p to unsafe %p size %d\n", + __func__, buf->safe + off, buf->ptr + off, sz); + memcpy(buf->ptr + off, buf->safe + off, sz); + } + return 0; } EXPORT_SYMBOL(dmabounce_sync_for_cpu); int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, unsigned long off, size_t sz, enum dma_data_direction dir) { - dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n", + struct safe_buffer *buf; + + dev_dbg(dev, "%s(dma=%#x,off=%#lx,sz=%zx,dir=%x)\n", __func__, addr, off, sz, dir); - return sync_single(dev, addr, off + sz, dir); + + buf = find_safe_buffer_dev(dev, addr, __func__); + if (!buf) + return 1; + + dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", + __func__, buf->ptr, virt_to_dma(dev, buf->ptr), + buf->safe, buf->safe_dma_addr); + + DO_STATS(dev->archdata.dmabounce->bounce_count++); + + if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) { + dev_dbg(dev, "%s: copy out unsafe %p to safe %p, size %d\n", + __func__,buf->ptr + off, buf->safe + off, sz); + memcpy(buf->safe + off, buf->ptr + off, sz); + } + return 0; } EXPORT_SYMBOL(dmabounce_sync_for_device); -- cgit v1.2.3-18-g5258 From 3216a97bb0d5166ec5795aa3db1c3a02415ac060 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 25 Sep 2008 22:23:31 +0100 Subject: [ARM] dma: coding style cleanups Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 48 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index d4b0c608fde..22aec95c986 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -154,9 +154,7 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr, #endif write_lock_irqsave(&device_info->lock, flags); - list_add(&buf->node, &device_info->safe_buffers); - write_unlock_irqrestore(&device_info->lock, flags); return buf; @@ -220,8 +218,7 @@ static struct safe_buffer *find_safe_buffer_dev(struct device *dev, return find_safe_buffer(dev->archdata.dmabounce, dma_addr); } -static inline dma_addr_t -map_single(struct device *dev, void *ptr, size_t size, +static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir) { struct dmabounce_device_info *device_info = dev->archdata.dmabounce; @@ -285,9 +282,8 @@ map_single(struct device *dev, void *ptr, size_t size, return dma_addr; } -static inline void -unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, - enum dma_data_direction dir) +static inline void unmap_single(struct device *dev, dma_addr_t dma_addr, + size_t size, enum dma_data_direction dir) { struct safe_buffer *buf = find_safe_buffer_dev(dev, dma_addr, "unmap"); @@ -332,25 +328,20 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, * substitute the safe buffer for the unsafe one. * (basically move the buffer from an unsafe area to a safe one) */ -dma_addr_t -dma_map_single(struct device *dev, void *ptr, size_t size, +dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir) { - dma_addr_t dma_addr; - dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", __func__, ptr, size, dir); BUG_ON(dir == DMA_NONE); - dma_addr = map_single(dev, ptr, size, dir); - - return dma_addr; + return map_single(dev, ptr, size, dir); } +EXPORT_SYMBOL(dma_map_single); dma_addr_t dma_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction dir) + unsigned long offset, size_t size, enum dma_data_direction dir) { dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n", __func__, page, offset, size, dir); @@ -368,9 +359,8 @@ EXPORT_SYMBOL(dma_map_page); * should be) */ -void -dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, - enum dma_data_direction dir) +void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, + enum dma_data_direction dir) { dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", __func__, (void *) dma_addr, size, dir); @@ -379,6 +369,7 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, unmap_single(dev, dma_addr, size, dir); } +EXPORT_SYMBOL(dma_unmap_single); int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, unsigned long off, size_t sz, enum dma_data_direction dir) @@ -434,9 +425,8 @@ int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, } EXPORT_SYMBOL(dmabounce_sync_for_device); -static int -dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char *name, - unsigned long size) +static int dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, + const char *name, unsigned long size) { pool->size = size; DO_STATS(pool->allocs = 0); @@ -447,9 +437,8 @@ dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char return pool->pool ? 0 : -ENOMEM; } -int -dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, - unsigned long large_buffer_size) +int dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, + unsigned long large_buffer_size) { struct dmabounce_device_info *device_info; int ret; @@ -505,9 +494,9 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, kfree(device_info); return ret; } +EXPORT_SYMBOL(dmabounce_register_dev); -void -dmabounce_unregister_dev(struct device *dev) +void dmabounce_unregister_dev(struct device *dev) { struct dmabounce_device_info *device_info = dev->archdata.dmabounce; @@ -540,11 +529,6 @@ dmabounce_unregister_dev(struct device *dev) dev_info(dev, "dmabounce: device unregistered\n"); } - - -EXPORT_SYMBOL(dma_map_single); -EXPORT_SYMBOL(dma_unmap_single); -EXPORT_SYMBOL(dmabounce_register_dev); EXPORT_SYMBOL(dmabounce_unregister_dev); MODULE_AUTHOR("Christopher Hoover , Deepak Saxena "); -- cgit v1.2.3-18-g5258 From 0e18b5d7c6339311f1e32e7b186ae3556c5b6d33 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 29 Sep 2008 13:48:17 +0100 Subject: [ARM] dma: add validation of DMA params Validate the direction argument like x86 does. In addition, validate the dma_unmap_* parameters against those passed to dma_map_* when using the DMA bounce code. Signed-off-by: Russell King --- arch/arm/common/dmabounce.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 22aec95c986..f030f0775be 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -289,6 +289,7 @@ static inline void unmap_single(struct device *dev, dma_addr_t dma_addr, if (buf) { BUG_ON(buf->size != size); + BUG_ON(buf->direction != dir); dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", @@ -334,7 +335,7 @@ dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", __func__, ptr, size, dir); - BUG_ON(dir == DMA_NONE); + BUG_ON(!valid_dma_direction(dir)); return map_single(dev, ptr, size, dir); } @@ -346,7 +347,7 @@ dma_addr_t dma_map_page(struct device *dev, struct page *page, dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n", __func__, page, offset, size, dir); - BUG_ON(dir == DMA_NONE); + BUG_ON(!valid_dma_direction(dir)); return map_single(dev, page_address(page) + offset, size, dir); } @@ -365,8 +366,6 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", __func__, (void *) dma_addr, size, dir); - BUG_ON(dir == DMA_NONE); - unmap_single(dev, dma_addr, size, dir); } EXPORT_SYMBOL(dma_unmap_single); @@ -383,6 +382,8 @@ int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, if (!buf) return 1; + BUG_ON(buf->direction != dir); + dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", __func__, buf->ptr, virt_to_dma(dev, buf->ptr), buf->safe, buf->safe_dma_addr); @@ -410,6 +411,8 @@ int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr, if (!buf) return 1; + BUG_ON(buf->direction != dir); + dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", __func__, buf->ptr, virt_to_dma(dev, buf->ptr), buf->safe, buf->safe_dma_addr); -- cgit v1.2.3-18-g5258 From ec36b16d0d1ae0a43eb8c395e9bf58efdadad1d7 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 27 Dec 2007 14:19:44 +0100 Subject: [ARM] 4733/1: export sharpsl_param EXPORT sharpsl_param which is necessary to support modular build of some depending drivers. Signed-off-by: Dmitry Baryshkov Signed-off-by: Russell King --- arch/arm/common/sharpsl_param.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/arm/common') diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c index aad4d94ba8f..d56c932580e 100644 --- a/arch/arm/common/sharpsl_param.c +++ b/arch/arm/common/sharpsl_param.c @@ -12,6 +12,7 @@ */ #include +#include #include #include @@ -36,6 +37,7 @@ #define PHAD_MAGIC MAGIC_CHG('P','H','A','D') struct sharpsl_param_info sharpsl_param; +EXPORT_SYMBOL(sharpsl_param); void sharpsl_save_param(void) { -- cgit v1.2.3-18-g5258 From d8aa0251f12546e9bd1e9ee1d9782d6492819a04 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 9 Oct 2008 13:36:24 +0100 Subject: [ARM] 5298/1: Drop desc_handle_irq() desc_handle_irq() was declared as obsolete since long ago. Replace it with generic_handle_irq() Signed-off-by: Dmitry Baryshkov Signed-off-by: Russell King --- arch/arm/common/it8152.c | 14 +++----------- arch/arm/common/locomo.c | 26 ++++++++------------------ 2 files changed, 11 insertions(+), 29 deletions(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c index 5fe9588db07..2793447621c 100644 --- a/arch/arm/common/it8152.c +++ b/arch/arm/common/it8152.c @@ -66,14 +66,6 @@ static void it8152_unmask_irq(unsigned int irq) } } -static inline void it8152_irq(int irq) -{ - struct irq_desc *desc; - - desc = irq_desc + irq; - desc_handle_irq(irq, desc); -} - static struct irq_chip it8152_irq_chip = { .name = "it8152", .ack = it8152_mask_irq, @@ -128,21 +120,21 @@ void it8152_irq_demux(unsigned int irq, struct irq_desc *desc) bits_pd &= ((1 << IT8152_PD_IRQ_COUNT) - 1); while (bits_pd) { i = __ffs(bits_pd); - it8152_irq(IT8152_PD_IRQ(i)); + generic_handle_irq(IT8152_PD_IRQ(i)); bits_pd &= ~(1 << i); } bits_lp &= ((1 << IT8152_LP_IRQ_COUNT) - 1); while (bits_lp) { i = __ffs(bits_lp); - it8152_irq(IT8152_LP_IRQ(i)); + generic_handle_irq(IT8152_LP_IRQ(i)); bits_lp &= ~(1 << i); } bits_ld &= ((1 << IT8152_LD_IRQ_COUNT) - 1); while (bits_ld) { i = __ffs(bits_ld); - it8152_irq(IT8152_LD_IRQ(i)); + generic_handle_irq(IT8152_LD_IRQ(i)); bits_ld &= ~(1 << i); } } diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 283051eaf93..8f473b7c349 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c @@ -169,7 +169,6 @@ static struct locomo_dev_info locomo_devices[] = { static void locomo_handler(unsigned int irq, struct irq_desc *desc) { int req, i; - struct irq_desc *d; void __iomem *mapbase = get_irq_chip_data(irq); /* Acknowledge the parent IRQ */ @@ -181,10 +180,9 @@ static void locomo_handler(unsigned int irq, struct irq_desc *desc) if (req) { /* generate the next interrupt(s) */ irq = LOCOMO_IRQ_START; - d = irq_desc + irq; - for (i = 0; i <= 3; i++, d++, irq++) { + for (i = 0; i <= 3; i++, irq++) { if (req & (0x0100 << i)) { - desc_handle_irq(irq, d); + generic_handle_irq(irq); } } @@ -222,12 +220,10 @@ static struct irq_chip locomo_chip = { static void locomo_key_handler(unsigned int irq, struct irq_desc *desc) { - struct irq_desc *d; void __iomem *mapbase = get_irq_chip_data(irq); if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) { - d = irq_desc + LOCOMO_IRQ_KEY_START; - desc_handle_irq(LOCOMO_IRQ_KEY_START, d); + generic_handle_irq(LOCOMO_IRQ_KEY_START); } } @@ -268,7 +264,6 @@ static struct irq_chip locomo_key_chip = { static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc) { int req, i; - struct irq_desc *d; void __iomem *mapbase = get_irq_chip_data(irq); req = locomo_readl(mapbase + LOCOMO_GIR) & @@ -277,10 +272,9 @@ static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc) if (req) { irq = LOCOMO_IRQ_GPIO_START; - d = irq_desc + LOCOMO_IRQ_GPIO_START; - for (i = 0; i <= 15; i++, irq++, d++) { + for (i = 0; i <= 15; i++, irq++) { if (req & (0x0001 << i)) { - desc_handle_irq(irq, d); + generic_handle_irq(irq); } } } @@ -361,12 +355,10 @@ static struct irq_chip locomo_gpio_chip = { static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc) { - struct irq_desc *d; void __iomem *mapbase = get_irq_chip_data(irq); if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) { - d = irq_desc + LOCOMO_IRQ_LT_START; - desc_handle_irq(LOCOMO_IRQ_LT_START, d); + generic_handle_irq(LOCOMO_IRQ_LT_START); } } @@ -407,17 +399,15 @@ static struct irq_chip locomo_lt_chip = { static void locomo_spi_handler(unsigned int irq, struct irq_desc *desc) { int req, i; - struct irq_desc *d; void __iomem *mapbase = get_irq_chip_data(irq); req = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIR) & 0x000F; if (req) { irq = LOCOMO_IRQ_SPI_START; - d = irq_desc + irq; - for (i = 0; i <= 3; i++, irq++, d++) { + for (i = 0; i <= 3; i++, irq++) { if (req & (0x0001 << i)) { - desc_handle_irq(irq, d); + generic_handle_irq(irq); } } } -- cgit v1.2.3-18-g5258 From 3bca103a1e658d23737d20e1989139d9ca8973bf Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Tue, 7 Oct 2008 20:14:55 +0100 Subject: [ARM] 5295/1: make ZONE_DMA optional Most ARM machines don't need a special "DMA" memory zone, and when configured out, the kernel becomes a bit smaller: | text data bss dec hex filename |3826182 102384 111700 4040266 3da64a vmlinux |3823593 101616 111700 4036909 3d992d vmlinux.nodmazone This is because the system now has only one zone total which effect is to optimize away many conditionals in page allocation paths. So let's configure this zone only on machines that need split zones. Signed-off-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch/arm/common') diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig index 3e073467cac..2e32acca02f 100644 --- a/arch/arm/common/Kconfig +++ b/arch/arm/common/Kconfig @@ -12,7 +12,8 @@ config ICST307 config SA1111 bool - select DMABOUNCE + select DMABOUNCE if !ARCH_PXA + select ZONE_DMA if !ARCH_PXA config DMABOUNCE bool -- cgit v1.2.3-18-g5258