| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * offload engine driver for the Intel Xscale series of i/o processors |
|---|
| 3 | 4 | * Copyright © 2006, Intel Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | |
|---|
| 16 | 7 | /* |
|---|
| .. | .. |
|---|
| 25 | 16 | #include <linux/spinlock.h> |
|---|
| 26 | 17 | #include <linux/interrupt.h> |
|---|
| 27 | 18 | #include <linux/platform_device.h> |
|---|
| 19 | +#include <linux/prefetch.h> |
|---|
| 28 | 20 | #include <linux/memory.h> |
|---|
| 29 | 21 | #include <linux/ioport.h> |
|---|
| 30 | 22 | #include <linux/raid/pq.h> |
|---|
| 31 | 23 | #include <linux/slab.h> |
|---|
| 32 | 24 | |
|---|
| 33 | | -#include <mach/adma.h> |
|---|
| 34 | | - |
|---|
| 25 | +#include "iop-adma.h" |
|---|
| 35 | 26 | #include "dmaengine.h" |
|---|
| 36 | 27 | |
|---|
| 37 | 28 | #define to_iop_adma_chan(chan) container_of(chan, struct iop_adma_chan, common) |
|---|
| .. | .. |
|---|
| 125 | 116 | list_for_each_entry_safe(iter, _iter, &iop_chan->chain, |
|---|
| 126 | 117 | chain_node) { |
|---|
| 127 | 118 | pr_debug("\tcookie: %d slot: %d busy: %d " |
|---|
| 128 | | - "this_desc: %#x next_desc: %#llx ack: %d\n", |
|---|
| 119 | + "this_desc: %pad next_desc: %#llx ack: %d\n", |
|---|
| 129 | 120 | iter->async_tx.cookie, iter->idx, busy, |
|---|
| 130 | | - iter->async_tx.phys, (u64)iop_desc_get_next_desc(iter), |
|---|
| 121 | + &iter->async_tx.phys, (u64)iop_desc_get_next_desc(iter), |
|---|
| 131 | 122 | async_tx_test_ack(&iter->async_tx)); |
|---|
| 132 | 123 | prefetch(_iter); |
|---|
| 133 | 124 | prefetch(&_iter->async_tx); |
|---|
| .. | .. |
|---|
| 182 | 173 | &iop_chan->chain, chain_node) { |
|---|
| 183 | 174 | zero_sum_result |= |
|---|
| 184 | 175 | iop_desc_get_zero_result(grp_iter); |
|---|
| 185 | | - pr_debug("\titer%d result: %d\n", |
|---|
| 176 | + pr_debug("\titer%d result: %d\n", |
|---|
| 186 | 177 | grp_iter->idx, zero_sum_result); |
|---|
| 187 | 178 | slot_cnt -= slots_per_op; |
|---|
| 188 | 179 | if (slot_cnt == 0) |
|---|
| .. | .. |
|---|
| 247 | 238 | spin_unlock_bh(&iop_chan->lock); |
|---|
| 248 | 239 | } |
|---|
| 249 | 240 | |
|---|
| 250 | | -static void iop_adma_tasklet(unsigned long data) |
|---|
| 241 | +static void iop_adma_tasklet(struct tasklet_struct *t) |
|---|
| 251 | 242 | { |
|---|
| 252 | | - struct iop_adma_chan *iop_chan = (struct iop_adma_chan *) data; |
|---|
| 243 | + struct iop_adma_chan *iop_chan = from_tasklet(iop_chan, t, |
|---|
| 244 | + irq_tasklet); |
|---|
| 253 | 245 | |
|---|
| 254 | 246 | /* lockdep will flag depedency submissions as potentially |
|---|
| 255 | 247 | * recursive locking, this is not the case as a dependency |
|---|
| .. | .. |
|---|
| 373 | 365 | struct iop_adma_chan *iop_chan = to_iop_adma_chan(tx->chan); |
|---|
| 374 | 366 | struct iop_adma_desc_slot *grp_start, *old_chain_tail; |
|---|
| 375 | 367 | int slot_cnt; |
|---|
| 376 | | - int slots_per_op; |
|---|
| 377 | 368 | dma_cookie_t cookie; |
|---|
| 378 | 369 | dma_addr_t next_dma; |
|---|
| 379 | 370 | |
|---|
| 380 | 371 | grp_start = sw_desc->group_head; |
|---|
| 381 | 372 | slot_cnt = grp_start->slot_cnt; |
|---|
| 382 | | - slots_per_op = grp_start->slots_per_op; |
|---|
| 383 | 373 | |
|---|
| 384 | 374 | spin_lock_bh(&iop_chan->lock); |
|---|
| 385 | 375 | cookie = dma_cookie_assign(tx); |
|---|
| .. | .. |
|---|
| 417 | 407 | |
|---|
| 418 | 408 | /** |
|---|
| 419 | 409 | * iop_adma_alloc_chan_resources - returns the number of allocated descriptors |
|---|
| 420 | | - * @chan - allocate descriptor resources for this channel |
|---|
| 421 | | - * @client - current client requesting the channel be ready for requests |
|---|
| 410 | + * @chan: allocate descriptor resources for this channel |
|---|
| 422 | 411 | * |
|---|
| 423 | 412 | * Note: We keep the slots for 1 operation on iop_chan->chain at all times. To |
|---|
| 424 | 413 | * avoid deadlock, via async_xor, num_descs_in_pool must at a minimum be |
|---|
| .. | .. |
|---|
| 428 | 417 | static int iop_adma_alloc_chan_resources(struct dma_chan *chan) |
|---|
| 429 | 418 | { |
|---|
| 430 | 419 | char *hw_desc; |
|---|
| 420 | + dma_addr_t dma_desc; |
|---|
| 431 | 421 | int idx; |
|---|
| 432 | 422 | struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan); |
|---|
| 433 | 423 | struct iop_adma_desc_slot *slot = NULL; |
|---|
| .. | .. |
|---|
| 456 | 446 | INIT_LIST_HEAD(&slot->tx_list); |
|---|
| 457 | 447 | INIT_LIST_HEAD(&slot->chain_node); |
|---|
| 458 | 448 | INIT_LIST_HEAD(&slot->slot_node); |
|---|
| 459 | | - hw_desc = (char *) iop_chan->device->dma_desc_pool; |
|---|
| 460 | | - slot->async_tx.phys = |
|---|
| 461 | | - (dma_addr_t) &hw_desc[idx * IOP_ADMA_SLOT_SIZE]; |
|---|
| 449 | + dma_desc = iop_chan->device->dma_desc_pool; |
|---|
| 450 | + slot->async_tx.phys = dma_desc + idx * IOP_ADMA_SLOT_SIZE; |
|---|
| 462 | 451 | slot->idx = idx; |
|---|
| 463 | 452 | |
|---|
| 464 | 453 | spin_lock_bh(&iop_chan->lock); |
|---|
| .. | .. |
|---|
| 1308 | 1297 | goto err_free_adev; |
|---|
| 1309 | 1298 | } |
|---|
| 1310 | 1299 | |
|---|
| 1311 | | - dev_dbg(&pdev->dev, "%s: allocated descriptor pool virt %p phys %p\n", |
|---|
| 1312 | | - __func__, adev->dma_desc_pool_virt, |
|---|
| 1313 | | - (void *) adev->dma_desc_pool); |
|---|
| 1300 | + dev_dbg(&pdev->dev, "%s: allocated descriptor pool virt %p phys %pad\n", |
|---|
| 1301 | + __func__, adev->dma_desc_pool_virt, &adev->dma_desc_pool); |
|---|
| 1314 | 1302 | |
|---|
| 1315 | 1303 | adev->id = plat_data->hw_id; |
|---|
| 1316 | 1304 | |
|---|
| .. | .. |
|---|
| 1363 | 1351 | ret = -ENOMEM; |
|---|
| 1364 | 1352 | goto err_free_iop_chan; |
|---|
| 1365 | 1353 | } |
|---|
| 1366 | | - tasklet_init(&iop_chan->irq_tasklet, iop_adma_tasklet, (unsigned long) |
|---|
| 1367 | | - iop_chan); |
|---|
| 1354 | + tasklet_setup(&iop_chan->irq_tasklet, iop_adma_tasklet); |
|---|
| 1368 | 1355 | |
|---|
| 1369 | 1356 | /* clear errors before enabling interrupts */ |
|---|
| 1370 | 1357 | iop_adma_device_clear_err_status(iop_chan); |
|---|
| 1371 | 1358 | |
|---|
| 1372 | 1359 | for (i = 0; i < 3; i++) { |
|---|
| 1373 | | - irq_handler_t handler[] = { iop_adma_eot_handler, |
|---|
| 1374 | | - iop_adma_eoc_handler, |
|---|
| 1375 | | - iop_adma_err_handler }; |
|---|
| 1360 | + static const irq_handler_t handler[] = { |
|---|
| 1361 | + iop_adma_eot_handler, |
|---|
| 1362 | + iop_adma_eoc_handler, |
|---|
| 1363 | + iop_adma_err_handler |
|---|
| 1364 | + }; |
|---|
| 1376 | 1365 | int irq = platform_get_irq(pdev, i); |
|---|
| 1377 | 1366 | if (irq < 0) { |
|---|
| 1378 | 1367 | ret = -ENXIO; |
|---|