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> 28c510182bSAndrew Lunn #include <linux/clk.h> 29c02cecb9SArnd Bergmann #include <linux/platform_data/dma-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_slot(tx) \ 40ff7b0479SSaeed Bishara container_of(tx, struct mv_xor_desc_slot, async_tx) 41ff7b0479SSaeed Bishara 42c98c1781SThomas Petazzoni #define mv_chan_to_devp(chan) \ 43c98c1781SThomas Petazzoni ((chan)->device->common.dev) 44c98c1781SThomas Petazzoni 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)); 169c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(chan), "%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: 209c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 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 226c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(chan), " 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 { 254c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%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 { 269c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%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; 311*ecde6cd4SThomas Petazzoni struct device *dev = mv_chan_to_devp(mv_chan); 312ff7b0479SSaeed Bishara u32 len = unmap->unmap_len; 313e1d181efSDan Williams enum dma_ctrl_flags flags = desc->async_tx.flags; 314e1d181efSDan Williams u32 src_cnt; 315e1d181efSDan Williams dma_addr_t addr; 316a06d568fSDan Williams dma_addr_t dest; 317ff7b0479SSaeed Bishara 318a06d568fSDan Williams src_cnt = unmap->unmap_src_cnt; 319a06d568fSDan Williams dest = mv_desc_get_dest_addr(unmap); 320e1d181efSDan Williams if (!(flags & DMA_COMPL_SKIP_DEST_UNMAP)) { 321a06d568fSDan Williams enum dma_data_direction dir; 322a06d568fSDan Williams 323a06d568fSDan Williams if (src_cnt > 1) /* is xor ? */ 324a06d568fSDan Williams dir = DMA_BIDIRECTIONAL; 325a06d568fSDan Williams else 326a06d568fSDan Williams dir = DMA_FROM_DEVICE; 327a06d568fSDan Williams dma_unmap_page(dev, dest, len, dir); 328e1d181efSDan Williams } 329e1d181efSDan Williams 330e1d181efSDan Williams if (!(flags & DMA_COMPL_SKIP_SRC_UNMAP)) { 331ff7b0479SSaeed Bishara while (src_cnt--) { 332e1d181efSDan Williams addr = mv_desc_get_src_addr(unmap, 333e1d181efSDan Williams src_cnt); 334a06d568fSDan Williams if (addr == dest) 335a06d568fSDan Williams continue; 336e1d181efSDan Williams dma_unmap_page(dev, addr, len, 337e1d181efSDan Williams DMA_TO_DEVICE); 338e1d181efSDan Williams } 339ff7b0479SSaeed Bishara } 340ff7b0479SSaeed Bishara desc->group_head = NULL; 341ff7b0479SSaeed Bishara } 342ff7b0479SSaeed Bishara } 343ff7b0479SSaeed Bishara 344ff7b0479SSaeed Bishara /* run dependent operations */ 34507f2211eSDan Williams dma_run_dependencies(&desc->async_tx); 346ff7b0479SSaeed Bishara 347ff7b0479SSaeed Bishara return cookie; 348ff7b0479SSaeed Bishara } 349ff7b0479SSaeed Bishara 350ff7b0479SSaeed Bishara static int 351ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(struct mv_xor_chan *mv_chan) 352ff7b0479SSaeed Bishara { 353ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 354ff7b0479SSaeed Bishara 355c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%s %d\n", __func__, __LINE__); 356ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->completed_slots, 357ff7b0479SSaeed Bishara completed_node) { 358ff7b0479SSaeed Bishara 359ff7b0479SSaeed Bishara if (async_tx_test_ack(&iter->async_tx)) { 360ff7b0479SSaeed Bishara list_del(&iter->completed_node); 361ff7b0479SSaeed Bishara mv_xor_free_slots(mv_chan, iter); 362ff7b0479SSaeed Bishara } 363ff7b0479SSaeed Bishara } 364ff7b0479SSaeed Bishara return 0; 365ff7b0479SSaeed Bishara } 366ff7b0479SSaeed Bishara 367ff7b0479SSaeed Bishara static int 368ff7b0479SSaeed Bishara mv_xor_clean_slot(struct mv_xor_desc_slot *desc, 369ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan) 370ff7b0479SSaeed Bishara { 371c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%s %d: desc %p flags %d\n", 372ff7b0479SSaeed Bishara __func__, __LINE__, desc, desc->async_tx.flags); 373ff7b0479SSaeed Bishara list_del(&desc->chain_node); 374ff7b0479SSaeed Bishara /* the client is allowed to attach dependent operations 375ff7b0479SSaeed Bishara * until 'ack' is set 376ff7b0479SSaeed Bishara */ 377ff7b0479SSaeed Bishara if (!async_tx_test_ack(&desc->async_tx)) { 378ff7b0479SSaeed Bishara /* move this slot to the completed_slots */ 379ff7b0479SSaeed Bishara list_add_tail(&desc->completed_node, &mv_chan->completed_slots); 380ff7b0479SSaeed Bishara return 0; 381ff7b0479SSaeed Bishara } 382ff7b0479SSaeed Bishara 383ff7b0479SSaeed Bishara mv_xor_free_slots(mv_chan, desc); 384ff7b0479SSaeed Bishara return 0; 385ff7b0479SSaeed Bishara } 386ff7b0479SSaeed Bishara 387ff7b0479SSaeed Bishara static void __mv_xor_slot_cleanup(struct mv_xor_chan *mv_chan) 388ff7b0479SSaeed Bishara { 389ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 390ff7b0479SSaeed Bishara dma_cookie_t cookie = 0; 391ff7b0479SSaeed Bishara int busy = mv_chan_is_busy(mv_chan); 392ff7b0479SSaeed Bishara u32 current_desc = mv_chan_get_current_desc(mv_chan); 393ff7b0479SSaeed Bishara int seen_current = 0; 394ff7b0479SSaeed Bishara 395c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%s %d\n", __func__, __LINE__); 396c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "current_desc %x\n", current_desc); 397ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(mv_chan); 398ff7b0479SSaeed Bishara 399ff7b0479SSaeed Bishara /* free completed slots from the chain starting with 400ff7b0479SSaeed Bishara * the oldest descriptor 401ff7b0479SSaeed Bishara */ 402ff7b0479SSaeed Bishara 403ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->chain, 404ff7b0479SSaeed Bishara chain_node) { 405ff7b0479SSaeed Bishara prefetch(_iter); 406ff7b0479SSaeed Bishara prefetch(&_iter->async_tx); 407ff7b0479SSaeed Bishara 408ff7b0479SSaeed Bishara /* do not advance past the current descriptor loaded into the 409ff7b0479SSaeed Bishara * hardware channel, subsequent descriptors are either in 410ff7b0479SSaeed Bishara * process or have not been submitted 411ff7b0479SSaeed Bishara */ 412ff7b0479SSaeed Bishara if (seen_current) 413ff7b0479SSaeed Bishara break; 414ff7b0479SSaeed Bishara 415ff7b0479SSaeed Bishara /* stop the search if we reach the current descriptor and the 416ff7b0479SSaeed Bishara * channel is busy 417ff7b0479SSaeed Bishara */ 418ff7b0479SSaeed Bishara if (iter->async_tx.phys == current_desc) { 419ff7b0479SSaeed Bishara seen_current = 1; 420ff7b0479SSaeed Bishara if (busy) 421ff7b0479SSaeed Bishara break; 422ff7b0479SSaeed Bishara } 423ff7b0479SSaeed Bishara 424ff7b0479SSaeed Bishara cookie = mv_xor_run_tx_complete_actions(iter, mv_chan, cookie); 425ff7b0479SSaeed Bishara 426ff7b0479SSaeed Bishara if (mv_xor_clean_slot(iter, mv_chan)) 427ff7b0479SSaeed Bishara break; 428ff7b0479SSaeed Bishara } 429ff7b0479SSaeed Bishara 430ff7b0479SSaeed Bishara if ((busy == 0) && !list_empty(&mv_chan->chain)) { 431ff7b0479SSaeed Bishara struct mv_xor_desc_slot *chain_head; 432ff7b0479SSaeed Bishara chain_head = list_entry(mv_chan->chain.next, 433ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 434ff7b0479SSaeed Bishara chain_node); 435ff7b0479SSaeed Bishara 436ff7b0479SSaeed Bishara mv_xor_start_new_chain(mv_chan, chain_head); 437ff7b0479SSaeed Bishara } 438ff7b0479SSaeed Bishara 439ff7b0479SSaeed Bishara if (cookie > 0) 4404d4e58deSRussell King - ARM Linux mv_chan->common.completed_cookie = cookie; 441ff7b0479SSaeed Bishara } 442ff7b0479SSaeed Bishara 443ff7b0479SSaeed Bishara static void 444ff7b0479SSaeed Bishara mv_xor_slot_cleanup(struct mv_xor_chan *mv_chan) 445ff7b0479SSaeed Bishara { 446ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 447ff7b0479SSaeed Bishara __mv_xor_slot_cleanup(mv_chan); 448ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 449ff7b0479SSaeed Bishara } 450ff7b0479SSaeed Bishara 451ff7b0479SSaeed Bishara static void mv_xor_tasklet(unsigned long data) 452ff7b0479SSaeed Bishara { 453ff7b0479SSaeed Bishara struct mv_xor_chan *chan = (struct mv_xor_chan *) data; 4548333f65eSSaeed Bishara mv_xor_slot_cleanup(chan); 455ff7b0479SSaeed Bishara } 456ff7b0479SSaeed Bishara 457ff7b0479SSaeed Bishara static struct mv_xor_desc_slot * 458ff7b0479SSaeed Bishara mv_xor_alloc_slots(struct mv_xor_chan *mv_chan, int num_slots, 459ff7b0479SSaeed Bishara int slots_per_op) 460ff7b0479SSaeed Bishara { 461ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter, *alloc_start = NULL; 462ff7b0479SSaeed Bishara LIST_HEAD(chain); 463ff7b0479SSaeed Bishara int slots_found, retry = 0; 464ff7b0479SSaeed Bishara 465ff7b0479SSaeed Bishara /* start search from the last allocated descrtiptor 466ff7b0479SSaeed Bishara * if a contiguous allocation can not be found start searching 467ff7b0479SSaeed Bishara * from the beginning of the list 468ff7b0479SSaeed Bishara */ 469ff7b0479SSaeed Bishara retry: 470ff7b0479SSaeed Bishara slots_found = 0; 471ff7b0479SSaeed Bishara if (retry == 0) 472ff7b0479SSaeed Bishara iter = mv_chan->last_used; 473ff7b0479SSaeed Bishara else 474ff7b0479SSaeed Bishara iter = list_entry(&mv_chan->all_slots, 475ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 476ff7b0479SSaeed Bishara slot_node); 477ff7b0479SSaeed Bishara 478ff7b0479SSaeed Bishara list_for_each_entry_safe_continue( 479ff7b0479SSaeed Bishara iter, _iter, &mv_chan->all_slots, slot_node) { 480ff7b0479SSaeed Bishara prefetch(_iter); 481ff7b0479SSaeed Bishara prefetch(&_iter->async_tx); 482ff7b0479SSaeed Bishara if (iter->slots_per_op) { 483ff7b0479SSaeed Bishara /* give up after finding the first busy slot 484ff7b0479SSaeed Bishara * on the second pass through the list 485ff7b0479SSaeed Bishara */ 486ff7b0479SSaeed Bishara if (retry) 487ff7b0479SSaeed Bishara break; 488ff7b0479SSaeed Bishara 489ff7b0479SSaeed Bishara slots_found = 0; 490ff7b0479SSaeed Bishara continue; 491ff7b0479SSaeed Bishara } 492ff7b0479SSaeed Bishara 493ff7b0479SSaeed Bishara /* start the allocation if the slot is correctly aligned */ 494ff7b0479SSaeed Bishara if (!slots_found++) 495ff7b0479SSaeed Bishara alloc_start = iter; 496ff7b0479SSaeed Bishara 497ff7b0479SSaeed Bishara if (slots_found == num_slots) { 498ff7b0479SSaeed Bishara struct mv_xor_desc_slot *alloc_tail = NULL; 499ff7b0479SSaeed Bishara struct mv_xor_desc_slot *last_used = NULL; 500ff7b0479SSaeed Bishara iter = alloc_start; 501ff7b0479SSaeed Bishara while (num_slots) { 502ff7b0479SSaeed Bishara int i; 503ff7b0479SSaeed Bishara 504ff7b0479SSaeed Bishara /* pre-ack all but the last descriptor */ 505ff7b0479SSaeed Bishara async_tx_ack(&iter->async_tx); 506ff7b0479SSaeed Bishara 507ff7b0479SSaeed Bishara list_add_tail(&iter->chain_node, &chain); 508ff7b0479SSaeed Bishara alloc_tail = iter; 509ff7b0479SSaeed Bishara iter->async_tx.cookie = 0; 510ff7b0479SSaeed Bishara iter->slot_cnt = num_slots; 511ff7b0479SSaeed Bishara iter->xor_check_result = NULL; 512ff7b0479SSaeed Bishara for (i = 0; i < slots_per_op; i++) { 513ff7b0479SSaeed Bishara iter->slots_per_op = slots_per_op - i; 514ff7b0479SSaeed Bishara last_used = iter; 515ff7b0479SSaeed Bishara iter = list_entry(iter->slot_node.next, 516ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 517ff7b0479SSaeed Bishara slot_node); 518ff7b0479SSaeed Bishara } 519ff7b0479SSaeed Bishara num_slots -= slots_per_op; 520ff7b0479SSaeed Bishara } 521ff7b0479SSaeed Bishara alloc_tail->group_head = alloc_start; 522ff7b0479SSaeed Bishara alloc_tail->async_tx.cookie = -EBUSY; 52364203b67SDan Williams list_splice(&chain, &alloc_tail->tx_list); 524ff7b0479SSaeed Bishara mv_chan->last_used = last_used; 525ff7b0479SSaeed Bishara mv_desc_clear_next_desc(alloc_start); 526ff7b0479SSaeed Bishara mv_desc_clear_next_desc(alloc_tail); 527ff7b0479SSaeed Bishara return alloc_tail; 528ff7b0479SSaeed Bishara } 529ff7b0479SSaeed Bishara } 530ff7b0479SSaeed Bishara if (!retry++) 531ff7b0479SSaeed Bishara goto retry; 532ff7b0479SSaeed Bishara 533ff7b0479SSaeed Bishara /* try to free some slots if the allocation fails */ 534ff7b0479SSaeed Bishara tasklet_schedule(&mv_chan->irq_tasklet); 535ff7b0479SSaeed Bishara 536ff7b0479SSaeed Bishara return NULL; 537ff7b0479SSaeed Bishara } 538ff7b0479SSaeed Bishara 539ff7b0479SSaeed Bishara /************************ DMA engine API functions ****************************/ 540ff7b0479SSaeed Bishara static dma_cookie_t 541ff7b0479SSaeed Bishara mv_xor_tx_submit(struct dma_async_tx_descriptor *tx) 542ff7b0479SSaeed Bishara { 543ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc = to_mv_xor_slot(tx); 544ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(tx->chan); 545ff7b0479SSaeed Bishara struct mv_xor_desc_slot *grp_start, *old_chain_tail; 546ff7b0479SSaeed Bishara dma_cookie_t cookie; 547ff7b0479SSaeed Bishara int new_hw_chain = 1; 548ff7b0479SSaeed Bishara 549c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 550ff7b0479SSaeed Bishara "%s sw_desc %p: async_tx %p\n", 551ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 552ff7b0479SSaeed Bishara 553ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 554ff7b0479SSaeed Bishara 555ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 556884485e1SRussell King - ARM Linux cookie = dma_cookie_assign(tx); 557ff7b0479SSaeed Bishara 558ff7b0479SSaeed Bishara if (list_empty(&mv_chan->chain)) 55964203b67SDan Williams list_splice_init(&sw_desc->tx_list, &mv_chan->chain); 560ff7b0479SSaeed Bishara else { 561ff7b0479SSaeed Bishara new_hw_chain = 0; 562ff7b0479SSaeed Bishara 563ff7b0479SSaeed Bishara old_chain_tail = list_entry(mv_chan->chain.prev, 564ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 565ff7b0479SSaeed Bishara chain_node); 56664203b67SDan Williams list_splice_init(&grp_start->tx_list, 567ff7b0479SSaeed Bishara &old_chain_tail->chain_node); 568ff7b0479SSaeed Bishara 569ff7b0479SSaeed Bishara if (!mv_can_chain(grp_start)) 570ff7b0479SSaeed Bishara goto submit_done; 571ff7b0479SSaeed Bishara 572c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "Append to last desc %x\n", 573ff7b0479SSaeed Bishara old_chain_tail->async_tx.phys); 574ff7b0479SSaeed Bishara 575ff7b0479SSaeed Bishara /* fix up the hardware chain */ 576ff7b0479SSaeed Bishara mv_desc_set_next_desc(old_chain_tail, grp_start->async_tx.phys); 577ff7b0479SSaeed Bishara 578ff7b0479SSaeed Bishara /* if the channel is not busy */ 579ff7b0479SSaeed Bishara if (!mv_chan_is_busy(mv_chan)) { 580ff7b0479SSaeed Bishara u32 current_desc = mv_chan_get_current_desc(mv_chan); 581ff7b0479SSaeed Bishara /* 582ff7b0479SSaeed Bishara * and the curren desc is the end of the chain before 583ff7b0479SSaeed Bishara * the append, then we need to start the channel 584ff7b0479SSaeed Bishara */ 585ff7b0479SSaeed Bishara if (current_desc == old_chain_tail->async_tx.phys) 586ff7b0479SSaeed Bishara new_hw_chain = 1; 587ff7b0479SSaeed Bishara } 588ff7b0479SSaeed Bishara } 589ff7b0479SSaeed Bishara 590ff7b0479SSaeed Bishara if (new_hw_chain) 591ff7b0479SSaeed Bishara mv_xor_start_new_chain(mv_chan, grp_start); 592ff7b0479SSaeed Bishara 593ff7b0479SSaeed Bishara submit_done: 594ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 595ff7b0479SSaeed Bishara 596ff7b0479SSaeed Bishara return cookie; 597ff7b0479SSaeed Bishara } 598ff7b0479SSaeed Bishara 599ff7b0479SSaeed Bishara /* returns the number of allocated descriptors */ 600aa1e6f1aSDan Williams static int mv_xor_alloc_chan_resources(struct dma_chan *chan) 601ff7b0479SSaeed Bishara { 602ff7b0479SSaeed Bishara char *hw_desc; 603ff7b0479SSaeed Bishara int idx; 604ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 605ff7b0479SSaeed Bishara struct mv_xor_desc_slot *slot = NULL; 60609f2b786SThomas Petazzoni int num_descs_in_pool = mv_chan->device->pool_size/MV_XOR_SLOT_SIZE; 607ff7b0479SSaeed Bishara 608ff7b0479SSaeed Bishara /* Allocate descriptor slots */ 609ff7b0479SSaeed Bishara idx = mv_chan->slots_allocated; 610ff7b0479SSaeed Bishara while (idx < num_descs_in_pool) { 611ff7b0479SSaeed Bishara slot = kzalloc(sizeof(*slot), GFP_KERNEL); 612ff7b0479SSaeed Bishara if (!slot) { 613ff7b0479SSaeed Bishara printk(KERN_INFO "MV XOR Channel only initialized" 614ff7b0479SSaeed Bishara " %d descriptor slots", idx); 615ff7b0479SSaeed Bishara break; 616ff7b0479SSaeed Bishara } 617ff7b0479SSaeed Bishara hw_desc = (char *) mv_chan->device->dma_desc_pool_virt; 618ff7b0479SSaeed Bishara slot->hw_desc = (void *) &hw_desc[idx * MV_XOR_SLOT_SIZE]; 619ff7b0479SSaeed Bishara 620ff7b0479SSaeed Bishara dma_async_tx_descriptor_init(&slot->async_tx, chan); 621ff7b0479SSaeed Bishara slot->async_tx.tx_submit = mv_xor_tx_submit; 622ff7b0479SSaeed Bishara INIT_LIST_HEAD(&slot->chain_node); 623ff7b0479SSaeed Bishara INIT_LIST_HEAD(&slot->slot_node); 62464203b67SDan Williams INIT_LIST_HEAD(&slot->tx_list); 625ff7b0479SSaeed Bishara hw_desc = (char *) mv_chan->device->dma_desc_pool; 626ff7b0479SSaeed Bishara slot->async_tx.phys = 627ff7b0479SSaeed Bishara (dma_addr_t) &hw_desc[idx * MV_XOR_SLOT_SIZE]; 628ff7b0479SSaeed Bishara slot->idx = idx++; 629ff7b0479SSaeed Bishara 630ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 631ff7b0479SSaeed Bishara mv_chan->slots_allocated = idx; 632ff7b0479SSaeed Bishara list_add_tail(&slot->slot_node, &mv_chan->all_slots); 633ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 634ff7b0479SSaeed Bishara } 635ff7b0479SSaeed Bishara 636ff7b0479SSaeed Bishara if (mv_chan->slots_allocated && !mv_chan->last_used) 637ff7b0479SSaeed Bishara mv_chan->last_used = list_entry(mv_chan->all_slots.next, 638ff7b0479SSaeed Bishara struct mv_xor_desc_slot, 639ff7b0479SSaeed Bishara slot_node); 640ff7b0479SSaeed Bishara 641c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 642ff7b0479SSaeed Bishara "allocated %d descriptor slots last_used: %p\n", 643ff7b0479SSaeed Bishara mv_chan->slots_allocated, mv_chan->last_used); 644ff7b0479SSaeed Bishara 645ff7b0479SSaeed Bishara return mv_chan->slots_allocated ? : -ENOMEM; 646ff7b0479SSaeed Bishara } 647ff7b0479SSaeed Bishara 648ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 649ff7b0479SSaeed Bishara mv_xor_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, 650ff7b0479SSaeed Bishara size_t len, unsigned long flags) 651ff7b0479SSaeed Bishara { 652ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 653ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 654ff7b0479SSaeed Bishara int slot_cnt; 655ff7b0479SSaeed Bishara 656c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 657ff7b0479SSaeed Bishara "%s dest: %x src %x len: %u flags: %ld\n", 658ff7b0479SSaeed Bishara __func__, dest, src, len, flags); 659ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 660ff7b0479SSaeed Bishara return NULL; 661ff7b0479SSaeed Bishara 6627912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 663ff7b0479SSaeed Bishara 664ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 665ff7b0479SSaeed Bishara slot_cnt = mv_chan_memcpy_slot_count(len); 666ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 667ff7b0479SSaeed Bishara if (sw_desc) { 668ff7b0479SSaeed Bishara sw_desc->type = DMA_MEMCPY; 669ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 670ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 671ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 672ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 673ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 674ff7b0479SSaeed Bishara mv_desc_set_src_addr(grp_start, 0, src); 675ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = 1; 676ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 677ff7b0479SSaeed Bishara } 678ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 679ff7b0479SSaeed Bishara 680c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 681ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p\n", 682ff7b0479SSaeed Bishara __func__, sw_desc, sw_desc ? &sw_desc->async_tx : 0); 683ff7b0479SSaeed Bishara 684ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 685ff7b0479SSaeed Bishara } 686ff7b0479SSaeed Bishara 687ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 688ff7b0479SSaeed Bishara mv_xor_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value, 689ff7b0479SSaeed Bishara size_t len, unsigned long flags) 690ff7b0479SSaeed Bishara { 691ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 692ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 693ff7b0479SSaeed Bishara int slot_cnt; 694ff7b0479SSaeed Bishara 695c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 696ff7b0479SSaeed Bishara "%s dest: %x len: %u flags: %ld\n", 697ff7b0479SSaeed Bishara __func__, dest, len, flags); 698ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 699ff7b0479SSaeed Bishara return NULL; 700ff7b0479SSaeed Bishara 7017912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 702ff7b0479SSaeed Bishara 703ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 704ff7b0479SSaeed Bishara slot_cnt = mv_chan_memset_slot_count(len); 705ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 706ff7b0479SSaeed Bishara if (sw_desc) { 707ff7b0479SSaeed Bishara sw_desc->type = DMA_MEMSET; 708ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 709ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 710ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 711ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 712ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 713ff7b0479SSaeed Bishara mv_desc_set_block_fill_val(grp_start, value); 714ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = 1; 715ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 716ff7b0479SSaeed Bishara } 717ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 718c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 719ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p \n", 720ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 721ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 722ff7b0479SSaeed Bishara } 723ff7b0479SSaeed Bishara 724ff7b0479SSaeed Bishara static struct dma_async_tx_descriptor * 725ff7b0479SSaeed Bishara mv_xor_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src, 726ff7b0479SSaeed Bishara unsigned int src_cnt, size_t len, unsigned long flags) 727ff7b0479SSaeed Bishara { 728ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 729ff7b0479SSaeed Bishara struct mv_xor_desc_slot *sw_desc, *grp_start; 730ff7b0479SSaeed Bishara int slot_cnt; 731ff7b0479SSaeed Bishara 732ff7b0479SSaeed Bishara if (unlikely(len < MV_XOR_MIN_BYTE_COUNT)) 733ff7b0479SSaeed Bishara return NULL; 734ff7b0479SSaeed Bishara 7357912d300SColy Li BUG_ON(len > MV_XOR_MAX_BYTE_COUNT); 736ff7b0479SSaeed Bishara 737c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 738ff7b0479SSaeed Bishara "%s src_cnt: %d len: dest %x %u flags: %ld\n", 739ff7b0479SSaeed Bishara __func__, src_cnt, len, dest, flags); 740ff7b0479SSaeed Bishara 741ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 742ff7b0479SSaeed Bishara slot_cnt = mv_chan_xor_slot_count(len, src_cnt); 743ff7b0479SSaeed Bishara sw_desc = mv_xor_alloc_slots(mv_chan, slot_cnt, 1); 744ff7b0479SSaeed Bishara if (sw_desc) { 745ff7b0479SSaeed Bishara sw_desc->type = DMA_XOR; 746ff7b0479SSaeed Bishara sw_desc->async_tx.flags = flags; 747ff7b0479SSaeed Bishara grp_start = sw_desc->group_head; 748ff7b0479SSaeed Bishara mv_desc_init(grp_start, flags); 749ff7b0479SSaeed Bishara /* the byte count field is the same as in memcpy desc*/ 750ff7b0479SSaeed Bishara mv_desc_set_byte_count(grp_start, len); 751ff7b0479SSaeed Bishara mv_desc_set_dest_addr(sw_desc->group_head, dest); 752ff7b0479SSaeed Bishara sw_desc->unmap_src_cnt = src_cnt; 753ff7b0479SSaeed Bishara sw_desc->unmap_len = len; 754ff7b0479SSaeed Bishara while (src_cnt--) 755ff7b0479SSaeed Bishara mv_desc_set_src_addr(grp_start, src_cnt, src[src_cnt]); 756ff7b0479SSaeed Bishara } 757ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 758c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), 759ff7b0479SSaeed Bishara "%s sw_desc %p async_tx %p \n", 760ff7b0479SSaeed Bishara __func__, sw_desc, &sw_desc->async_tx); 761ff7b0479SSaeed Bishara return sw_desc ? &sw_desc->async_tx : NULL; 762ff7b0479SSaeed Bishara } 763ff7b0479SSaeed Bishara 764ff7b0479SSaeed Bishara static void mv_xor_free_chan_resources(struct dma_chan *chan) 765ff7b0479SSaeed Bishara { 766ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 767ff7b0479SSaeed Bishara struct mv_xor_desc_slot *iter, *_iter; 768ff7b0479SSaeed Bishara int in_use_descs = 0; 769ff7b0479SSaeed Bishara 770ff7b0479SSaeed Bishara mv_xor_slot_cleanup(mv_chan); 771ff7b0479SSaeed Bishara 772ff7b0479SSaeed Bishara spin_lock_bh(&mv_chan->lock); 773ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->chain, 774ff7b0479SSaeed Bishara chain_node) { 775ff7b0479SSaeed Bishara in_use_descs++; 776ff7b0479SSaeed Bishara list_del(&iter->chain_node); 777ff7b0479SSaeed Bishara } 778ff7b0479SSaeed Bishara list_for_each_entry_safe(iter, _iter, &mv_chan->completed_slots, 779ff7b0479SSaeed Bishara completed_node) { 780ff7b0479SSaeed Bishara in_use_descs++; 781ff7b0479SSaeed Bishara list_del(&iter->completed_node); 782ff7b0479SSaeed Bishara } 783ff7b0479SSaeed Bishara list_for_each_entry_safe_reverse( 784ff7b0479SSaeed Bishara iter, _iter, &mv_chan->all_slots, slot_node) { 785ff7b0479SSaeed Bishara list_del(&iter->slot_node); 786ff7b0479SSaeed Bishara kfree(iter); 787ff7b0479SSaeed Bishara mv_chan->slots_allocated--; 788ff7b0479SSaeed Bishara } 789ff7b0479SSaeed Bishara mv_chan->last_used = NULL; 790ff7b0479SSaeed Bishara 791c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(mv_chan), "%s slots_allocated %d\n", 792ff7b0479SSaeed Bishara __func__, mv_chan->slots_allocated); 793ff7b0479SSaeed Bishara spin_unlock_bh(&mv_chan->lock); 794ff7b0479SSaeed Bishara 795ff7b0479SSaeed Bishara if (in_use_descs) 796c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(mv_chan), 797ff7b0479SSaeed Bishara "freeing %d in use descriptors!\n", in_use_descs); 798ff7b0479SSaeed Bishara } 799ff7b0479SSaeed Bishara 800ff7b0479SSaeed Bishara /** 80107934481SLinus Walleij * mv_xor_status - poll the status of an XOR transaction 802ff7b0479SSaeed Bishara * @chan: XOR channel handle 803ff7b0479SSaeed Bishara * @cookie: XOR transaction identifier 80407934481SLinus Walleij * @txstate: XOR transactions state holder (or NULL) 805ff7b0479SSaeed Bishara */ 80607934481SLinus Walleij static enum dma_status mv_xor_status(struct dma_chan *chan, 807ff7b0479SSaeed Bishara dma_cookie_t cookie, 80807934481SLinus Walleij struct dma_tx_state *txstate) 809ff7b0479SSaeed Bishara { 810ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 811ff7b0479SSaeed Bishara enum dma_status ret; 812ff7b0479SSaeed Bishara 81396a2af41SRussell King - ARM Linux ret = dma_cookie_status(chan, cookie, txstate); 814ff7b0479SSaeed Bishara if (ret == DMA_SUCCESS) { 815ff7b0479SSaeed Bishara mv_xor_clean_completed_slots(mv_chan); 816ff7b0479SSaeed Bishara return ret; 817ff7b0479SSaeed Bishara } 818ff7b0479SSaeed Bishara mv_xor_slot_cleanup(mv_chan); 819ff7b0479SSaeed Bishara 82096a2af41SRussell King - ARM Linux return dma_cookie_status(chan, cookie, txstate); 821ff7b0479SSaeed Bishara } 822ff7b0479SSaeed Bishara 823ff7b0479SSaeed Bishara static void mv_dump_xor_regs(struct mv_xor_chan *chan) 824ff7b0479SSaeed Bishara { 825ff7b0479SSaeed Bishara u32 val; 826ff7b0479SSaeed Bishara 827ff7b0479SSaeed Bishara val = __raw_readl(XOR_CONFIG(chan)); 828c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 829ff7b0479SSaeed Bishara "config 0x%08x.\n", val); 830ff7b0479SSaeed Bishara 831ff7b0479SSaeed Bishara val = __raw_readl(XOR_ACTIVATION(chan)); 832c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 833ff7b0479SSaeed Bishara "activation 0x%08x.\n", val); 834ff7b0479SSaeed Bishara 835ff7b0479SSaeed Bishara val = __raw_readl(XOR_INTR_CAUSE(chan)); 836c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 837ff7b0479SSaeed Bishara "intr cause 0x%08x.\n", val); 838ff7b0479SSaeed Bishara 839ff7b0479SSaeed Bishara val = __raw_readl(XOR_INTR_MASK(chan)); 840c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 841ff7b0479SSaeed Bishara "intr mask 0x%08x.\n", val); 842ff7b0479SSaeed Bishara 843ff7b0479SSaeed Bishara val = __raw_readl(XOR_ERROR_CAUSE(chan)); 844c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 845ff7b0479SSaeed Bishara "error cause 0x%08x.\n", val); 846ff7b0479SSaeed Bishara 847ff7b0479SSaeed Bishara val = __raw_readl(XOR_ERROR_ADDR(chan)); 848c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 849ff7b0479SSaeed Bishara "error addr 0x%08x.\n", val); 850ff7b0479SSaeed Bishara } 851ff7b0479SSaeed Bishara 852ff7b0479SSaeed Bishara static void mv_xor_err_interrupt_handler(struct mv_xor_chan *chan, 853ff7b0479SSaeed Bishara u32 intr_cause) 854ff7b0479SSaeed Bishara { 855ff7b0479SSaeed Bishara if (intr_cause & (1 << 4)) { 856c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(chan), 857ff7b0479SSaeed Bishara "ignore this error\n"); 858ff7b0479SSaeed Bishara return; 859ff7b0479SSaeed Bishara } 860ff7b0479SSaeed Bishara 861c98c1781SThomas Petazzoni dev_err(mv_chan_to_devp(chan), 862ff7b0479SSaeed Bishara "error on chan %d. intr cause 0x%08x.\n", 863ff7b0479SSaeed Bishara chan->idx, intr_cause); 864ff7b0479SSaeed Bishara 865ff7b0479SSaeed Bishara mv_dump_xor_regs(chan); 866ff7b0479SSaeed Bishara BUG(); 867ff7b0479SSaeed Bishara } 868ff7b0479SSaeed Bishara 869ff7b0479SSaeed Bishara static irqreturn_t mv_xor_interrupt_handler(int irq, void *data) 870ff7b0479SSaeed Bishara { 871ff7b0479SSaeed Bishara struct mv_xor_chan *chan = data; 872ff7b0479SSaeed Bishara u32 intr_cause = mv_chan_get_intr_cause(chan); 873ff7b0479SSaeed Bishara 874c98c1781SThomas Petazzoni dev_dbg(mv_chan_to_devp(chan), "intr cause %x\n", intr_cause); 875ff7b0479SSaeed Bishara 876ff7b0479SSaeed Bishara if (mv_is_err_intr(intr_cause)) 877ff7b0479SSaeed Bishara mv_xor_err_interrupt_handler(chan, intr_cause); 878ff7b0479SSaeed Bishara 879ff7b0479SSaeed Bishara tasklet_schedule(&chan->irq_tasklet); 880ff7b0479SSaeed Bishara 881ff7b0479SSaeed Bishara mv_xor_device_clear_eoc_cause(chan); 882ff7b0479SSaeed Bishara 883ff7b0479SSaeed Bishara return IRQ_HANDLED; 884ff7b0479SSaeed Bishara } 885ff7b0479SSaeed Bishara 886ff7b0479SSaeed Bishara static void mv_xor_issue_pending(struct dma_chan *chan) 887ff7b0479SSaeed Bishara { 888ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 889ff7b0479SSaeed Bishara 890ff7b0479SSaeed Bishara if (mv_chan->pending >= MV_XOR_THRESHOLD) { 891ff7b0479SSaeed Bishara mv_chan->pending = 0; 892ff7b0479SSaeed Bishara mv_chan_activate(mv_chan); 893ff7b0479SSaeed Bishara } 894ff7b0479SSaeed Bishara } 895ff7b0479SSaeed Bishara 896ff7b0479SSaeed Bishara /* 897ff7b0479SSaeed Bishara * Perform a transaction to verify the HW works. 898ff7b0479SSaeed Bishara */ 899ff7b0479SSaeed Bishara #define MV_XOR_TEST_SIZE 2000 900ff7b0479SSaeed Bishara 901ff7b0479SSaeed Bishara static int __devinit mv_xor_memcpy_self_test(struct mv_xor_device *device) 902ff7b0479SSaeed Bishara { 903ff7b0479SSaeed Bishara int i; 904ff7b0479SSaeed Bishara void *src, *dest; 905ff7b0479SSaeed Bishara dma_addr_t src_dma, dest_dma; 906ff7b0479SSaeed Bishara struct dma_chan *dma_chan; 907ff7b0479SSaeed Bishara dma_cookie_t cookie; 908ff7b0479SSaeed Bishara struct dma_async_tx_descriptor *tx; 909ff7b0479SSaeed Bishara int err = 0; 910ff7b0479SSaeed Bishara 911ff7b0479SSaeed Bishara src = kmalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); 912ff7b0479SSaeed Bishara if (!src) 913ff7b0479SSaeed Bishara return -ENOMEM; 914ff7b0479SSaeed Bishara 915ff7b0479SSaeed Bishara dest = kzalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); 916ff7b0479SSaeed Bishara if (!dest) { 917ff7b0479SSaeed Bishara kfree(src); 918ff7b0479SSaeed Bishara return -ENOMEM; 919ff7b0479SSaeed Bishara } 920ff7b0479SSaeed Bishara 921ff7b0479SSaeed Bishara /* Fill in src buffer */ 922ff7b0479SSaeed Bishara for (i = 0; i < MV_XOR_TEST_SIZE; i++) 923ff7b0479SSaeed Bishara ((u8 *) src)[i] = (u8)i; 924ff7b0479SSaeed Bishara 925ff7b0479SSaeed Bishara /* Start copy, using first DMA channel */ 926ff7b0479SSaeed Bishara dma_chan = container_of(device->common.channels.next, 927ff7b0479SSaeed Bishara struct dma_chan, 928ff7b0479SSaeed Bishara device_node); 929aa1e6f1aSDan Williams if (mv_xor_alloc_chan_resources(dma_chan) < 1) { 930ff7b0479SSaeed Bishara err = -ENODEV; 931ff7b0479SSaeed Bishara goto out; 932ff7b0479SSaeed Bishara } 933ff7b0479SSaeed Bishara 934ff7b0479SSaeed Bishara dest_dma = dma_map_single(dma_chan->device->dev, dest, 935ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); 936ff7b0479SSaeed Bishara 937ff7b0479SSaeed Bishara src_dma = dma_map_single(dma_chan->device->dev, src, 938ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_TO_DEVICE); 939ff7b0479SSaeed Bishara 940ff7b0479SSaeed Bishara tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, 941ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, 0); 942ff7b0479SSaeed Bishara cookie = mv_xor_tx_submit(tx); 943ff7b0479SSaeed Bishara mv_xor_issue_pending(dma_chan); 944ff7b0479SSaeed Bishara async_tx_ack(tx); 945ff7b0479SSaeed Bishara msleep(1); 946ff7b0479SSaeed Bishara 94707934481SLinus Walleij if (mv_xor_status(dma_chan, cookie, NULL) != 948ff7b0479SSaeed Bishara DMA_SUCCESS) { 949a3fc74bcSThomas Petazzoni dev_err(dma_chan->device->dev, 950ff7b0479SSaeed Bishara "Self-test copy timed out, disabling\n"); 951ff7b0479SSaeed Bishara err = -ENODEV; 952ff7b0479SSaeed Bishara goto free_resources; 953ff7b0479SSaeed Bishara } 954ff7b0479SSaeed Bishara 955c35064c4SThomas Petazzoni dma_sync_single_for_cpu(dma_chan->device->dev, dest_dma, 956ff7b0479SSaeed Bishara MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); 957ff7b0479SSaeed Bishara if (memcmp(src, dest, MV_XOR_TEST_SIZE)) { 958a3fc74bcSThomas Petazzoni dev_err(dma_chan->device->dev, 959ff7b0479SSaeed Bishara "Self-test copy failed compare, disabling\n"); 960ff7b0479SSaeed Bishara err = -ENODEV; 961ff7b0479SSaeed Bishara goto free_resources; 962ff7b0479SSaeed Bishara } 963ff7b0479SSaeed Bishara 964ff7b0479SSaeed Bishara free_resources: 965ff7b0479SSaeed Bishara mv_xor_free_chan_resources(dma_chan); 966ff7b0479SSaeed Bishara out: 967ff7b0479SSaeed Bishara kfree(src); 968ff7b0479SSaeed Bishara kfree(dest); 969ff7b0479SSaeed Bishara return err; 970ff7b0479SSaeed Bishara } 971ff7b0479SSaeed Bishara 972ff7b0479SSaeed Bishara #define MV_XOR_NUM_SRC_TEST 4 /* must be <= 15 */ 973ff7b0479SSaeed Bishara static int __devinit 974ff7b0479SSaeed Bishara mv_xor_xor_self_test(struct mv_xor_device *device) 975ff7b0479SSaeed Bishara { 976ff7b0479SSaeed Bishara int i, src_idx; 977ff7b0479SSaeed Bishara struct page *dest; 978ff7b0479SSaeed Bishara struct page *xor_srcs[MV_XOR_NUM_SRC_TEST]; 979ff7b0479SSaeed Bishara dma_addr_t dma_srcs[MV_XOR_NUM_SRC_TEST]; 980ff7b0479SSaeed Bishara dma_addr_t dest_dma; 981ff7b0479SSaeed Bishara struct dma_async_tx_descriptor *tx; 982ff7b0479SSaeed Bishara struct dma_chan *dma_chan; 983ff7b0479SSaeed Bishara dma_cookie_t cookie; 984ff7b0479SSaeed Bishara u8 cmp_byte = 0; 985ff7b0479SSaeed Bishara u32 cmp_word; 986ff7b0479SSaeed Bishara int err = 0; 987ff7b0479SSaeed Bishara 988ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 989ff7b0479SSaeed Bishara xor_srcs[src_idx] = alloc_page(GFP_KERNEL); 990a09b09aeSRoel Kluin if (!xor_srcs[src_idx]) { 991a09b09aeSRoel Kluin while (src_idx--) 992ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 993ff7b0479SSaeed Bishara return -ENOMEM; 994ff7b0479SSaeed Bishara } 995ff7b0479SSaeed Bishara } 996ff7b0479SSaeed Bishara 997ff7b0479SSaeed Bishara dest = alloc_page(GFP_KERNEL); 998a09b09aeSRoel Kluin if (!dest) { 999a09b09aeSRoel Kluin while (src_idx--) 1000ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 1001ff7b0479SSaeed Bishara return -ENOMEM; 1002ff7b0479SSaeed Bishara } 1003ff7b0479SSaeed Bishara 1004ff7b0479SSaeed Bishara /* Fill in src buffers */ 1005ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { 1006ff7b0479SSaeed Bishara u8 *ptr = page_address(xor_srcs[src_idx]); 1007ff7b0479SSaeed Bishara for (i = 0; i < PAGE_SIZE; i++) 1008ff7b0479SSaeed Bishara ptr[i] = (1 << src_idx); 1009ff7b0479SSaeed Bishara } 1010ff7b0479SSaeed Bishara 1011ff7b0479SSaeed Bishara for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) 1012ff7b0479SSaeed Bishara cmp_byte ^= (u8) (1 << src_idx); 1013ff7b0479SSaeed Bishara 1014ff7b0479SSaeed Bishara cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | 1015ff7b0479SSaeed Bishara (cmp_byte << 8) | cmp_byte; 1016ff7b0479SSaeed Bishara 1017ff7b0479SSaeed Bishara memset(page_address(dest), 0, PAGE_SIZE); 1018ff7b0479SSaeed Bishara 1019ff7b0479SSaeed Bishara dma_chan = container_of(device->common.channels.next, 1020ff7b0479SSaeed Bishara struct dma_chan, 1021ff7b0479SSaeed Bishara device_node); 1022aa1e6f1aSDan Williams if (mv_xor_alloc_chan_resources(dma_chan) < 1) { 1023ff7b0479SSaeed Bishara err = -ENODEV; 1024ff7b0479SSaeed Bishara goto out; 1025ff7b0479SSaeed Bishara } 1026ff7b0479SSaeed Bishara 1027ff7b0479SSaeed Bishara /* test xor */ 1028ff7b0479SSaeed Bishara dest_dma = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, 1029ff7b0479SSaeed Bishara DMA_FROM_DEVICE); 1030ff7b0479SSaeed Bishara 1031ff7b0479SSaeed Bishara for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) 1032ff7b0479SSaeed Bishara dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], 1033ff7b0479SSaeed Bishara 0, PAGE_SIZE, DMA_TO_DEVICE); 1034ff7b0479SSaeed Bishara 1035ff7b0479SSaeed Bishara tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, 1036ff7b0479SSaeed Bishara MV_XOR_NUM_SRC_TEST, PAGE_SIZE, 0); 1037ff7b0479SSaeed Bishara 1038ff7b0479SSaeed Bishara cookie = mv_xor_tx_submit(tx); 1039ff7b0479SSaeed Bishara mv_xor_issue_pending(dma_chan); 1040ff7b0479SSaeed Bishara async_tx_ack(tx); 1041ff7b0479SSaeed Bishara msleep(8); 1042ff7b0479SSaeed Bishara 104307934481SLinus Walleij if (mv_xor_status(dma_chan, cookie, NULL) != 1044ff7b0479SSaeed Bishara DMA_SUCCESS) { 1045a3fc74bcSThomas Petazzoni dev_err(dma_chan->device->dev, 1046ff7b0479SSaeed Bishara "Self-test xor timed out, disabling\n"); 1047ff7b0479SSaeed Bishara err = -ENODEV; 1048ff7b0479SSaeed Bishara goto free_resources; 1049ff7b0479SSaeed Bishara } 1050ff7b0479SSaeed Bishara 1051c35064c4SThomas Petazzoni dma_sync_single_for_cpu(dma_chan->device->dev, dest_dma, 1052ff7b0479SSaeed Bishara PAGE_SIZE, DMA_FROM_DEVICE); 1053ff7b0479SSaeed Bishara for (i = 0; i < (PAGE_SIZE / sizeof(u32)); i++) { 1054ff7b0479SSaeed Bishara u32 *ptr = page_address(dest); 1055ff7b0479SSaeed Bishara if (ptr[i] != cmp_word) { 1056a3fc74bcSThomas Petazzoni dev_err(dma_chan->device->dev, 1057ff7b0479SSaeed Bishara "Self-test xor failed compare, disabling." 1058ff7b0479SSaeed Bishara " index %d, data %x, expected %x\n", i, 1059ff7b0479SSaeed Bishara ptr[i], cmp_word); 1060ff7b0479SSaeed Bishara err = -ENODEV; 1061ff7b0479SSaeed Bishara goto free_resources; 1062ff7b0479SSaeed Bishara } 1063ff7b0479SSaeed Bishara } 1064ff7b0479SSaeed Bishara 1065ff7b0479SSaeed Bishara free_resources: 1066ff7b0479SSaeed Bishara mv_xor_free_chan_resources(dma_chan); 1067ff7b0479SSaeed Bishara out: 1068ff7b0479SSaeed Bishara src_idx = MV_XOR_NUM_SRC_TEST; 1069ff7b0479SSaeed Bishara while (src_idx--) 1070ff7b0479SSaeed Bishara __free_page(xor_srcs[src_idx]); 1071ff7b0479SSaeed Bishara __free_page(dest); 1072ff7b0479SSaeed Bishara return err; 1073ff7b0479SSaeed Bishara } 1074ff7b0479SSaeed Bishara 1075a6b4a9d2SThomas Petazzoni static int mv_xor_channel_remove(struct mv_xor_device *device) 1076ff7b0479SSaeed Bishara { 1077ff7b0479SSaeed Bishara struct dma_chan *chan, *_chan; 1078ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 1079*ecde6cd4SThomas Petazzoni struct device *dev = device->common.dev; 1080ff7b0479SSaeed Bishara 1081ff7b0479SSaeed Bishara dma_async_device_unregister(&device->common); 1082ff7b0479SSaeed Bishara 1083*ecde6cd4SThomas Petazzoni dma_free_coherent(dev, device->pool_size, 1084ff7b0479SSaeed Bishara device->dma_desc_pool_virt, device->dma_desc_pool); 1085ff7b0479SSaeed Bishara 1086ff7b0479SSaeed Bishara list_for_each_entry_safe(chan, _chan, &device->common.channels, 1087ff7b0479SSaeed Bishara device_node) { 1088ff7b0479SSaeed Bishara mv_chan = to_mv_xor_chan(chan); 1089ff7b0479SSaeed Bishara list_del(&chan->device_node); 1090ff7b0479SSaeed Bishara } 1091ff7b0479SSaeed Bishara 1092ff7b0479SSaeed Bishara return 0; 1093ff7b0479SSaeed Bishara } 1094ff7b0479SSaeed Bishara 1095a6b4a9d2SThomas Petazzoni static struct mv_xor_device * 109661971656SThomas Petazzoni mv_xor_channel_add(struct mv_xor_private *msp, 1097a6b4a9d2SThomas Petazzoni struct platform_device *pdev, 1098a6b4a9d2SThomas Petazzoni int hw_id, dma_cap_mask_t cap_mask, 1099a6b4a9d2SThomas Petazzoni size_t pool_size, int irq) 1100ff7b0479SSaeed Bishara { 1101ff7b0479SSaeed Bishara int ret = 0; 1102ff7b0479SSaeed Bishara struct mv_xor_device *adev; 1103ff7b0479SSaeed Bishara struct mv_xor_chan *mv_chan; 1104ff7b0479SSaeed Bishara struct dma_device *dma_dev; 1105ff7b0479SSaeed Bishara 1106ff7b0479SSaeed Bishara adev = devm_kzalloc(&pdev->dev, sizeof(*adev), GFP_KERNEL); 1107ff7b0479SSaeed Bishara if (!adev) 1108a6b4a9d2SThomas Petazzoni return ERR_PTR(-ENOMEM); 1109ff7b0479SSaeed Bishara 1110ff7b0479SSaeed Bishara dma_dev = &adev->common; 1111ff7b0479SSaeed Bishara 1112ff7b0479SSaeed Bishara /* allocate coherent memory for hardware descriptors 1113ff7b0479SSaeed Bishara * note: writecombine gives slightly better performance, but 1114ff7b0479SSaeed Bishara * requires that we explicitly flush the writes 1115ff7b0479SSaeed Bishara */ 1116a6b4a9d2SThomas Petazzoni adev->pool_size = pool_size; 1117ff7b0479SSaeed Bishara adev->dma_desc_pool_virt = dma_alloc_writecombine(&pdev->dev, 111809f2b786SThomas Petazzoni adev->pool_size, 1119ff7b0479SSaeed Bishara &adev->dma_desc_pool, 1120ff7b0479SSaeed Bishara GFP_KERNEL); 1121ff7b0479SSaeed Bishara if (!adev->dma_desc_pool_virt) 1122a6b4a9d2SThomas Petazzoni return ERR_PTR(-ENOMEM); 1123ff7b0479SSaeed Bishara 1124ff7b0479SSaeed Bishara /* discover transaction capabilites from the platform data */ 1125a6b4a9d2SThomas Petazzoni dma_dev->cap_mask = cap_mask; 1126a6b4a9d2SThomas Petazzoni adev->shared = msp; 1127ff7b0479SSaeed Bishara 1128ff7b0479SSaeed Bishara INIT_LIST_HEAD(&dma_dev->channels); 1129ff7b0479SSaeed Bishara 1130ff7b0479SSaeed Bishara /* set base routines */ 1131ff7b0479SSaeed Bishara dma_dev->device_alloc_chan_resources = mv_xor_alloc_chan_resources; 1132ff7b0479SSaeed Bishara dma_dev->device_free_chan_resources = mv_xor_free_chan_resources; 113307934481SLinus Walleij dma_dev->device_tx_status = mv_xor_status; 1134ff7b0479SSaeed Bishara dma_dev->device_issue_pending = mv_xor_issue_pending; 1135ff7b0479SSaeed Bishara dma_dev->dev = &pdev->dev; 1136ff7b0479SSaeed Bishara 1137ff7b0479SSaeed Bishara /* set prep routines based on capability */ 1138ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) 1139ff7b0479SSaeed Bishara dma_dev->device_prep_dma_memcpy = mv_xor_prep_dma_memcpy; 1140ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMSET, dma_dev->cap_mask)) 1141ff7b0479SSaeed Bishara dma_dev->device_prep_dma_memset = mv_xor_prep_dma_memset; 1142ff7b0479SSaeed Bishara if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1143c019894eSJoe Perches dma_dev->max_xor = 8; 1144ff7b0479SSaeed Bishara dma_dev->device_prep_dma_xor = mv_xor_prep_dma_xor; 1145ff7b0479SSaeed Bishara } 1146ff7b0479SSaeed Bishara 1147ff7b0479SSaeed Bishara mv_chan = devm_kzalloc(&pdev->dev, sizeof(*mv_chan), GFP_KERNEL); 1148ff7b0479SSaeed Bishara if (!mv_chan) { 1149ff7b0479SSaeed Bishara ret = -ENOMEM; 1150ff7b0479SSaeed Bishara goto err_free_dma; 1151ff7b0479SSaeed Bishara } 1152ff7b0479SSaeed Bishara mv_chan->device = adev; 1153a6b4a9d2SThomas Petazzoni mv_chan->idx = hw_id; 1154ff7b0479SSaeed Bishara mv_chan->mmr_base = adev->shared->xor_base; 1155ff7b0479SSaeed Bishara 1156ff7b0479SSaeed Bishara if (!mv_chan->mmr_base) { 1157ff7b0479SSaeed Bishara ret = -ENOMEM; 1158ff7b0479SSaeed Bishara goto err_free_dma; 1159ff7b0479SSaeed Bishara } 1160ff7b0479SSaeed Bishara tasklet_init(&mv_chan->irq_tasklet, mv_xor_tasklet, (unsigned long) 1161ff7b0479SSaeed Bishara mv_chan); 1162ff7b0479SSaeed Bishara 1163ff7b0479SSaeed Bishara /* clear errors before enabling interrupts */ 1164ff7b0479SSaeed Bishara mv_xor_device_clear_err_status(mv_chan); 1165ff7b0479SSaeed Bishara 1166ff7b0479SSaeed Bishara ret = devm_request_irq(&pdev->dev, irq, 1167ff7b0479SSaeed Bishara mv_xor_interrupt_handler, 1168ff7b0479SSaeed Bishara 0, dev_name(&pdev->dev), mv_chan); 1169ff7b0479SSaeed Bishara if (ret) 1170ff7b0479SSaeed Bishara goto err_free_dma; 1171ff7b0479SSaeed Bishara 1172ff7b0479SSaeed Bishara mv_chan_unmask_interrupts(mv_chan); 1173ff7b0479SSaeed Bishara 1174ff7b0479SSaeed Bishara mv_set_mode(mv_chan, DMA_MEMCPY); 1175ff7b0479SSaeed Bishara 1176ff7b0479SSaeed Bishara spin_lock_init(&mv_chan->lock); 1177ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->chain); 1178ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->completed_slots); 1179ff7b0479SSaeed Bishara INIT_LIST_HEAD(&mv_chan->all_slots); 1180ff7b0479SSaeed Bishara mv_chan->common.device = dma_dev; 11818ac69546SRussell King - ARM Linux dma_cookie_init(&mv_chan->common); 1182ff7b0479SSaeed Bishara 1183ff7b0479SSaeed Bishara list_add_tail(&mv_chan->common.device_node, &dma_dev->channels); 1184ff7b0479SSaeed Bishara 1185ff7b0479SSaeed Bishara if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) { 1186ff7b0479SSaeed Bishara ret = mv_xor_memcpy_self_test(adev); 1187ff7b0479SSaeed Bishara dev_dbg(&pdev->dev, "memcpy self test returned %d\n", ret); 1188ff7b0479SSaeed Bishara if (ret) 1189ff7b0479SSaeed Bishara goto err_free_dma; 1190ff7b0479SSaeed Bishara } 1191ff7b0479SSaeed Bishara 1192ff7b0479SSaeed Bishara if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1193ff7b0479SSaeed Bishara ret = mv_xor_xor_self_test(adev); 1194ff7b0479SSaeed Bishara dev_dbg(&pdev->dev, "xor self test returned %d\n", ret); 1195ff7b0479SSaeed Bishara if (ret) 1196ff7b0479SSaeed Bishara goto err_free_dma; 1197ff7b0479SSaeed Bishara } 1198ff7b0479SSaeed Bishara 1199a3fc74bcSThomas Petazzoni dev_info(&pdev->dev, "Marvell XOR: " 1200ff7b0479SSaeed Bishara "( %s%s%s%s)\n", 1201ff7b0479SSaeed Bishara dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "xor " : "", 1202ff7b0479SSaeed Bishara dma_has_cap(DMA_MEMSET, dma_dev->cap_mask) ? "fill " : "", 1203ff7b0479SSaeed Bishara dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask) ? "cpy " : "", 1204ff7b0479SSaeed Bishara dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask) ? "intr " : ""); 1205ff7b0479SSaeed Bishara 1206ff7b0479SSaeed Bishara dma_async_device_register(dma_dev); 1207a6b4a9d2SThomas Petazzoni return adev; 1208ff7b0479SSaeed Bishara 1209ff7b0479SSaeed Bishara err_free_dma: 1210*ecde6cd4SThomas Petazzoni dma_free_coherent(&pdev->dev, pool_size, 1211ff7b0479SSaeed Bishara adev->dma_desc_pool_virt, adev->dma_desc_pool); 1212a6b4a9d2SThomas Petazzoni return ERR_PTR(ret); 1213a6b4a9d2SThomas Petazzoni } 1214a6b4a9d2SThomas Petazzoni 1215ff7b0479SSaeed Bishara static void 121661971656SThomas Petazzoni mv_xor_conf_mbus_windows(struct mv_xor_private *msp, 121763a9332bSAndrew Lunn const struct mbus_dram_target_info *dram) 1218ff7b0479SSaeed Bishara { 1219ff7b0479SSaeed Bishara void __iomem *base = msp->xor_base; 1220ff7b0479SSaeed Bishara u32 win_enable = 0; 1221ff7b0479SSaeed Bishara int i; 1222ff7b0479SSaeed Bishara 1223ff7b0479SSaeed Bishara for (i = 0; i < 8; i++) { 1224ff7b0479SSaeed Bishara writel(0, base + WINDOW_BASE(i)); 1225ff7b0479SSaeed Bishara writel(0, base + WINDOW_SIZE(i)); 1226ff7b0479SSaeed Bishara if (i < 4) 1227ff7b0479SSaeed Bishara writel(0, base + WINDOW_REMAP_HIGH(i)); 1228ff7b0479SSaeed Bishara } 1229ff7b0479SSaeed Bishara 1230ff7b0479SSaeed Bishara for (i = 0; i < dram->num_cs; i++) { 123163a9332bSAndrew Lunn const struct mbus_dram_window *cs = dram->cs + i; 1232ff7b0479SSaeed Bishara 1233ff7b0479SSaeed Bishara writel((cs->base & 0xffff0000) | 1234ff7b0479SSaeed Bishara (cs->mbus_attr << 8) | 1235ff7b0479SSaeed Bishara dram->mbus_dram_target_id, base + WINDOW_BASE(i)); 1236ff7b0479SSaeed Bishara writel((cs->size - 1) & 0xffff0000, base + WINDOW_SIZE(i)); 1237ff7b0479SSaeed Bishara 1238ff7b0479SSaeed Bishara win_enable |= (1 << i); 1239ff7b0479SSaeed Bishara win_enable |= 3 << (16 + (2 * i)); 1240ff7b0479SSaeed Bishara } 1241ff7b0479SSaeed Bishara 1242ff7b0479SSaeed Bishara writel(win_enable, base + WINDOW_BAR_ENABLE(0)); 1243ff7b0479SSaeed Bishara writel(win_enable, base + WINDOW_BAR_ENABLE(1)); 1244ff7b0479SSaeed Bishara } 1245ff7b0479SSaeed Bishara 124661971656SThomas Petazzoni static int mv_xor_probe(struct platform_device *pdev) 1247ff7b0479SSaeed Bishara { 124863a9332bSAndrew Lunn const struct mbus_dram_target_info *dram; 124961971656SThomas Petazzoni struct mv_xor_private *msp; 12507dde453dSThomas Petazzoni struct mv_xor_platform_data *pdata = pdev->dev.platform_data; 1251ff7b0479SSaeed Bishara struct resource *res; 125260d151f3SThomas Petazzoni int i, ret; 1253ff7b0479SSaeed Bishara 125461971656SThomas Petazzoni dev_notice(&pdev->dev, "Marvell XOR driver\n"); 1255ff7b0479SSaeed Bishara 1256ff7b0479SSaeed Bishara msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL); 1257ff7b0479SSaeed Bishara if (!msp) 1258ff7b0479SSaeed Bishara return -ENOMEM; 1259ff7b0479SSaeed Bishara 1260ff7b0479SSaeed Bishara res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1261ff7b0479SSaeed Bishara if (!res) 1262ff7b0479SSaeed Bishara return -ENODEV; 1263ff7b0479SSaeed Bishara 1264ff7b0479SSaeed Bishara msp->xor_base = devm_ioremap(&pdev->dev, res->start, 12654de1ba15SH Hartley Sweeten resource_size(res)); 1266ff7b0479SSaeed Bishara if (!msp->xor_base) 1267ff7b0479SSaeed Bishara return -EBUSY; 1268ff7b0479SSaeed Bishara 1269ff7b0479SSaeed Bishara res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1270ff7b0479SSaeed Bishara if (!res) 1271ff7b0479SSaeed Bishara return -ENODEV; 1272ff7b0479SSaeed Bishara 1273ff7b0479SSaeed Bishara msp->xor_high_base = devm_ioremap(&pdev->dev, res->start, 12744de1ba15SH Hartley Sweeten resource_size(res)); 1275ff7b0479SSaeed Bishara if (!msp->xor_high_base) 1276ff7b0479SSaeed Bishara return -EBUSY; 1277ff7b0479SSaeed Bishara 1278ff7b0479SSaeed Bishara platform_set_drvdata(pdev, msp); 1279ff7b0479SSaeed Bishara 1280ff7b0479SSaeed Bishara /* 1281ff7b0479SSaeed Bishara * (Re-)program MBUS remapping windows if we are asked to. 1282ff7b0479SSaeed Bishara */ 128363a9332bSAndrew Lunn dram = mv_mbus_dram_info(); 128463a9332bSAndrew Lunn if (dram) 128563a9332bSAndrew Lunn mv_xor_conf_mbus_windows(msp, dram); 1286ff7b0479SSaeed Bishara 1287c510182bSAndrew Lunn /* Not all platforms can gate the clock, so it is not 1288c510182bSAndrew Lunn * an error if the clock does not exists. 1289c510182bSAndrew Lunn */ 1290c510182bSAndrew Lunn msp->clk = clk_get(&pdev->dev, NULL); 1291c510182bSAndrew Lunn if (!IS_ERR(msp->clk)) 1292c510182bSAndrew Lunn clk_prepare_enable(msp->clk); 1293c510182bSAndrew Lunn 129460d151f3SThomas Petazzoni if (pdata && pdata->channels) { 129560d151f3SThomas Petazzoni for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { 1296e39f6ec1SThomas Petazzoni struct mv_xor_channel_data *cd; 129760d151f3SThomas Petazzoni int irq; 129860d151f3SThomas Petazzoni 129960d151f3SThomas Petazzoni cd = &pdata->channels[i]; 130060d151f3SThomas Petazzoni if (!cd) { 130160d151f3SThomas Petazzoni ret = -ENODEV; 130260d151f3SThomas Petazzoni goto err_channel_add; 130360d151f3SThomas Petazzoni } 130460d151f3SThomas Petazzoni 130560d151f3SThomas Petazzoni irq = platform_get_irq(pdev, i); 130660d151f3SThomas Petazzoni if (irq < 0) { 130760d151f3SThomas Petazzoni ret = irq; 130860d151f3SThomas Petazzoni goto err_channel_add; 130960d151f3SThomas Petazzoni } 131060d151f3SThomas Petazzoni 131160d151f3SThomas Petazzoni msp->channels[i] = 131260d151f3SThomas Petazzoni mv_xor_channel_add(msp, pdev, cd->hw_id, 131360d151f3SThomas Petazzoni cd->cap_mask, 131460d151f3SThomas Petazzoni cd->pool_size, irq); 131560d151f3SThomas Petazzoni if (IS_ERR(msp->channels[i])) { 131660d151f3SThomas Petazzoni ret = PTR_ERR(msp->channels[i]); 131760d151f3SThomas Petazzoni goto err_channel_add; 131860d151f3SThomas Petazzoni } 131960d151f3SThomas Petazzoni } 132060d151f3SThomas Petazzoni } 132160d151f3SThomas Petazzoni 1322ff7b0479SSaeed Bishara return 0; 132360d151f3SThomas Petazzoni 132460d151f3SThomas Petazzoni err_channel_add: 132560d151f3SThomas Petazzoni for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) 132660d151f3SThomas Petazzoni if (msp->channels[i]) 132760d151f3SThomas Petazzoni mv_xor_channel_remove(msp->channels[i]); 132860d151f3SThomas Petazzoni 132960d151f3SThomas Petazzoni clk_disable_unprepare(msp->clk); 133060d151f3SThomas Petazzoni clk_put(msp->clk); 133160d151f3SThomas Petazzoni return ret; 1332ff7b0479SSaeed Bishara } 1333ff7b0479SSaeed Bishara 133461971656SThomas Petazzoni static int mv_xor_remove(struct platform_device *pdev) 1335ff7b0479SSaeed Bishara { 133661971656SThomas Petazzoni struct mv_xor_private *msp = platform_get_drvdata(pdev); 133760d151f3SThomas Petazzoni int i; 133860d151f3SThomas Petazzoni 133960d151f3SThomas Petazzoni for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { 134060d151f3SThomas Petazzoni if (msp->channels[i]) 134160d151f3SThomas Petazzoni mv_xor_channel_remove(msp->channels[i]); 134260d151f3SThomas Petazzoni } 1343c510182bSAndrew Lunn 1344c510182bSAndrew Lunn if (!IS_ERR(msp->clk)) { 1345c510182bSAndrew Lunn clk_disable_unprepare(msp->clk); 1346c510182bSAndrew Lunn clk_put(msp->clk); 1347c510182bSAndrew Lunn } 1348c510182bSAndrew Lunn 1349ff7b0479SSaeed Bishara return 0; 1350ff7b0479SSaeed Bishara } 1351ff7b0479SSaeed Bishara 135261971656SThomas Petazzoni static struct platform_driver mv_xor_driver = { 135361971656SThomas Petazzoni .probe = mv_xor_probe, 135461971656SThomas Petazzoni .remove = mv_xor_remove, 1355ff7b0479SSaeed Bishara .driver = { 1356ff7b0479SSaeed Bishara .owner = THIS_MODULE, 13570dddee7aSThomas Petazzoni .name = MV_XOR_NAME, 1358ff7b0479SSaeed Bishara }, 1359ff7b0479SSaeed Bishara }; 1360ff7b0479SSaeed Bishara 1361ff7b0479SSaeed Bishara 1362ff7b0479SSaeed Bishara static int __init mv_xor_init(void) 1363ff7b0479SSaeed Bishara { 136461971656SThomas Petazzoni return platform_driver_register(&mv_xor_driver); 1365ff7b0479SSaeed Bishara } 1366ff7b0479SSaeed Bishara module_init(mv_xor_init); 1367ff7b0479SSaeed Bishara 1368ff7b0479SSaeed Bishara /* it's currently unsafe to unload this module */ 1369ff7b0479SSaeed Bishara #if 0 1370ff7b0479SSaeed Bishara static void __exit mv_xor_exit(void) 1371ff7b0479SSaeed Bishara { 137261971656SThomas Petazzoni platform_driver_unregister(&mv_xor_driver); 1373ff7b0479SSaeed Bishara return; 1374ff7b0479SSaeed Bishara } 1375ff7b0479SSaeed Bishara 1376ff7b0479SSaeed Bishara module_exit(mv_xor_exit); 1377ff7b0479SSaeed Bishara #endif 1378ff7b0479SSaeed Bishara 1379ff7b0479SSaeed Bishara MODULE_AUTHOR("Saeed Bishara <saeed@marvell.com>"); 1380ff7b0479SSaeed Bishara MODULE_DESCRIPTION("DMA engine driver for Marvell's XOR engine"); 1381ff7b0479SSaeed Bishara MODULE_LICENSE("GPL"); 1382