DMA: PL330: Add dma api driver
[safe/jmp/linux-2.6] / drivers / dma / dmaengine.c
index 51d7480..9d31d5e 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/jiffies.h>
 #include <linux/rculist.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 
 static DEFINE_MUTEX(dma_list_mutex);
 static LIST_HEAD(dma_device_list);
@@ -284,7 +285,7 @@ struct dma_chan_tbl_ent {
 /**
  * channel_table - percpu lookup table for memory-to-memory offload providers
  */
-static struct dma_chan_tbl_ent *channel_table[DMA_TX_TYPE_END];
+static struct dma_chan_tbl_ent __percpu *channel_table[DMA_TX_TYPE_END];
 
 static int __init dma_channel_table_init(void)
 {
@@ -514,7 +515,6 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
                                break;
                        if (--device->privatecnt == 0)
                                dma_cap_clear(DMA_PRIVATE, device->cap_mask);
-                       chan->private = NULL;
                        chan = NULL;
                }
        }
@@ -536,7 +536,6 @@ void dma_release_channel(struct dma_chan *chan)
        /* drop PRIVATE cap enabled by __dma_request_channel() */
        if (--chan->device->privatecnt == 0)
                dma_cap_clear(DMA_PRIVATE, chan->device->cap_mask);
-       chan->private = NULL;
        mutex_unlock(&dma_list_mutex);
 }
 EXPORT_SYMBOL_GPL(dma_release_channel);
@@ -625,11 +624,21 @@ static bool device_has_all_tx_types(struct dma_device *device)
        #if defined(CONFIG_ASYNC_XOR) || defined(CONFIG_ASYNC_XOR_MODULE)
        if (!dma_has_cap(DMA_XOR, device->cap_mask))
                return false;
+
+       #ifndef CONFIG_ASYNC_TX_DISABLE_XOR_VAL_DMA
+       if (!dma_has_cap(DMA_XOR_VAL, device->cap_mask))
+               return false;
+       #endif
        #endif
 
        #if defined(CONFIG_ASYNC_PQ) || defined(CONFIG_ASYNC_PQ_MODULE)
        if (!dma_has_cap(DMA_PQ, device->cap_mask))
                return false;
+
+       #ifndef CONFIG_ASYNC_TX_DISABLE_PQ_VAL_DMA
+       if (!dma_has_cap(DMA_PQ_VAL, device->cap_mask))
+               return false;
+       #endif
        #endif
 
        return true;
@@ -684,11 +693,11 @@ int dma_async_device_register(struct dma_device *device)
        BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
                !device->device_prep_slave_sg);
        BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
-               !device->device_terminate_all);
+               !device->device_control);
 
        BUG_ON(!device->device_alloc_chan_resources);
        BUG_ON(!device->device_free_chan_resources);
-       BUG_ON(!device->device_is_tx_complete);
+       BUG_ON(!device->device_tx_status);
        BUG_ON(!device->device_issue_pending);
        BUG_ON(!device->dev);
 
@@ -816,6 +825,7 @@ void dma_async_device_unregister(struct dma_device *device)
                chan->dev->chan = NULL;
                mutex_unlock(&dma_list_mutex);
                device_unregister(&chan->dev->device);
+               free_percpu(chan->local);
        }
 }
 EXPORT_SYMBOL(dma_async_device_unregister);
@@ -966,7 +976,9 @@ void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
        struct dma_chan *chan)
 {
        tx->chan = chan;
+       #ifndef CONFIG_ASYNC_TX_DISABLE_CHANNEL_SWITCH
        spin_lock_init(&tx->lock);
+       #endif
 }
 EXPORT_SYMBOL(dma_async_tx_descriptor_init);
 
@@ -999,7 +1011,7 @@ EXPORT_SYMBOL_GPL(dma_wait_for_async_tx);
  */
 void dma_run_dependencies(struct dma_async_tx_descriptor *tx)
 {
-       struct dma_async_tx_descriptor *dep = tx->next;
+       struct dma_async_tx_descriptor *dep = txd_next(tx);
        struct dma_async_tx_descriptor *dep_next;
        struct dma_chan *chan;
 
@@ -1007,7 +1019,7 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx)
                return;
 
        /* we'll submit tx->next now, so clear the link */
-       tx->next = NULL;
+       txd_clear_next(tx);
        chan = dep->chan;
 
        /* keep submitting up until a channel switch is detected
@@ -1015,14 +1027,14 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx)
         * processing the interrupt from async_tx_channel_switch
         */
        for (; dep; dep = dep_next) {
-               spin_lock_bh(&dep->lock);
-               dep->parent = NULL;
-               dep_next = dep->next;
+               txd_lock(dep);
+               txd_clear_parent(dep);
+               dep_next = txd_next(dep);
                if (dep_next && dep_next->chan == chan)
-                       dep->next = NULL; /* ->next will be submitted */
+                       txd_clear_next(dep); /* ->next will be submitted */
                else
                        dep_next = NULL; /* submit current dep and terminate */
-               spin_unlock_bh(&dep->lock);
+               txd_unlock(dep);
 
                dep->tx_submit(dep);
        }