1ff7b0479SSaeed Bishara /* 2ff7b0479SSaeed Bishara * offload engine driver for the Marvell XOR engine 3ff7b0479SSaeed Bishara * Copyright (C) 2007, 2008, Marvell International Ltd. 4ff7b0479SSaeed Bishara * 5ff7b0479SSaeed Bishara * This program is free software; you can redistribute it and/or modify it 6ff7b0479SSaeed Bishara * under the terms and conditions of the GNU General Public License, 7ff7b0479SSaeed Bishara * version 2, as published by the Free Software Foundation. 8ff7b0479SSaeed Bishara * 9ff7b0479SSaeed Bishara * This program is distributed in the hope it will be useful, but WITHOUT 10ff7b0479SSaeed Bishara * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11ff7b0479SSaeed Bishara * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12ff7b0479SSaeed Bishara * more details. 13ff7b0479SSaeed Bishara * 14ff7b0479SSaeed Bishara * You should have received a copy of the GNU General Public License along with 15ff7b0479SSaeed Bishara * this program; if not, write to the Free Software Foundation, Inc., 16ff7b0479SSaeed Bishara * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17ff7b0479SSaeed Bishara */ 18ff7b0479SSaeed Bishara 19ff7b0479SSaeed Bishara #include <linux/init.h> 20ff7b0479SSaeed Bishara #include <linux/module.h> 215a0e3ad6STejun Heo #include <linux/slab.h> 22ff7b0479SSaeed Bishara #include <linux/delay.h> 23ff7b0479SSaeed Bishara #include <linux/dma-mapping.h> 24ff7b0479SSaeed Bishara #include <linux/spinlock.h> 25ff7b0479SSaeed Bishara #include <linux/interrupt.h> 26ff7b0479SSaeed Bishara #include <linux/platform_device.h> 27ff7b0479SSaeed Bishara #include <linux/memory.h> 28*c510182bSAndrew Lunn #include <linux/clk.h> 296f088f1dSLennert Buytenhek #include <plat/mv_xor.h> 30d2ebfb33SRussell King - ARM Linux 31d2ebfb33SRussell King - ARM Linux #include "dmaengine.h" 32ff7b0479SSaeed Bishara #include "mv_xor.h" 33ff7b0479SSaeed Bishara 34ff7b0479SSaeed Bishara static void mv_xor_issue_pending(struct dma_chan *chan); 35ff7b0479SSaeed Bishara 36ff7b0479SSaeed Bishara #define to_mv_xor_chan(chan) \ 37ff7b0479SSaeed Bishara container_of(chan, struct mv_xor_chan, common) 38ff7b0479SSaeed Bishara 39ff7b0479SSaeed Bishara #define to_mv_xor_device(dev) \ 40ff7b0479SSaeed Bishara container_of(dev, struct mv_xor_device, common) 41ff7b0479SSaeed Bishara 42ff7b0479SSaeed Bishara #define to_mv_xor_slot(tx) \ 43ff7b0479SSaeed Bishara container_of(tx, struct mv_xor_desc_slot, async_tx) 44ff7b0479SSaeed Bishara 45ff7b0479SSaeed Bishara static void mv_desc_init(struct mv_xor_desc_slot *desc, unsigned long flags) 46ff7b0479SSaeed Bishara { 47ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 48ff7b0479SSaeed Bishara 49ff7b0479SSaeed Bishara hw_desc->status = (1 << 31); 50ff7b0479SSaeed Bishara hw_desc->phy_next_desc = 0; 51ff7b0479SSaeed Bishara hw_desc->desc_command = (1 << 31); 52ff7b0479SSaeed Bishara } 53ff7b0479SSaeed Bishara 54ff7b0479SSaeed Bishara static u32 mv_desc_get_dest_addr(struct mv_xor_desc_slot *desc) 55ff7b0479SSaeed Bishara { 56ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 57ff7b0479SSaeed Bishara return hw_desc->phy_dest_addr; 58ff7b0479SSaeed Bishara } 59ff7b0479SSaeed Bishara 60ff7b0479SSaeed Bishara static u32 mv_desc_get_src_addr(struct mv_xor_desc_slot *desc, 61ff7b0479SSaeed Bishara int src_idx) 62ff7b0479SSaeed Bishara { 63ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 64ff7b0479SSaeed Bishara return hw_desc->phy_src_addr[src_idx]; 65ff7b0479SSaeed Bishara } 66ff7b0479SSaeed Bishara 67ff7b0479SSaeed Bishara 68ff7b0479SSaeed Bishara static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc, 69ff7b0479SSaeed Bishara u32 byte_count) 70ff7b0479SSaeed Bishara { 71ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 72ff7b0479SSaeed Bishara hw_desc->byte_count = byte_count; 73ff7b0479SSaeed Bishara } 74ff7b0479SSaeed Bishara 75ff7b0479SSaeed Bishara static void mv_desc_set_next_desc(struct mv_xor_desc_slot *desc, 76ff7b0479SSaeed Bishara u32 next_desc_addr) 77ff7b0479SSaeed Bishara { 78ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 79ff7b0479SSaeed Bishara BUG_ON(hw_desc->phy_next_desc); 80ff7b0479SSaeed Bishara hw_desc->phy_next_desc = next_desc_addr; 81ff7b0479SSaeed Bishara } 82ff7b0479SSaeed Bishara 83ff7b0479SSaeed Bishara static void mv_desc_clear_next_desc(struct mv_xor_desc_slot *desc) 84ff7b0479SSaeed Bishara { 85ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 86ff7b0479SSaeed Bishara hw_desc->phy_next_desc = 0; 87ff7b0479SSaeed Bishara } 88ff7b0479SSaeed Bishara 89ff7b0479SSaeed Bishara static void mv_desc_set_block_fill_val(struct mv_xor_desc_slot *desc, u32 val) 90ff7b0479SSaeed Bishara { 91ff7b0479SSaeed Bishara desc->value = val; 92ff7b0479SSaeed Bishara } 93ff7b0479SSaeed Bishara 94ff7b0479SSaeed Bishara static void mv_desc_set_dest_addr(struct mv_xor_desc_slot *desc, 95ff7b0479SSaeed Bishara dma_addr_t addr) 96ff7b0479SSaeed Bishara { 97ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 98ff7b0479SSaeed Bishara hw_desc->phy_dest_addr = addr; 99ff7b0479SSaeed Bishara } 100ff7b0479SSaeed Bishara 101ff7b0479SSaeed Bishara static int mv_chan_memset_slot_count(size_t len) 102ff7b0479SSaeed Bishara { 103ff7b0479SSaeed Bishara return 1; 104ff7b0479SSaeed Bishara } 105ff7b0479SSaeed Bishara 106ff7b0479SSaeed Bishara #define mv_chan_memcpy_slot_count(c) mv_chan_memset_slot_count(c) 107ff7b0479SSaeed Bishara 108ff7b0479SSaeed Bishara static void mv_desc_set_src_addr(struct mv_xor_desc_slot *desc, 109ff7b0479SSaeed Bishara int index, dma_addr_t addr) 110ff7b0479SSaeed Bishara { 111ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = desc->hw_desc; 112ff7b0479SSaeed Bishara hw_desc->phy_src_addr[index] = addr; 113ff7b0479SSaeed Bishara if (desc->type == DMA_XOR) 114ff7b0479SSaeed Bishara hw_desc->desc_command |= (1 << index); 115ff7b0479SSaeed Bishara } 116ff7b0479SSaeed Bishara 117ff7b0479SSaeed Bishara static u32 mv_chan_get_current_desc(struct mv_xor_chan *chan) 118ff7b0479SSaeed Bishara { 119ff7b0479SSaeed Bishara return __raw_readl(XOR_CURR_DESC(chan)); 120ff7b0479SSaeed Bishara } 121ff7b0479SSaeed Bishara 122ff7b0479SSaeed Bishara static void mv_chan_set_next_descriptor(struct mv_xor_chan *chan, 123ff7b0479SSaeed Bishara u32 next_desc_addr) 124ff7b0479SSaeed Bishara { 125ff7b0479SSaeed Bishara __raw_writel(next_desc_addr, XOR_NEXT_DESC(chan)); 126ff7b0479SSaeed Bishara } 127ff7b0479SSaeed Bishara 128ff7b0479SSaeed Bishara static void mv_chan_set_dest_pointer(struct mv_xor_chan *chan, u32 desc_addr) 129ff7b0479SSaeed Bishara { 130ff7b0479SSaeed Bishara __raw_writel(desc_addr, XOR_DEST_POINTER(chan)); 131ff7b0479SSaeed Bishara } 132ff7b0479SSaeed Bishara 133ff7b0479SSaeed Bishara static void mv_chan_set_block_size(struct mv_xor_chan *chan, u32 block_size) 134ff7b0479SSaeed Bishara { 135ff7b0479SSaeed Bishara __raw_writel(block_size, XOR_BLOCK_SIZE(chan)); 136ff7b0479SSaeed Bishara } 137ff7b0479SSaeed Bishara 138ff7b0479SSaeed Bishara static void mv_chan_set_value(struct mv_xor_chan *chan, u32 value) 139ff7b0479SSaeed Bishara { 140ff7b0479SSaeed Bishara __raw_writel(value, XOR_INIT_VALUE_LOW(chan)); 141ff7b0479SSaeed Bishara __raw_writel(value, XOR_INIT_VALUE_HIGH(chan)); 142ff7b0479SSaeed Bishara } 143ff7b0479SSaeed Bishara 144ff7b0479SSaeed Bishara static void mv_chan_unmask_interrupts(struct mv_xor_chan *chan) 145ff7b0479SSaeed Bishara { 146ff7b0479SSaeed Bishara u32 val = __raw_readl(XOR_INTR_MASK(chan)); 147ff7b0479SSaeed Bishara val |= XOR_INTR_MASK_VALUE << (chan->idx * 16); 148ff7b0479SSaeed Bishara __raw_writel(val, XOR_INTR_MASK(chan)); 149ff7b0479SSaeed Bishara } 150ff7b0479SSaeed Bishara 151ff7b0479SSaeed Bishara static u32 mv_chan_get_intr_cause(struct mv_xor_chan *chan) 152ff7b0479SSaeed Bishara { 153ff7b0479SSaeed Bishara u32 intr_cause = __raw_readl(XOR_INTR_CAUSE(chan)); 154ff7b0479SSaeed Bishara intr_cause = (intr_cause >> (chan->idx * 16)) & 0xFFFF; 155ff7b0479SSaeed Bishara return intr_cause; 156ff7b0479SSaeed Bishara } 157ff7b0479SSaeed Bishara 158ff7b0479SSaeed Bishara static int mv_is_err_intr(u32 intr_cause) 159ff7b0479SSaeed Bishara { 160ff7b0479SSaeed Bishara if (intr_cause & ((1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9))) 161ff7b0479SSaeed Bishara return 1; 162ff7b0479SSaeed Bishara 163ff7b0479SSaeed Bishara return 0; 164ff7b0479SSaeed Bishara } 165ff7b0479SSaeed Bishara 166ff7b0479SSaeed Bishara static void mv_xor_device_clear_eoc_cause(struct mv_xor_chan *chan) 167ff7b0479SSaeed Bishara { 16886363682SSimon Guinot u32 val = ~(1 << (chan->idx * 16)); 169ff7b0479SSaeed Bishara dev_dbg(chan->device->common.dev, "%s, val 0x%08x\n", __func__, val); 170ff7b0479SSaeed Bishara __raw_writel(val, XOR_INTR_CAUSE(chan)); 171ff7b0479SSaeed Bishara } 172ff7b0479SSaeed Bishara 173ff7b0479SSaeed Bishara static void mv_xor_device_clear_err_status(struct mv_xor_chan *chan) 174ff7b0479SSaeed Bishara { 175ff7b0479SSaeed Bishara u32 val = 0xFFFF0000 >> (chan->idx * 16); 176ff7b0479SSaeed Bishara __raw_writel(val, XOR_INTR_CAUSE(chan)); 177ff7b0479SSaeed Bishara } 178ff7b0479SSaeed Bishara 179ff7b0479SSaeed Bishara static int mv_can_chain(struct mv_xor_desc_slot *desc) 180ff7b0479SSaeed Bishara { 181ff7b0479SSaeed Bishara struct mv_xor_desc_slot *chain_old_tail = list_entry( 182ff7b0479SSaeed Bishara desc->chain_node.prev, struct mv_xor_desc_slot, chain_node); 183ff7b0479SSaeed Bishara 184ff7b0479SSaeed Bishara if (chain_old_tail->type != desc->type) 185ff7b0479SSaeed Bishara return 0; 186ff7b0479SSaeed Bishara if (desc->type == DMA_MEMSET) 187ff7b0479SSaeed Bishara return 0; 188ff7b0479SSaeed Bishara 189ff7b0479SSaeed Bishara return 1; 190ff7b0479SSaeed Bishara } 191ff7b0479SSaeed Bishara 192ff7b0479SSaeed Bishara static void mv_set_mode(struct mv_xor_chan *chan, 193ff7b0479SSaeed Bishara enum dma_transaction_type type) 194ff7b0479SSaeed Bishara { 195ff7b0479SSaeed Bishara u32 op_mode; 196ff7b0479SSaeed Bishara u32 config = __raw_readl(XOR_CONFIG(chan)); 197ff7b0479SSaeed Bishara 198ff7b0479SSaeed Bishara switch (type) { 199ff7b0479SSaeed Bishara case DMA_XOR: 200ff7b0479SSaeed Bishara op_mode = XOR_OPERATION_MODE_XOR; 201ff7b0479SSaeed Bishara break; 202ff7b0479SSaeed Bishara case DMA_MEMCPY: 203ff7b0479SSaeed Bishara op_mode = XOR_OPERATION_MODE_MEMCPY; 204ff7b0479SSaeed Bishara break; 205ff7b0479SSaeed Bishara case DMA_MEMSET: 206ff7b0479SSaeed Bishara op_mode = XOR_OPERATION_MODE_MEMSET; 207ff7b0479SSaeed Bishara break; 208ff7b0479SSaeed Bishara default: 209ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 210ff7b0479SSaeed Bishara "error: unsupported operation %d.\n", 211ff7b0479SSaeed Bishara type); 212ff7b0479SSaeed Bishara BUG(); 213ff7b0479SSaeed Bishara return; 214ff7b0479SSaeed Bishara } 215ff7b0479SSaeed Bishara 216ff7b0479SSaeed Bishara config &= ~0x7; 217ff7b0479SSaeed Bishara config |= op_mode; 218ff7b0479SSaeed Bishara __raw_writel(config, XOR_CONFIG(chan)); 219ff7b0479SSaeed Bishara chan->current_type = type; 220ff7b0479SSaeed Bishara } 221ff7b0479SSaeed Bishara 222ff7b0479SSaeed Bishara static void mv_chan_activate(struct mv_xor_chan *chan) 223ff7b0479SSaeed Bishara { 224ff7b0479SSaeed Bishara u32 activation; 225ff7b0479SSaeed Bishara 226ff7b0479SSaeed Bishara dev_dbg(chan->device->common.dev, " activate chan.\n"); 227ff7b0479SSaeed Bishara activation = __raw_readl(XOR_ACTIVATION(chan)); 228ff7b0479SSaeed Bishara activation |= 0x1; 229ff7b0479SSaeed Bishara __raw_writel(activation, XOR_ACTIVATION(chan)); 230ff7b0479SSaeed Bishara } 231ff7b0479SSaeed Bishara 232ff7b0479SSaeed Bishara static char mv_chan_is_busy(struct mv_xor_chan *chan) 233ff7b0479SSaeed Bishara { 234ff7b0479SSaeed Bishara u32 state = __raw_readl(XOR_ACTIVATION(chan)); 235ff7b0479SSaeed Bishara 236ff7b0479SSaeed Bishara state = (state >> 4) & 0x3; 237ff7b0479SSaeed Bishara 238ff7b0479SSaeed Bishara return (state == 1) ? 1 : 0; 239ff7b0479SSaeed Bishara } 240ff7b0479SSaeed Bishara 241ff7b0479SSaeed Bishara static int mv_chan_xor_slot_count(size_t len, int src_cnt) 242ff7b0479SSaeed Bishara { 243ff7b0479SSaeed Bishara return 1; 244ff7b0479SSaeed Bishara } 245ff7b0479SSaeed Bishara 246ff7b0479SSaeed Bishara /** 247ff7b0479SSaeed Bishara * mv_xor_free_slots - flags descriptor slots for reuse 248ff7b0479SSaeed Bishara * @slot: Slot to free 249ff7b0479SSaeed Bishara * Caller must hold &mv_chan->lock while calling this function 250ff7b0479SSaeed Bishara */ 251ff7b0479SSaeed Bishara static void mv_xor_free_slots(struct mv_xor_chan *mv_chan, 252ff7b0479SSaeed Bishara struct mv_xor_desc_slot *slot) 253ff7b0479SSaeed Bishara { 254ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s %d slot %p\n", 255ff7b0479SSaeed Bishara __func__, __LINE__, slot); 256ff7b0479SSaeed Bishara 257ff7b0479SSaeed Bishara slot->slots_per_op = 0; 258ff7b0479SSaeed Bishara 259ff7b0479SSaeed Bishara } 260ff7b0479SSaeed Bishara 261ff7b0479SSaeed Bishara /* 262ff7b0479SSaeed Bishara * mv_xor_start_new_chain - program the engine to operate on new chain headed by 263ff7b0479SSaeed Bishara * sw_desc 264ff7b0479SSaeed Bishara * Caller must hold &mv_chan->lock while calling this function 265ff7b0479SSaeed Bishara */ 266ff7b0479SSaeed Bishara static void mv_xor_start_new_chain(struct mv_xor_chan *mv_chan, 267ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc) 268ff7b0479SSaeed Bishara { 269ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s %d: sw_desc %p\n", 270ff7b0479SSaeed Bishara __func__, __LINE__, sw_desc); 271ff7b0479SSaeed Bishara if (sw_desc->type != mv_chan->current_type) 272ff7b0479SSaeed Bishara mv_set_mode(mv_chan, sw_desc->type); 273ff7b0479SSaeed Bishara 274ff7b0479SSaeed Bishara if (sw_desc->type == DMA_MEMSET) { 275ff7b0479SSaeed Bishara /* for memset requests we need to program the engine, no 276ff7b0479SSaeed Bishara * descriptors used. 277ff7b0479SSaeed Bishara */ 278ff7b0479SSaeed Bishara struct mv_xor_desc *hw_desc = sw_desc->hw_desc; 279ff7b0479SSaeed Bishara mv_chan_set_dest_pointer(mv_chan, hw_desc->phy_dest_addr); 280ff7b0479SSaeed Bishara mv_chan_set_block_size(mv_chan, sw_desc->unmap_len); 281ff7b0479SSaeed Bishara mv_chan_set_value(mv_chan, sw_desc->value); 282ff7b0479SSaeed Bishara } else { 283ff7b0479SSaeed Bishara /* set the hardware chain */ 284ff7b0479SSaeed Bishara mv_chan_set_next_descriptor(mv_chan, sw_desc->async_tx.phys); 285ff7b0479SSaeed Bishara } 286ff7b0479SSaeed Bishara mv_chan->pending += sw_desc->slot_cnt; 287ff7b0479SSaeed Bishara mv_xor_issue_pending(&mv_chan->common); 288ff7b0479SSaeed Bishara } 289ff7b0479SSaeed Bishara 290ff7b0479SSaeed Bishara static dma_cookie_t 291ff7b0479SSaeed Bishara mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc, 292ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan, dma_cookie_t cookie) 293ff7b0479SSaeed Bishara { 294ff7b0479SSaeed Bishara BUG_ON(desc->async_tx.cookie < 0); 295ff7b0479SSaeed Bishara 296ff7b0479SSaeed Bishara if (desc->async_tx.cookie > 0) { 297ff7b0479SSaeed Bishara cookie = desc->async_tx.cookie; 298ff7b0479SSaeed Bishara 299ff7b0479SSaeed Bishara /* call the callback (must not sleep or submit new 300ff7b0479SSaeed Bishara * operations to this channel) 301ff7b0479SSaeed Bishara */ 302ff7b0479SSaeed Bishara if (desc->async_tx.callback) 303ff7b0479SSaeed Bishara desc->async_tx.callback( 304ff7b0479SSaeed Bishara desc->async_tx.callback_param); 305ff7b0479SSaeed Bishara 306ff7b0479SSaeed Bishara /* unmap dma addresses 307ff7b0479SSaeed Bishara * (unmap_single vs unmap_page?) 308ff7b0479SSaeed Bishara */ 309ff7b0479SSaeed Bishara if (desc->group_head && desc->unmap_len) { 310ff7b0479SSaeed Bishara struct mv_xor_desc_slot *unmap = desc->group_head; 311ff7b0479SSaeed Bishara struct device *dev = 312ff7b0479SSaeed Bishara &mv_chan->device->pdev->dev; 313ff7b0479SSaeed Bishara u32 len = unmap->unmap_len; 314e1d181efSDan Williams enum dma_ctrl_flags flags = desc->async_tx.flags; 315e1d181efSDan Williams u32 src_cnt; 316e1d181efSDan Williams dma_addr_t addr; 317a06d568fSDan Williams dma_addr_t dest; 318ff7b0479SSaeed Bishara 319a06d568fSDan Williams src_cnt = unmap->unmap_src_cnt; 320a06d568fSDan Williams dest = mv_desc_get_dest_addr(unmap); 321e1d181efSDan Williams if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { 322a06d568fSDan Williams enum dma_data_direction dir; 323a06d568fSDan Williams 324a06d568fSDan Williams if (src_cnt > 1) /* is xor ? */ 325a06d568fSDan Williams dir = DMA_BIDIRECTIONAL; 326a06d568fSDan Williams else 327a06d568fSDan Williams dir = DMA_FROM_DEVICE; 328a06d568fSDan Williams dma_unmap_page(dev, dest, len, dir); 329e1d181efSDan Williams } 330e1d181efSDan Williams 331e1d181efSDan Williams if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { 332ff7b0479SSaeed Bishara while (src_cnt--) { 333e1d181efSDan Williams addr = mv_desc_get_src_addr(unmap, 334e1d181efSDan Williams src_cnt); 335a06d568fSDan Williams if (addr == dest) 336a06d568fSDan Williams continue; 337e1d181efSDan Williams dma_unmap_page(dev, addr, len, 338e1d181efSDan Williams DMA_TO_DEVICE); 339e1d181efSDan Williams } 340ff7b0479SSaeed Bishara } 341ff7b0479SSaeed Bishara desc->group_head = NULL; 342ff7b0479SSaeed Bishara } 343ff7b0479SSaeed Bishara } 344ff7b0479SSaeed Bishara 345ff7b0479SSaeed Bishara /* run dependent operations */ 34607f2211eSDan Williams dma_run_dependencies(&desc->async_tx); 347ff7b0479SSaeed Bishara 348ff7b0479SSaeed Bishara return cookie; 349ff7b0479SSaeed Bishara } 350ff7b0479SSaeed Bishara 351ff7b0479SSaeed Bishara static int 352ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(struct mv_xor_chan *mv_chan) 353ff7b0479SSaeed Bishara { 354ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 355ff7b0479SSaeed Bishara 356ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s %d\n", __func__, __LINE__); 357ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->completed_slots, 358ff7b0479SSaeed Bishara completed_node) { 359ff7b0479SSaeed Bishara 360ff7b0479SSaeed Bishara if (async_tx_test_ack(&iter->async_tx)) { 361ff7b0479SSaeed Bishara list_del(&iter->completed_node); 362ff7b0479SSaeed Bishara mv_xor_free_slots(mv_chan, iter); 363ff7b0479SSaeed Bishara } 364ff7b0479SSaeed Bishara } 365ff7b0479SSaeed Bishara return 0; 366ff7b0479SSaeed Bishara } 367ff7b0479SSaeed Bishara 368ff7b0479SSaeed Bishara static int 369ff7b0479SSaeed Bishara mv_xor_clean_slot(struct mv_xor_desc_slot *desc, 370ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan) 371ff7b0479SSaeed Bishara { 372ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s %d: desc %p flags %d\n", 373ff7b0479SSaeed Bishara __func__, __LINE__, desc, desc->async_tx.flags); 374ff7b0479SSaeed Bishara list_del(&desc->chain_node); 375ff7b0479SSaeed Bishara /* the client is allowed to attach dependent operations 376ff7b0479SSaeed Bishara * until 'ack' is set 377ff7b0479SSaeed Bishara */ 378ff7b0479SSaeed Bishara if (!async_tx_test_ack(&desc->async_tx)) { 379ff7b0479SSaeed Bishara /* move this slot to the completed_slots */ 380ff7b0479SSaeed Bishara list_add_tail(&desc->completed_node, &mv_chan->completed_slots); 381ff7b0479SSaeed Bishara return 0; 382ff7b0479SSaeed Bishara } 383ff7b0479SSaeed Bishara 384ff7b0479SSaeed Bishara mv_xor_free_slots(mv_chan, desc); 385ff7b0479SSaeed Bishara return 0; 386ff7b0479SSaeed Bishara } 387ff7b0479SSaeed Bishara 388ff7b0479SSaeed Bishara static void __mv_xor_slot_cleanup(struct mv_xor_chan *mv_chan) 389ff7b0479SSaeed Bishara { 390ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 391ff7b0479SSaeed Bishara dma_cookie_t cookie = 0; 392ff7b0479SSaeed Bishara int busy = mv_chan_is_busy(mv_chan); 393ff7b0479SSaeed Bishara u32 current_desc = mv_chan_get_current_desc(mv_chan); 394ff7b0479SSaeed Bishara int seen_current = 0; 395ff7b0479SSaeed Bishara 396ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s %d\n", __func__, __LINE__); 397ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "current_desc %x\n", current_desc); 398ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(mv_chan); 399ff7b0479SSaeed Bishara 400ff7b0479SSaeed Bishara /* free completed slots from the chain starting with 401ff7b0479SSaeed Bishara * the oldest descriptor 402ff7b0479SSaeed Bishara */ 403ff7b0479SSaeed Bishara 404ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->chain, 405ff7b0479SSaeed Bishara chain_node) { 406ff7b0479SSaeed Bishara prefetch(_iter); 407ff7b0479SSaeed Bishara prefetch(&_iter->async_tx); 408ff7b0479SSaeed Bishara 409ff7b0479SSaeed Bishara /* do not advance past the current descriptor loaded into the 410ff7b0479SSaeed Bishara * hardware channel, subsequent descriptors are either in 411ff7b0479SSaeed Bishara * process or have not been submitted 412ff7b0479SSaeed Bishara */ 413ff7b0479SSaeed Bishara if (seen_current) 414ff7b0479SSaeed Bishara break; 415ff7b0479SSaeed Bishara 416ff7b0479SSaeed Bishara /* stop the search if we reach the current descriptor and the 417ff7b0479SSaeed Bishara * channel is busy 418ff7b0479SSaeed Bishara */ 419ff7b0479SSaeed Bishara if (iter->async_tx.phys == current_desc) { 420ff7b0479SSaeed Bishara seen_current = 1; 421ff7b0479SSaeed Bishara if (busy) 422ff7b0479SSaeed Bishara break; 423ff7b0479SSaeed Bishara } 424ff7b0479SSaeed Bishara 425ff7b0479SSaeed Bishara cookie = mv_xor_run_tx_complete_actions(iter, mv_chan, cookie); 426ff7b0479SSaeed Bishara 427ff7b0479SSaeed Bishara if (mv_xor_clean_slot(iter, mv_chan)) 428ff7b0479SSaeed Bishara break; 429ff7b0479SSaeed Bishara } 430ff7b0479SSaeed Bishara 431ff7b0479SSaeed Bishara if ((busy == 0) && !list_empty(&mv_chan->chain)) { 432ff7b0479SSaeed Bishara struct mv_xor_desc_slot *chain_head; 433ff7b0479SSaeed Bishara chain_head = list_entry(mv_chan->chain.next, 434ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 435ff7b0479SSaeed Bishara chain_node); 436ff7b0479SSaeed Bishara 437ff7b0479SSaeed Bishara mv_xor_start_new_chain(mv_chan, chain_head); 438ff7b0479SSaeed Bishara } 439ff7b0479SSaeed Bishara 440ff7b0479SSaeed Bishara if (cookie > 0) 4414d4e58deSRussell King - ARM Linux mv_chan->common.completed_cookie = cookie; 442ff7b0479SSaeed Bishara } 443ff7b0479SSaeed Bishara 444ff7b0479SSaeed Bishara static void 445ff7b0479SSaeed Bishara mv_xor_slot_cleanup(struct mv_xor_chan *mv_chan) 446ff7b0479SSaeed Bishara { 447ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 448ff7b0479SSaeed Bishara __mv_xor_slot_cleanup(mv_chan); 449ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 450ff7b0479SSaeed Bishara } 451ff7b0479SSaeed Bishara 452ff7b0479SSaeed Bishara static void mv_xor_tasklet(unsigned long data) 453ff7b0479SSaeed Bishara { 454ff7b0479SSaeed Bishara struct mv_xor_chan *chan = (struct mv_xor_chan *) data; 4558333f65eSSaeed Bishara mv_xor_slot_cleanup(chan); 456ff7b0479SSaeed Bishara } 457ff7b0479SSaeed Bishara 458ff7b0479SSaeed Bishara static struct mv_xor_desc_slot * 459ff7b0479SSaeed Bishara mv_xor_alloc_slots(struct mv_xor_chan *mv_chan, int num_slots, 460ff7b0479SSaeed Bishara int slots_per_op) 461ff7b0479SSaeed Bishara { 462ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter, *alloc_start = NULL; 463ff7b0479SSaeed Bishara LIST_HEAD(chain); 464ff7b0479SSaeed Bishara int slots_found, retry = 0; 465ff7b0479SSaeed Bishara 466ff7b0479SSaeed Bishara /* start search from the last allocated descrtiptor 467ff7b0479SSaeed Bishara * if a contiguous allocation can not be found start searching 468ff7b0479SSaeed Bishara * from the beginning of the list 469ff7b0479SSaeed Bishara */ 470ff7b0479SSaeed Bishara retry: 471ff7b0479SSaeed Bishara slots_found = 0; 472ff7b0479SSaeed Bishara if (retry == 0) 473ff7b0479SSaeed Bishara iter = mv_chan->last_used; 474ff7b0479SSaeed Bishara else 475ff7b0479SSaeed Bishara iter = list_entry(&mv_chan->all_slots, 476ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 477ff7b0479SSaeed Bishara slot_node); 478ff7b0479SSaeed Bishara 479ff7b0479SSaeed Bishara list_for_each_entry_safe_continue( 480ff7b0479SSaeed Bishara iter, _iter, &mv_chan->all_slots, slot_node) { 481ff7b0479SSaeed Bishara prefetch(_iter); 482ff7b0479SSaeed Bishara prefetch(&_iter->async_tx); 483ff7b0479SSaeed Bishara if (iter->slots_per_op) { 484ff7b0479SSaeed Bishara /* give up after finding the first busy slot 485ff7b0479SSaeed Bishara * on the second pass through the list 486ff7b0479SSaeed Bishara */ 487ff7b0479SSaeed Bishara if (retry) 488ff7b0479SSaeed Bishara break; 489ff7b0479SSaeed Bishara 490ff7b0479SSaeed Bishara slots_found = 0; 491ff7b0479SSaeed Bishara continue; 492ff7b0479SSaeed Bishara } 493ff7b0479SSaeed Bishara 494ff7b0479SSaeed Bishara /* start the allocation if the slot is correctly aligned */ 495ff7b0479SSaeed Bishara if (!slots_found++) 496ff7b0479SSaeed Bishara alloc_start = iter; 497ff7b0479SSaeed Bishara 498ff7b0479SSaeed Bishara if (slots_found == num_slots) { 499ff7b0479SSaeed Bishara struct mv_xor_desc_slot *alloc_tail = NULL; 500ff7b0479SSaeed Bishara struct mv_xor_desc_slot *last_used = NULL; 501ff7b0479SSaeed Bishara iter = alloc_start; 502ff7b0479SSaeed Bishara while (num_slots) { 503ff7b0479SSaeed Bishara int i; 504ff7b0479SSaeed Bishara 505ff7b0479SSaeed Bishara /* pre-ack all but the last descriptor */ 506ff7b0479SSaeed Bishara async_tx_ack(&iter->async_tx); 507ff7b0479SSaeed Bishara 508ff7b0479SSaeed Bishara list_add_tail(&iter->chain_node, &chain); 509ff7b0479SSaeed Bishara alloc_tail = iter; 510ff7b0479SSaeed Bishara iter->async_tx.cookie = 0; 511ff7b0479SSaeed Bishara iter->slot_cnt = num_slots; 512ff7b0479SSaeed Bishara iter->xor_check_result = NULL; 513ff7b0479SSaeed Bishara for (i = 0; i < slots_per_op; i++) { 514ff7b0479SSaeed Bishara iter->slots_per_op = slots_per_op - i; 515ff7b0479SSaeed Bishara last_used = iter; 516ff7b0479SSaeed Bishara iter = list_entry(iter->slot_node.next, 517ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 518ff7b0479SSaeed Bishara slot_node); 519ff7b0479SSaeed Bishara } 520ff7b0479SSaeed Bishara num_slots -= slots_per_op; 521ff7b0479SSaeed Bishara } 522ff7b0479SSaeed Bishara alloc_tail->group_head = alloc_start; 523ff7b0479SSaeed Bishara alloc_tail->async_tx.cookie = -EBUSY; 52464203b67SDan Williams list_splice(&chain, &alloc_tail->tx_list); 525ff7b0479SSaeed Bishara mv_chan->last_used = last_used; 526ff7b0479SSaeed Bishara mv_desc_clear_next_desc(alloc_start); 527ff7b0479SSaeed Bishara mv_desc_clear_next_desc(alloc_tail); 528ff7b0479SSaeed Bishara return alloc_tail; 529ff7b0479SSaeed Bishara } 530ff7b0479SSaeed Bishara } 531ff7b0479SSaeed Bishara if (!retry++) 532ff7b0479SSaeed Bishara goto retry; 533ff7b0479SSaeed Bishara 534ff7b0479SSaeed Bishara /* try to free some slots if the allocation fails */ 535ff7b0479SSaeed Bishara tasklet_schedule(&mv_chan->irq_tasklet); 536ff7b0479SSaeed Bishara 537ff7b0479SSaeed Bishara return NULL; 538ff7b0479SSaeed Bishara } 539ff7b0479SSaeed Bishara 540ff7b0479SSaeed Bishara /************************ DMA engine API functions ****************************/ 541ff7b0479SSaeed Bishara static dma_cookie_t 542ff7b0479SSaeed Bishara mv_xor_tx_submit(struct dma_async_tx_descriptor *tx) 543ff7b0479SSaeed Bishara { 544ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc = to_mv_xor_slot(tx); 545ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(tx->chan); 546ff7b0479SSaeed Bishara struct mv_xor_desc_slot *grp_start, *old_chain_tail; 547ff7b0479SSaeed Bishara dma_cookie_t cookie; 548ff7b0479SSaeed Bishara int new_hw_chain = 1; 549ff7b0479SSaeed Bishara 550ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 551ff7b0479SSaeed Bishara "%s sw_desc %p: async_tx %p\n", 552ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 553ff7b0479SSaeed Bishara 554ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 555ff7b0479SSaeed Bishara 556ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 557884485e1SRussell King - ARM Linux cookie = dma_cookie_assign(tx); 558ff7b0479SSaeed Bishara 559ff7b0479SSaeed Bishara if (list_empty(&mv_chan->chain)) 56064203b67SDan Williams list_splice_init(&sw_desc->tx_list, &mv_chan->chain); 561ff7b0479SSaeed Bishara else { 562ff7b0479SSaeed Bishara new_hw_chain = 0; 563ff7b0479SSaeed Bishara 564ff7b0479SSaeed Bishara old_chain_tail = list_entry(mv_chan->chain.prev, 565ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 566ff7b0479SSaeed Bishara chain_node); 56764203b67SDan Williams list_splice_init(&grp_start->tx_list, 568ff7b0479SSaeed Bishara &old_chain_tail->chain_node); 569ff7b0479SSaeed Bishara 570ff7b0479SSaeed Bishara if (!mv_can_chain(grp_start)) 571ff7b0479SSaeed Bishara goto submit_done; 572ff7b0479SSaeed Bishara 573ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "Append to last desc %x\n", 574ff7b0479SSaeed Bishara old_chain_tail->async_tx.phys); 575ff7b0479SSaeed Bishara 576ff7b0479SSaeed Bishara /* fix up the hardware chain */ 577ff7b0479SSaeed Bishara mv_desc_set_next_desc(old_chain_tail, grp_start->async_tx.phys); 578ff7b0479SSaeed Bishara 579ff7b0479SSaeed Bishara /* if the channel is not busy */ 580ff7b0479SSaeed Bishara if (!mv_chan_is_busy(mv_chan)) { 581ff7b0479SSaeed Bishara u32 current_desc = mv_chan_get_current_desc(mv_chan); 582ff7b0479SSaeed Bishara /* 583ff7b0479SSaeed Bishara * and the curren desc is the end of the chain before 584ff7b0479SSaeed Bishara * the append, then we need to start the channel 585ff7b0479SSaeed Bishara */ 586ff7b0479SSaeed Bishara if (current_desc == old_chain_tail->async_tx.phys) 587ff7b0479SSaeed Bishara new_hw_chain = 1; 588ff7b0479SSaeed Bishara } 589ff7b0479SSaeed Bishara } 590ff7b0479SSaeed Bishara 591ff7b0479SSaeed Bishara if (new_hw_chain) 592ff7b0479SSaeed Bishara mv_xor_start_new_chain(mv_chan, grp_start); 593ff7b0479SSaeed Bishara 594ff7b0479SSaeed Bishara submit_done: 595ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 596ff7b0479SSaeed Bishara 597ff7b0479SSaeed Bishara return cookie; 598ff7b0479SSaeed Bishara } 599ff7b0479SSaeed Bishara 600ff7b0479SSaeed Bishara /* returns the number of allocated descriptors */ 601aa1e6f1aSDan Williams static int mv_xor_alloc_chan_resources(struct dma_chan *chan) 602ff7b0479SSaeed Bishara { 603ff7b0479SSaeed Bishara char *hw_desc; 604ff7b0479SSaeed Bishara int idx; 605ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 606ff7b0479SSaeed Bishara struct mv_xor_desc_slot *slot = NULL; 607ff7b0479SSaeed Bishara struct mv_xor_platform_data *plat_data = 608ff7b0479SSaeed Bishara mv_chan->device->pdev->dev.platform_data; 609ff7b0479SSaeed Bishara int num_descs_in_pool = plat_data->pool_size/MV_XOR_SLOT_SIZE; 610ff7b0479SSaeed Bishara 611ff7b0479SSaeed Bishara /* Allocate descriptor slots */ 612ff7b0479SSaeed Bishara idx = mv_chan->slots_allocated; 613ff7b0479SSaeed Bishara while (idx < num_descs_in_pool) { 614ff7b0479SSaeed Bishara slot = kzalloc(sizeof(*slot), GFP_KERNEL); 615ff7b0479SSaeed Bishara if (!slot) { 616ff7b0479SSaeed Bishara printk(KERN_INFO "MV XOR Channel only initialized" 617ff7b0479SSaeed Bishara " %d descriptor slots", idx); 618ff7b0479SSaeed Bishara break; 619ff7b0479SSaeed Bishara } 620ff7b0479SSaeed Bishara hw_desc = (char *) mv_chan->device->dma_desc_pool_virt; 621ff7b0479SSaeed Bishara slot->hw_desc = (void *) &hw_desc[idx * MV_XOR_SLOT_SIZE]; 622ff7b0479SSaeed Bishara 623ff7b0479SSaeed Bishara dma_async_tx_descriptor_init(&slot->async_tx, chan); 624ff7b0479SSaeed Bishara slot->async_tx.tx_submit = mv_xor_tx_submit; 625ff7b0479SSaeed Bishara INIT_LIST_HEAD(&slot->chain_node); 626ff7b0479SSaeed Bishara INIT_LIST_HEAD(&slot->slot_node); 62764203b67SDan Williams INIT_LIST_HEAD(&slot->tx_list); 628ff7b0479SSaeed Bishara hw_desc = (char *) mv_chan->device->dma_desc_pool; 629ff7b0479SSaeed Bishara slot->async_tx.phys = 630ff7b0479SSaeed Bishara (dma_addr_t) &hw_desc[idx * MV_XOR_SLOT_SIZE]; 631ff7b0479SSaeed Bishara slot->idx = idx++; 632ff7b0479SSaeed Bishara 633ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 634ff7b0479SSaeed Bishara mv_chan->slots_allocated = idx; 635ff7b0479SSaeed Bishara list_add_tail(&slot->slot_node, &mv_chan->all_slots); 636ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 637ff7b0479SSaeed Bishara } 638ff7b0479SSaeed Bishara 639ff7b0479SSaeed Bishara if (mv_chan->slots_allocated && !mv_chan->last_used) 640ff7b0479SSaeed Bishara mv_chan->last_used = list_entry(mv_chan->all_slots.next, 641ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 642ff7b0479SSaeed Bishara slot_node); 643ff7b0479SSaeed Bishara 644ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 645ff7b0479SSaeed Bishara "allocated %d descriptor slots last_used: %p\n", 646ff7b0479SSaeed Bishara mv_chan->slots_allocated, mv_chan->last_used); 647ff7b0479SSaeed Bishara 648ff7b0479SSaeed Bishara return mv_chan->slots_allocated ? : -ENOMEM; 649ff7b0479SSaeed Bishara } 650ff7b0479SSaeed Bishara 651ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 652ff7b0479SSaeed Bishara mv_xor_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, 653ff7b0479SSaeed Bishara size_t len, unsigned long flags) 654ff7b0479SSaeed Bishara { 655ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 656ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 657ff7b0479SSaeed Bishara int slot_cnt; 658ff7b0479SSaeed Bishara 659ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 660ff7b0479SSaeed Bishara "%s dest: %x src %x len: %u flags: %ld\n", 661ff7b0479SSaeed Bishara __func__, dest, src, len, flags); 662ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 663ff7b0479SSaeed Bishara return NULL; 664ff7b0479SSaeed Bishara 6657912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 666ff7b0479SSaeed Bishara 667ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 668ff7b0479SSaeed Bishara slot_cnt = mv_chan_memcpy_slot_count(len); 669ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 670ff7b0479SSaeed Bishara if (sw_desc) { 671ff7b0479SSaeed Bishara sw_desc->type = DMA_MEMCPY; 672ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 673ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 674ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 675ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 676ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 677ff7b0479SSaeed Bishara mv_desc_set_src_addr(grp_start, 0, src); 678ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = 1; 679ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 680ff7b0479SSaeed Bishara } 681ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 682ff7b0479SSaeed Bishara 683ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 684ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p\n", 685ff7b0479SSaeed Bishara __func__, sw_desc, sw_desc ? &sw_desc->async_tx : 0); 686ff7b0479SSaeed Bishara 687ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 688ff7b0479SSaeed Bishara } 689ff7b0479SSaeed Bishara 690ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 691ff7b0479SSaeed Bishara mv_xor_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value, 692ff7b0479SSaeed Bishara size_t len, unsigned long flags) 693ff7b0479SSaeed Bishara { 694ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 695ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 696ff7b0479SSaeed Bishara int slot_cnt; 697ff7b0479SSaeed Bishara 698ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 699ff7b0479SSaeed Bishara "%s dest: %x len: %u flags: %ld\n", 700ff7b0479SSaeed Bishara __func__, dest, len, flags); 701ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 702ff7b0479SSaeed Bishara return NULL; 703ff7b0479SSaeed Bishara 7047912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 705ff7b0479SSaeed Bishara 706ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 707ff7b0479SSaeed Bishara slot_cnt = mv_chan_memset_slot_count(len); 708ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 709ff7b0479SSaeed Bishara if (sw_desc) { 710ff7b0479SSaeed Bishara sw_desc->type = DMA_MEMSET; 711ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 712ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 713ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 714ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 715ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 716ff7b0479SSaeed Bishara mv_desc_set_block_fill_val(grp_start, value); 717ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = 1; 718ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 719ff7b0479SSaeed Bishara } 720ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 721ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 722ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p \n", 723ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 724ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 725ff7b0479SSaeed Bishara } 726ff7b0479SSaeed Bishara 727ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 728ff7b0479SSaeed Bishara mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, 729ff7b0479SSaeed Bishara unsigned int src_cnt, size_t len, unsigned long flags) 730ff7b0479SSaeed Bishara { 731ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 732ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 733ff7b0479SSaeed Bishara int slot_cnt; 734ff7b0479SSaeed Bishara 735ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 736ff7b0479SSaeed Bishara return NULL; 737ff7b0479SSaeed Bishara 7387912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 739ff7b0479SSaeed Bishara 740ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 741ff7b0479SSaeed Bishara "%s src_cnt: %d len: dest %x %u flags: %ld\n", 742ff7b0479SSaeed Bishara __func__, src_cnt, len, dest, flags); 743ff7b0479SSaeed Bishara 744ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 745ff7b0479SSaeed Bishara slot_cnt = mv_chan_xor_slot_count(len, src_cnt); 746ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 747ff7b0479SSaeed Bishara if (sw_desc) { 748ff7b0479SSaeed Bishara sw_desc->type = DMA_XOR; 749ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 750ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 751ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 752ff7b0479SSaeed Bishara /* the byte count field is the same as in memcpy desc*/ 753ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 754ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 755ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = src_cnt; 756ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 757ff7b0479SSaeed Bishara while (src_cnt--) 758ff7b0479SSaeed Bishara mv_desc_set_src_addr(grp_start, src_cnt, src[src_cnt]); 759ff7b0479SSaeed Bishara } 760ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 761ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, 762ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p \n", 763ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 764ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 765ff7b0479SSaeed Bishara } 766ff7b0479SSaeed Bishara 767ff7b0479SSaeed Bishara static void mv_xor_free_chan_resources(struct dma_chan *chan) 768ff7b0479SSaeed Bishara { 769ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 770ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 771ff7b0479SSaeed Bishara int in_use_descs = 0; 772ff7b0479SSaeed Bishara 773ff7b0479SSaeed Bishara mv_xor_slot_cleanup(mv_chan); 774ff7b0479SSaeed Bishara 775ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 776ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->chain, 777ff7b0479SSaeed Bishara chain_node) { 778ff7b0479SSaeed Bishara in_use_descs++; 779ff7b0479SSaeed Bishara list_del(&iter->chain_node); 780ff7b0479SSaeed Bishara } 781ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->completed_slots, 782ff7b0479SSaeed Bishara completed_node) { 783ff7b0479SSaeed Bishara in_use_descs++; 784ff7b0479SSaeed Bishara list_del(&iter->completed_node); 785ff7b0479SSaeed Bishara } 786ff7b0479SSaeed Bishara list_for_each_entry_safe_reverse( 787ff7b0479SSaeed Bishara iter, _iter, &mv_chan->all_slots, slot_node) { 788ff7b0479SSaeed Bishara list_del(&iter->slot_node); 789ff7b0479SSaeed Bishara kfree(iter); 790ff7b0479SSaeed Bishara mv_chan->slots_allocated--; 791ff7b0479SSaeed Bishara } 792ff7b0479SSaeed Bishara mv_chan->last_used = NULL; 793ff7b0479SSaeed Bishara 794ff7b0479SSaeed Bishara dev_dbg(mv_chan->device->common.dev, "%s slots_allocated %d\n", 795ff7b0479SSaeed Bishara __func__, mv_chan->slots_allocated); 796ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 797ff7b0479SSaeed Bishara 798ff7b0479SSaeed Bishara if (in_use_descs) 799ff7b0479SSaeed Bishara dev_err(mv_chan->device->common.dev, 800ff7b0479SSaeed Bishara "freeing %d in use descriptors!\n", in_use_descs); 801ff7b0479SSaeed Bishara } 802ff7b0479SSaeed Bishara 803ff7b0479SSaeed Bishara /** 80407934481SLinus Walleij * mv_xor_status - poll the status of an XOR transaction 805ff7b0479SSaeed Bishara * @chan: XOR channel handle 806ff7b0479SSaeed Bishara * @cookie: XOR transaction identifier 80707934481SLinus Walleij * @txstate: XOR transactions state holder (or NULL) 808ff7b0479SSaeed Bishara */ 80907934481SLinus Walleij static enum dma_status mv_xor_status(struct dma_chan *chan, 810ff7b0479SSaeed Bishara dma_cookie_t cookie, 81107934481SLinus Walleij struct dma_tx_state *txstate) 812ff7b0479SSaeed Bishara { 813ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 814ff7b0479SSaeed Bishara enum dma_status ret; 815ff7b0479SSaeed Bishara 81696a2af41SRussell King - ARM Linux ret = dma_cookie_status(chan, cookie, txstate); 817ff7b0479SSaeed Bishara if (ret == DMA_SUCCESS) { 818ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(mv_chan); 819ff7b0479SSaeed Bishara return ret; 820ff7b0479SSaeed Bishara } 821ff7b0479SSaeed Bishara mv_xor_slot_cleanup(mv_chan); 822ff7b0479SSaeed Bishara 82396a2af41SRussell King - ARM Linux return dma_cookie_status(chan, cookie, txstate); 824ff7b0479SSaeed Bishara } 825ff7b0479SSaeed Bishara 826ff7b0479SSaeed Bishara static void mv_dump_xor_regs(struct mv_xor_chan *chan) 827ff7b0479SSaeed Bishara { 828ff7b0479SSaeed Bishara u32 val; 829ff7b0479SSaeed Bishara 830ff7b0479SSaeed Bishara val = __raw_readl(XOR_CONFIG(chan)); 831ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 832ff7b0479SSaeed Bishara "config 0x%08x.\n", val); 833ff7b0479SSaeed Bishara 834ff7b0479SSaeed Bishara val = __raw_readl(XOR_ACTIVATION(chan)); 835ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 836ff7b0479SSaeed Bishara "activation 0x%08x.\n", val); 837ff7b0479SSaeed Bishara 838ff7b0479SSaeed Bishara val = __raw_readl(XOR_INTR_CAUSE(chan)); 839ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 840ff7b0479SSaeed Bishara "intr cause 0x%08x.\n", val); 841ff7b0479SSaeed Bishara 842ff7b0479SSaeed Bishara val = __raw_readl(XOR_INTR_MASK(chan)); 843ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 844ff7b0479SSaeed Bishara "intr mask 0x%08x.\n", val); 845ff7b0479SSaeed Bishara 846ff7b0479SSaeed Bishara val = __raw_readl(XOR_ERROR_CAUSE(chan)); 847ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 848ff7b0479SSaeed Bishara "error cause 0x%08x.\n", val); 849ff7b0479SSaeed Bishara 850ff7b0479SSaeed Bishara val = __raw_readl(XOR_ERROR_ADDR(chan)); 851ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 852ff7b0479SSaeed Bishara "error addr 0x%08x.\n", val); 853ff7b0479SSaeed Bishara } 854ff7b0479SSaeed Bishara 855ff7b0479SSaeed Bishara static void mv_xor_err_interrupt_handler(struct mv_xor_chan *chan, 856ff7b0479SSaeed Bishara u32 intr_cause) 857ff7b0479SSaeed Bishara { 858ff7b0479SSaeed Bishara if (intr_cause & (1 << 4)) { 859ff7b0479SSaeed Bishara dev_dbg(chan->device->common.dev, 860ff7b0479SSaeed Bishara "ignore this error\n"); 861ff7b0479SSaeed Bishara return; 862ff7b0479SSaeed Bishara } 863ff7b0479SSaeed Bishara 864ff7b0479SSaeed Bishara dev_printk(KERN_ERR, chan->device->common.dev, 865ff7b0479SSaeed Bishara "error on chan %d. intr cause 0x%08x.\n", 866ff7b0479SSaeed Bishara chan->idx, intr_cause); 867ff7b0479SSaeed Bishara 868ff7b0479SSaeed Bishara mv_dump_xor_regs(chan); 869ff7b0479SSaeed Bishara BUG(); 870ff7b0479SSaeed Bishara } 871ff7b0479SSaeed Bishara 872ff7b0479SSaeed Bishara static irqreturn_t mv_xor_interrupt_handler(int irq, void *data) 873ff7b0479SSaeed Bishara { 874ff7b0479SSaeed Bishara struct mv_xor_chan *chan = data; 875ff7b0479SSaeed Bishara u32 intr_cause = mv_chan_get_intr_cause(chan); 876ff7b0479SSaeed Bishara 877ff7b0479SSaeed Bishara dev_dbg(chan->device->common.dev, "intr cause %x\n", intr_cause); 878ff7b0479SSaeed Bishara 879ff7b0479SSaeed Bishara if (mv_is_err_intr(intr_cause)) 880ff7b0479SSaeed Bishara mv_xor_err_interrupt_handler(chan, intr_cause); 881ff7b0479SSaeed Bishara 882ff7b0479SSaeed Bishara tasklet_schedule(&chan->irq_tasklet); 883ff7b0479SSaeed Bishara 884ff7b0479SSaeed Bishara mv_xor_device_clear_eoc_cause(chan); 885ff7b0479SSaeed Bishara 886ff7b0479SSaeed Bishara return IRQ_HANDLED; 887ff7b0479SSaeed Bishara } 888ff7b0479SSaeed Bishara 889ff7b0479SSaeed Bishara static void mv_xor_issue_pending(struct dma_chan *chan) 890ff7b0479SSaeed Bishara { 891ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 892ff7b0479SSaeed Bishara 893ff7b0479SSaeed Bishara if (mv_chan->pending >= MV_XOR_THRESHOLD) { 894ff7b0479SSaeed Bishara mv_chan->pending = 0; 895ff7b0479SSaeed Bishara mv_chan_activate(mv_chan); 896ff7b0479SSaeed Bishara } 897ff7b0479SSaeed Bishara } 898ff7b0479SSaeed Bishara 899ff7b0479SSaeed Bishara /* 900ff7b0479SSaeed Bishara * Perform a transaction to verify the HW works. 901ff7b0479SSaeed Bishara */ 902ff7b0479SSaeed Bishara #define MV_XOR_TEST_SIZE 2000 903ff7b0479SSaeed Bishara 904ff7b0479SSaeed Bishara static int __devinit mv_xor_memcpy_self_test(struct mv_xor_device *device) 905ff7b0479SSaeed Bishara { 906ff7b0479SSaeed Bishara int i; 907ff7b0479SSaeed Bishara void *src, *dest; 908ff7b0479SSaeed Bishara dma_addr_t src_dma, dest_dma; 909ff7b0479SSaeed Bishara struct dma_chan *dma_chan; 910ff7b0479SSaeed Bishara dma_cookie_t cookie; 911ff7b0479SSaeed Bishara struct dma_async_tx_descriptor *tx; 912ff7b0479SSaeed Bishara int err = 0; 913ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 914ff7b0479SSaeed Bishara 915ff7b0479SSaeed Bishara src = kmalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); 916ff7b0479SSaeed Bishara if (!src) 917ff7b0479SSaeed Bishara return -ENOMEM; 918ff7b0479SSaeed Bishara 919ff7b0479SSaeed Bishara dest = kzalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); 920ff7b0479SSaeed Bishara if (!dest) { 921ff7b0479SSaeed Bishara kfree(src); 922ff7b0479SSaeed Bishara return -ENOMEM; 923ff7b0479SSaeed Bishara } 924ff7b0479SSaeed Bishara 925ff7b0479SSaeed Bishara /* Fill in src buffer */ 926ff7b0479SSaeed Bishara for (i = 0; i < MV_XOR_TEST_SIZE; i++) 927ff7b0479SSaeed Bishara ((u8 *) src)[i] = (u8)i; 928ff7b0479SSaeed Bishara 929ff7b0479SSaeed Bishara /* Start copy, using first DMA channel */ 930ff7b0479SSaeed Bishara dma_chan = container_of(device->common.channels.next, 931ff7b0479SSaeed Bishara struct dma_chan, 932ff7b0479SSaeed Bishara device_node); 933aa1e6f1aSDan Williams if (mv_xor_alloc_chan_resources(dma_chan) < 1) { 934ff7b0479SSaeed Bishara err = -ENODEV; 935ff7b0479SSaeed Bishara goto out; 936ff7b0479SSaeed Bishara } 937ff7b0479SSaeed Bishara 938ff7b0479SSaeed Bishara dest_dma = dma_map_single(dma_chan->device->dev, dest, 939ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); 940ff7b0479SSaeed Bishara 941ff7b0479SSaeed Bishara src_dma = dma_map_single(dma_chan->device->dev, src, 942ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_TO_DEVICE); 943ff7b0479SSaeed Bishara 944ff7b0479SSaeed Bishara tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, 945ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, 0); 946ff7b0479SSaeed Bishara cookie = mv_xor_tx_submit(tx); 947ff7b0479SSaeed Bishara mv_xor_issue_pending(dma_chan); 948ff7b0479SSaeed Bishara async_tx_ack(tx); 949ff7b0479SSaeed Bishara msleep(1); 950ff7b0479SSaeed Bishara 95107934481SLinus Walleij if (mv_xor_status(dma_chan, cookie, NULL) != 952ff7b0479SSaeed Bishara DMA_SUCCESS) { 953ff7b0479SSaeed Bishara dev_printk(KERN_ERR, dma_chan->device->dev, 954ff7b0479SSaeed Bishara "Self-test copy timed out, disabling\n"); 955ff7b0479SSaeed Bishara err = -ENODEV; 956ff7b0479SSaeed Bishara goto free_resources; 957ff7b0479SSaeed Bishara } 958ff7b0479SSaeed Bishara 959ff7b0479SSaeed Bishara mv_chan = to_mv_xor_chan(dma_chan); 960ff7b0479SSaeed Bishara dma_sync_single_for_cpu(&mv_chan->device->pdev->dev, dest_dma, 961ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); 962ff7b0479SSaeed Bishara if (memcmp(src, dest, MV_XOR_TEST_SIZE)) { 963ff7b0479SSaeed Bishara dev_printk(KERN_ERR, dma_chan->device->dev, 964ff7b0479SSaeed Bishara "Self-test copy failed compare, disabling\n"); 965ff7b0479SSaeed Bishara err = -ENODEV; 966ff7b0479SSaeed Bishara goto free_resources; 967ff7b0479SSaeed Bishara } 968ff7b0479SSaeed Bishara 969ff7b0479SSaeed Bishara free_resources: 970ff7b0479SSaeed Bishara mv_xor_free_chan_resources(dma_chan); 971ff7b0479SSaeed Bishara out: 972ff7b0479SSaeed Bishara kfree(src); 973ff7b0479SSaeed Bishara kfree(dest); 974ff7b0479SSaeed Bishara return err; 975ff7b0479SSaeed Bishara } 976ff7b0479SSaeed Bishara 977ff7b0479SSaeed Bishara #define MV_XOR_NUM_SRC_TEST 4 /* must be <= 15 */ 978ff7b0479SSaeed Bishara static int __devinit 979ff7b0479SSaeed Bishara mv_xor_xor_self_test(struct mv_xor_device *device) 980ff7b0479SSaeed Bishara { 981ff7b0479SSaeed Bishara int i, src_idx; 982ff7b0479SSaeed Bishara struct page *dest; 983ff7b0479SSaeed Bishara struct page *xor_srcs[MV_XOR_NUM_SRC_TEST]; 984ff7b0479SSaeed Bishara dma_addr_t dma_srcs[MV_XOR_NUM_SRC_TEST]; 985ff7b0479SSaeed Bishara dma_addr_t dest_dma; 986ff7b0479SSaeed Bishara struct dma_async_tx_descriptor *tx; 987ff7b0479SSaeed Bishara struct dma_chan *dma_chan; 988ff7b0479SSaeed Bishara dma_cookie_t cookie; 989ff7b0479SSaeed Bishara u8 cmp_byte = 0; 990ff7b0479SSaeed Bishara u32 cmp_word; 991ff7b0479SSaeed Bishara int err = 0; 992ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 993ff7b0479SSaeed Bishara 994ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 995ff7b0479SSaeed Bishara xor_srcs[src_idx] = alloc_page(GFP_KERNEL); 996a09b09aeSRoel Kluin if (!xor_srcs[src_idx]) { 997a09b09aeSRoel Kluin while (src_idx--) 998ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 999ff7b0479SSaeed Bishara return -ENOMEM; 1000ff7b0479SSaeed Bishara } 1001ff7b0479SSaeed Bishara } 1002ff7b0479SSaeed Bishara 1003ff7b0479SSaeed Bishara dest = alloc_page(GFP_KERNEL); 1004a09b09aeSRoel Kluin if (!dest) { 1005a09b09aeSRoel Kluin while (src_idx--) 1006ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 1007ff7b0479SSaeed Bishara return -ENOMEM; 1008ff7b0479SSaeed Bishara } 1009ff7b0479SSaeed Bishara 1010ff7b0479SSaeed Bishara /* Fill in src buffers */ 1011ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 1012ff7b0479SSaeed Bishara u8 *ptr = page_address(xor_srcs[src_idx]); 1013ff7b0479SSaeed Bishara for (i = 0; i < PAGE_SIZE; i++) 1014ff7b0479SSaeed Bishara ptr[i] = (1 << src_idx); 1015ff7b0479SSaeed Bishara } 1016ff7b0479SSaeed Bishara 1017ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) 1018ff7b0479SSaeed Bishara cmp_byte ^= (u8) (1 << src_idx); 1019ff7b0479SSaeed Bishara 1020ff7b0479SSaeed Bishara cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | 1021ff7b0479SSaeed Bishara (cmp_byte << 8) | cmp_byte; 1022ff7b0479SSaeed Bishara 1023ff7b0479SSaeed Bishara memset(page_address(dest), 0, PAGE_SIZE); 1024ff7b0479SSaeed Bishara 1025ff7b0479SSaeed Bishara dma_chan = container_of(device->common.channels.next, 1026ff7b0479SSaeed Bishara struct dma_chan, 1027ff7b0479SSaeed Bishara device_node); 1028aa1e6f1aSDan Williams if (mv_xor_alloc_chan_resources(dma_chan) < 1) { 1029ff7b0479SSaeed Bishara err = -ENODEV; 1030ff7b0479SSaeed Bishara goto out; 1031ff7b0479SSaeed Bishara } 1032ff7b0479SSaeed Bishara 1033ff7b0479SSaeed Bishara /* test xor */ 1034ff7b0479SSaeed Bishara dest_dma = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, 1035ff7b0479SSaeed Bishara DMA_FROM_DEVICE); 1036ff7b0479SSaeed Bishara 1037ff7b0479SSaeed Bishara for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) 1038ff7b0479SSaeed Bishara dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], 1039ff7b0479SSaeed Bishara 0, PAGE_SIZE, DMA_TO_DEVICE); 1040ff7b0479SSaeed Bishara 1041ff7b0479SSaeed Bishara tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, 1042ff7b0479SSaeed Bishara MV_XOR_NUM_SRC_TEST, PAGE_SIZE, 0); 1043ff7b0479SSaeed Bishara 1044ff7b0479SSaeed Bishara cookie = mv_xor_tx_submit(tx); 1045ff7b0479SSaeed Bishara mv_xor_issue_pending(dma_chan); 1046ff7b0479SSaeed Bishara async_tx_ack(tx); 1047ff7b0479SSaeed Bishara msleep(8); 1048ff7b0479SSaeed Bishara 104907934481SLinus Walleij if (mv_xor_status(dma_chan, cookie, NULL) != 1050ff7b0479SSaeed Bishara DMA_SUCCESS) { 1051ff7b0479SSaeed Bishara dev_printk(KERN_ERR, dma_chan->device->dev, 1052ff7b0479SSaeed Bishara "Self-test xor timed out, disabling\n"); 1053ff7b0479SSaeed Bishara err = -ENODEV; 1054ff7b0479SSaeed Bishara goto free_resources; 1055ff7b0479SSaeed Bishara } 1056ff7b0479SSaeed Bishara 1057ff7b0479SSaeed Bishara mv_chan = to_mv_xor_chan(dma_chan); 1058ff7b0479SSaeed Bishara dma_sync_single_for_cpu(&mv_chan->device->pdev->dev, dest_dma, 1059ff7b0479SSaeed Bishara PAGE_SIZE, DMA_FROM_DEVICE); 1060ff7b0479SSaeed Bishara for (i = 0; i < (PAGE_SIZE / sizeof(u32)); i++) { 1061ff7b0479SSaeed Bishara u32 *ptr = page_address(dest); 1062ff7b0479SSaeed Bishara if (ptr[i] != cmp_word) { 1063ff7b0479SSaeed Bishara dev_printk(KERN_ERR, dma_chan->device->dev, 1064ff7b0479SSaeed Bishara "Self-test xor failed compare, disabling." 1065ff7b0479SSaeed Bishara " index %d, data %x, expected %x\n", i, 1066ff7b0479SSaeed Bishara ptr[i], cmp_word); 1067ff7b0479SSaeed Bishara err = -ENODEV; 1068ff7b0479SSaeed Bishara goto free_resources; 1069ff7b0479SSaeed Bishara } 1070ff7b0479SSaeed Bishara } 1071ff7b0479SSaeed Bishara 1072ff7b0479SSaeed Bishara free_resources: 1073ff7b0479SSaeed Bishara mv_xor_free_chan_resources(dma_chan); 1074ff7b0479SSaeed Bishara out: 1075ff7b0479SSaeed Bishara src_idx = MV_XOR_NUM_SRC_TEST; 1076ff7b0479SSaeed Bishara while (src_idx--) 1077ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 1078ff7b0479SSaeed Bishara __free_page(dest); 1079ff7b0479SSaeed Bishara return err; 1080ff7b0479SSaeed Bishara } 1081ff7b0479SSaeed Bishara 1082ff7b0479SSaeed Bishara static int __devexit mv_xor_remove(struct platform_device *dev) 1083ff7b0479SSaeed Bishara { 1084ff7b0479SSaeed Bishara struct mv_xor_device *device = platform_get_drvdata(dev); 1085ff7b0479SSaeed Bishara struct dma_chan *chan, *_chan; 1086ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 1087ff7b0479SSaeed Bishara struct mv_xor_platform_data *plat_data = dev->dev.platform_data; 1088ff7b0479SSaeed Bishara 1089ff7b0479SSaeed Bishara dma_async_device_unregister(&device->common); 1090ff7b0479SSaeed Bishara 1091ff7b0479SSaeed Bishara dma_free_coherent(&dev->dev, plat_data->pool_size, 1092ff7b0479SSaeed Bishara device->dma_desc_pool_virt, device->dma_desc_pool); 1093ff7b0479SSaeed Bishara 1094ff7b0479SSaeed Bishara list_for_each_entry_safe(chan, _chan, &device->common.channels, 1095ff7b0479SSaeed Bishara device_node) { 1096ff7b0479SSaeed Bishara mv_chan = to_mv_xor_chan(chan); 1097ff7b0479SSaeed Bishara list_del(&chan->device_node); 1098ff7b0479SSaeed Bishara } 1099ff7b0479SSaeed Bishara 1100ff7b0479SSaeed Bishara return 0; 1101ff7b0479SSaeed Bishara } 1102ff7b0479SSaeed Bishara 1103ff7b0479SSaeed Bishara static int __devinit mv_xor_probe(struct platform_device *pdev) 1104ff7b0479SSaeed Bishara { 1105ff7b0479SSaeed Bishara int ret = 0; 1106ff7b0479SSaeed Bishara int irq; 1107ff7b0479SSaeed Bishara struct mv_xor_device *adev; 1108ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 1109ff7b0479SSaeed Bishara struct dma_device *dma_dev; 1110ff7b0479SSaeed Bishara struct mv_xor_platform_data *plat_data = pdev->dev.platform_data; 1111ff7b0479SSaeed Bishara 1112ff7b0479SSaeed Bishara 1113ff7b0479SSaeed Bishara adev = devm_kzalloc(&pdev->dev, sizeof(*adev), GFP_KERNEL); 1114ff7b0479SSaeed Bishara if (!adev) 1115ff7b0479SSaeed Bishara return -ENOMEM; 1116ff7b0479SSaeed Bishara 1117ff7b0479SSaeed Bishara dma_dev = &adev->common; 1118ff7b0479SSaeed Bishara 1119ff7b0479SSaeed Bishara /* allocate coherent memory for hardware descriptors 1120ff7b0479SSaeed Bishara * note: writecombine gives slightly better performance, but 1121ff7b0479SSaeed Bishara * requires that we explicitly flush the writes 1122ff7b0479SSaeed Bishara */ 1123ff7b0479SSaeed Bishara adev->dma_desc_pool_virt = dma_alloc_writecombine(&pdev->dev, 1124ff7b0479SSaeed Bishara plat_data->pool_size, 1125ff7b0479SSaeed Bishara &adev->dma_desc_pool, 1126ff7b0479SSaeed Bishara GFP_KERNEL); 1127ff7b0479SSaeed Bishara if (!adev->dma_desc_pool_virt) 1128ff7b0479SSaeed Bishara return -ENOMEM; 1129ff7b0479SSaeed Bishara 1130ff7b0479SSaeed Bishara adev->id = plat_data->hw_id; 1131ff7b0479SSaeed Bishara 1132ff7b0479SSaeed Bishara /* discover transaction capabilites from the platform data */ 1133ff7b0479SSaeed Bishara dma_dev->cap_mask = plat_data->cap_mask; 1134ff7b0479SSaeed Bishara adev->pdev = pdev; 1135ff7b0479SSaeed Bishara platform_set_drvdata(pdev, adev); 1136ff7b0479SSaeed Bishara 1137ff7b0479SSaeed Bishara adev->shared = platform_get_drvdata(plat_data->shared); 1138ff7b0479SSaeed Bishara 1139ff7b0479SSaeed Bishara INIT_LIST_HEAD(&dma_dev->channels); 1140ff7b0479SSaeed Bishara 1141ff7b0479SSaeed Bishara /* set base routines */ 1142ff7b0479SSaeed Bishara dma_dev->device_alloc_chan_resources = mv_xor_alloc_chan_resources; 1143ff7b0479SSaeed Bishara dma_dev->device_free_chan_resources = mv_xor_free_chan_resources; 114407934481SLinus Walleij dma_dev->device_tx_status = mv_xor_status; 1145ff7b0479SSaeed Bishara dma_dev->device_issue_pending = mv_xor_issue_pending; 1146ff7b0479SSaeed Bishara dma_dev->dev = &pdev->dev; 1147ff7b0479SSaeed Bishara 1148ff7b0479SSaeed Bishara /* set prep routines based on capability */ 1149ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) 1150ff7b0479SSaeed Bishara dma_dev->device_prep_dma_memcpy = mv_xor_prep_dma_memcpy; 1151ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMSET, dma_dev->cap_mask)) 1152ff7b0479SSaeed Bishara dma_dev->device_prep_dma_memset = mv_xor_prep_dma_memset; 1153ff7b0479SSaeed Bishara if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1154c019894eSJoe Perches dma_dev->max_xor = 8; 1155ff7b0479SSaeed Bishara dma_dev->device_prep_dma_xor = mv_xor_prep_dma_xor; 1156ff7b0479SSaeed Bishara } 1157ff7b0479SSaeed Bishara 1158ff7b0479SSaeed Bishara mv_chan = devm_kzalloc(&pdev->dev, sizeof(*mv_chan), GFP_KERNEL); 1159ff7b0479SSaeed Bishara if (!mv_chan) { 1160ff7b0479SSaeed Bishara ret = -ENOMEM; 1161ff7b0479SSaeed Bishara goto err_free_dma; 1162ff7b0479SSaeed Bishara } 1163ff7b0479SSaeed Bishara mv_chan->device = adev; 1164ff7b0479SSaeed Bishara mv_chan->idx = plat_data->hw_id; 1165ff7b0479SSaeed Bishara mv_chan->mmr_base = adev->shared->xor_base; 1166ff7b0479SSaeed Bishara 1167ff7b0479SSaeed Bishara if (!mv_chan->mmr_base) { 1168ff7b0479SSaeed Bishara ret = -ENOMEM; 1169ff7b0479SSaeed Bishara goto err_free_dma; 1170ff7b0479SSaeed Bishara } 1171ff7b0479SSaeed Bishara tasklet_init(&mv_chan->irq_tasklet, mv_xor_tasklet, (unsigned long) 1172ff7b0479SSaeed Bishara mv_chan); 1173ff7b0479SSaeed Bishara 1174ff7b0479SSaeed Bishara /* clear errors before enabling interrupts */ 1175ff7b0479SSaeed Bishara mv_xor_device_clear_err_status(mv_chan); 1176ff7b0479SSaeed Bishara 1177ff7b0479SSaeed Bishara irq = platform_get_irq(pdev, 0); 1178ff7b0479SSaeed Bishara if (irq < 0) { 1179ff7b0479SSaeed Bishara ret = irq; 1180ff7b0479SSaeed Bishara goto err_free_dma; 1181ff7b0479SSaeed Bishara } 1182ff7b0479SSaeed Bishara ret = devm_request_irq(&pdev->dev, irq, 1183ff7b0479SSaeed Bishara mv_xor_interrupt_handler, 1184ff7b0479SSaeed Bishara 0, dev_name(&pdev->dev), mv_chan); 1185ff7b0479SSaeed Bishara if (ret) 1186ff7b0479SSaeed Bishara goto err_free_dma; 1187ff7b0479SSaeed Bishara 1188ff7b0479SSaeed Bishara mv_chan_unmask_interrupts(mv_chan); 1189ff7b0479SSaeed Bishara 1190ff7b0479SSaeed Bishara mv_set_mode(mv_chan, DMA_MEMCPY); 1191ff7b0479SSaeed Bishara 1192ff7b0479SSaeed Bishara spin_lock_init(&mv_chan->lock); 1193ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->chain); 1194ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->completed_slots); 1195ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->all_slots); 1196ff7b0479SSaeed Bishara mv_chan->common.device = dma_dev; 11978ac69546SRussell King - ARM Linux dma_cookie_init(&mv_chan->common); 1198ff7b0479SSaeed Bishara 1199ff7b0479SSaeed Bishara list_add_tail(&mv_chan->common.device_node, &dma_dev->channels); 1200ff7b0479SSaeed Bishara 1201ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) { 1202ff7b0479SSaeed Bishara ret = mv_xor_memcpy_self_test(adev); 1203ff7b0479SSaeed Bishara dev_dbg(&pdev->dev, "memcpy self test returned %d\n", ret); 1204ff7b0479SSaeed Bishara if (ret) 1205ff7b0479SSaeed Bishara goto err_free_dma; 1206ff7b0479SSaeed Bishara } 1207ff7b0479SSaeed Bishara 1208ff7b0479SSaeed Bishara if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1209ff7b0479SSaeed Bishara ret = mv_xor_xor_self_test(adev); 1210ff7b0479SSaeed Bishara dev_dbg(&pdev->dev, "xor self test returned %d\n", ret); 1211ff7b0479SSaeed Bishara if (ret) 1212ff7b0479SSaeed Bishara goto err_free_dma; 1213ff7b0479SSaeed Bishara } 1214ff7b0479SSaeed Bishara 1215ff7b0479SSaeed Bishara dev_printk(KERN_INFO, &pdev->dev, "Marvell XOR: " 1216ff7b0479SSaeed Bishara "( %s%s%s%s)\n", 1217ff7b0479SSaeed Bishara dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "xor " : "", 1218ff7b0479SSaeed Bishara dma_has_cap(DMA_MEMSET, dma_dev->cap_mask) ? "fill " : "", 1219ff7b0479SSaeed Bishara dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask) ? "cpy " : "", 1220ff7b0479SSaeed Bishara dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask) ? "intr " : ""); 1221ff7b0479SSaeed Bishara 1222ff7b0479SSaeed Bishara dma_async_device_register(dma_dev); 1223ff7b0479SSaeed Bishara goto out; 1224ff7b0479SSaeed Bishara 1225ff7b0479SSaeed Bishara err_free_dma: 1226ff7b0479SSaeed Bishara dma_free_coherent(&adev->pdev->dev, plat_data->pool_size, 1227ff7b0479SSaeed Bishara adev->dma_desc_pool_virt, adev->dma_desc_pool); 1228ff7b0479SSaeed Bishara out: 1229ff7b0479SSaeed Bishara return ret; 1230ff7b0479SSaeed Bishara } 1231ff7b0479SSaeed Bishara 1232ff7b0479SSaeed Bishara static void 1233ff7b0479SSaeed Bishara mv_xor_conf_mbus_windows(struct mv_xor_shared_private *msp, 123463a9332bSAndrew Lunn const struct mbus_dram_target_info *dram) 1235ff7b0479SSaeed Bishara { 1236ff7b0479SSaeed Bishara void __iomem *base = msp->xor_base; 1237ff7b0479SSaeed Bishara u32 win_enable = 0; 1238ff7b0479SSaeed Bishara int i; 1239ff7b0479SSaeed Bishara 1240ff7b0479SSaeed Bishara for (i = 0; i < 8; i++) { 1241ff7b0479SSaeed Bishara writel(0, base + WINDOW_BASE(i)); 1242ff7b0479SSaeed Bishara writel(0, base + WINDOW_SIZE(i)); 1243ff7b0479SSaeed Bishara if (i < 4) 1244ff7b0479SSaeed Bishara writel(0, base + WINDOW_REMAP_HIGH(i)); 1245ff7b0479SSaeed Bishara } 1246ff7b0479SSaeed Bishara 1247ff7b0479SSaeed Bishara for (i = 0; i < dram->num_cs; i++) { 124863a9332bSAndrew Lunn const struct mbus_dram_window *cs = dram->cs + i; 1249ff7b0479SSaeed Bishara 1250ff7b0479SSaeed Bishara writel((cs->base & 0xffff0000) | 1251ff7b0479SSaeed Bishara (cs->mbus_attr << 8) | 1252ff7b0479SSaeed Bishara dram->mbus_dram_target_id, base + WINDOW_BASE(i)); 1253ff7b0479SSaeed Bishara writel((cs->size - 1) & 0xffff0000, base + WINDOW_SIZE(i)); 1254ff7b0479SSaeed Bishara 1255ff7b0479SSaeed Bishara win_enable |= (1 << i); 1256ff7b0479SSaeed Bishara win_enable |= 3 << (16 + (2 * i)); 1257ff7b0479SSaeed Bishara } 1258ff7b0479SSaeed Bishara 1259ff7b0479SSaeed Bishara writel(win_enable, base + WINDOW_BAR_ENABLE(0)); 1260ff7b0479SSaeed Bishara writel(win_enable, base + WINDOW_BAR_ENABLE(1)); 1261ff7b0479SSaeed Bishara } 1262ff7b0479SSaeed Bishara 1263ff7b0479SSaeed Bishara static struct platform_driver mv_xor_driver = { 1264ff7b0479SSaeed Bishara .probe = mv_xor_probe, 1265bdf602bdSRussell King .remove = __devexit_p(mv_xor_remove), 1266ff7b0479SSaeed Bishara .driver = { 1267ff7b0479SSaeed Bishara .owner = THIS_MODULE, 1268ff7b0479SSaeed Bishara .name = MV_XOR_NAME, 1269ff7b0479SSaeed Bishara }, 1270ff7b0479SSaeed Bishara }; 1271ff7b0479SSaeed Bishara 1272ff7b0479SSaeed Bishara static int mv_xor_shared_probe(struct platform_device *pdev) 1273ff7b0479SSaeed Bishara { 127463a9332bSAndrew Lunn const struct mbus_dram_target_info *dram; 1275ff7b0479SSaeed Bishara struct mv_xor_shared_private *msp; 1276ff7b0479SSaeed Bishara struct resource *res; 1277ff7b0479SSaeed Bishara 1278ff7b0479SSaeed Bishara dev_printk(KERN_NOTICE, &pdev->dev, "Marvell shared XOR driver\n"); 1279ff7b0479SSaeed Bishara 1280ff7b0479SSaeed Bishara msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL); 1281ff7b0479SSaeed Bishara if (!msp) 1282ff7b0479SSaeed Bishara return -ENOMEM; 1283ff7b0479SSaeed Bishara 1284ff7b0479SSaeed Bishara res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1285ff7b0479SSaeed Bishara if (!res) 1286ff7b0479SSaeed Bishara return -ENODEV; 1287ff7b0479SSaeed Bishara 1288ff7b0479SSaeed Bishara msp->xor_base = devm_ioremap(&pdev->dev, res->start, 12894de1ba15SH Hartley Sweeten resource_size(res)); 1290ff7b0479SSaeed Bishara if (!msp->xor_base) 1291ff7b0479SSaeed Bishara return -EBUSY; 1292ff7b0479SSaeed Bishara 1293ff7b0479SSaeed Bishara res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1294ff7b0479SSaeed Bishara if (!res) 1295ff7b0479SSaeed Bishara return -ENODEV; 1296ff7b0479SSaeed Bishara 1297ff7b0479SSaeed Bishara msp->xor_high_base = devm_ioremap(&pdev->dev, res->start, 12984de1ba15SH Hartley Sweeten resource_size(res)); 1299ff7b0479SSaeed Bishara if (!msp->xor_high_base) 1300ff7b0479SSaeed Bishara return -EBUSY; 1301ff7b0479SSaeed Bishara 1302ff7b0479SSaeed Bishara platform_set_drvdata(pdev, msp); 1303ff7b0479SSaeed Bishara 1304ff7b0479SSaeed Bishara /* 1305ff7b0479SSaeed Bishara * (Re-)program MBUS remapping windows if we are asked to. 1306ff7b0479SSaeed Bishara */ 130763a9332bSAndrew Lunn dram = mv_mbus_dram_info(); 130863a9332bSAndrew Lunn if (dram) 130963a9332bSAndrew Lunn mv_xor_conf_mbus_windows(msp, dram); 1310ff7b0479SSaeed Bishara 1311*c510182bSAndrew Lunn /* Not all platforms can gate the clock, so it is not 1312*c510182bSAndrew Lunn * an error if the clock does not exists. 1313*c510182bSAndrew Lunn */ 1314*c510182bSAndrew Lunn msp->clk = clk_get(&pdev->dev, NULL); 1315*c510182bSAndrew Lunn if (!IS_ERR(msp->clk)) 1316*c510182bSAndrew Lunn clk_prepare_enable(msp->clk); 1317*c510182bSAndrew Lunn 1318ff7b0479SSaeed Bishara return 0; 1319ff7b0479SSaeed Bishara } 1320ff7b0479SSaeed Bishara 1321ff7b0479SSaeed Bishara static int mv_xor_shared_remove(struct platform_device *pdev) 1322ff7b0479SSaeed Bishara { 1323*c510182bSAndrew Lunn struct mv_xor_shared_private *msp = platform_get_drvdata(pdev); 1324*c510182bSAndrew Lunn 1325*c510182bSAndrew Lunn if (!IS_ERR(msp->clk)) { 1326*c510182bSAndrew Lunn clk_disable_unprepare(msp->clk); 1327*c510182bSAndrew Lunn clk_put(msp->clk); 1328*c510182bSAndrew Lunn } 1329*c510182bSAndrew Lunn 1330ff7b0479SSaeed Bishara return 0; 1331ff7b0479SSaeed Bishara } 1332ff7b0479SSaeed Bishara 1333ff7b0479SSaeed Bishara static struct platform_driver mv_xor_shared_driver = { 1334ff7b0479SSaeed Bishara .probe = mv_xor_shared_probe, 1335ff7b0479SSaeed Bishara .remove = mv_xor_shared_remove, 1336ff7b0479SSaeed Bishara .driver = { 1337ff7b0479SSaeed Bishara .owner = THIS_MODULE, 1338ff7b0479SSaeed Bishara .name = MV_XOR_SHARED_NAME, 1339ff7b0479SSaeed Bishara }, 1340ff7b0479SSaeed Bishara }; 1341ff7b0479SSaeed Bishara 1342ff7b0479SSaeed Bishara 1343ff7b0479SSaeed Bishara static int __init mv_xor_init(void) 1344ff7b0479SSaeed Bishara { 1345ff7b0479SSaeed Bishara int rc; 1346ff7b0479SSaeed Bishara 1347ff7b0479SSaeed Bishara rc = platform_driver_register(&mv_xor_shared_driver); 1348ff7b0479SSaeed Bishara if (!rc) { 1349ff7b0479SSaeed Bishara rc = platform_driver_register(&mv_xor_driver); 1350ff7b0479SSaeed Bishara if (rc) 1351ff7b0479SSaeed Bishara platform_driver_unregister(&mv_xor_shared_driver); 1352ff7b0479SSaeed Bishara } 1353ff7b0479SSaeed Bishara return rc; 1354ff7b0479SSaeed Bishara } 1355ff7b0479SSaeed Bishara module_init(mv_xor_init); 1356ff7b0479SSaeed Bishara 1357ff7b0479SSaeed Bishara /* it's currently unsafe to unload this module */ 1358ff7b0479SSaeed Bishara #if 0 1359ff7b0479SSaeed Bishara static void __exit mv_xor_exit(void) 1360ff7b0479SSaeed Bishara { 1361ff7b0479SSaeed Bishara platform_driver_unregister(&mv_xor_driver); 1362ff7b0479SSaeed Bishara platform_driver_unregister(&mv_xor_shared_driver); 1363ff7b0479SSaeed Bishara return; 1364ff7b0479SSaeed Bishara } 1365ff7b0479SSaeed Bishara 1366ff7b0479SSaeed Bishara module_exit(mv_xor_exit); 1367ff7b0479SSaeed Bishara #endif 1368ff7b0479SSaeed Bishara 1369ff7b0479SSaeed Bishara MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>"); 1370ff7b0479SSaeed Bishara MODULE_DESCRIPTION("DMA engine driver for Marvell's XOR engine"); 1371ff7b0479SSaeed Bishara MODULE_LICENSE("GPL"); 1372