]> git.hungrycats.org Git - linux/commitdiff
[ARM] Move DMA mask-based bounce detection to dmabounce code.
authorRussell King <rmk@flint.arm.linux.org.uk>
Wed, 25 Aug 2004 15:29:22 +0000 (16:29 +0100)
committerRussell King <rmk@flint.arm.linux.org.uk>
Wed, 25 Aug 2004 15:29:22 +0000 (16:29 +0100)
arch/arm/common/dmabounce.c
arch/arm/common/sa1111.c

index c3a87663b040b7f6ff6ff3c083fcda51e9fabff4..7c5d61924a09927112b98baa08ff644a7409658c 100644 (file)
@@ -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);
index 18ba42e694e4359ada561623ca7b1e68d4994ab7..16f30a3551ad7b3682b93aafbeb50abb5235cd1f 100644 (file)
@@ -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 {