hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/rknpu/rknpu_debugger.c
....@@ -14,7 +14,9 @@
1414 #include <asm/div64.h>
1515
1616 #ifndef FPGA_PLATFORM
17
+#ifdef CONFIG_PM_DEVFREQ
1718 #include <../drivers/devfreq/governor.h>
19
+#endif
1820 #endif
1921
2022 #include "rknpu_drv.h"
....@@ -44,7 +46,7 @@
4446 unsigned long flags;
4547 int i;
4648 int load;
47
- uint64_t busy_time_total, div_value;
49
+ uint64_t total_busy_time, div_value;
4850
4951 seq_puts(m, "NPU load: ");
5052 for (i = 0; i < rknpu_dev->config->num_irqs; i++) {
....@@ -55,13 +57,13 @@
5557
5658 spin_lock_irqsave(&rknpu_dev->irq_lock, flags);
5759
58
- busy_time_total = subcore_data->timer.busy_time_record;
60
+ total_busy_time = subcore_data->timer.total_busy_time;
5961
6062 spin_unlock_irqrestore(&rknpu_dev->irq_lock, flags);
6163
62
- div_value = (RKNPU_LOAD_INTERVAL / 100000);
63
- do_div(busy_time_total, div_value);
64
- load = busy_time_total;
64
+ div_value = (RKNPU_LOAD_INTERVAL / 100);
65
+ do_div(total_busy_time, div_value);
66
+ load = total_busy_time > 100 ? 100 : total_busy_time;
6567
6668 if (rknpu_dev->config->num_irqs > 1)
6769 seq_printf(m, "%2.d%%,", load);
....@@ -191,6 +193,7 @@
191193 return 0;
192194 }
193195
196
+#ifdef CONFIG_PM_DEVFREQ
194197 static ssize_t rknpu_freq_set(struct file *file, const char __user *ubuf,
195198 size_t len, loff_t *offp)
196199 {
....@@ -233,6 +236,13 @@
233236
234237 return len;
235238 }
239
+#else
240
+static ssize_t rknpu_freq_set(struct file *file, const char __user *ubuf,
241
+ size_t len, loff_t *offp)
242
+{
243
+ return -EFAULT;
244
+}
245
+#endif
236246
237247 static int rknpu_volt_show(struct seq_file *m, void *data)
238248 {
....@@ -447,7 +457,11 @@
447457 #ifdef CONFIG_ROCKCHIP_RKNPU_PROC_FS
448458 static int rknpu_procfs_open(struct inode *inode, struct file *file)
449459 {
460
+#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
450461 struct rknpu_debugger_node *node = PDE_DATA(inode);
462
+#else
463
+ struct rknpu_debugger_node *node = pde_data(inode);
464
+#endif
451465
452466 return single_open(file, node->info_ent->show, node);
453467 }