forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/dma/xgene-dma.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Applied Micro X-Gene SoC DMA engine Driver
34 *
45 * Copyright (c) 2015, Applied Micro Circuits Corporation
56 * Authors: Rameshwar Prasad Sahu <rsahu@apm.com>
67 * Loc Ho <lho@apm.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
208 *
219 * NOTE: PM support is currently not available.
2210 */
....@@ -299,6 +287,8 @@
299287
300288 /**
301289 * struct xgene_dma - internal representation of an X-Gene DMA device
290
+ * @dev: reference to this device's struct device
291
+ * @clk: reference to this device's clock
302292 * @err_irq: DMA error irq number
303293 * @ring_num: start id number for DMA ring
304294 * @csr_dma: base for DMA register access
....@@ -703,7 +693,7 @@
703693
704694 INIT_LIST_HEAD(&ld_completed);
705695
706
- spin_lock_bh(&chan->lock);
696
+ spin_lock(&chan->lock);
707697
708698 /* Clean already completed and acked descriptors */
709699 xgene_dma_clean_completed_descriptor(chan);
....@@ -772,7 +762,7 @@
772762 */
773763 xgene_chan_xfer_ld_pending(chan);
774764
775
- spin_unlock_bh(&chan->lock);
765
+ spin_unlock(&chan->lock);
776766
777767 /* Run the callback for each descriptor, in order */
778768 list_for_each_entry_safe(desc_sw, _desc_sw, &ld_completed, node) {
....@@ -797,7 +787,7 @@
797787 return -ENOMEM;
798788 }
799789
800
- chan_dbg(chan, "Allocate descripto pool\n");
790
+ chan_dbg(chan, "Allocate descriptor pool\n");
801791
802792 return 1;
803793 }
....@@ -985,9 +975,9 @@
985975 return dma_cookie_status(dchan, cookie, txstate);
986976 }
987977
988
-static void xgene_dma_tasklet_cb(unsigned long data)
978
+static void xgene_dma_tasklet_cb(struct tasklet_struct *t)
989979 {
990
- struct xgene_dma_chan *chan = (struct xgene_dma_chan *)data;
980
+ struct xgene_dma_chan *chan = from_tasklet(chan, t, tasklet);
991981
992982 /* Run all cleanup for descriptors which have been completed */
993983 xgene_dma_cleanup_descriptors(chan);
....@@ -1208,8 +1198,8 @@
12081198 ring->size = ret;
12091199
12101200 /* Allocate memory for DMA ring descriptor */
1211
- ring->desc_vaddr = dma_zalloc_coherent(chan->dev, ring->size,
1212
- &ring->desc_paddr, GFP_KERNEL);
1201
+ ring->desc_vaddr = dma_alloc_coherent(chan->dev, ring->size,
1202
+ &ring->desc_paddr, GFP_KERNEL);
12131203 if (!ring->desc_vaddr) {
12141204 chan_err(chan, "Failed to allocate ring desc\n");
12151205 return -ENOMEM;
....@@ -1549,8 +1539,7 @@
15491539 INIT_LIST_HEAD(&chan->ld_pending);
15501540 INIT_LIST_HEAD(&chan->ld_running);
15511541 INIT_LIST_HEAD(&chan->ld_completed);
1552
- tasklet_init(&chan->tasklet, xgene_dma_tasklet_cb,
1553
- (unsigned long)chan);
1542
+ tasklet_setup(&chan->tasklet, xgene_dma_tasklet_cb);
15541543
15551544 chan->pending = 0;
15561545 chan->desc_pool = NULL;
....@@ -1690,20 +1679,16 @@
16901679
16911680 /* Get DMA error interrupt */
16921681 irq = platform_get_irq(pdev, 0);
1693
- if (irq <= 0) {
1694
- dev_err(&pdev->dev, "Failed to get Error IRQ\n");
1682
+ if (irq <= 0)
16951683 return -ENXIO;
1696
- }
16971684
16981685 pdma->err_irq = irq;
16991686
17001687 /* Get DMA Rx ring descriptor interrupts for all DMA channels */
17011688 for (i = 1; i <= XGENE_DMA_MAX_CHANNEL; i++) {
17021689 irq = platform_get_irq(pdev, i);
1703
- if (irq <= 0) {
1704
- dev_err(&pdev->dev, "Failed to get Rx IRQ\n");
1690
+ if (irq <= 0)
17051691 return -ENXIO;
1706
- }
17071692
17081693 pdma->chan[i - 1].rx_irq = irq;
17091694 }