hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/dma/iop-adma.c
....@@ -1,16 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * offload engine driver for the Intel Xscale series of i/o processors
34 * 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
- *
145 */
156
167 /*
....@@ -25,13 +16,13 @@
2516 #include <linux/spinlock.h>
2617 #include <linux/interrupt.h>
2718 #include <linux/platform_device.h>
19
+#include <linux/prefetch.h>
2820 #include <linux/memory.h>
2921 #include <linux/ioport.h>
3022 #include <linux/raid/pq.h>
3123 #include <linux/slab.h>
3224
33
-#include <mach/adma.h>
34
-
25
+#include "iop-adma.h"
3526 #include "dmaengine.h"
3627
3728 #define to_iop_adma_chan(chan) container_of(chan, struct iop_adma_chan, common)
....@@ -125,9 +116,9 @@
125116 list_for_each_entry_safe(iter, _iter, &iop_chan->chain,
126117 chain_node) {
127118 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",
129120 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),
131122 async_tx_test_ack(&iter->async_tx));
132123 prefetch(_iter);
133124 prefetch(&_iter->async_tx);
....@@ -182,7 +173,7 @@
182173 &iop_chan->chain, chain_node) {
183174 zero_sum_result |=
184175 iop_desc_get_zero_result(grp_iter);
185
- pr_debug("\titer%d result: %d\n",
176
+ pr_debug("\titer%d result: %d\n",
186177 grp_iter->idx, zero_sum_result);
187178 slot_cnt -= slots_per_op;
188179 if (slot_cnt == 0)
....@@ -247,9 +238,10 @@
247238 spin_unlock_bh(&iop_chan->lock);
248239 }
249240
250
-static void iop_adma_tasklet(unsigned long data)
241
+static void iop_adma_tasklet(struct tasklet_struct *t)
251242 {
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);
253245
254246 /* lockdep will flag depedency submissions as potentially
255247 * recursive locking, this is not the case as a dependency
....@@ -373,13 +365,11 @@
373365 struct iop_adma_chan *iop_chan = to_iop_adma_chan(tx->chan);
374366 struct iop_adma_desc_slot *grp_start, *old_chain_tail;
375367 int slot_cnt;
376
- int slots_per_op;
377368 dma_cookie_t cookie;
378369 dma_addr_t next_dma;
379370
380371 grp_start = sw_desc->group_head;
381372 slot_cnt = grp_start->slot_cnt;
382
- slots_per_op = grp_start->slots_per_op;
383373
384374 spin_lock_bh(&iop_chan->lock);
385375 cookie = dma_cookie_assign(tx);
....@@ -417,8 +407,7 @@
417407
418408 /**
419409 * 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
422411 *
423412 * Note: We keep the slots for 1 operation on iop_chan->chain at all times. To
424413 * avoid deadlock, via async_xor, num_descs_in_pool must at a minimum be
....@@ -428,6 +417,7 @@
428417 static int iop_adma_alloc_chan_resources(struct dma_chan *chan)
429418 {
430419 char *hw_desc;
420
+ dma_addr_t dma_desc;
431421 int idx;
432422 struct iop_adma_chan *iop_chan = to_iop_adma_chan(chan);
433423 struct iop_adma_desc_slot *slot = NULL;
....@@ -456,9 +446,8 @@
456446 INIT_LIST_HEAD(&slot->tx_list);
457447 INIT_LIST_HEAD(&slot->chain_node);
458448 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;
462451 slot->idx = idx;
463452
464453 spin_lock_bh(&iop_chan->lock);
....@@ -1308,9 +1297,8 @@
13081297 goto err_free_adev;
13091298 }
13101299
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);
13141302
13151303 adev->id = plat_data->hw_id;
13161304
....@@ -1363,16 +1351,17 @@
13631351 ret = -ENOMEM;
13641352 goto err_free_iop_chan;
13651353 }
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);
13681355
13691356 /* clear errors before enabling interrupts */
13701357 iop_adma_device_clear_err_status(iop_chan);
13711358
13721359 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
+ };
13761365 int irq = platform_get_irq(pdev, i);
13771366 if (irq < 0) {
13781367 ret = -ENXIO;