]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Merge commit 'dmaengine-3.13-v2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorVinod Koul <vinod.koul@intel.com>
Sat, 16 Nov 2013 06:24:17 +0000 (11:54 +0530)
committerVinod Koul <vinod.koul@intel.com>
Sat, 16 Nov 2013 06:32:36 +0000 (12:02 +0530)
Pull dmaengine changes from Dan

1/ Bartlomiej and Dan finalized a rework of the dma address unmap
   implementation.

2/ In the course of testing 1/ a collection of enhancements to dmatest
   fell out.  Notably basic performance statistics, and fixed / enhanced
   test control through new module parameters 'run', 'wait', 'noverify',
   and 'verbose'.  Thanks to Andriy and Linus for their review.

3/ Testing the raid related corner cases of 1/ triggered bugs in the
   recently added 16-source operation support in the ioatdma driver.

4/ Some minor fixes / cleanups to mv_xor and ioatdma.

Conflicts:
drivers/dma/dmatest.c

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
14 files changed:
1  2 
drivers/dma/amba-pl08x.c
drivers/dma/at_hdmac.c
drivers/dma/dmaengine.c
drivers/dma/dmatest.c
drivers/dma/dw/core.c
drivers/dma/fsldma.c
drivers/dma/ioat/dma.c
drivers/dma/ioat/dma_v3.c
drivers/dma/iop-adma.c
drivers/dma/mv_xor.c
drivers/dma/pl330.c
drivers/dma/ppc4xx/adma.c
drivers/dma/txx9dmac.c
include/linux/dmaengine.h

diff --combined drivers/dma/amba-pl08x.c
index 4ee6533108f6265f792cd501b431ce140c040f7e,6a5f782ec7ebe059198b92069b74db39935d0d40..f2917e2035bacdaff5b679885627d4845faca9ca
@@@ -1164,42 -1164,12 +1164,12 @@@ static void pl08x_free_txd(struct pl08x
        kfree(txd);
  }
  
- static void pl08x_unmap_buffers(struct pl08x_txd *txd)
- {
-       struct device *dev = txd->vd.tx.chan->device->dev;
-       struct pl08x_sg *dsg;
-       if (!(txd->vd.tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-               if (txd->vd.tx.flags & DMA_COMPL_SRC_UNMAP_SINGLE)
-                       list_for_each_entry(dsg, &txd->dsg_list, node)
-                               dma_unmap_single(dev, dsg->src_addr, dsg->len,
-                                               DMA_TO_DEVICE);
-               else {
-                       list_for_each_entry(dsg, &txd->dsg_list, node)
-                               dma_unmap_page(dev, dsg->src_addr, dsg->len,
-                                               DMA_TO_DEVICE);
-               }
-       }
-       if (!(txd->vd.tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-               if (txd->vd.tx.flags & DMA_COMPL_DEST_UNMAP_SINGLE)
-                       list_for_each_entry(dsg, &txd->dsg_list, node)
-                               dma_unmap_single(dev, dsg->dst_addr, dsg->len,
-                                               DMA_FROM_DEVICE);
-               else
-                       list_for_each_entry(dsg, &txd->dsg_list, node)
-                               dma_unmap_page(dev, dsg->dst_addr, dsg->len,
-                                               DMA_FROM_DEVICE);
-       }
- }
  static void pl08x_desc_free(struct virt_dma_desc *vd)
  {
        struct pl08x_txd *txd = to_pl08x_txd(&vd->tx);
        struct pl08x_dma_chan *plchan = to_pl08x_chan(vd->tx.chan);
  
-       if (!plchan->slave)
-               pl08x_unmap_buffers(txd);
+       dma_descriptor_unmap(txd);
        if (!txd->done)
                pl08x_release_mux(plchan);
  
@@@ -1252,7 -1222,7 +1222,7 @@@ static enum dma_status pl08x_dma_tx_sta
        size_t bytes = 0;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        /*
  
        spin_lock_irqsave(&plchan->vc.lock, flags);
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret != DMA_SUCCESS) {
 +      if (ret != DMA_COMPLETE) {
                vd = vchan_find_desc(&plchan->vc, cookie);
                if (vd) {
                        /* On the issued list, so hasn't been processed yet */
@@@ -2133,7 -2103,8 +2103,7 @@@ static int pl08x_probe(struct amba_devi
        writel(0x000000FF, pl08x->base + PL080_ERR_CLEAR);
        writel(0x000000FF, pl08x->base + PL080_TC_CLEAR);
  
 -      ret = request_irq(adev->irq[0], pl08x_irq, IRQF_DISABLED,
 -                        DRIVER_NAME, pl08x);
 +      ret = request_irq(adev->irq[0], pl08x_irq, 0, DRIVER_NAME, pl08x);
        if (ret) {
                dev_err(&adev->dev, "%s failed to request interrupt %d\n",
                        __func__, adev->irq[0]);
diff --combined drivers/dma/at_hdmac.c
index 1ef74579447d5c0cc201cab4425748be75368eef,6deaefbec0b0c1a1acc6faefc4fc3812311df096..e2c04dc81e2a903ea13956e872150c40ed8b00e8
@@@ -344,31 -344,7 +344,7 @@@ atc_chain_complete(struct at_dma_chan *
        /* move myself to free_list */
        list_move(&desc->desc_node, &atchan->free_list);
  
-       /* unmap dma addresses (not on slave channels) */
-       if (!atchan->chan_common.private) {
-               struct device *parent = chan2parent(&atchan->chan_common);
-               if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                       if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE)
-                               dma_unmap_single(parent,
-                                               desc->lli.daddr,
-                                               desc->len, DMA_FROM_DEVICE);
-                       else
-                               dma_unmap_page(parent,
-                                               desc->lli.daddr,
-                                               desc->len, DMA_FROM_DEVICE);
-               }
-               if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       if (txd->flags & DMA_COMPL_SRC_UNMAP_SINGLE)
-                               dma_unmap_single(parent,
-                                               desc->lli.saddr,
-                                               desc->len, DMA_TO_DEVICE);
-                       else
-                               dma_unmap_page(parent,
-                                               desc->lli.saddr,
-                                               desc->len, DMA_TO_DEVICE);
-               }
-       }
+       dma_descriptor_unmap(txd);
        /* for cyclic transfers,
         * no need to replay callback function while stopping */
        if (!atc_chan_is_cyclic(atchan)) {
@@@ -1102,7 -1078,7 +1078,7 @@@ atc_tx_status(struct dma_chan *chan
        int bytes = 0;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
        /*
         * There's no point calculating the residue if there's
diff --combined drivers/dma/dmaengine.c
index 81d876528c70d60152628b04bb41b08d860ec565,b69ac3892b862862a682f96ed67249ef7190bb9e..ea806bdc12ef92418c528be0b950758de59c3ee7
@@@ -65,6 -65,7 +65,7 @@@
  #include <linux/acpi.h>
  #include <linux/acpi_dma.h>
  #include <linux/of_dma.h>
+ #include <linux/mempool.h>
  
  static DEFINE_MUTEX(dma_list_mutex);
  static DEFINE_IDR(dma_idr);
@@@ -901,98 -902,132 +902,132 @@@ void dma_async_device_unregister(struc
  }
  EXPORT_SYMBOL(dma_async_device_unregister);
  
- /**
-  * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
-  * @chan: DMA channel to offload copy to
-  * @dest: destination address (virtual)
-  * @src: source address (virtual)
-  * @len: length
-  *
-  * Both @dest and @src must be mappable to a bus address according to the
-  * DMA mapping API rules for streaming mappings.
-  * Both @dest and @src must stay memory resident (kernel memory or locked
-  * user space pages).
-  */
- dma_cookie_t
- dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
-                       void *src, size_t len)
- {
-       struct dma_device *dev = chan->device;
-       struct dma_async_tx_descriptor *tx;
-       dma_addr_t dma_dest, dma_src;
-       dma_cookie_t cookie;
-       unsigned long flags;
+ struct dmaengine_unmap_pool {
+       struct kmem_cache *cache;
+       const char *name;
+       mempool_t *pool;
+       size_t size;
+ };
  
-       dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
-       dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE);
-       flags = DMA_CTRL_ACK |
-               DMA_COMPL_SRC_UNMAP_SINGLE |
-               DMA_COMPL_DEST_UNMAP_SINGLE;
-       tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
+ #define __UNMAP_POOL(x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) }
+ static struct dmaengine_unmap_pool unmap_pool[] = {
+       __UNMAP_POOL(2),
+       #if IS_ENABLED(CONFIG_ASYNC_TX_DMA)
+       __UNMAP_POOL(16),
+       __UNMAP_POOL(128),
+       __UNMAP_POOL(256),
+       #endif
+ };
  
-       if (!tx) {
-               dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
-               dma_unmap_single(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
-               return -ENOMEM;
+ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)
+ {
+       int order = get_count_order(nr);
+       switch (order) {
+       case 0 ... 1:
+               return &unmap_pool[0];
+       case 2 ... 4:
+               return &unmap_pool[1];
+       case 5 ... 7:
+               return &unmap_pool[2];
+       case 8:
+               return &unmap_pool[3];
+       default:
+               BUG();
+               return NULL;
        }
+ }
  
-       tx->callback = NULL;
-       cookie = tx->tx_submit(tx);
+ static void dmaengine_unmap(struct kref *kref)
+ {
+       struct dmaengine_unmap_data *unmap = container_of(kref, typeof(*unmap), kref);
+       struct device *dev = unmap->dev;
+       int cnt, i;
+       cnt = unmap->to_cnt;
+       for (i = 0; i < cnt; i++)
+               dma_unmap_page(dev, unmap->addr[i], unmap->len,
+                              DMA_TO_DEVICE);
+       cnt += unmap->from_cnt;
+       for (; i < cnt; i++)
+               dma_unmap_page(dev, unmap->addr[i], unmap->len,
+                              DMA_FROM_DEVICE);
+       cnt += unmap->bidi_cnt;
+       for (; i < cnt; i++) {
+               if (unmap->addr[i] == 0)
+                       continue;
+               dma_unmap_page(dev, unmap->addr[i], unmap->len,
+                              DMA_BIDIRECTIONAL);
+       }
+       mempool_free(unmap, __get_unmap_pool(cnt)->pool);
+ }
  
-       preempt_disable();
-       __this_cpu_add(chan->local->bytes_transferred, len);
-       __this_cpu_inc(chan->local->memcpy_count);
-       preempt_enable();
+ void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap)
+ {
+       if (unmap)
+               kref_put(&unmap->kref, dmaengine_unmap);
+ }
+ EXPORT_SYMBOL_GPL(dmaengine_unmap_put);
  
-       return cookie;
+ static void dmaengine_destroy_unmap_pool(void)
+ {
+       int i;
+       for (i = 0; i < ARRAY_SIZE(unmap_pool); i++) {
+               struct dmaengine_unmap_pool *p = &unmap_pool[i];
+               if (p->pool)
+                       mempool_destroy(p->pool);
+               p->pool = NULL;
+               if (p->cache)
+                       kmem_cache_destroy(p->cache);
+               p->cache = NULL;
+       }
  }
- EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);
  
- /**
-  * dma_async_memcpy_buf_to_pg - offloaded copy from address to page
-  * @chan: DMA channel to offload copy to
-  * @page: destination page
-  * @offset: offset in page to copy to
-  * @kdata: source address (virtual)
-  * @len: length
-  *
-  * Both @page/@offset and @kdata must be mappable to a bus address according
-  * to the DMA mapping API rules for streaming mappings.
-  * Both @page/@offset and @kdata must stay memory resident (kernel memory or
-  * locked user space pages)
-  */
- dma_cookie_t
- dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
-                       unsigned int offset, void *kdata, size_t len)
+ static int __init dmaengine_init_unmap_pool(void)
  {
-       struct dma_device *dev = chan->device;
-       struct dma_async_tx_descriptor *tx;
-       dma_addr_t dma_dest, dma_src;
-       dma_cookie_t cookie;
-       unsigned long flags;
+       int i;
  
-       dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
-       dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE);
-       flags = DMA_CTRL_ACK | DMA_COMPL_SRC_UNMAP_SINGLE;
-       tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
+       for (i = 0; i < ARRAY_SIZE(unmap_pool); i++) {
+               struct dmaengine_unmap_pool *p = &unmap_pool[i];
+               size_t size;
  
-       if (!tx) {
-               dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
-               dma_unmap_page(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
-               return -ENOMEM;
+               size = sizeof(struct dmaengine_unmap_data) +
+                      sizeof(dma_addr_t) * p->size;
+               p->cache = kmem_cache_create(p->name, size, 0,
+                                            SLAB_HWCACHE_ALIGN, NULL);
+               if (!p->cache)
+                       break;
+               p->pool = mempool_create_slab_pool(1, p->cache);
+               if (!p->pool)
+                       break;
        }
  
-       tx->callback = NULL;
-       cookie = tx->tx_submit(tx);
+       if (i == ARRAY_SIZE(unmap_pool))
+               return 0;
  
-       preempt_disable();
-       __this_cpu_add(chan->local->bytes_transferred, len);
-       __this_cpu_inc(chan->local->memcpy_count);
-       preempt_enable();
+       dmaengine_destroy_unmap_pool();
+       return -ENOMEM;
+ }
  
-       return cookie;
+ struct dmaengine_unmap_data *
+ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
+ {
+       struct dmaengine_unmap_data *unmap;
+       unmap = mempool_alloc(__get_unmap_pool(nr)->pool, flags);
+       if (!unmap)
+               return NULL;
+       memset(unmap, 0, sizeof(*unmap));
+       kref_init(&unmap->kref);
+       unmap->dev = dev;
+       return unmap;
  }
- EXPORT_SYMBOL(dma_async_memcpy_buf_to_pg);
+ EXPORT_SYMBOL(dmaengine_get_unmap_data);
  
  /**
   * dma_async_memcpy_pg_to_pg - offloaded copy from page to page
@@@ -1015,24 -1050,33 +1050,33 @@@ dma_async_memcpy_pg_to_pg(struct dma_ch
  {
        struct dma_device *dev = chan->device;
        struct dma_async_tx_descriptor *tx;
-       dma_addr_t dma_dest, dma_src;
+       struct dmaengine_unmap_data *unmap;
        dma_cookie_t cookie;
        unsigned long flags;
  
-       dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
-       dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len,
-                               DMA_FROM_DEVICE);
+       unmap = dmaengine_get_unmap_data(dev->dev, 2, GFP_NOIO);
+       if (!unmap)
+               return -ENOMEM;
+       unmap->to_cnt = 1;
+       unmap->from_cnt = 1;
+       unmap->addr[0] = dma_map_page(dev->dev, src_pg, src_off, len,
+                                     DMA_TO_DEVICE);
+       unmap->addr[1] = dma_map_page(dev->dev, dest_pg, dest_off, len,
+                                     DMA_FROM_DEVICE);
+       unmap->len = len;
        flags = DMA_CTRL_ACK;
-       tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
+       tx = dev->device_prep_dma_memcpy(chan, unmap->addr[1], unmap->addr[0],
+                                        len, flags);
  
        if (!tx) {
-               dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE);
-               dma_unmap_page(dev->dev, dma_dest, len, DMA_FROM_DEVICE);
+               dmaengine_unmap_put(unmap);
                return -ENOMEM;
        }
  
-       tx->callback = NULL;
+       dma_set_unmap(tx, unmap);
        cookie = tx->tx_submit(tx);
+       dmaengine_unmap_put(unmap);
  
        preempt_disable();
        __this_cpu_add(chan->local->bytes_transferred, len);
  }
  EXPORT_SYMBOL(dma_async_memcpy_pg_to_pg);
  
+ /**
+  * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
+  * @chan: DMA channel to offload copy to
+  * @dest: destination address (virtual)
+  * @src: source address (virtual)
+  * @len: length
+  *
+  * Both @dest and @src must be mappable to a bus address according to the
+  * DMA mapping API rules for streaming mappings.
+  * Both @dest and @src must stay memory resident (kernel memory or locked
+  * user space pages).
+  */
+ dma_cookie_t
+ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
+                           void *src, size_t len)
+ {
+       return dma_async_memcpy_pg_to_pg(chan, virt_to_page(dest),
+                                        (unsigned long) dest & ~PAGE_MASK,
+                                        virt_to_page(src),
+                                        (unsigned long) src & ~PAGE_MASK, len);
+ }
+ EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);
+ /**
+  * dma_async_memcpy_buf_to_pg - offloaded copy from address to page
+  * @chan: DMA channel to offload copy to
+  * @page: destination page
+  * @offset: offset in page to copy to
+  * @kdata: source address (virtual)
+  * @len: length
+  *
+  * Both @page/@offset and @kdata must be mappable to a bus address according
+  * to the DMA mapping API rules for streaming mappings.
+  * Both @page/@offset and @kdata must stay memory resident (kernel memory or
+  * locked user space pages)
+  */
+ dma_cookie_t
+ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
+                          unsigned int offset, void *kdata, size_t len)
+ {
+       return dma_async_memcpy_pg_to_pg(chan, page, offset,
+                                        virt_to_page(kdata),
+                                        (unsigned long) kdata & ~PAGE_MASK, len);
+ }
+ EXPORT_SYMBOL(dma_async_memcpy_buf_to_pg);
  void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
        struct dma_chan *chan)
  {
@@@ -1062,7 -1152,7 +1152,7 @@@ dma_wait_for_async_tx(struct dma_async_
        unsigned long dma_sync_wait_timeout = jiffies + msecs_to_jiffies(5000);
  
        if (!tx)
 -              return DMA_SUCCESS;
 +              return DMA_COMPLETE;
  
        while (tx->cookie == -EBUSY) {
                if (time_after_eq(jiffies, dma_sync_wait_timeout)) {
@@@ -1116,6 -1206,10 +1206,10 @@@ EXPORT_SYMBOL_GPL(dma_run_dependencies)
  
  static int __init dma_bus_init(void)
  {
+       int err = dmaengine_init_unmap_pool();
+       if (err)
+               return err;
        return class_register(&dma_devclass);
  }
  arch_initcall(dma_bus_init);
diff --combined drivers/dma/dmatest.c
index 59e287f56dfca28bb0ff40fc79b6c0e612af58ac,329b7cf02f8ed9537a7b52c2576c83f93bcf3417..20f9a3aaf9266ea6daa71a18f08d258afa8a1a1e
@@@ -8,6 -8,8 +8,8 @@@
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  #include <linux/delay.h>
  #include <linux/dma-mapping.h>
  #include <linux/dmaengine.h>
  #include <linux/random.h>
  #include <linux/slab.h>
  #include <linux/wait.h>
- #include <linux/ctype.h>
- #include <linux/debugfs.h>
- #include <linux/uaccess.h>
- #include <linux/seq_file.h>
  
  static unsigned int test_buf_size = 16384;
  module_param(test_buf_size, uint, S_IRUGO | S_IWUSR);
@@@ -68,92 -66,13 +66,13 @@@ module_param(timeout, uint, S_IRUGO | S
  MODULE_PARM_DESC(timeout, "Transfer Timeout in msec (default: 3000), "
                 "Pass -1 for infinite timeout");
  
- /* Maximum amount of mismatched bytes in buffer to print */
- #define MAX_ERROR_COUNT               32
- /*
-  * Initialization patterns. All bytes in the source buffer has bit 7
-  * set, all bytes in the destination buffer has bit 7 cleared.
-  *
-  * Bit 6 is set for all bytes which are to be copied by the DMA
-  * engine. Bit 5 is set for all bytes which are to be overwritten by
-  * the DMA engine.
-  *
-  * The remaining bits are the inverse of a counter which increments by
-  * one for each byte address.
-  */
- #define PATTERN_SRC           0x80
- #define PATTERN_DST           0x00
- #define PATTERN_COPY          0x40
- #define PATTERN_OVERWRITE     0x20
- #define PATTERN_COUNT_MASK    0x1f
- enum dmatest_error_type {
-       DMATEST_ET_OK,
-       DMATEST_ET_MAP_SRC,
-       DMATEST_ET_MAP_DST,
-       DMATEST_ET_PREP,
-       DMATEST_ET_SUBMIT,
-       DMATEST_ET_TIMEOUT,
-       DMATEST_ET_DMA_ERROR,
-       DMATEST_ET_DMA_IN_PROGRESS,
-       DMATEST_ET_VERIFY,
-       DMATEST_ET_VERIFY_BUF,
- };
- struct dmatest_verify_buffer {
-       unsigned int    index;
-       u8              expected;
-       u8              actual;
- };
- struct dmatest_verify_result {
-       unsigned int                    error_count;
-       struct dmatest_verify_buffer    data[MAX_ERROR_COUNT];
-       u8                              pattern;
-       bool                            is_srcbuf;
- };
- struct dmatest_thread_result {
-       struct list_head        node;
-       unsigned int            n;
-       unsigned int            src_off;
-       unsigned int            dst_off;
-       unsigned int            len;
-       enum dmatest_error_type type;
-       union {
-               unsigned long                   data;
-               dma_cookie_t                    cookie;
-               enum dma_status                 status;
-               int                             error;
-               struct dmatest_verify_result    *vr;
-       };
- };
- struct dmatest_result {
-       struct list_head        node;
-       char                    *name;
-       struct list_head        results;
- };
- struct dmatest_info;
- struct dmatest_thread {
-       struct list_head        node;
-       struct dmatest_info     *info;
-       struct task_struct      *task;
-       struct dma_chan         *chan;
-       u8                      **srcs;
-       u8                      **dsts;
-       enum dma_transaction_type type;
-       bool                    done;
- };
+ static bool noverify;
+ module_param(noverify, bool, S_IRUGO | S_IWUSR);
+ MODULE_PARM_DESC(noverify, "Disable random data setup and verification");
  
- struct dmatest_chan {
-       struct list_head        node;
-       struct dma_chan         *chan;
-       struct list_head        threads;
- };
+ static bool verbose;
+ module_param(verbose, bool, S_IRUGO | S_IWUSR);
+ MODULE_PARM_DESC(verbose, "Enable \"success\" result messages (default: off)");
  
  /**
   * struct dmatest_params - test parameters.
@@@ -177,6 -96,7 +96,7 @@@ struct dmatest_params 
        unsigned int    xor_sources;
        unsigned int    pq_sources;
        int             timeout;
+       bool            noverify;
  };
  
  /**
   * @params:           test parameters
   * @lock:             access protection to the fields of this structure
   */
- struct dmatest_info {
+ static struct dmatest_info {
        /* Test parameters */
        struct dmatest_params   params;
  
        struct list_head        channels;
        unsigned int            nr_channels;
        struct mutex            lock;
+       bool                    did_init;
+ } test_info = {
+       .channels = LIST_HEAD_INIT(test_info.channels),
+       .lock = __MUTEX_INITIALIZER(test_info.lock),
+ };
+ static int dmatest_run_set(const char *val, const struct kernel_param *kp);
+ static int dmatest_run_get(char *val, const struct kernel_param *kp);
+ static struct kernel_param_ops run_ops = {
+       .set = dmatest_run_set,
+       .get = dmatest_run_get,
+ };
+ static bool dmatest_run;
+ module_param_cb(run, &run_ops, &dmatest_run, S_IRUGO | S_IWUSR);
+ MODULE_PARM_DESC(run, "Run the test (default: false)");
+ /* Maximum amount of mismatched bytes in buffer to print */
+ #define MAX_ERROR_COUNT               32
+ /*
+  * Initialization patterns. All bytes in the source buffer has bit 7
+  * set, all bytes in the destination buffer has bit 7 cleared.
+  *
+  * Bit 6 is set for all bytes which are to be copied by the DMA
+  * engine. Bit 5 is set for all bytes which are to be overwritten by
+  * the DMA engine.
+  *
+  * The remaining bits are the inverse of a counter which increments by
+  * one for each byte address.
+  */
+ #define PATTERN_SRC           0x80
+ #define PATTERN_DST           0x00
+ #define PATTERN_COPY          0x40
+ #define PATTERN_OVERWRITE     0x20
+ #define PATTERN_COUNT_MASK    0x1f
  
-       /* debugfs related stuff */
-       struct dentry           *root;
+ struct dmatest_thread {
+       struct list_head        node;
+       struct dmatest_info     *info;
+       struct task_struct      *task;
+       struct dma_chan         *chan;
+       u8                      **srcs;
+       u8                      **dsts;
+       enum dma_transaction_type type;
+       bool                    done;
+ };
  
-       /* Test results */
-       struct list_head        results;
-       struct mutex            results_lock;
+ struct dmatest_chan {
+       struct list_head        node;
+       struct dma_chan         *chan;
+       struct list_head        threads;
  };
  
- static struct dmatest_info test_info;
+ static DECLARE_WAIT_QUEUE_HEAD(thread_wait);
+ static bool wait;
+ static bool is_threaded_test_run(struct dmatest_info *info)
+ {
+       struct dmatest_chan *dtc;
+       list_for_each_entry(dtc, &info->channels, node) {
+               struct dmatest_thread *thread;
+               list_for_each_entry(thread, &dtc->threads, node) {
+                       if (!thread->done)
+                               return true;
+               }
+       }
+       return false;
+ }
+ static int dmatest_wait_get(char *val, const struct kernel_param *kp)
+ {
+       struct dmatest_info *info = &test_info;
+       struct dmatest_params *params = &info->params;
+       if (params->iterations)
+               wait_event(thread_wait, !is_threaded_test_run(info));
+       wait = true;
+       return param_get_bool(val, kp);
+ }
+ static struct kernel_param_ops wait_ops = {
+       .get = dmatest_wait_get,
+       .set = param_set_bool,
+ };
+ module_param_cb(wait, &wait_ops, &wait, S_IRUGO);
+ MODULE_PARM_DESC(wait, "Wait for tests to complete (default: false)");
  
  static bool dmatest_match_channel(struct dmatest_params *params,
                struct dma_chan *chan)
@@@ -223,7 -222,7 +222,7 @@@ static unsigned long dmatest_random(voi
  {
        unsigned long buf;
  
-       get_random_bytes(&buf, sizeof(buf));
+       prandom_bytes(&buf, sizeof(buf));
        return buf;
  }
  
@@@ -262,9 -261,31 +261,31 @@@ static void dmatest_init_dsts(u8 **bufs
        }
  }
  
- static unsigned int dmatest_verify(struct dmatest_verify_result *vr, u8 **bufs,
-               unsigned int start, unsigned int end, unsigned int counter,
-               u8 pattern, bool is_srcbuf)
+ static void dmatest_mismatch(u8 actual, u8 pattern, unsigned int index,
+               unsigned int counter, bool is_srcbuf)
+ {
+       u8              diff = actual ^ pattern;
+       u8              expected = pattern | (~counter & PATTERN_COUNT_MASK);
+       const char      *thread_name = current->comm;
+       if (is_srcbuf)
+               pr_warn("%s: srcbuf[0x%x] overwritten! Expected %02x, got %02x\n",
+                       thread_name, index, expected, actual);
+       else if ((pattern & PATTERN_COPY)
+                       && (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
+               pr_warn("%s: dstbuf[0x%x] not copied! Expected %02x, got %02x\n",
+                       thread_name, index, expected, actual);
+       else if (diff & PATTERN_SRC)
+               pr_warn("%s: dstbuf[0x%x] was copied! Expected %02x, got %02x\n",
+                       thread_name, index, expected, actual);
+       else
+               pr_warn("%s: dstbuf[0x%x] mismatch! Expected %02x, got %02x\n",
+                       thread_name, index, expected, actual);
+ }
+ static unsigned int dmatest_verify(u8 **bufs, unsigned int start,
+               unsigned int end, unsigned int counter, u8 pattern,
+               bool is_srcbuf)
  {
        unsigned int i;
        unsigned int error_count = 0;
        u8 expected;
        u8 *buf;
        unsigned int counter_orig = counter;
-       struct dmatest_verify_buffer *vb;
  
        for (; (buf = *bufs); bufs++) {
                counter = counter_orig;
                        actual = buf[i];
                        expected = pattern | (~counter & PATTERN_COUNT_MASK);
                        if (actual != expected) {
-                               if (error_count < MAX_ERROR_COUNT && vr) {
-                                       vb = &vr->data[error_count];
-                                       vb->index = i;
-                                       vb->expected = expected;
-                                       vb->actual = actual;
-                               }
+                               if (error_count < MAX_ERROR_COUNT)
+                                       dmatest_mismatch(actual, pattern, i,
+                                                        counter, is_srcbuf);
                                error_count++;
                        }
                        counter++;
        }
  
        if (error_count > MAX_ERROR_COUNT)
-               pr_warning("%s: %u errors suppressed\n",
+               pr_warn("%s: %u errors suppressed\n",
                        current->comm, error_count - MAX_ERROR_COUNT);
  
        return error_count;
@@@ -313,20 -330,6 +330,6 @@@ static void dmatest_callback(void *arg
        wake_up_all(done->wait);
  }
  
- static inline void unmap_src(struct device *dev, dma_addr_t *addr, size_t len,
-                            unsigned int count)
- {
-       while (count--)
-               dma_unmap_single(dev, addr[count], len, DMA_TO_DEVICE);
- }
- static inline void unmap_dst(struct device *dev, dma_addr_t *addr, size_t len,
-                            unsigned int count)
- {
-       while (count--)
-               dma_unmap_single(dev, addr[count], len, DMA_BIDIRECTIONAL);
- }
  static unsigned int min_odd(unsigned int x, unsigned int y)
  {
        unsigned int val = min(x, y);
        return val % 2 ? val : val - 1;
  }
  
- static char *verify_result_get_one(struct dmatest_verify_result *vr,
-               unsigned int i)
+ static void result(const char *err, unsigned int n, unsigned int src_off,
+                  unsigned int dst_off, unsigned int len, unsigned long data)
  {
-       struct dmatest_verify_buffer *vb = &vr->data[i];
-       u8 diff = vb->actual ^ vr->pattern;
-       static char buf[512];
-       char *msg;
-       if (vr->is_srcbuf)
-               msg = "srcbuf overwritten!";
-       else if ((vr->pattern & PATTERN_COPY)
-                       && (diff & (PATTERN_COPY | PATTERN_OVERWRITE)))
-               msg = "dstbuf not copied!";
-       else if (diff & PATTERN_SRC)
-               msg = "dstbuf was copied!";
-       else
-               msg = "dstbuf mismatch!";
-       snprintf(buf, sizeof(buf) - 1, "%s [0x%x] Expected %02x, got %02x", msg,
-                vb->index, vb->expected, vb->actual);
-       return buf;
+       pr_info("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)",
+               current->comm, n, err, src_off, dst_off, len, data);
  }
  
- static char *thread_result_get(const char *name,
-               struct dmatest_thread_result *tr)
+ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
+                      unsigned int dst_off, unsigned int len,
+                      unsigned long data)
  {
-       static const char * const messages[] = {
-               [DMATEST_ET_OK]                 = "No errors",
-               [DMATEST_ET_MAP_SRC]            = "src mapping error",
-               [DMATEST_ET_MAP_DST]            = "dst mapping error",
-               [DMATEST_ET_PREP]               = "prep error",
-               [DMATEST_ET_SUBMIT]             = "submit error",
-               [DMATEST_ET_TIMEOUT]            = "test timed out",
-               [DMATEST_ET_DMA_ERROR]          =
-                       "got completion callback (DMA_ERROR)",
-               [DMATEST_ET_DMA_IN_PROGRESS]    =
-                       "got completion callback (DMA_IN_PROGRESS)",
-               [DMATEST_ET_VERIFY]             = "errors",
-               [DMATEST_ET_VERIFY_BUF]         = "verify errors",
-       };
-       static char buf[512];
-       snprintf(buf, sizeof(buf) - 1,
-                "%s: #%u: %s with src_off=0x%x ""dst_off=0x%x len=0x%x (%lu)",
-                name, tr->n, messages[tr->type], tr->src_off, tr->dst_off,
-                tr->len, tr->data);
-       return buf;
+       pr_debug("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)",
+                  current->comm, n, err, src_off, dst_off, len, data);
  }
  
- static int thread_result_add(struct dmatest_info *info,
-               struct dmatest_result *r, enum dmatest_error_type type,
-               unsigned int n, unsigned int src_off, unsigned int dst_off,
-               unsigned int len, unsigned long data)
- {
-       struct dmatest_thread_result *tr;
-       tr = kzalloc(sizeof(*tr), GFP_KERNEL);
-       if (!tr)
-               return -ENOMEM;
-       tr->type = type;
-       tr->n = n;
-       tr->src_off = src_off;
-       tr->dst_off = dst_off;
-       tr->len = len;
-       tr->data = data;
+ #define verbose_result(err, n, src_off, dst_off, len, data) ({ \
+       if (verbose) \
+               result(err, n, src_off, dst_off, len, data); \
+       else \
+               dbg_result(err, n, src_off, dst_off, len, data); \
+ })
  
-       mutex_lock(&info->results_lock);
-       list_add_tail(&tr->node, &r->results);
-       mutex_unlock(&info->results_lock);
-       if (tr->type == DMATEST_ET_OK)
-               pr_debug("%s\n", thread_result_get(r->name, tr));
-       else
-               pr_warn("%s\n", thread_result_get(r->name, tr));
-       return 0;
- }
- static unsigned int verify_result_add(struct dmatest_info *info,
-               struct dmatest_result *r, unsigned int n,
-               unsigned int src_off, unsigned int dst_off, unsigned int len,
-               u8 **bufs, int whence, unsigned int counter, u8 pattern,
-               bool is_srcbuf)
+ static unsigned long long dmatest_persec(s64 runtime, unsigned int val)
  {
-       struct dmatest_verify_result *vr;
-       unsigned int error_count;
-       unsigned int buf_off = is_srcbuf ? src_off : dst_off;
-       unsigned int start, end;
-       if (whence < 0) {
-               start = 0;
-               end = buf_off;
-       } else if (whence > 0) {
-               start = buf_off + len;
-               end = info->params.buf_size;
-       } else {
-               start = buf_off;
-               end = buf_off + len;
-       }
+       unsigned long long per_sec = 1000000;
  
-       vr = kmalloc(sizeof(*vr), GFP_KERNEL);
-       if (!vr) {
-               pr_warn("dmatest: No memory to store verify result\n");
-               return dmatest_verify(NULL, bufs, start, end, counter, pattern,
-                                     is_srcbuf);
-       }
-       vr->pattern = pattern;
-       vr->is_srcbuf = is_srcbuf;
-       error_count = dmatest_verify(vr, bufs, start, end, counter, pattern,
-                                    is_srcbuf);
-       if (error_count) {
-               vr->error_count = error_count;
-               thread_result_add(info, r, DMATEST_ET_VERIFY_BUF, n, src_off,
-                                 dst_off, len, (unsigned long)vr);
-               return error_count;
-       }
-       kfree(vr);
-       return 0;
- }
- static void result_free(struct dmatest_info *info, const char *name)
- {
-       struct dmatest_result *r, *_r;
-       mutex_lock(&info->results_lock);
-       list_for_each_entry_safe(r, _r, &info->results, node) {
-               struct dmatest_thread_result *tr, *_tr;
-               if (name && strcmp(r->name, name))
-                       continue;
-               list_for_each_entry_safe(tr, _tr, &r->results, node) {
-                       if (tr->type == DMATEST_ET_VERIFY_BUF)
-                               kfree(tr->vr);
-                       list_del(&tr->node);
-                       kfree(tr);
-               }
+       if (runtime <= 0)
+               return 0;
  
-               kfree(r->name);
-               list_del(&r->node);
-               kfree(r);
+       /* drop precision until runtime is 32-bits */
+       while (runtime > UINT_MAX) {
+               runtime >>= 1;
+               per_sec <<= 1;
        }
  
-       mutex_unlock(&info->results_lock);
+       per_sec *= val;
+       do_div(per_sec, runtime);
+       return per_sec;
  }
  
- static struct dmatest_result *result_init(struct dmatest_info *info,
-               const char *name)
+ static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
  {
-       struct dmatest_result *r;
-       r = kzalloc(sizeof(*r), GFP_KERNEL);
-       if (r) {
-               r->name = kstrdup(name, GFP_KERNEL);
-               INIT_LIST_HEAD(&r->results);
-               mutex_lock(&info->results_lock);
-               list_add_tail(&r->node, &info->results);
-               mutex_unlock(&info->results_lock);
-       }
-       return r;
+       return dmatest_persec(runtime, len >> 10);
  }
  
  /*
@@@ -525,7 -405,6 +405,6 @@@ static int dmatest_func(void *data
        struct dmatest_params   *params;
        struct dma_chan         *chan;
        struct dma_device       *dev;
-       const char              *thread_name;
        unsigned int            src_off, dst_off, len;
        unsigned int            error_count;
        unsigned int            failed_tests = 0;
        int                     src_cnt;
        int                     dst_cnt;
        int                     i;
-       struct dmatest_result   *result;
+       ktime_t                 ktime;
+       s64                     runtime = 0;
+       unsigned long long      total_len = 0;
  
-       thread_name = current->comm;
        set_freezable();
  
        ret = -ENOMEM;
        } else
                goto err_thread_type;
  
-       result = result_init(info, thread_name);
-       if (!result)
-               goto err_srcs;
        thread->srcs = kcalloc(src_cnt+1, sizeof(u8 *), GFP_KERNEL);
        if (!thread->srcs)
                goto err_srcs;
        set_user_nice(current, 10);
  
        /*
-        * src buffers are freed by the DMAEngine code with dma_unmap_single()
-        * dst buffers are freed by ourselves below
+        * src and dst buffers are freed by ourselves below
         */
-       flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT
-             | DMA_COMPL_SKIP_DEST_UNMAP | DMA_COMPL_SRC_UNMAP_SINGLE;
+       flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
  
+       ktime = ktime_get();
        while (!kthread_should_stop()
               && !(params->iterations && total_tests >= params->iterations)) {
                struct dma_async_tx_descriptor *tx = NULL;
-               dma_addr_t dma_srcs[src_cnt];
-               dma_addr_t dma_dsts[dst_cnt];
+               struct dmaengine_unmap_data *um;
+               dma_addr_t srcs[src_cnt];
+               dma_addr_t *dsts;
                u8 align = 0;
  
                total_tests++;
                        break;
                }
  
-               len = dmatest_random() % params->buf_size + 1;
+               if (params->noverify) {
+                       len = params->buf_size;
+                       src_off = 0;
+                       dst_off = 0;
+               } else {
+                       len = dmatest_random() % params->buf_size + 1;
+                       len = (len >> align) << align;
+                       if (!len)
+                               len = 1 << align;
+                       src_off = dmatest_random() % (params->buf_size - len + 1);
+                       dst_off = dmatest_random() % (params->buf_size - len + 1);
+                       src_off = (src_off >> align) << align;
+                       dst_off = (dst_off >> align) << align;
+                       dmatest_init_srcs(thread->srcs, src_off, len,
+                                         params->buf_size);
+                       dmatest_init_dsts(thread->dsts, dst_off, len,
+                                         params->buf_size);
+               }
                len = (len >> align) << align;
                if (!len)
                        len = 1 << align;
-               src_off = dmatest_random() % (params->buf_size - len + 1);
-               dst_off = dmatest_random() % (params->buf_size - len + 1);
+               total_len += len;
  
-               src_off = (src_off >> align) << align;
-               dst_off = (dst_off >> align) << align;
-               dmatest_init_srcs(thread->srcs, src_off, len, params->buf_size);
-               dmatest_init_dsts(thread->dsts, dst_off, len, params->buf_size);
+               um = dmaengine_get_unmap_data(dev->dev, src_cnt+dst_cnt,
+                                             GFP_KERNEL);
+               if (!um) {
+                       failed_tests++;
+                       result("unmap data NULL", total_tests,
+                              src_off, dst_off, len, ret);
+                       continue;
+               }
  
+               um->len = params->buf_size;
                for (i = 0; i < src_cnt; i++) {
-                       u8 *buf = thread->srcs[i] + src_off;
-                       dma_srcs[i] = dma_map_single(dev->dev, buf, len,
-                                                    DMA_TO_DEVICE);
-                       ret = dma_mapping_error(dev->dev, dma_srcs[i]);
+                       unsigned long buf = (unsigned long) thread->srcs[i];
+                       struct page *pg = virt_to_page(buf);
+                       unsigned pg_off = buf & ~PAGE_MASK;
+                       um->addr[i] = dma_map_page(dev->dev, pg, pg_off,
+                                                  um->len, DMA_TO_DEVICE);
+                       srcs[i] = um->addr[i] + src_off;
+                       ret = dma_mapping_error(dev->dev, um->addr[i]);
                        if (ret) {
-                               unmap_src(dev->dev, dma_srcs, len, i);
-                               thread_result_add(info, result,
-                                                 DMATEST_ET_MAP_SRC,
-                                                 total_tests, src_off, dst_off,
-                                                 len, ret);
+                               dmaengine_unmap_put(um);
+                               result("src mapping error", total_tests,
+                                      src_off, dst_off, len, ret);
                                failed_tests++;
                                continue;
                        }
+                       um->to_cnt++;
                }
                /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */
+               dsts = &um->addr[src_cnt];
                for (i = 0; i < dst_cnt; i++) {
-                       dma_dsts[i] = dma_map_single(dev->dev, thread->dsts[i],
-                                                    params->buf_size,
-                                                    DMA_BIDIRECTIONAL);
-                       ret = dma_mapping_error(dev->dev, dma_dsts[i]);
+                       unsigned long buf = (unsigned long) thread->dsts[i];
+                       struct page *pg = virt_to_page(buf);
+                       unsigned pg_off = buf & ~PAGE_MASK;
+                       dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len,
+                                              DMA_BIDIRECTIONAL);
+                       ret = dma_mapping_error(dev->dev, dsts[i]);
                        if (ret) {
-                               unmap_src(dev->dev, dma_srcs, len, src_cnt);
-                               unmap_dst(dev->dev, dma_dsts, params->buf_size,
-                                         i);
-                               thread_result_add(info, result,
-                                                 DMATEST_ET_MAP_DST,
-                                                 total_tests, src_off, dst_off,
-                                                 len, ret);
+                               dmaengine_unmap_put(um);
+                               result("dst mapping error", total_tests,
+                                      src_off, dst_off, len, ret);
                                failed_tests++;
                                continue;
                        }
+                       um->bidi_cnt++;
                }
  
                if (thread->type == DMA_MEMCPY)
                        tx = dev->device_prep_dma_memcpy(chan,
-                                                        dma_dsts[0] + dst_off,
-                                                        dma_srcs[0], len,
-                                                        flags);
+                                                        dsts[0] + dst_off,
+                                                        srcs[0], len, flags);
                else if (thread->type == DMA_XOR)
                        tx = dev->device_prep_dma_xor(chan,
-                                                     dma_dsts[0] + dst_off,
-                                                     dma_srcs, src_cnt,
+                                                     dsts[0] + dst_off,
+                                                     srcs, src_cnt,
                                                      len, flags);
                else if (thread->type == DMA_PQ) {
                        dma_addr_t dma_pq[dst_cnt];
  
                        for (i = 0; i < dst_cnt; i++)
-                               dma_pq[i] = dma_dsts[i] + dst_off;
-                       tx = dev->device_prep_dma_pq(chan, dma_pq, dma_srcs,
+                               dma_pq[i] = dsts[i] + dst_off;
+                       tx = dev->device_prep_dma_pq(chan, dma_pq, srcs,
                                                     src_cnt, pq_coefs,
                                                     len, flags);
                }
  
                if (!tx) {
-                       unmap_src(dev->dev, dma_srcs, len, src_cnt);
-                       unmap_dst(dev->dev, dma_dsts, params->buf_size,
-                                 dst_cnt);
-                       thread_result_add(info, result, DMATEST_ET_PREP,
-                                         total_tests, src_off, dst_off,
-                                         len, 0);
+                       dmaengine_unmap_put(um);
+                       result("prep error", total_tests, src_off,
+                              dst_off, len, ret);
                        msleep(100);
                        failed_tests++;
                        continue;
                cookie = tx->tx_submit(tx);
  
                if (dma_submit_error(cookie)) {
-                       thread_result_add(info, result, DMATEST_ET_SUBMIT,
-                                         total_tests, src_off, dst_off,
-                                         len, cookie);
+                       dmaengine_unmap_put(um);
+                       result("submit error", total_tests, src_off,
+                              dst_off, len, ret);
                        msleep(100);
                        failed_tests++;
                        continue;
                         * free it this time?" dancing.  For now, just
                         * leave it dangling.
                         */
-                       thread_result_add(info, result, DMATEST_ET_TIMEOUT,
-                                         total_tests, src_off, dst_off,
-                                         len, 0);
+                       dmaengine_unmap_put(um);
+                       result("test timed out", total_tests, src_off, dst_off,
+                              len, 0);
                        failed_tests++;
                        continue;
 -              } else if (status != DMA_SUCCESS) {
 +              } else if (status != DMA_COMPLETE) {
-                       enum dmatest_error_type type = (status == DMA_ERROR) ?
-                               DMATEST_ET_DMA_ERROR : DMATEST_ET_DMA_IN_PROGRESS;
-                       thread_result_add(info, result, type,
-                                         total_tests, src_off, dst_off,
-                                         len, status);
+                       dmaengine_unmap_put(um);
+                       result(status == DMA_ERROR ?
+                              "completion error status" :
+                              "completion busy status", total_tests, src_off,
+                              dst_off, len, ret);
                        failed_tests++;
                        continue;
                }
  
-               /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */
-               unmap_dst(dev->dev, dma_dsts, params->buf_size, dst_cnt);
+               dmaengine_unmap_put(um);
  
-               error_count = 0;
+               if (params->noverify) {
+                       verbose_result("test passed", total_tests, src_off,
+                                      dst_off, len, 0);
+                       continue;
+               }
  
-               pr_debug("%s: verifying source buffer...\n", thread_name);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->srcs, -1,
+               pr_debug("%s: verifying source buffer...\n", current->comm);
+               error_count = dmatest_verify(thread->srcs, 0, src_off,
                                0, PATTERN_SRC, true);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->srcs, 0,
-                               src_off, PATTERN_SRC | PATTERN_COPY, true);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->srcs, 1,
-                               src_off + len, PATTERN_SRC, true);
-               pr_debug("%s: verifying dest buffer...\n", thread_name);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->dsts, -1,
+               error_count += dmatest_verify(thread->srcs, src_off,
+                               src_off + len, src_off,
+                               PATTERN_SRC | PATTERN_COPY, true);
+               error_count += dmatest_verify(thread->srcs, src_off + len,
+                               params->buf_size, src_off + len,
+                               PATTERN_SRC, true);
+               pr_debug("%s: verifying dest buffer...\n", current->comm);
+               error_count += dmatest_verify(thread->dsts, 0, dst_off,
                                0, PATTERN_DST, false);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->dsts, 0,
-                               src_off, PATTERN_SRC | PATTERN_COPY, false);
-               error_count += verify_result_add(info, result, total_tests,
-                               src_off, dst_off, len, thread->dsts, 1,
-                               dst_off + len, PATTERN_DST, false);
+               error_count += dmatest_verify(thread->dsts, dst_off,
+                               dst_off + len, src_off,
+                               PATTERN_SRC | PATTERN_COPY, false);
+               error_count += dmatest_verify(thread->dsts, dst_off + len,
+                               params->buf_size, dst_off + len,
+                               PATTERN_DST, false);
  
                if (error_count) {
-                       thread_result_add(info, result, DMATEST_ET_VERIFY,
-                                         total_tests, src_off, dst_off,
-                                         len, error_count);
+                       result("data error", total_tests, src_off, dst_off,
+                              len, error_count);
                        failed_tests++;
                } else {
-                       thread_result_add(info, result, DMATEST_ET_OK,
-                                         total_tests, src_off, dst_off,
-                                         len, 0);
+                       verbose_result("test passed", total_tests, src_off,
+                                      dst_off, len, 0);
                }
        }
+       runtime = ktime_us_delta(ktime_get(), ktime);
  
        ret = 0;
        for (i = 0; thread->dsts[i]; i++)
@@@ -802,20 -700,17 +700,17 @@@ err_srcbuf
  err_srcs:
        kfree(pq_coefs);
  err_thread_type:
-       pr_notice("%s: terminating after %u tests, %u failures (status %d)\n",
-                       thread_name, total_tests, failed_tests, ret);
+       pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
+               current->comm, total_tests, failed_tests,
+               dmatest_persec(runtime, total_tests),
+               dmatest_KBs(runtime, total_len), ret);
  
        /* terminate all transfers on specified channels */
        if (ret)
                dmaengine_terminate_all(chan);
  
        thread->done = true;
-       if (params->iterations > 0)
-               while (!kthread_should_stop()) {
-                       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait_dmatest_exit);
-                       interruptible_sleep_on(&wait_dmatest_exit);
-               }
+       wake_up(&thread_wait);
  
        return ret;
  }
@@@ -828,9 -723,10 +723,10 @@@ static void dmatest_cleanup_channel(str
  
        list_for_each_entry_safe(thread, _thread, &dtc->threads, node) {
                ret = kthread_stop(thread->task);
-               pr_debug("dmatest: thread %s exited with status %d\n",
-                               thread->task->comm, ret);
+               pr_debug("thread %s exited with status %d\n",
+                        thread->task->comm, ret);
                list_del(&thread->node);
+               put_task_struct(thread->task);
                kfree(thread);
        }
  
@@@ -861,27 -757,27 +757,27 @@@ static int dmatest_add_threads(struct d
        for (i = 0; i < params->threads_per_chan; i++) {
                thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
                if (!thread) {
-                       pr_warning("dmatest: No memory for %s-%s%u\n",
-                                  dma_chan_name(chan), op, i);
+                       pr_warn("No memory for %s-%s%u\n",
+                               dma_chan_name(chan), op, i);
                        break;
                }
                thread->info = info;
                thread->chan = dtc->chan;
                thread->type = type;
                smp_wmb();
-               thread->task = kthread_run(dmatest_func, thread, "%s-%s%u",
+               thread->task = kthread_create(dmatest_func, thread, "%s-%s%u",
                                dma_chan_name(chan), op, i);
                if (IS_ERR(thread->task)) {
-                       pr_warning("dmatest: Failed to run thread %s-%s%u\n",
-                                       dma_chan_name(chan), op, i);
+                       pr_warn("Failed to create thread %s-%s%u\n",
+                               dma_chan_name(chan), op, i);
                        kfree(thread);
                        break;
                }
  
                /* srcbuf and dstbuf are allocated by the thread itself */
+               get_task_struct(thread->task);
                list_add_tail(&thread->node, &dtc->threads);
+               wake_up_process(thread->task);
        }
  
        return i;
@@@ -897,7 -793,7 +793,7 @@@ static int dmatest_add_channel(struct d
  
        dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
        if (!dtc) {
-               pr_warning("dmatest: No memory for %s\n", dma_chan_name(chan));
+               pr_warn("No memory for %s\n", dma_chan_name(chan));
                return -ENOMEM;
        }
  
                thread_count += cnt > 0 ? cnt : 0;
        }
  
-       pr_info("dmatest: Started %u threads using %s\n",
+       pr_info("Started %u threads using %s\n",
                thread_count, dma_chan_name(chan));
  
        list_add_tail(&dtc->node, &info->channels);
@@@ -937,20 -833,20 +833,20 @@@ static bool filter(struct dma_chan *cha
                return true;
  }
  
- static int __run_threaded_test(struct dmatest_info *info)
+ static void request_channels(struct dmatest_info *info,
+                            enum dma_transaction_type type)
  {
        dma_cap_mask_t mask;
-       struct dma_chan *chan;
-       struct dmatest_params *params = &info->params;
-       int err = 0;
  
        dma_cap_zero(mask);
-       dma_cap_set(DMA_MEMCPY, mask);
+       dma_cap_set(type, mask);
        for (;;) {
+               struct dmatest_params *params = &info->params;
+               struct dma_chan *chan;
                chan = dma_request_channel(mask, filter, params);
                if (chan) {
-                       err = dmatest_add_channel(info, chan);
-                       if (err) {
+                       if (dmatest_add_channel(info, chan)) {
                                dma_release_channel(chan);
                                break; /* add_channel failed, punt */
                        }
                    info->nr_channels >= params->max_channels)
                        break; /* we have all we need */
        }
-       return err;
  }
  
- #ifndef MODULE
- static int run_threaded_test(struct dmatest_info *info)
+ static void run_threaded_test(struct dmatest_info *info)
  {
-       int ret;
+       struct dmatest_params *params = &info->params;
  
-       mutex_lock(&info->lock);
-       ret = __run_threaded_test(info);
-       mutex_unlock(&info->lock);
-       return ret;
+       /* Copy test parameters */
+       params->buf_size = test_buf_size;
+       strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
+       strlcpy(params->device, strim(test_device), sizeof(params->device));
+       params->threads_per_chan = threads_per_chan;
+       params->max_channels = max_channels;
+       params->iterations = iterations;
+       params->xor_sources = xor_sources;
+       params->pq_sources = pq_sources;
+       params->timeout = timeout;
+       params->noverify = noverify;
+       request_channels(info, DMA_MEMCPY);
+       request_channels(info, DMA_XOR);
+       request_channels(info, DMA_PQ);
  }
- #endif
  
- static void __stop_threaded_test(struct dmatest_info *info)
+ static void stop_threaded_test(struct dmatest_info *info)
  {
        struct dmatest_chan *dtc, *_dtc;
        struct dma_chan *chan;
                list_del(&dtc->node);
                chan = dtc->chan;
                dmatest_cleanup_channel(dtc);
-               pr_debug("dmatest: dropped channel %s\n", dma_chan_name(chan));
+               pr_debug("dropped channel %s\n", dma_chan_name(chan));
                dma_release_channel(chan);
        }
  
        info->nr_channels = 0;
  }
  
- static void stop_threaded_test(struct dmatest_info *info)
+ static void restart_threaded_test(struct dmatest_info *info, bool run)
  {
-       mutex_lock(&info->lock);
-       __stop_threaded_test(info);
-       mutex_unlock(&info->lock);
- }
- static int __restart_threaded_test(struct dmatest_info *info, bool run)
- {
-       struct dmatest_params *params = &info->params;
+       /* we might be called early to set run=, defer running until all
+        * parameters have been evaluated
+        */
+       if (!info->did_init)
+               return;
  
        /* Stop any running test first */
-       __stop_threaded_test(info);
-       if (run == false)
-               return 0;
-       /* Clear results from previous run */
-       result_free(info, NULL);
-       /* Copy test parameters */
-       params->buf_size = test_buf_size;
-       strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
-       strlcpy(params->device, strim(test_device), sizeof(params->device));
-       params->threads_per_chan = threads_per_chan;
-       params->max_channels = max_channels;
-       params->iterations = iterations;
-       params->xor_sources = xor_sources;
-       params->pq_sources = pq_sources;
-       params->timeout = timeout;
+       stop_threaded_test(info);
  
        /* Run test with new parameters */
-       return __run_threaded_test(info);
- }
- static bool __is_threaded_test_run(struct dmatest_info *info)
- {
-       struct dmatest_chan *dtc;
-       list_for_each_entry(dtc, &info->channels, node) {
-               struct dmatest_thread *thread;
-               list_for_each_entry(thread, &dtc->threads, node) {
-                       if (!thread->done)
-                               return true;
-               }
-       }
-       return false;
+       run_threaded_test(info);
  }
  
- static ssize_t dtf_read_run(struct file *file, char __user *user_buf,
-               size_t count, loff_t *ppos)
+ static int dmatest_run_get(char *val, const struct kernel_param *kp)
  {
-       struct dmatest_info *info = file->private_data;
-       char buf[3];
+       struct dmatest_info *info = &test_info;
  
        mutex_lock(&info->lock);
-       if (__is_threaded_test_run(info)) {
-               buf[0] = 'Y';
+       if (is_threaded_test_run(info)) {
+               dmatest_run = true;
        } else {
-               __stop_threaded_test(info);
-               buf[0] = 'N';
+               stop_threaded_test(info);
+               dmatest_run = false;
        }
        mutex_unlock(&info->lock);
-       buf[1] = '\n';
-       buf[2] = 0x00;
-       return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
- }
- static ssize_t dtf_write_run(struct file *file, const char __user *user_buf,
-               size_t count, loff_t *ppos)
- {
-       struct dmatest_info *info = file->private_data;
-       char buf[16];
-       bool bv;
-       int ret = 0;
  
-       if (copy_from_user(buf, user_buf, min(count, (sizeof(buf) - 1))))
-               return -EFAULT;
-       if (strtobool(buf, &bv) == 0) {
-               mutex_lock(&info->lock);
-               if (__is_threaded_test_run(info))
-                       ret = -EBUSY;
-               else
-                       ret = __restart_threaded_test(info, bv);
-               mutex_unlock(&info->lock);
-       }
-       return ret ? ret : count;
+       return param_get_bool(val, kp);
  }
  
- static const struct file_operations dtf_run_fops = {
-       .read   = dtf_read_run,
-       .write  = dtf_write_run,
-       .open   = simple_open,
-       .llseek = default_llseek,
- };
- static int dtf_results_show(struct seq_file *sf, void *data)
+ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
  {
-       struct dmatest_info *info = sf->private;
-       struct dmatest_result *result;
-       struct dmatest_thread_result *tr;
-       unsigned int i;
+       struct dmatest_info *info = &test_info;
+       int ret;
  
-       mutex_lock(&info->results_lock);
-       list_for_each_entry(result, &info->results, node) {
-               list_for_each_entry(tr, &result->results, node) {
-                       seq_printf(sf, "%s\n",
-                               thread_result_get(result->name, tr));
-                       if (tr->type == DMATEST_ET_VERIFY_BUF) {
-                               for (i = 0; i < tr->vr->error_count; i++) {
-                                       seq_printf(sf, "\t%s\n",
-                                               verify_result_get_one(tr->vr, i));
-                               }
-                       }
-               }
+       mutex_lock(&info->lock);
+       ret = param_set_bool(val, kp);
+       if (ret) {
+               mutex_unlock(&info->lock);
+               return ret;
        }
  
-       mutex_unlock(&info->results_lock);
-       return 0;
- }
- static int dtf_results_open(struct inode *inode, struct file *file)
- {
-       return single_open(file, dtf_results_show, inode->i_private);
- }
- static const struct file_operations dtf_results_fops = {
-       .open           = dtf_results_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
- };
- static int dmatest_register_dbgfs(struct dmatest_info *info)
- {
-       struct dentry *d;
-       d = debugfs_create_dir("dmatest", NULL);
-       if (IS_ERR(d))
-               return PTR_ERR(d);
-       if (!d)
-               goto err_root;
+       if (is_threaded_test_run(info))
+               ret = -EBUSY;
+       else if (dmatest_run)
+               restart_threaded_test(info, dmatest_run);
  
-       info->root = d;
-       /* Run or stop threaded test */
-       debugfs_create_file("run", S_IWUSR | S_IRUGO, info->root, info,
-                           &dtf_run_fops);
-       /* Results of test in progress */
-       debugfs_create_file("results", S_IRUGO, info->root, info,
-                           &dtf_results_fops);
-       return 0;
+       mutex_unlock(&info->lock);
  
- err_root:
-       pr_err("dmatest: Failed to initialize debugfs\n");
-       return -ENOMEM;
+       return ret;
  }
  
  static int __init dmatest_init(void)
  {
        struct dmatest_info *info = &test_info;
-       int ret;
-       memset(info, 0, sizeof(*info));
+       struct dmatest_params *params = &info->params;
  
-       mutex_init(&info->lock);
-       INIT_LIST_HEAD(&info->channels);
+       if (dmatest_run) {
+               mutex_lock(&info->lock);
+               run_threaded_test(info);
+               mutex_unlock(&info->lock);
+       }
  
-       mutex_init(&info->results_lock);
-       INIT_LIST_HEAD(&info->results);
+       if (params->iterations && wait)
+               wait_event(thread_wait, !is_threaded_test_run(info));
  
-       ret = dmatest_register_dbgfs(info);
-       if (ret)
-               return ret;
+       /* module parameters are stable, inittime tests are started,
+        * let userspace take over 'run' control
+        */
+       info->did_init = true;
  
- #ifdef MODULE
        return 0;
- #else
-       return run_threaded_test(info);
- #endif
  }
  /* when compiled-in wait for drivers to load first */
  late_initcall(dmatest_init);
@@@ -1189,9 -976,9 +976,9 @@@ static void __exit dmatest_exit(void
  {
        struct dmatest_info *info = &test_info;
  
-       debugfs_remove_recursive(info->root);
+       mutex_lock(&info->lock);
        stop_threaded_test(info);
-       result_free(info, NULL);
+       mutex_unlock(&info->lock);
  }
  module_exit(dmatest_exit);
  
diff --combined drivers/dma/dw/core.c
index 2c29331571e4a142f2f2b965a15ebbc26657bb2a,1f39ccce2727957ccb057af88e196fba4fca19ab..7516be4677cf7e778ba3bef2482cae9179ff41a3
@@@ -85,10 -85,6 +85,6 @@@ static struct device *chan2dev(struct d
  {
        return &chan->dev->device;
  }
- static struct device *chan2parent(struct dma_chan *chan)
- {
-       return chan->dev->device.parent;
- }
  
  static struct dw_desc *dwc_first_active(struct dw_dma_chan *dwc)
  {
@@@ -311,26 -307,7 +307,7 @@@ dwc_descriptor_complete(struct dw_dma_c
        list_splice_init(&desc->tx_list, &dwc->free_list);
        list_move(&desc->desc_node, &dwc->free_list);
  
-       if (!is_slave_direction(dwc->direction)) {
-               struct device *parent = chan2parent(&dwc->chan);
-               if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                       if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE)
-                               dma_unmap_single(parent, desc->lli.dar,
-                                       desc->total_len, DMA_FROM_DEVICE);
-                       else
-                               dma_unmap_page(parent, desc->lli.dar,
-                                       desc->total_len, DMA_FROM_DEVICE);
-               }
-               if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       if (txd->flags & DMA_COMPL_SRC_UNMAP_SINGLE)
-                               dma_unmap_single(parent, desc->lli.sar,
-                                       desc->total_len, DMA_TO_DEVICE);
-                       else
-                               dma_unmap_page(parent, desc->lli.sar,
-                                       desc->total_len, DMA_TO_DEVICE);
-               }
-       }
+       dma_descriptor_unmap(txd);
        spin_unlock_irqrestore(&dwc->lock, flags);
  
        if (callback)
@@@ -1098,13 -1075,13 +1075,13 @@@ dwc_tx_status(struct dma_chan *chan
        enum dma_status         ret;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret != DMA_SUCCESS)
 +      if (ret != DMA_COMPLETE)
                dma_set_residue(txstate, dwc_get_residue(dwc));
  
        if (dwc->paused && ret == DMA_IN_PROGRESS)
diff --combined drivers/dma/fsldma.c
index 4e898121707b4051ac077568b5a732145c9c4ae8,d9e6381b2b1624f523f7e90754433fecaf702947..bd7f888b760143361d4a7889b1783a0c3cb82d28
@@@ -868,22 -868,7 +868,7 @@@ static void fsldma_cleanup_descriptor(s
        /* Run any dependencies */
        dma_run_dependencies(txd);
  
-       /* Unmap the dst buffer, if requested */
-       if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-               if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE)
-                       dma_unmap_single(dev, dst, len, DMA_FROM_DEVICE);
-               else
-                       dma_unmap_page(dev, dst, len, DMA_FROM_DEVICE);
-       }
-       /* Unmap the src buffer, if requested */
-       if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-               if (txd->flags & DMA_COMPL_SRC_UNMAP_SINGLE)
-                       dma_unmap_single(dev, src, len, DMA_TO_DEVICE);
-               else
-                       dma_unmap_page(dev, src, len, DMA_TO_DEVICE);
-       }
+       dma_descriptor_unmap(txd);
  #ifdef FSL_DMA_LD_DEBUG
        chan_dbg(chan, "LD %p free\n", desc);
  #endif
@@@ -1253,9 -1238,7 +1238,9 @@@ static int fsl_dma_chan_probe(struct fs
        WARN_ON(fdev->feature != chan->feature);
  
        chan->dev = fdev->dev;
 -      chan->id = ((res.start - 0x100) & 0xfff) >> 7;
 +      chan->id = (res.start & 0xfff) < 0x300 ?
 +                 ((res.start - 0x100) & 0xfff) >> 7 :
 +                 ((res.start - 0x200) & 0xfff) >> 7;
        if (chan->id >= FSL_DMA_MAX_CHANS_PER_DEVICE) {
                dev_err(fdev->dev, "too many channels for device\n");
                err = -EINVAL;
@@@ -1428,7 -1411,6 +1413,7 @@@ static int fsldma_of_remove(struct plat
  }
  
  static const struct of_device_id fsldma_of_ids[] = {
 +      { .compatible = "fsl,elo3-dma", },
        { .compatible = "fsl,eloplus-dma", },
        { .compatible = "fsl,elo-dma", },
        {}
@@@ -1450,7 -1432,7 +1435,7 @@@ static struct platform_driver fsldma_of
  
  static __init int fsldma_init(void)
  {
 -      pr_info("Freescale Elo / Elo Plus DMA driver\n");
 +      pr_info("Freescale Elo series DMA driver\n");
        return platform_driver_register(&fsldma_of_driver);
  }
  
@@@ -1462,5 -1444,5 +1447,5 @@@ static void __exit fsldma_exit(void
  subsys_initcall(fsldma_init);
  module_exit(fsldma_exit);
  
 -MODULE_DESCRIPTION("Freescale Elo / Elo Plus DMA driver");
 +MODULE_DESCRIPTION("Freescale Elo series DMA driver");
  MODULE_LICENSE("GPL");
diff --combined drivers/dma/ioat/dma.c
index a0f0fce5a84e1aefc27dadeea28cbca528cb8f85,4f67473f3b8143face0c4a7aea6a1ba05ead0f31..1a49c777607c50d313482f3ead21c19572a1cf8d
@@@ -531,21 -531,6 +531,6 @@@ static void ioat1_cleanup_event(unsigne
        writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
  }
  
- void ioat_dma_unmap(struct ioat_chan_common *chan, enum dma_ctrl_flags flags,
-                   size_t len, struct ioat_dma_descriptor *hw)
- {
-       struct pci_dev *pdev = chan->device->pdev;
-       size_t offset = len - hw->size;
-       if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP))
-               ioat_unmap(pdev, hw->dst_addr - offset, len,
-                          PCI_DMA_FROMDEVICE, flags, 1);
-       if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP))
-               ioat_unmap(pdev, hw->src_addr - offset, len,
-                          PCI_DMA_TODEVICE, flags, 0);
- }
  dma_addr_t ioat_get_current_completion(struct ioat_chan_common *chan)
  {
        dma_addr_t phys_complete;
@@@ -602,7 -587,7 +587,7 @@@ static void __cleanup(struct ioat_dma_c
                dump_desc_dbg(ioat, desc);
                if (tx->cookie) {
                        dma_cookie_complete(tx);
-                       ioat_dma_unmap(chan, tx->flags, desc->len, desc->hw);
+                       dma_descriptor_unmap(tx);
                        ioat->active -= desc->hw->tx_cnt;
                        if (tx->callback) {
                                tx->callback(tx->callback_param);
@@@ -733,7 -718,7 +718,7 @@@ ioat_dma_tx_status(struct dma_chan *c, 
        enum dma_status ret;
  
        ret = dma_cookie_status(c, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        device->cleanup_fn((unsigned long) c);
@@@ -833,8 -818,7 +818,7 @@@ int ioat_dma_self_test(struct ioatdma_d
  
        dma_src = dma_map_single(dev, src, IOAT_TEST_SIZE, DMA_TO_DEVICE);
        dma_dest = dma_map_single(dev, dest, IOAT_TEST_SIZE, DMA_FROM_DEVICE);
-       flags = DMA_COMPL_SKIP_SRC_UNMAP | DMA_COMPL_SKIP_DEST_UNMAP |
-               DMA_PREP_INTERRUPT;
+       flags = DMA_PREP_INTERRUPT;
        tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src,
                                                   IOAT_TEST_SIZE, flags);
        if (!tx) {
  
        if (tmo == 0 ||
            dma->device_tx_status(dma_chan, cookie, NULL)
 -                                      != DMA_SUCCESS) {
 +                                      != DMA_COMPLETE) {
                dev_err(dev, "Self-test copy timed out, disabling\n");
                err = -ENODEV;
                goto unmap_dma;
@@@ -885,8 -869,7 +869,7 @@@ static char ioat_interrupt_style[32] = 
  module_param_string(ioat_interrupt_style, ioat_interrupt_style,
                    sizeof(ioat_interrupt_style), 0644);
  MODULE_PARM_DESC(ioat_interrupt_style,
-                "set ioat interrupt style: msix (default), "
-                "msix-single-vector, msi, intx)");
+                "set ioat interrupt style: msix (default), msi, intx");
  
  /**
   * ioat_dma_setup_interrupts - setup interrupt handler
@@@ -904,8 -887,6 +887,6 @@@ int ioat_dma_setup_interrupts(struct io
  
        if (!strcmp(ioat_interrupt_style, "msix"))
                goto msix;
-       if (!strcmp(ioat_interrupt_style, "msix-single-vector"))
-               goto msix_single_vector;
        if (!strcmp(ioat_interrupt_style, "msi"))
                goto msi;
        if (!strcmp(ioat_interrupt_style, "intx"))
@@@ -920,10 -901,8 +901,8 @@@ msix
                device->msix_entries[i].entry = i;
  
        err = pci_enable_msix(pdev, device->msix_entries, msixcnt);
-       if (err < 0)
+       if (err)
                goto msi;
-       if (err > 0)
-               goto msix_single_vector;
  
        for (i = 0; i < msixcnt; i++) {
                msix = &device->msix_entries[i];
                                chan = ioat_chan_by_index(device, j);
                                devm_free_irq(dev, msix->vector, chan);
                        }
-                       goto msix_single_vector;
+                       goto msi;
                }
        }
        intrctrl |= IOAT_INTRCTRL_MSIX_VECTOR_CONTROL;
        device->irq_mode = IOAT_MSIX;
        goto done;
  
- msix_single_vector:
-       msix = &device->msix_entries[0];
-       msix->entry = 0;
-       err = pci_enable_msix(pdev, device->msix_entries, 1);
-       if (err)
-               goto msi;
-       err = devm_request_irq(dev, msix->vector, ioat_dma_do_interrupt, 0,
-                              "ioat-msix", device);
-       if (err) {
-               pci_disable_msix(pdev);
-               goto msi;
-       }
-       device->irq_mode = IOAT_MSIX_SINGLE;
-       goto done;
  msi:
        err = pci_enable_msi(pdev);
        if (err)
                pci_disable_msi(pdev);
                goto intx;
        }
-       device->irq_mode = IOAT_MSIX;
+       device->irq_mode = IOAT_MSI;
        goto done;
  
  intx:
index 806b4ce5e38c79d84a5d759b108798dbd8b3b22a,915b1f66f2daa72e399a01b6af1e86b080a75098..820817e97e626a498561a9e5f0f3a61f22ffc9fa
@@@ -67,6 -67,8 +67,8 @@@
  #include "dma.h"
  #include "dma_v2.h"
  
+ extern struct kmem_cache *ioat3_sed_cache;
  /* ioat hardware assumes at least two sources for raid operations */
  #define src_cnt_to_sw(x) ((x) + 2)
  #define src_cnt_to_hw(x) ((x) - 2)
@@@ -87,22 -89,8 +89,8 @@@ static const u8 pq_idx_to_field[] = { 1
  static const u8 pq16_idx_to_field[] = { 1, 4, 1, 2, 3, 4, 5, 6, 7,
                                        0, 1, 2, 3, 4, 5, 6 };
  
- /*
-  * technically sources 1 and 2 do not require SED, but the op will have
-  * at least 9 descriptors so that's irrelevant.
-  */
- static const u8 pq16_idx_to_sed[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,
-                                     1, 1, 1, 1, 1, 1, 1 };
  static void ioat3_eh(struct ioat2_dma_chan *ioat);
  
- static dma_addr_t xor_get_src(struct ioat_raw_descriptor *descs[2], int idx)
- {
-       struct ioat_raw_descriptor *raw = descs[xor_idx_to_desc >> idx & 1];
-       return raw->field[xor_idx_to_field[idx]];
- }
  static void xor_set_src(struct ioat_raw_descriptor *descs[2],
                        dma_addr_t addr, u32 offset, int idx)
  {
@@@ -135,12 -123,6 +123,6 @@@ static void pq_set_src(struct ioat_raw_
        pq->coef[idx] = coef;
  }
  
- static int sed_get_pq16_pool_idx(int src_cnt)
- {
-       return pq16_idx_to_sed[src_cnt];
- }
  static bool is_jf_ioat(struct pci_dev *pdev)
  {
        switch (pdev->device) {
@@@ -272,7 -254,7 +254,7 @@@ ioat3_alloc_sed(struct ioatdma_device *
        struct ioat_sed_ent *sed;
        gfp_t flags = __GFP_ZERO | GFP_ATOMIC;
  
-       sed = kmem_cache_alloc(device->sed_pool, flags);
+       sed = kmem_cache_alloc(ioat3_sed_cache, flags);
        if (!sed)
                return NULL;
  
        sed->hw = dma_pool_alloc(device->sed_hw_pool[hw_pool],
                                 flags, &sed->dma);
        if (!sed->hw) {
-               kmem_cache_free(device->sed_pool, sed);
+               kmem_cache_free(ioat3_sed_cache, sed);
                return NULL;
        }
  
@@@ -293,165 -275,7 +275,7 @@@ static void ioat3_free_sed(struct ioatd
                return;
  
        dma_pool_free(device->sed_hw_pool[sed->hw_pool], sed->hw, sed->dma);
-       kmem_cache_free(device->sed_pool, sed);
- }
- static void ioat3_dma_unmap(struct ioat2_dma_chan *ioat,
-                           struct ioat_ring_ent *desc, int idx)
- {
-       struct ioat_chan_common *chan = &ioat->base;
-       struct pci_dev *pdev = chan->device->pdev;
-       size_t len = desc->len;
-       size_t offset = len - desc->hw->size;
-       struct dma_async_tx_descriptor *tx = &desc->txd;
-       enum dma_ctrl_flags flags = tx->flags;
-       switch (desc->hw->ctl_f.op) {
-       case IOAT_OP_COPY:
-               if (!desc->hw->ctl_f.null) /* skip 'interrupt' ops */
-                       ioat_dma_unmap(chan, flags, len, desc->hw);
-               break;
-       case IOAT_OP_XOR_VAL:
-       case IOAT_OP_XOR: {
-               struct ioat_xor_descriptor *xor = desc->xor;
-               struct ioat_ring_ent *ext;
-               struct ioat_xor_ext_descriptor *xor_ex = NULL;
-               int src_cnt = src_cnt_to_sw(xor->ctl_f.src_cnt);
-               struct ioat_raw_descriptor *descs[2];
-               int i;
-               if (src_cnt > 5) {
-                       ext = ioat2_get_ring_ent(ioat, idx + 1);
-                       xor_ex = ext->xor_ex;
-               }
-               if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       descs[0] = (struct ioat_raw_descriptor *) xor;
-                       descs[1] = (struct ioat_raw_descriptor *) xor_ex;
-                       for (i = 0; i < src_cnt; i++) {
-                               dma_addr_t src = xor_get_src(descs, i);
-                               ioat_unmap(pdev, src - offset, len,
-                                          PCI_DMA_TODEVICE, flags, 0);
-                       }
-                       /* dest is a source in xor validate operations */
-                       if (xor->ctl_f.op == IOAT_OP_XOR_VAL) {
-                               ioat_unmap(pdev, xor->dst_addr - offset, len,
-                                          PCI_DMA_TODEVICE, flags, 1);
-                               break;
-                       }
-               }
-               if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP))
-                       ioat_unmap(pdev, xor->dst_addr - offset, len,
-                                  PCI_DMA_FROMDEVICE, flags, 1);
-               break;
-       }
-       case IOAT_OP_PQ_VAL:
-       case IOAT_OP_PQ: {
-               struct ioat_pq_descriptor *pq = desc->pq;
-               struct ioat_ring_ent *ext;
-               struct ioat_pq_ext_descriptor *pq_ex = NULL;
-               int src_cnt = src_cnt_to_sw(pq->ctl_f.src_cnt);
-               struct ioat_raw_descriptor *descs[2];
-               int i;
-               if (src_cnt > 3) {
-                       ext = ioat2_get_ring_ent(ioat, idx + 1);
-                       pq_ex = ext->pq_ex;
-               }
-               /* in the 'continue' case don't unmap the dests as sources */
-               if (dmaf_p_disabled_continue(flags))
-                       src_cnt--;
-               else if (dmaf_continue(flags))
-                       src_cnt -= 3;
-               if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       descs[0] = (struct ioat_raw_descriptor *) pq;
-                       descs[1] = (struct ioat_raw_descriptor *) pq_ex;
-                       for (i = 0; i < src_cnt; i++) {
-                               dma_addr_t src = pq_get_src(descs, i);
-                               ioat_unmap(pdev, src - offset, len,
-                                          PCI_DMA_TODEVICE, flags, 0);
-                       }
-                       /* the dests are sources in pq validate operations */
-                       if (pq->ctl_f.op == IOAT_OP_XOR_VAL) {
-                               if (!(flags & DMA_PREP_PQ_DISABLE_P))
-                                       ioat_unmap(pdev, pq->p_addr - offset,
-                                                  len, PCI_DMA_TODEVICE, flags, 0);
-                               if (!(flags & DMA_PREP_PQ_DISABLE_Q))
-                                       ioat_unmap(pdev, pq->q_addr - offset,
-                                                  len, PCI_DMA_TODEVICE, flags, 0);
-                               break;
-                       }
-               }
-               if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                       if (!(flags & DMA_PREP_PQ_DISABLE_P))
-                               ioat_unmap(pdev, pq->p_addr - offset, len,
-                                          PCI_DMA_BIDIRECTIONAL, flags, 1);
-                       if (!(flags & DMA_PREP_PQ_DISABLE_Q))
-                               ioat_unmap(pdev, pq->q_addr - offset, len,
-                                          PCI_DMA_BIDIRECTIONAL, flags, 1);
-               }
-               break;
-       }
-       case IOAT_OP_PQ_16S:
-       case IOAT_OP_PQ_VAL_16S: {
-               struct ioat_pq_descriptor *pq = desc->pq;
-               int src_cnt = src16_cnt_to_sw(pq->ctl_f.src_cnt);
-               struct ioat_raw_descriptor *descs[4];
-               int i;
-               /* in the 'continue' case don't unmap the dests as sources */
-               if (dmaf_p_disabled_continue(flags))
-                       src_cnt--;
-               else if (dmaf_continue(flags))
-                       src_cnt -= 3;
-               if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       descs[0] = (struct ioat_raw_descriptor *)pq;
-                       descs[1] = (struct ioat_raw_descriptor *)(desc->sed->hw);
-                       descs[2] = (struct ioat_raw_descriptor *)(&desc->sed->hw->b[0]);
-                       for (i = 0; i < src_cnt; i++) {
-                               dma_addr_t src = pq16_get_src(descs, i);
-                               ioat_unmap(pdev, src - offset, len,
-                                          PCI_DMA_TODEVICE, flags, 0);
-                       }
-                       /* the dests are sources in pq validate operations */
-                       if (pq->ctl_f.op == IOAT_OP_XOR_VAL) {
-                               if (!(flags & DMA_PREP_PQ_DISABLE_P))
-                                       ioat_unmap(pdev, pq->p_addr - offset,
-                                                  len, PCI_DMA_TODEVICE,
-                                                  flags, 0);
-                               if (!(flags & DMA_PREP_PQ_DISABLE_Q))
-                                       ioat_unmap(pdev, pq->q_addr - offset,
-                                                  len, PCI_DMA_TODEVICE,
-                                                  flags, 0);
-                               break;
-                       }
-               }
-               if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                       if (!(flags & DMA_PREP_PQ_DISABLE_P))
-                               ioat_unmap(pdev, pq->p_addr - offset, len,
-                                          PCI_DMA_BIDIRECTIONAL, flags, 1);
-                       if (!(flags & DMA_PREP_PQ_DISABLE_Q))
-                               ioat_unmap(pdev, pq->q_addr - offset, len,
-                                          PCI_DMA_BIDIRECTIONAL, flags, 1);
-               }
-               break;
-       }
-       default:
-               dev_err(&pdev->dev, "%s: unknown op type: %#x\n",
-                       __func__, desc->hw->ctl_f.op);
-       }
+       kmem_cache_free(ioat3_sed_cache, sed);
  }
  
  static bool desc_has_ext(struct ioat_ring_ent *desc)
@@@ -577,7 -401,7 +401,7 @@@ static void __cleanup(struct ioat2_dma_
                tx = &desc->txd;
                if (tx->cookie) {
                        dma_cookie_complete(tx);
-                       ioat3_dma_unmap(ioat, desc, idx + i);
+                       dma_descriptor_unmap(tx);
                        if (tx->callback) {
                                tx->callback(tx->callback_param);
                                tx->callback = NULL;
@@@ -807,7 -631,7 +631,7 @@@ ioat3_tx_status(struct dma_chan *c, dma
        enum dma_status ret;
  
        ret = dma_cookie_status(c, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        ioat3_cleanup(ioat);
@@@ -1129,9 -953,6 +953,6 @@@ __ioat3_prep_pq16_lock(struct dma_chan 
        u8 op;
        int i, s, idx, num_descs;
  
-       /* this function only handles src_cnt 9 - 16 */
-       BUG_ON(src_cnt < 9);
        /* this function is only called with 9-16 sources */
        op = result ? IOAT_OP_PQ_VAL_16S : IOAT_OP_PQ_16S;
  
  
                descs[0] = (struct ioat_raw_descriptor *) pq;
  
-               desc->sed = ioat3_alloc_sed(device,
-                                           sed_get_pq16_pool_idx(src_cnt));
+               desc->sed = ioat3_alloc_sed(device, (src_cnt-2) >> 3);
                if (!desc->sed) {
                        dev_err(to_dev(chan),
                                "%s: no free sed entries\n", __func__);
        return &desc->txd;
  }
  
+ static int src_cnt_flags(unsigned int src_cnt, unsigned long flags)
+ {
+       if (dmaf_p_disabled_continue(flags))
+               return src_cnt + 1;
+       else if (dmaf_continue(flags))
+               return src_cnt + 3;
+       else
+               return src_cnt;
+ }
  static struct dma_async_tx_descriptor *
  ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
              unsigned int src_cnt, const unsigned char *scf, size_t len,
              unsigned long flags)
  {
-       struct dma_device *dma = chan->device;
        /* specify valid address for disabled result */
        if (flags & DMA_PREP_PQ_DISABLE_P)
                dst[0] = dst[1];
                single_source_coef[0] = scf[0];
                single_source_coef[1] = 0;
  
-               return (src_cnt > 8) && (dma->max_pq > 8) ?
+               return src_cnt_flags(src_cnt, flags) > 8 ?
                        __ioat3_prep_pq16_lock(chan, NULL, dst, single_source,
                                               2, single_source_coef, len,
                                               flags) :
                                             single_source_coef, len, flags);
  
        } else {
-               return (src_cnt > 8) && (dma->max_pq > 8) ?
+               return src_cnt_flags(src_cnt, flags) > 8 ?
                        __ioat3_prep_pq16_lock(chan, NULL, dst, src, src_cnt,
                                               scf, len, flags) :
                        __ioat3_prep_pq_lock(chan, NULL, dst, src, src_cnt,
@@@ -1265,8 -1093,6 +1093,6 @@@ ioat3_prep_pq_val(struct dma_chan *chan
                  unsigned int src_cnt, const unsigned char *scf, size_t len,
                  enum sum_check_flags *pqres, unsigned long flags)
  {
-       struct dma_device *dma = chan->device;
        /* specify valid address for disabled result */
        if (flags & DMA_PREP_PQ_DISABLE_P)
                pq[0] = pq[1];
         */
        *pqres = 0;
  
-       return (src_cnt > 8) && (dma->max_pq > 8) ?
+       return src_cnt_flags(src_cnt, flags) > 8 ?
                __ioat3_prep_pq16_lock(chan, pqres, pq, src, src_cnt, scf, len,
                                       flags) :
                __ioat3_prep_pq_lock(chan, pqres, pq, src, src_cnt, scf, len,
@@@ -1289,7 -1115,6 +1115,6 @@@ static struct dma_async_tx_descriptor 
  ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
                 unsigned int src_cnt, size_t len, unsigned long flags)
  {
-       struct dma_device *dma = chan->device;
        unsigned char scf[src_cnt];
        dma_addr_t pq[2];
  
        flags |= DMA_PREP_PQ_DISABLE_Q;
        pq[1] = dst; /* specify valid address for disabled result */
  
-       return (src_cnt > 8) && (dma->max_pq > 8) ?
+       return src_cnt_flags(src_cnt, flags) > 8 ?
                __ioat3_prep_pq16_lock(chan, NULL, pq, src, src_cnt, scf, len,
                                       flags) :
                __ioat3_prep_pq_lock(chan, NULL, pq, src, src_cnt, scf, len,
@@@ -1310,7 -1135,6 +1135,6 @@@ ioat3_prep_pqxor_val(struct dma_chan *c
                     unsigned int src_cnt, size_t len,
                     enum sum_check_flags *result, unsigned long flags)
  {
-       struct dma_device *dma = chan->device;
        unsigned char scf[src_cnt];
        dma_addr_t pq[2];
  
        flags |= DMA_PREP_PQ_DISABLE_Q;
        pq[1] = pq[0]; /* specify valid address for disabled result */
  
-       return (src_cnt > 8) && (dma->max_pq > 8) ?
+       return src_cnt_flags(src_cnt, flags) > 8 ?
                __ioat3_prep_pq16_lock(chan, result, pq, &src[1], src_cnt - 1,
                                       scf, len, flags) :
                __ioat3_prep_pq_lock(chan, result, pq, &src[1], src_cnt - 1,
@@@ -1444,9 -1267,7 +1267,7 @@@ static int ioat_xor_val_self_test(struc
                                           DMA_TO_DEVICE);
        tx = dma->device_prep_dma_xor(dma_chan, dest_dma, dma_srcs,
                                      IOAT_NUM_SRC_TEST, PAGE_SIZE,
-                                     DMA_PREP_INTERRUPT |
-                                     DMA_COMPL_SKIP_SRC_UNMAP |
-                                     DMA_COMPL_SKIP_DEST_UNMAP);
+                                     DMA_PREP_INTERRUPT);
  
        if (!tx) {
                dev_err(dev, "Self-test xor prep failed\n");
  
        tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000));
  
 -      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 +      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) {
                dev_err(dev, "Self-test xor timed out\n");
                err = -ENODEV;
                goto dma_unmap;
                                           DMA_TO_DEVICE);
        tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs,
                                          IOAT_NUM_SRC_TEST + 1, PAGE_SIZE,
-                                         &xor_val_result, DMA_PREP_INTERRUPT |
-                                         DMA_COMPL_SKIP_SRC_UNMAP |
-                                         DMA_COMPL_SKIP_DEST_UNMAP);
+                                         &xor_val_result, DMA_PREP_INTERRUPT);
        if (!tx) {
                dev_err(dev, "Self-test zero prep failed\n");
                err = -ENODEV;
  
        tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000));
  
 -      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 +      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) {
                dev_err(dev, "Self-test validate timed out\n");
                err = -ENODEV;
                goto dma_unmap;
                goto free_resources;
        }
  
+       memset(page_address(dest), 0, PAGE_SIZE);
        /* test for non-zero parity sum */
        op = IOAT_OP_XOR_VAL;
  
                                           DMA_TO_DEVICE);
        tx = dma->device_prep_dma_xor_val(dma_chan, dma_srcs,
                                          IOAT_NUM_SRC_TEST + 1, PAGE_SIZE,
-                                         &xor_val_result, DMA_PREP_INTERRUPT |
-                                         DMA_COMPL_SKIP_SRC_UNMAP |
-                                         DMA_COMPL_SKIP_DEST_UNMAP);
+                                         &xor_val_result, DMA_PREP_INTERRUPT);
        if (!tx) {
                dev_err(dev, "Self-test 2nd zero prep failed\n");
                err = -ENODEV;
  
        tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000));
  
 -      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 +      if (dma->device_tx_status(dma_chan, cookie, NULL) != DMA_COMPLETE) {
                dev_err(dev, "Self-test 2nd validate timed out\n");
                err = -ENODEV;
                goto dma_unmap;
@@@ -1630,52 -1449,36 +1449,36 @@@ static int ioat3_dma_self_test(struct i
  
  static int ioat3_irq_reinit(struct ioatdma_device *device)
  {
-       int msixcnt = device->common.chancnt;
        struct pci_dev *pdev = device->pdev;
-       int i;
-       struct msix_entry *msix;
-       struct ioat_chan_common *chan;
-       int err = 0;
+       int irq = pdev->irq, i;
+       if (!is_bwd_ioat(pdev))
+               return 0;
  
        switch (device->irq_mode) {
        case IOAT_MSIX:
+               for (i = 0; i < device->common.chancnt; i++) {
+                       struct msix_entry *msix = &device->msix_entries[i];
+                       struct ioat_chan_common *chan;
  
-               for (i = 0; i < msixcnt; i++) {
-                       msix = &device->msix_entries[i];
                        chan = ioat_chan_by_index(device, i);
                        devm_free_irq(&pdev->dev, msix->vector, chan);
                }
  
                pci_disable_msix(pdev);
                break;
-       case IOAT_MSIX_SINGLE:
-               msix = &device->msix_entries[0];
-               chan = ioat_chan_by_index(device, 0);
-               devm_free_irq(&pdev->dev, msix->vector, chan);
-               pci_disable_msix(pdev);
-               break;
        case IOAT_MSI:
-               chan = ioat_chan_by_index(device, 0);
-               devm_free_irq(&pdev->dev, pdev->irq, chan);
                pci_disable_msi(pdev);
-               break;
+               /* fall through */
        case IOAT_INTX:
-               chan = ioat_chan_by_index(device, 0);
-               devm_free_irq(&pdev->dev, pdev->irq, chan);
+               devm_free_irq(&pdev->dev, irq, device);
                break;
        default:
                return 0;
        }
        device->irq_mode = IOAT_NOIRQ;
  
-       err = ioat_dma_setup_interrupts(device);
-       return err;
+       return ioat_dma_setup_interrupts(device);
  }
  
  static int ioat3_reset_hw(struct ioat_chan_common *chan)
        }
  
        err = ioat2_reset_sync(chan, msecs_to_jiffies(200));
-       if (err) {
-               dev_err(&pdev->dev, "Failed to reset!\n");
-               return err;
-       }
-       if (device->irq_mode != IOAT_NOIRQ && is_bwd_ioat(pdev))
+       if (!err)
                err = ioat3_irq_reinit(device);
  
+       if (err)
+               dev_err(&pdev->dev, "Failed to reset: %d\n", err);
        return err;
  }
  
@@@ -1835,21 -1636,15 +1636,15 @@@ int ioat3_dma_probe(struct ioatdma_devi
                char pool_name[14];
                int i;
  
-               /* allocate sw descriptor pool for SED */
-               device->sed_pool = kmem_cache_create("ioat_sed",
-                               sizeof(struct ioat_sed_ent), 0, 0, NULL);
-               if (!device->sed_pool)
-                       return -ENOMEM;
                for (i = 0; i < MAX_SED_POOLS; i++) {
                        snprintf(pool_name, 14, "ioat_hw%d_sed", i);
  
                        /* allocate SED DMA pool */
-                       device->sed_hw_pool[i] = dma_pool_create(pool_name,
+                       device->sed_hw_pool[i] = dmam_pool_create(pool_name,
                                        &pdev->dev,
                                        SED_SIZE * (i + 1), 64, 0);
                        if (!device->sed_hw_pool[i])
-                               goto sed_pool_cleanup;
+                               return -ENOMEM;
  
                }
        }
                device->dca = ioat3_dca_init(pdev, device->reg_base);
  
        return 0;
- sed_pool_cleanup:
-       if (device->sed_pool) {
-               int i;
-               kmem_cache_destroy(device->sed_pool);
-               for (i = 0; i < MAX_SED_POOLS; i++)
-                       if (device->sed_hw_pool[i])
-                               dma_pool_destroy(device->sed_hw_pool[i]);
-       }
-       return -ENOMEM;
- }
- void ioat3_dma_remove(struct ioatdma_device *device)
- {
-       if (device->sed_pool) {
-               int i;
-               kmem_cache_destroy(device->sed_pool);
-               for (i = 0; i < MAX_SED_POOLS; i++)
-                       if (device->sed_hw_pool[i])
-                               dma_pool_destroy(device->sed_hw_pool[i]);
-       }
  }
diff --combined drivers/dma/iop-adma.c
index 408fe6be15f4f394a1a3467e7822d92031af4ec3,173e26ff18f8a382b3fc4d4ef77e2219fe06638c..c56137bc3868da7cdc43bf38fab53a30ca410430
@@@ -61,80 -61,6 +61,6 @@@ static void iop_adma_free_slots(struct 
        }
  }
  
- static void
- iop_desc_unmap(struct iop_adma_chan *iop_chan, struct iop_adma_desc_slot *desc)
- {
-       struct dma_async_tx_descriptor *tx = &desc->async_tx;
-       struct iop_adma_desc_slot *unmap = desc->group_head;
-       struct device *dev = &iop_chan->device->pdev->dev;
-       u32 len = unmap->unmap_len;
-       enum dma_ctrl_flags flags = tx->flags;
-       u32 src_cnt;
-       dma_addr_t addr;
-       dma_addr_t dest;
-       src_cnt = unmap->unmap_src_cnt;
-       dest = iop_desc_get_dest_addr(unmap, iop_chan);
-       if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-               enum dma_data_direction dir;
-               if (src_cnt > 1) /* is xor? */
-                       dir = DMA_BIDIRECTIONAL;
-               else
-                       dir = DMA_FROM_DEVICE;
-               dma_unmap_page(dev, dest, len, dir);
-       }
-       if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-               while (src_cnt--) {
-                       addr = iop_desc_get_src_addr(unmap, iop_chan, src_cnt);
-                       if (addr == dest)
-                               continue;
-                       dma_unmap_page(dev, addr, len, DMA_TO_DEVICE);
-               }
-       }
-       desc->group_head = NULL;
- }
- static void
- iop_desc_unmap_pq(struct iop_adma_chan *iop_chan, struct iop_adma_desc_slot *desc)
- {
-       struct dma_async_tx_descriptor *tx = &desc->async_tx;
-       struct iop_adma_desc_slot *unmap = desc->group_head;
-       struct device *dev = &iop_chan->device->pdev->dev;
-       u32 len = unmap->unmap_len;
-       enum dma_ctrl_flags flags = tx->flags;
-       u32 src_cnt = unmap->unmap_src_cnt;
-       dma_addr_t pdest = iop_desc_get_dest_addr(unmap, iop_chan);
-       dma_addr_t qdest = iop_desc_get_qdest_addr(unmap, iop_chan);
-       int i;
-       if (tx->flags & DMA_PREP_CONTINUE)
-               src_cnt -= 3;
-       if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP) && !desc->pq_check_result) {
-               dma_unmap_page(dev, pdest, len, DMA_BIDIRECTIONAL);
-               dma_unmap_page(dev, qdest, len, DMA_BIDIRECTIONAL);
-       }
-       if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-               dma_addr_t addr;
-               for (i = 0; i < src_cnt; i++) {
-                       addr = iop_desc_get_src_addr(unmap, iop_chan, i);
-                       dma_unmap_page(dev, addr, len, DMA_TO_DEVICE);
-               }
-               if (desc->pq_check_result) {
-                       dma_unmap_page(dev, pdest, len, DMA_TO_DEVICE);
-                       dma_unmap_page(dev, qdest, len, DMA_TO_DEVICE);
-               }
-       }
-       desc->group_head = NULL;
- }
  static dma_cookie_t
  iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
        struct iop_adma_chan *iop_chan, dma_cookie_t cookie)
                if (tx->callback)
                        tx->callback(tx->callback_param);
  
-               /* unmap dma addresses
-                * (unmap_single vs unmap_page?)
-                */
-               if (desc->group_head && desc->unmap_len) {
-                       if (iop_desc_is_pq(desc))
-                               iop_desc_unmap_pq(iop_chan, desc);
-                       else
-                               iop_desc_unmap(iop_chan, desc);
-               }
+               dma_descriptor_unmap(tx);
+               if (desc->group_head)
+                       desc->group_head = NULL;
        }
  
        /* run dependent operations */
@@@ -591,7 -511,6 +511,6 @@@ iop_adma_prep_dma_interrupt(struct dma_
        if (sw_desc) {
                grp_start = sw_desc->group_head;
                iop_desc_init_interrupt(grp_start, iop_chan);
-               grp_start->unmap_len = 0;
                sw_desc->async_tx.flags = flags;
        }
        spin_unlock_bh(&iop_chan->lock);
@@@ -623,8 -542,6 +542,6 @@@ iop_adma_prep_dma_memcpy(struct dma_cha
                iop_desc_set_byte_count(grp_start, iop_chan, len);
                iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
                iop_desc_set_memcpy_src_addr(grp_start, dma_src);
-               sw_desc->unmap_src_cnt = 1;
-               sw_desc->unmap_len = len;
                sw_desc->async_tx.flags = flags;
        }
        spin_unlock_bh(&iop_chan->lock);
@@@ -657,8 -574,6 +574,6 @@@ iop_adma_prep_dma_xor(struct dma_chan *
                iop_desc_init_xor(grp_start, src_cnt, flags);
                iop_desc_set_byte_count(grp_start, iop_chan, len);
                iop_desc_set_dest_addr(grp_start, iop_chan, dma_dest);
-               sw_desc->unmap_src_cnt = src_cnt;
-               sw_desc->unmap_len = len;
                sw_desc->async_tx.flags = flags;
                while (src_cnt--)
                        iop_desc_set_xor_src_addr(grp_start, src_cnt,
@@@ -694,8 -609,6 +609,6 @@@ iop_adma_prep_dma_xor_val(struct dma_ch
                grp_start->xor_check_result = result;
                pr_debug("\t%s: grp_start->xor_check_result: %p\n",
                        __func__, grp_start->xor_check_result);
-               sw_desc->unmap_src_cnt = src_cnt;
-               sw_desc->unmap_len = len;
                sw_desc->async_tx.flags = flags;
                while (src_cnt--)
                        iop_desc_set_zero_sum_src_addr(grp_start, src_cnt,
@@@ -748,8 -661,6 +661,6 @@@ iop_adma_prep_dma_pq(struct dma_chan *c
                        dst[0] = dst[1] & 0x7;
  
                iop_desc_set_pq_addr(g, dst);
-               sw_desc->unmap_src_cnt = src_cnt;
-               sw_desc->unmap_len = len;
                sw_desc->async_tx.flags = flags;
                for (i = 0; i < src_cnt; i++)
                        iop_desc_set_pq_src_addr(g, i, src[i], scf[i]);
@@@ -804,8 -715,6 +715,6 @@@ iop_adma_prep_dma_pq_val(struct dma_cha
                g->pq_check_result = pqres;
                pr_debug("\t%s: g->pq_check_result: %p\n",
                        __func__, g->pq_check_result);
-               sw_desc->unmap_src_cnt = src_cnt+2;
-               sw_desc->unmap_len = len;
                sw_desc->async_tx.flags = flags;
                while (src_cnt--)
                        iop_desc_set_pq_zero_sum_src_addr(g, src_cnt,
@@@ -864,7 -773,7 +773,7 @@@ static enum dma_status iop_adma_status(
        int ret;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        iop_adma_slot_cleanup(iop_chan);
@@@ -983,7 -892,7 +892,7 @@@ static int iop_adma_memcpy_self_test(st
        msleep(1);
  
        if (iop_adma_status(dma_chan, cookie, NULL) !=
 -                      DMA_SUCCESS) {
 +                      DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test copy timed out, disabling\n");
                err = -ENODEV;
@@@ -1083,7 -992,7 +992,7 @@@ iop_adma_xor_val_self_test(struct iop_a
        msleep(8);
  
        if (iop_adma_status(dma_chan, cookie, NULL) !=
 -              DMA_SUCCESS) {
 +              DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test xor timed out, disabling\n");
                err = -ENODEV;
        iop_adma_issue_pending(dma_chan);
        msleep(8);
  
 -      if (iop_adma_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 +      if (iop_adma_status(dma_chan, cookie, NULL) != DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test zero sum timed out, disabling\n");
                err = -ENODEV;
        iop_adma_issue_pending(dma_chan);
        msleep(8);
  
 -      if (iop_adma_status(dma_chan, cookie, NULL) != DMA_SUCCESS) {
 +      if (iop_adma_status(dma_chan, cookie, NULL) != DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test non-zero sum timed out, disabling\n");
                err = -ENODEV;
@@@ -1254,7 -1163,7 +1163,7 @@@ iop_adma_pq_zero_sum_self_test(struct i
        msleep(8);
  
        if (iop_adma_status(dma_chan, cookie, NULL) !=
 -              DMA_SUCCESS) {
 +              DMA_COMPLETE) {
                dev_err(dev, "Self-test pq timed out, disabling\n");
                err = -ENODEV;
                goto free_resources;
        msleep(8);
  
        if (iop_adma_status(dma_chan, cookie, NULL) !=
 -              DMA_SUCCESS) {
 +              DMA_COMPLETE) {
                dev_err(dev, "Self-test pq-zero-sum timed out, disabling\n");
                err = -ENODEV;
                goto free_resources;
        msleep(8);
  
        if (iop_adma_status(dma_chan, cookie, NULL) !=
 -              DMA_SUCCESS) {
 +              DMA_COMPLETE) {
                dev_err(dev, "Self-test !pq-zero-sum timed out, disabling\n");
                err = -ENODEV;
                goto free_resources;
diff --combined drivers/dma/mv_xor.c
index 8d5bce9e867e4fc40225fe642019aa9cb47fb6c0,1b846d5d84088fa875ba8f88da90910d433adc1f..7807f0ef4e209c25ad90db9d32f7bc13955391cf
@@@ -60,14 -60,6 +60,6 @@@ static u32 mv_desc_get_dest_addr(struc
        return hw_desc->phy_dest_addr;
  }
  
- static u32 mv_desc_get_src_addr(struct mv_xor_desc_slot *desc,
-                               int src_idx)
- {
-       struct mv_xor_desc *hw_desc = desc->hw_desc;
-       return hw_desc->phy_src_addr[mv_phy_src_idx(src_idx)];
- }
  static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc,
                                   u32 byte_count)
  {
@@@ -278,42 -270,9 +270,9 @@@ mv_xor_run_tx_complete_actions(struct m
                        desc->async_tx.callback(
                                desc->async_tx.callback_param);
  
-               /* unmap dma addresses
-                * (unmap_single vs unmap_page?)
-                */
-               if (desc->group_head && desc->unmap_len) {
-                       struct mv_xor_desc_slot *unmap = desc->group_head;
-                       struct device *dev = mv_chan_to_devp(mv_chan);
-                       u32 len = unmap->unmap_len;
-                       enum dma_ctrl_flags flags = desc->async_tx.flags;
-                       u32 src_cnt;
-                       dma_addr_t addr;
-                       dma_addr_t dest;
-                       src_cnt = unmap->unmap_src_cnt;
-                       dest = mv_desc_get_dest_addr(unmap);
-                       if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                               enum dma_data_direction dir;
-                               if (src_cnt > 1) /* is xor ? */
-                                       dir = DMA_BIDIRECTIONAL;
-                               else
-                                       dir = DMA_FROM_DEVICE;
-                               dma_unmap_page(dev, dest, len, dir);
-                       }
-                       if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                               while (src_cnt--) {
-                                       addr = mv_desc_get_src_addr(unmap,
-                                                                   src_cnt);
-                                       if (addr == dest)
-                                               continue;
-                                       dma_unmap_page(dev, addr, len,
-                                                      DMA_TO_DEVICE);
-                               }
-                       }
+               dma_descriptor_unmap(&desc->async_tx);
+               if (desc->group_head)
                        desc->group_head = NULL;
-               }
        }
  
        /* run dependent operations */
@@@ -749,7 -708,7 +708,7 @@@ static enum dma_status mv_xor_status(st
        enum dma_status ret;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS) {
 +      if (ret == DMA_COMPLETE) {
                mv_xor_clean_completed_slots(mv_chan);
                return ret;
        }
@@@ -874,7 -833,7 +833,7 @@@ static int mv_xor_memcpy_self_test(stru
        msleep(1);
  
        if (mv_xor_status(dma_chan, cookie, NULL) !=
 -          DMA_SUCCESS) {
 +          DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test copy timed out, disabling\n");
                err = -ENODEV;
@@@ -968,7 -927,7 +927,7 @@@ mv_xor_xor_self_test(struct mv_xor_cha
        msleep(8);
  
        if (mv_xor_status(dma_chan, cookie, NULL) !=
 -          DMA_SUCCESS) {
 +          DMA_COMPLETE) {
                dev_err(dma_chan->device->dev,
                        "Self-test xor timed out, disabling\n");
                err = -ENODEV;
@@@ -1076,10 -1035,7 +1035,7 @@@ mv_xor_channel_add(struct mv_xor_devic
        }
  
        mv_chan->mmr_base = xordev->xor_base;
-       if (!mv_chan->mmr_base) {
-               ret = -ENOMEM;
-               goto err_free_dma;
-       }
+       mv_chan->mmr_high_base = xordev->xor_high_base;
        tasklet_init(&mv_chan->irq_tasklet, mv_xor_tasklet, (unsigned long)
                     mv_chan);
  
@@@ -1138,7 -1094,7 +1094,7 @@@ static voi
  mv_xor_conf_mbus_windows(struct mv_xor_device *xordev,
                         const struct mbus_dram_target_info *dram)
  {
-       void __iomem *base = xordev->xor_base;
+       void __iomem *base = xordev->xor_high_base;
        u32 win_enable = 0;
        int i;
  
diff --combined drivers/dma/pl330.c
index 0ee2c547b304ab0498f422228d1f68fc3bdeaf65,ab25e52cd43b888d3cabd5438d6d15c2289541eb..877d7bb767d98fb6bebe10bcbba1ef757c7c9b76
@@@ -2268,6 -2268,8 +2268,8 @@@ static void pl330_tasklet(unsigned lon
                        list_move_tail(&desc->node, &pch->dmac->desc_pool);
                }
  
+               dma_descriptor_unmap(&desc->txd);
                if (callback) {
                        spin_unlock_irqrestore(&pch->lock, flags);
                        callback(callback_param);
@@@ -2314,7 -2316,7 +2316,7 @@@ bool pl330_filter(struct dma_chan *chan
                return false;
  
        peri_id = chan->private;
 -      return *peri_id == (unsigned)param;
 +      return *peri_id == (unsigned long)param;
  }
  EXPORT_SYMBOL(pl330_filter);
  
@@@ -2922,23 -2924,16 +2924,23 @@@ pl330_probe(struct amba_device *adev, c
  
        amba_set_drvdata(adev, pdmac);
  
 -      irq = adev->irq[0];
 -      ret = request_irq(irq, pl330_irq_handler, 0,
 -                      dev_name(&adev->dev), pi);
 -      if (ret)
 -              return ret;
 +      for (i = 0; i < AMBA_NR_IRQS; i++) {
 +              irq = adev->irq[i];
 +              if (irq) {
 +                      ret = devm_request_irq(&adev->dev, irq,
 +                                             pl330_irq_handler, 0,
 +                                             dev_name(&adev->dev), pi);
 +                      if (ret)
 +                              return ret;
 +              } else {
 +                      break;
 +              }
 +      }
  
        pi->pcfg.periph_id = adev->periphid;
        ret = pl330_add(pi);
        if (ret)
 -              goto probe_err1;
 +              return ret;
  
        INIT_LIST_HEAD(&pdmac->desc_pool);
        spin_lock_init(&pdmac->pool_lock);
  
        return 0;
  probe_err3:
 -      amba_set_drvdata(adev, NULL);
 -
        /* Idle the DMAC */
        list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
                        chan.device_node) {
        }
  probe_err2:
        pl330_del(pi);
 -probe_err1:
 -      free_irq(irq, pi);
  
        return ret;
  }
@@@ -3058,6 -3057,7 +3060,6 @@@ static int pl330_remove(struct amba_dev
        struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev);
        struct dma_pl330_chan *pch, *_p;
        struct pl330_info *pi;
 -      int irq;
  
        if (!pdmac)
                return 0;
                of_dma_controller_free(adev->dev.of_node);
  
        dma_async_device_unregister(&pdmac->ddma);
 -      amba_set_drvdata(adev, NULL);
  
        /* Idle the DMAC */
        list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
  
        pl330_del(pi);
  
 -      irq = adev->irq[0];
 -      free_irq(irq, pi);
 -
        return 0;
  }
  
index 60e02ae38b04a46f4327ea76c0590b427808196d,429be432ab7e34d0fca2b3780e1d7771e8cc0813..3005938ba47ac682bf68b5ea64e9a0d57dd27991
@@@ -801,218 -801,6 +801,6 @@@ static void ppc440spe_desc_set_link(str
        local_irq_restore(flags);
  }
  
- /**
-  * ppc440spe_desc_get_src_addr - extract the source address from the descriptor
-  */
- static u32 ppc440spe_desc_get_src_addr(struct ppc440spe_adma_desc_slot *desc,
-                               struct ppc440spe_adma_chan *chan, int src_idx)
- {
-       struct dma_cdb *dma_hw_desc;
-       struct xor_cb *xor_hw_desc;
-       switch (chan->device->id) {
-       case PPC440SPE_DMA0_ID:
-       case PPC440SPE_DMA1_ID:
-               dma_hw_desc = desc->hw_desc;
-               /* May have 0, 1, 2, or 3 sources */
-               switch (dma_hw_desc->opc) {
-               case DMA_CDB_OPC_NO_OP:
-               case DMA_CDB_OPC_DFILL128:
-                       return 0;
-               case DMA_CDB_OPC_DCHECK128:
-                       if (unlikely(src_idx)) {
-                               printk(KERN_ERR "%s: try to get %d source for"
-                                   " DCHECK128\n", __func__, src_idx);
-                               BUG();
-                       }
-                       return le32_to_cpu(dma_hw_desc->sg1l);
-               case DMA_CDB_OPC_MULTICAST:
-               case DMA_CDB_OPC_MV_SG1_SG2:
-                       if (unlikely(src_idx > 2)) {
-                               printk(KERN_ERR "%s: try to get %d source from"
-                                   " DMA descr\n", __func__, src_idx);
-                               BUG();
-                       }
-                       if (src_idx) {
-                               if (le32_to_cpu(dma_hw_desc->sg1u) &
-                                   DMA_CUED_XOR_WIN_MSK) {
-                                       u8 region;
-                                       if (src_idx == 1)
-                                               return le32_to_cpu(
-                                                   dma_hw_desc->sg1l) +
-                                                       desc->unmap_len;
-                                       region = (le32_to_cpu(
-                                           dma_hw_desc->sg1u)) >>
-                                               DMA_CUED_REGION_OFF;
-                                       region &= DMA_CUED_REGION_MSK;
-                                       switch (region) {
-                                       case DMA_RXOR123:
-                                               return le32_to_cpu(
-                                                   dma_hw_desc->sg1l) +
-                                                       (desc->unmap_len << 1);
-                                       case DMA_RXOR124:
-                                               return le32_to_cpu(
-                                                   dma_hw_desc->sg1l) +
-                                                       (desc->unmap_len * 3);
-                                       case DMA_RXOR125:
-                                               return le32_to_cpu(
-                                                   dma_hw_desc->sg1l) +
-                                                       (desc->unmap_len << 2);
-                                       default:
-                                               printk(KERN_ERR
-                                                   "%s: try to"
-                                                   " get src3 for region %02x"
-                                                   "PPC440SPE_DESC_RXOR12?\n",
-                                                   __func__, region);
-                                               BUG();
-                                       }
-                               } else {
-                                       printk(KERN_ERR
-                                               "%s: try to get %d"
-                                               " source for non-cued descr\n",
-                                               __func__, src_idx);
-                                       BUG();
-                               }
-                       }
-                       return le32_to_cpu(dma_hw_desc->sg1l);
-               default:
-                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
-                               __func__, dma_hw_desc->opc);
-                       BUG();
-               }
-               return le32_to_cpu(dma_hw_desc->sg1l);
-       case PPC440SPE_XOR_ID:
-               /* May have up to 16 sources */
-               xor_hw_desc = desc->hw_desc;
-               return xor_hw_desc->ops[src_idx].l;
-       }
-       return 0;
- }
- /**
-  * ppc440spe_desc_get_dest_addr - extract the destination address from the
-  * descriptor
-  */
- static u32 ppc440spe_desc_get_dest_addr(struct ppc440spe_adma_desc_slot *desc,
-                               struct ppc440spe_adma_chan *chan, int idx)
- {
-       struct dma_cdb *dma_hw_desc;
-       struct xor_cb *xor_hw_desc;
-       switch (chan->device->id) {
-       case PPC440SPE_DMA0_ID:
-       case PPC440SPE_DMA1_ID:
-               dma_hw_desc = desc->hw_desc;
-               if (likely(!idx))
-                       return le32_to_cpu(dma_hw_desc->sg2l);
-               return le32_to_cpu(dma_hw_desc->sg3l);
-       case PPC440SPE_XOR_ID:
-               xor_hw_desc = desc->hw_desc;
-               return xor_hw_desc->cbtal;
-       }
-       return 0;
- }
- /**
-  * ppc440spe_desc_get_src_num - extract the number of source addresses from
-  * the descriptor
-  */
- static u32 ppc440spe_desc_get_src_num(struct ppc440spe_adma_desc_slot *desc,
-                               struct ppc440spe_adma_chan *chan)
- {
-       struct dma_cdb *dma_hw_desc;
-       struct xor_cb *xor_hw_desc;
-       switch (chan->device->id) {
-       case PPC440SPE_DMA0_ID:
-       case PPC440SPE_DMA1_ID:
-               dma_hw_desc = desc->hw_desc;
-               switch (dma_hw_desc->opc) {
-               case DMA_CDB_OPC_NO_OP:
-               case DMA_CDB_OPC_DFILL128:
-                       return 0;
-               case DMA_CDB_OPC_DCHECK128:
-                       return 1;
-               case DMA_CDB_OPC_MV_SG1_SG2:
-               case DMA_CDB_OPC_MULTICAST:
-                       /*
-                        * Only for RXOR operations we have more than
-                        * one source
-                        */
-                       if (le32_to_cpu(dma_hw_desc->sg1u) &
-                           DMA_CUED_XOR_WIN_MSK) {
-                               /* RXOR op, there are 2 or 3 sources */
-                               if (((le32_to_cpu(dma_hw_desc->sg1u) >>
-                                   DMA_CUED_REGION_OFF) &
-                                     DMA_CUED_REGION_MSK) == DMA_RXOR12) {
-                                       /* RXOR 1-2 */
-                                       return 2;
-                               } else {
-                                       /* RXOR 1-2-3/1-2-4/1-2-5 */
-                                       return 3;
-                               }
-                       }
-                       return 1;
-               default:
-                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
-                               __func__, dma_hw_desc->opc);
-                       BUG();
-               }
-       case PPC440SPE_XOR_ID:
-               /* up to 16 sources */
-               xor_hw_desc = desc->hw_desc;
-               return xor_hw_desc->cbc & XOR_CDCR_OAC_MSK;
-       default:
-               BUG();
-       }
-       return 0;
- }
- /**
-  * ppc440spe_desc_get_dst_num - get the number of destination addresses in
-  * this descriptor
-  */
- static u32 ppc440spe_desc_get_dst_num(struct ppc440spe_adma_desc_slot *desc,
-                               struct ppc440spe_adma_chan *chan)
- {
-       struct dma_cdb *dma_hw_desc;
-       switch (chan->device->id) {
-       case PPC440SPE_DMA0_ID:
-       case PPC440SPE_DMA1_ID:
-               /* May be 1 or 2 destinations */
-               dma_hw_desc = desc->hw_desc;
-               switch (dma_hw_desc->opc) {
-               case DMA_CDB_OPC_NO_OP:
-               case DMA_CDB_OPC_DCHECK128:
-                       return 0;
-               case DMA_CDB_OPC_MV_SG1_SG2:
-               case DMA_CDB_OPC_DFILL128:
-                       return 1;
-               case DMA_CDB_OPC_MULTICAST:
-                       if (desc->dst_cnt == 2)
-                               return 2;
-                       else
-                               return 1;
-               default:
-                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
-                               __func__, dma_hw_desc->opc);
-                       BUG();
-               }
-       case PPC440SPE_XOR_ID:
-               /* Always only 1 destination */
-               return 1;
-       default:
-               BUG();
-       }
-       return 0;
- }
  /**
   * ppc440spe_desc_get_link - get the address of the descriptor that
   * follows this one
@@@ -1705,43 -1493,6 +1493,6 @@@ static void ppc440spe_adma_free_slots(s
        }
  }
  
- static void ppc440spe_adma_unmap(struct ppc440spe_adma_chan *chan,
-                                struct ppc440spe_adma_desc_slot *desc)
- {
-       u32 src_cnt, dst_cnt;
-       dma_addr_t addr;
-       /*
-        * get the number of sources & destination
-        * included in this descriptor and unmap
-        * them all
-        */
-       src_cnt = ppc440spe_desc_get_src_num(desc, chan);
-       dst_cnt = ppc440spe_desc_get_dst_num(desc, chan);
-       /* unmap destinations */
-       if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-               while (dst_cnt--) {
-                       addr = ppc440spe_desc_get_dest_addr(
-                               desc, chan, dst_cnt);
-                       dma_unmap_page(chan->device->dev,
-                                       addr, desc->unmap_len,
-                                       DMA_FROM_DEVICE);
-               }
-       }
-       /* unmap sources */
-       if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-               while (src_cnt--) {
-                       addr = ppc440spe_desc_get_src_addr(
-                               desc, chan, src_cnt);
-                       dma_unmap_page(chan->device->dev,
-                                       addr, desc->unmap_len,
-                                       DMA_TO_DEVICE);
-               }
-       }
- }
  /**
   * ppc440spe_adma_run_tx_complete_actions - call functions to be called
   * upon completion
@@@ -1765,26 -1516,7 +1516,7 @@@ static dma_cookie_t ppc440spe_adma_run_
                        desc->async_tx.callback(
                                desc->async_tx.callback_param);
  
-               /* unmap dma addresses
-                * (unmap_single vs unmap_page?)
-                *
-                * actually, ppc's dma_unmap_page() functions are empty, so
-                * the following code is just for the sake of completeness
-                */
-               if (chan && chan->needs_unmap && desc->group_head &&
-                    desc->unmap_len) {
-                       struct ppc440spe_adma_desc_slot *unmap =
-                                                       desc->group_head;
-                       /* assume 1 slot per op always */
-                       u32 slot_count = unmap->slot_cnt;
-                       /* Run through the group list and unmap addresses */
-                       for (i = 0; i < slot_count; i++) {
-                               BUG_ON(!unmap);
-                               ppc440spe_adma_unmap(chan, unmap);
-                               unmap = unmap->hw_next;
-                       }
-               }
+               dma_descriptor_unmap(&desc->async_tx);
        }
  
        /* run dependent operations */
@@@ -3891,7 -3623,7 +3623,7 @@@ static enum dma_status ppc440spe_adma_t
  
        ppc440spe_chan = to_ppc440spe_adma_chan(chan);
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 +      if (ret == DMA_COMPLETE)
                return ret;
  
        ppc440spe_adma_slot_cleanup(ppc440spe_chan);
diff --combined drivers/dma/txx9dmac.c
index c2829b481bf2c6b2d576e16aab730c06df375173,6f2729874016c5469d6926d218b095567acc60c5..bae6c29f5502ab951f7926bdf621977703bc96b1
@@@ -419,30 -419,7 +419,7 @@@ txx9dmac_descriptor_complete(struct txx
        list_splice_init(&desc->tx_list, &dc->free_list);
        list_move(&desc->desc_node, &dc->free_list);
  
-       if (!ds) {
-               dma_addr_t dmaaddr;
-               if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
-                       dmaaddr = is_dmac64(dc) ?
-                               desc->hwdesc.DAR : desc->hwdesc32.DAR;
-                       if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE)
-                               dma_unmap_single(chan2parent(&dc->chan),
-                                       dmaaddr, desc->len, DMA_FROM_DEVICE);
-                       else
-                               dma_unmap_page(chan2parent(&dc->chan),
-                                       dmaaddr, desc->len, DMA_FROM_DEVICE);
-               }
-               if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
-                       dmaaddr = is_dmac64(dc) ?
-                               desc->hwdesc.SAR : desc->hwdesc32.SAR;
-                       if (txd->flags & DMA_COMPL_SRC_UNMAP_SINGLE)
-                               dma_unmap_single(chan2parent(&dc->chan),
-                                       dmaaddr, desc->len, DMA_TO_DEVICE);
-                       else
-                               dma_unmap_page(chan2parent(&dc->chan),
-                                       dmaaddr, desc->len, DMA_TO_DEVICE);
-               }
-       }
+       dma_descriptor_unmap(txd);
        /*
         * The API requires that no submissions are done from a
         * callback, so we don't need to drop the lock here
@@@ -962,8 -939,8 +939,8 @@@ txx9dmac_tx_status(struct dma_chan *cha
        enum dma_status ret;
  
        ret = dma_cookie_status(chan, cookie, txstate);
 -      if (ret == DMA_SUCCESS)
 -              return DMA_SUCCESS;
 +      if (ret == DMA_COMPLETE)
 +              return DMA_COMPLETE;
  
        spin_lock_bh(&dc->lock);
        txx9dmac_scan_descriptors(dc);
index 4b460a683968670f5eaf836fde0ff16e88e39d9a,491072cb5ba01c9702b5dca691c55d1ffd01a003..41cf0c399288e022edf32f7e65c6f151004829d9
@@@ -45,13 -45,13 +45,13 @@@ static inline int dma_submit_error(dma_
  
  /**
   * enum dma_status - DMA transaction status
 - * @DMA_SUCCESS: transaction completed successfully
 + * @DMA_COMPLETE: transaction completed
   * @DMA_IN_PROGRESS: transaction not yet processed
   * @DMA_PAUSED: transaction is paused
   * @DMA_ERROR: transaction failed
   */
  enum dma_status {
 -      DMA_SUCCESS,
 +      DMA_COMPLETE,
        DMA_IN_PROGRESS,
        DMA_PAUSED,
        DMA_ERROR,
@@@ -171,12 -171,6 +171,6 @@@ struct dma_interleaved_template 
   * @DMA_CTRL_ACK - if clear, the descriptor cannot be reused until the client
   *  acknowledges receipt, i.e. has has a chance to establish any dependency
   *  chains
-  * @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s)
-  * @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s)
-  * @DMA_COMPL_SRC_UNMAP_SINGLE - set to do the source dma-unmapping as single
-  *    (if not set, do the source dma-unmapping as page)
-  * @DMA_COMPL_DEST_UNMAP_SINGLE - set to do the destination dma-unmapping as single
-  *    (if not set, do the destination dma-unmapping as page)
   * @DMA_PREP_PQ_DISABLE_P - prevent generation of P while generating Q
   * @DMA_PREP_PQ_DISABLE_Q - prevent generation of Q while generating P
   * @DMA_PREP_CONTINUE - indicate to a driver that it is reusing buffers as
  enum dma_ctrl_flags {
        DMA_PREP_INTERRUPT = (1 << 0),
        DMA_CTRL_ACK = (1 << 1),
-       DMA_COMPL_SKIP_SRC_UNMAP = (1 << 2),
-       DMA_COMPL_SKIP_DEST_UNMAP = (1 << 3),
-       DMA_COMPL_SRC_UNMAP_SINGLE = (1 << 4),
-       DMA_COMPL_DEST_UNMAP_SINGLE = (1 << 5),
-       DMA_PREP_PQ_DISABLE_P = (1 << 6),
-       DMA_PREP_PQ_DISABLE_Q = (1 << 7),
-       DMA_PREP_CONTINUE = (1 << 8),
-       DMA_PREP_FENCE = (1 << 9),
+       DMA_PREP_PQ_DISABLE_P = (1 << 2),
+       DMA_PREP_PQ_DISABLE_Q = (1 << 3),
+       DMA_PREP_CONTINUE = (1 << 4),
+       DMA_PREP_FENCE = (1 << 5),
  };
  
  /**
@@@ -413,6 -403,17 +403,17 @@@ void dma_chan_cleanup(struct kref *kref
  typedef bool (*dma_filter_fn)(struct dma_chan *chan, void *filter_param);
  
  typedef void (*dma_async_tx_callback)(void *dma_async_param);
+ struct dmaengine_unmap_data {
+       u8 to_cnt;
+       u8 from_cnt;
+       u8 bidi_cnt;
+       struct device *dev;
+       struct kref kref;
+       size_t len;
+       dma_addr_t addr[0];
+ };
  /**
   * struct dma_async_tx_descriptor - async transaction descriptor
   * ---dma generic offload fields---
@@@ -438,6 -439,7 +439,7 @@@ struct dma_async_tx_descriptor 
        dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);
        dma_async_tx_callback callback;
        void *callback_param;
+       struct dmaengine_unmap_data *unmap;
  #ifdef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH
        struct dma_async_tx_descriptor *next;
        struct dma_async_tx_descriptor *parent;
  #endif
  };
  
+ #ifdef CONFIG_DMA_ENGINE
+ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
+                                struct dmaengine_unmap_data *unmap)
+ {
+       kref_get(&unmap->kref);
+       tx->unmap = unmap;
+ }
+ struct dmaengine_unmap_data *
+ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags);
+ void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap);
+ #else
+ static inline void dma_set_unmap(struct dma_async_tx_descriptor *tx,
+                                struct dmaengine_unmap_data *unmap)
+ {
+ }
+ static inline struct dmaengine_unmap_data *
+ dmaengine_get_unmap_data(struct device *dev, int nr, gfp_t flags)
+ {
+       return NULL;
+ }
+ static inline void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap)
+ {
+ }
+ #endif
+ static inline void dma_descriptor_unmap(struct dma_async_tx_descriptor *tx)
+ {
+       if (tx->unmap) {
+               dmaengine_unmap_put(tx->unmap);
+               tx->unmap = NULL;
+       }
+ }
  #ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH
  static inline void txd_lock(struct dma_async_tx_descriptor *txd)
  {
@@@ -979,10 -1015,10 +1015,10 @@@ static inline enum dma_status dma_async
  {
        if (last_complete <= last_used) {
                if ((cookie <= last_complete) || (cookie > last_used))
 -                      return DMA_SUCCESS;
 +                      return DMA_COMPLETE;
        } else {
                if ((cookie <= last_complete) && (cookie > last_used))
 -                      return DMA_SUCCESS;
 +                      return DMA_COMPLETE;
        }
        return DMA_IN_PROGRESS;
  }
@@@ -1013,11 -1049,11 +1049,11 @@@ static inline struct dma_chan *dma_find
  }
  static inline enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie)
  {
 -      return DMA_SUCCESS;
 +      return DMA_COMPLETE;
  }
  static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
  {
 -      return DMA_SUCCESS;
 +      return DMA_COMPLETE;
  }
  static inline void dma_issue_pending_all(void)
  {