hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/dma/amba-pl08x.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2006 ARM Ltd.
34 * Copyright (c) 2010 ST-Ericsson SA
....@@ -5,19 +6,6 @@
56 *
67 * Author: Peter Pearse <peter.pearse@arm.com>
78 * Author: Linus Walleij <linus.walleij@linaro.org>
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of the GNU General Public License as published by the Free
11
- * Software Foundation; either version 2 of the License, or (at your option)
12
- * any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful, but WITHOUT
15
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17
- * more details.
18
- *
19
- * The full GNU General Public License is in this distribution in the file
20
- * called COPYING.
219 *
2210 * Documentation: ARM DDI 0196G == PL080
2311 * Documentation: ARM DDI 0218E == PL081
....@@ -254,6 +242,7 @@
254242 * @slave: whether this channel is a device (slave) or for memcpy
255243 * @signal: the physical DMA request signal which this channel is using
256244 * @mux_use: count of descriptors using this DMA request signal setting
245
+ * @waiting_at: time in jiffies when this channel moved to waiting state
257246 */
258247 struct pl08x_dma_chan {
259248 struct virt_dma_chan vc;
....@@ -267,6 +256,7 @@
267256 bool slave;
268257 int signal;
269258 unsigned mux_use;
259
+ unsigned long waiting_at;
270260 };
271261
272262 /**
....@@ -875,6 +865,7 @@
875865 if (!ch) {
876866 dev_dbg(&pl08x->adev->dev, "no physical channel available for xfer on %s\n", plchan->name);
877867 plchan->state = PL08X_CHAN_WAITING;
868
+ plchan->waiting_at = jiffies;
878869 return;
879870 }
880871
....@@ -913,22 +904,29 @@
913904 {
914905 struct pl08x_driver_data *pl08x = plchan->host;
915906 struct pl08x_dma_chan *p, *next;
916
-
907
+ unsigned long waiting_at;
917908 retry:
918909 next = NULL;
910
+ waiting_at = jiffies;
919911
920
- /* Find a waiting virtual channel for the next transfer. */
912
+ /*
913
+ * Find a waiting virtual channel for the next transfer.
914
+ * To be fair, time when each channel reached waiting state is compared
915
+ * to select channel that is waiting for the longest time.
916
+ */
921917 list_for_each_entry(p, &pl08x->memcpy.channels, vc.chan.device_node)
922
- if (p->state == PL08X_CHAN_WAITING) {
918
+ if (p->state == PL08X_CHAN_WAITING &&
919
+ p->waiting_at <= waiting_at) {
923920 next = p;
924
- break;
921
+ waiting_at = p->waiting_at;
925922 }
926923
927924 if (!next && pl08x->has_slave) {
928925 list_for_each_entry(p, &pl08x->slave.channels, vc.chan.device_node)
929
- if (p->state == PL08X_CHAN_WAITING) {
926
+ if (p->state == PL08X_CHAN_WAITING &&
927
+ p->waiting_at <= waiting_at) {
930928 next = p;
931
- break;
929
+ waiting_at = p->waiting_at;
932930 }
933931 }
934932
....@@ -1769,7 +1767,7 @@
17691767 default:
17701768 dev_err(&pl08x->adev->dev,
17711769 "illegal burst size for memcpy, set to 1\n");
1772
- /* Fall through */
1770
+ fallthrough;
17731771 case PL08X_BURST_SZ_1:
17741772 cctl |= PL080_BSIZE_1 << PL080_CONTROL_SB_SIZE_SHIFT |
17751773 PL080_BSIZE_1 << PL080_CONTROL_DB_SIZE_SHIFT;
....@@ -1808,7 +1806,7 @@
18081806 default:
18091807 dev_err(&pl08x->adev->dev,
18101808 "illegal bus width for memcpy, set to 8 bits\n");
1811
- /* Fall through */
1809
+ fallthrough;
18121810 case PL08X_BUS_WIDTH_8_BITS:
18131811 cctl |= PL080_WIDTH_8BIT << PL080_CONTROL_SWIDTH_SHIFT |
18141812 PL080_WIDTH_8BIT << PL080_CONTROL_DWIDTH_SHIFT;
....@@ -1852,7 +1850,7 @@
18521850 default:
18531851 dev_err(&pl08x->adev->dev,
18541852 "illegal bus width for memcpy, set to 8 bits\n");
1855
- /* Fall through */
1853
+ fallthrough;
18561854 case PL08X_BUS_WIDTH_8_BITS:
18571855 cctl |= PL080_WIDTH_8BIT << FTDMAC020_LLI_SRC_WIDTH_SHIFT |
18581856 PL080_WIDTH_8BIT << FTDMAC020_LLI_DST_WIDTH_SHIFT;
....@@ -2505,24 +2503,13 @@
25052503 return 0;
25062504 }
25072505
2508
-static int pl08x_debugfs_open(struct inode *inode, struct file *file)
2509
-{
2510
- return single_open(file, pl08x_debugfs_show, inode->i_private);
2511
-}
2512
-
2513
-static const struct file_operations pl08x_debugfs_operations = {
2514
- .open = pl08x_debugfs_open,
2515
- .read = seq_read,
2516
- .llseek = seq_lseek,
2517
- .release = single_release,
2518
-};
2506
+DEFINE_SHOW_ATTRIBUTE(pl08x_debugfs);
25192507
25202508 static void init_pl08x_debugfs(struct pl08x_driver_data *pl08x)
25212509 {
25222510 /* Expose a simple debugfs interface to view all clocks */
2523
- (void) debugfs_create_file(dev_name(&pl08x->adev->dev),
2524
- S_IFREG | S_IRUGO, NULL, pl08x,
2525
- &pl08x_debugfs_operations);
2511
+ debugfs_create_file(dev_name(&pl08x->adev->dev), S_IFREG | S_IRUGO,
2512
+ NULL, pl08x, &pl08x_debugfs_fops);
25262513 }
25272514
25282515 #else
....@@ -2625,7 +2612,7 @@
26252612 switch (val) {
26262613 default:
26272614 dev_err(&adev->dev, "illegal burst size for memcpy, set to 1\n");
2628
- /* Fall through */
2615
+ fallthrough;
26292616 case 1:
26302617 pd->memcpy_burst_size = PL08X_BURST_SZ_1;
26312618 break;
....@@ -2660,7 +2647,7 @@
26602647 switch (val) {
26612648 default:
26622649 dev_err(&adev->dev, "illegal bus width for memcpy, set to 8 bits\n");
2663
- /* Fall through */
2650
+ fallthrough;
26642651 case 8:
26652652 pd->memcpy_bus_width = PL08X_BUS_WIDTH_8_BITS;
26662653 break;