Commit 19b6a7e4 authored by Russell King's avatar Russell King

[ARM] Move DMA mask-based bounce detection to dmabounce code.

parent 46e13d2a
......@@ -216,27 +216,33 @@ static inline dma_addr_t
map_single(struct device *dev, void *ptr, size_t size,
enum dma_data_direction dir)
{
dma_addr_t dma_addr;
struct dmabounce_device_info *device_info = find_dmabounce_dev(dev);
dma_addr_t dma_addr;
int needs_bounce = 0;
if (device_info)
DO_STATS ( device_info->map_op_count++ );
dma_addr = virt_to_dma(dev, ptr);
if (dev->dma_mask) {
unsigned long mask = *dev->dma_mask;
unsigned long limit;
limit = (*dev->dma_mask + 1) & ~(*dev->dma_mask);
if (limit && (size > limit)) {
dev_err(dev, "DMA mapping too big "
"(requested %#x mask %#Lx)\n",
size, *dev->dma_mask);
limit = (mask + 1) & ~mask;
if (limit && size > limit) {
dev_err(dev, "DMA mapping too big (requested %#x "
"mask %#Lx)\n", size, *dev->dma_mask);
return ~0;
}
}
dma_addr = virt_to_dma(dev, ptr);
/*
* Figure out if we need to bounce from the DMA mask.
*/
needs_bounce = (dma_addr | (dma_addr + size - 1)) & ~mask;
}
if (device_info && dma_needs_bounce(dev, dma_addr, size)) {
if (device_info && (needs_bounce || dma_needs_bounce(dev, dma_addr, size))) {
struct safe_buffer *buf;
buf = alloc_safe_buffer(device_info, ptr, size, dir);
......
......@@ -761,9 +761,6 @@ static void __sa1111_remove(struct sa1111 *sachip)
*/
int dma_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
{
unsigned int physaddr = SA1111_DMA_ADDR((unsigned int)addr);
u32 dma_mask = *dev->dma_mask;
/*
* Section 4.6 of the "Intel StrongARM SA-1111 Development Module
* User's Guide" mentions that jumpers R51 and R52 control the
......@@ -771,14 +768,8 @@ int dma_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
* SDRAM bank 1 on Neponset). The default configuration selects
* Assabet, so any address in bank 1 is necessarily invalid.
*/
if ((machine_is_assabet() || machine_is_pfs168()) &&
(addr >= 0xc8000000 || (addr + size) >= 0xc8000000))
return 1;
/*
* Check to see if either the start or end are illegal.
*/
return ((addr & ~dma_mask)) || ((addr + size - 1) & ~dma_mask);
return ((machine_is_assabet() || machine_is_pfs168()) &&
(addr >= 0xc8000000 || (addr + size) >= 0xc8000000));
}
struct sa1111_save_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment