hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/arm/bifrost/device/backend/mali_kbase_device_hw_jm.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2020-2022 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -51,6 +51,7 @@
5151 address);
5252 if (multiple)
5353 dev_warn(kbdev->dev, "There were multiple GPU faults - some have not been reported\n");
54
+
5455 }
5556
5657 void kbase_gpu_interrupt(struct kbase_device *kbdev, u32 val)
....@@ -62,11 +63,19 @@
6263 if (val & RESET_COMPLETED)
6364 kbase_pm_reset_done(kbdev);
6465
66
+ /* Defer clearing CLEAN_CACHES_COMPLETED to kbase_clean_caches_done.
67
+ * We need to acquire hwaccess_lock to avoid a race condition with
68
+ * kbase_gpu_cache_flush_and_busy_wait
69
+ */
70
+ KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_CLEAR, NULL, val & ~CLEAN_CACHES_COMPLETED);
71
+ kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_CLEAR), val & ~CLEAN_CACHES_COMPLETED);
72
+
73
+ /* kbase_instr_hwcnt_sample_done frees the HWCNT pipeline to request another
74
+ * sample. Therefore this must be called after clearing the IRQ to avoid a
75
+ * race between clearing and the next sample raising the IRQ again.
76
+ */
6577 if (val & PRFCNT_SAMPLE_COMPLETED)
6678 kbase_instr_hwcnt_sample_done(kbdev);
67
-
68
- KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_CLEAR, NULL, val);
69
- kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_CLEAR), val);
7079
7180 /* kbase_pm_check_transitions (called by kbase_pm_power_changed) must
7281 * be called after the IRQ has been cleared. This is because it might
....@@ -96,3 +105,39 @@
96105
97106 KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_DONE, NULL, val);
98107 }
108
+
109
+#if IS_ENABLED(CONFIG_MALI_REAL_HW)
110
+void kbase_reg_write(struct kbase_device *kbdev, u32 offset, u32 value)
111
+{
112
+ WARN_ON(!kbdev->pm.backend.gpu_powered);
113
+
114
+ writel(value, kbdev->reg + offset);
115
+
116
+#if IS_ENABLED(CONFIG_DEBUG_FS)
117
+ if (unlikely(kbdev->io_history.enabled))
118
+ kbase_io_history_add(&kbdev->io_history, kbdev->reg + offset,
119
+ value, 1);
120
+#endif /* CONFIG_DEBUG_FS */
121
+ dev_dbg(kbdev->dev, "w: reg %08x val %08x", offset, value);
122
+}
123
+KBASE_EXPORT_TEST_API(kbase_reg_write);
124
+
125
+u32 kbase_reg_read(struct kbase_device *kbdev, u32 offset)
126
+{
127
+ u32 val;
128
+
129
+ WARN_ON(!kbdev->pm.backend.gpu_powered);
130
+
131
+ val = readl(kbdev->reg + offset);
132
+
133
+#if IS_ENABLED(CONFIG_DEBUG_FS)
134
+ if (unlikely(kbdev->io_history.enabled))
135
+ kbase_io_history_add(&kbdev->io_history, kbdev->reg + offset,
136
+ val, 0);
137
+#endif /* CONFIG_DEBUG_FS */
138
+ dev_dbg(kbdev->dev, "r: reg %08x val %08x", offset, val);
139
+
140
+ return val;
141
+}
142
+KBASE_EXPORT_TEST_API(kbase_reg_read);
143
+#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */