forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/soc/ti/knav_qmss_queue.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Keystone Queue Manager subsystem driver
34 *
....@@ -5,15 +6,6 @@
56 * Authors: Sandeep Nair <sandeep_n@ti.com>
67 * Cyril Chemparathy <cyril@ti.com>
78 * Santosh Shilimkar <santosh.shilimkar@ti.com>
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License
11
- * version 2 as published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
179 */
1810
1911 #include <linux/debugfs.h>
....@@ -33,6 +25,8 @@
3325
3426 static struct knav_device *kdev;
3527 static DEFINE_MUTEX(knav_dev_lock);
28
+#define knav_dev_lock_held() \
29
+ lockdep_is_held(&knav_dev_lock)
3630
3731 /* Queue manager register indices in DTS */
3832 #define KNAV_QUEUE_PEEK_REG_INDEX 0
....@@ -60,8 +54,9 @@
6054 #define knav_queue_idx_to_inst(kdev, idx) \
6155 (kdev->instances + (idx << kdev->inst_shift))
6256
63
-#define for_each_handle_rcu(qh, inst) \
64
- list_for_each_entry_rcu(qh, &inst->handles, list)
57
+#define for_each_handle_rcu(qh, inst) \
58
+ list_for_each_entry_rcu(qh, &inst->handles, list, \
59
+ knav_dev_lock_held())
6560
6661 #define for_each_instance(idx, inst, kdev) \
6762 for (idx = 0, inst = kdev->instances; \
....@@ -72,7 +67,7 @@
7267 * Newest followed by older ones. Search is done from start of the array
7368 * until a firmware file is found.
7469 */
75
-const char *knav_acc_firmwares[] = {"ks2_qmss_pdsp_acc48.bin"};
70
+static const char * const knav_acc_firmwares[] = {"ks2_qmss_pdsp_acc48.bin"};
7671
7772 static bool device_ready;
7873 bool knav_qmss_device_ready(void)
....@@ -414,7 +409,7 @@
414409 return 0;
415410 }
416411
417
-struct knav_range_ops knav_gp_range_ops = {
412
+static struct knav_range_ops knav_gp_range_ops = {
418413 .set_notify = knav_gp_set_notify,
419414 .open_queue = knav_gp_open_queue,
420415 .close_queue = knav_gp_close_queue,
....@@ -483,17 +478,7 @@
483478 return 0;
484479 }
485480
486
-static int knav_queue_debug_open(struct inode *inode, struct file *file)
487
-{
488
- return single_open(file, knav_queue_debug_show, NULL);
489
-}
490
-
491
-static const struct file_operations knav_queue_debug_ops = {
492
- .open = knav_queue_debug_open,
493
- .read = seq_read,
494
- .llseek = seq_lseek,
495
- .release = single_release,
496
-};
481
+DEFINE_SHOW_ATTRIBUTE(knav_queue_debug);
497482
498483 static inline int knav_queue_pdsp_wait(u32 * __iomem addr, unsigned timeout,
499484 u32 flags)
....@@ -1390,15 +1375,15 @@
13901375
13911376 ret = of_address_to_resource(node, index, &res);
13921377 if (ret) {
1393
- dev_err(kdev->dev, "Can't translate of node(%s) address for index(%d)\n",
1394
- node->name, index);
1378
+ dev_err(kdev->dev, "Can't translate of node(%pOFn) address for index(%d)\n",
1379
+ node, index);
13951380 return ERR_PTR(ret);
13961381 }
13971382
13981383 regs = devm_ioremap_resource(kdev->dev, &res);
13991384 if (IS_ERR(regs))
1400
- dev_err(kdev->dev, "Failed to map register base for index(%d) node(%s)\n",
1401
- index, node->name);
1385
+ dev_err(kdev->dev, "Failed to map register base for index(%d) node(%pOFn)\n",
1386
+ index, node);
14021387 return regs;
14031388 }
14041389
....@@ -1797,9 +1782,9 @@
17971782 INIT_LIST_HEAD(&kdev->pdsps);
17981783
17991784 pm_runtime_enable(&pdev->dev);
1800
- ret = pm_runtime_get_sync(&pdev->dev);
1785
+ ret = pm_runtime_resume_and_get(&pdev->dev);
18011786 if (ret < 0) {
1802
- pm_runtime_put_noidle(&pdev->dev);
1787
+ pm_runtime_disable(&pdev->dev);
18031788 dev_err(dev, "Failed to enable QMSS\n");
18041789 return ret;
18051790 }
....@@ -1885,7 +1870,7 @@
18851870 }
18861871
18871872 debugfs_create_file("qmss", S_IFREG | S_IRUGO, NULL, NULL,
1888
- &knav_queue_debug_ops);
1873
+ &knav_queue_debug_fops);
18891874 device_ready = true;
18901875 return 0;
18911876