hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/arbiter/mali_kbase_arbiter_pm.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2019-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
....@@ -20,15 +20,12 @@
2020 */
2121
2222 /**
23
- * @file
24
- * Mali arbiter power manager state machine and APIs
23
+ * DOC: Mali arbiter power manager state machine and APIs
2524 */
2625
2726 #include <mali_kbase.h>
2827 #include <mali_kbase_pm.h>
29
-#include <mali_kbase_hwaccess_jm.h>
3028 #include <backend/gpu/mali_kbase_irq_internal.h>
31
-#include <mali_kbase_hwcnt_context.h>
3229 #include <backend/gpu/mali_kbase_pm_internal.h>
3330 #include <tl/mali_kbase_tracepoints.h>
3431 #include <mali_kbase_gpuprops.h>
....@@ -319,6 +316,7 @@
319316 if (kbdev->arb.arb_if) {
320317 kbase_arbif_gpu_request(kbdev);
321318 dev_dbg(kbdev->dev, "Waiting for initial GPU assignment...\n");
319
+
322320 err = wait_event_timeout(arb_vm_state->vm_state_wait,
323321 arb_vm_state->vm_state ==
324322 KBASE_VM_STATE_INITIALIZING_WITH_GPU,
....@@ -328,8 +326,9 @@
328326 dev_dbg(kbdev->dev,
329327 "Kbase probe Deferred after waiting %d ms to receive GPU_GRANT\n",
330328 gpu_req_timeout);
331
- err = -EPROBE_DEFER;
332
- goto arbif_eprobe_defer;
329
+
330
+ err = -ENODEV;
331
+ goto arbif_timeout;
333332 }
334333
335334 dev_dbg(kbdev->dev,
....@@ -337,9 +336,10 @@
337336 }
338337 return 0;
339338
340
-arbif_eprobe_defer:
339
+arbif_timeout:
341340 kbase_arbiter_pm_early_term(kbdev);
342341 return err;
342
+
343343 arbif_init_fail:
344344 destroy_workqueue(arb_vm_state->vm_arb_wq);
345345 kfree(arb_vm_state);
....@@ -394,6 +394,8 @@
394394 * @kbdev: The kbase device structure for the device (must be a valid pointer)
395395 *
396396 * Install interrupts and set the interrupt_install flag to true.
397
+ *
398
+ * Return: 0 if success, or a Linux error code
397399 */
398400 int kbase_arbiter_pm_install_interrupts(struct kbase_device *kbdev)
399401 {
....@@ -924,6 +926,8 @@
924926 * @kbdev: The kbase device structure for the device (must be a valid pointer)
925927 *
926928 * Checks if the virtual machine holds VM state lock.
929
+ *
930
+ * Return: true if GPU is assigned, else false.
927931 */
928932 static inline bool kbase_arbiter_pm_vm_gpu_assigned_lockheld(
929933 struct kbase_device *kbdev)
....@@ -951,7 +955,6 @@
951955 int kbase_arbiter_pm_ctx_active_handle_suspend(struct kbase_device *kbdev,
952956 enum kbase_pm_suspend_handler suspend_handler)
953957 {
954
- struct kbasep_js_device_data *js_devdata = &kbdev->js_data;
955958 struct kbase_arbiter_vm_state *arb_vm_state = kbdev->pm.arb_vm_state;
956959 int res = 0;
957960
....@@ -1004,11 +1007,9 @@
10041007 /* Need to synchronously wait for GPU assignment */
10051008 atomic_inc(&kbdev->pm.gpu_users_waiting);
10061009 mutex_unlock(&arb_vm_state->vm_state_lock);
1007
- mutex_unlock(&kbdev->pm.lock);
1008
- mutex_unlock(&js_devdata->runpool_mutex);
1010
+ kbase_pm_unlock(kbdev);
10091011 kbase_arbiter_pm_vm_wait_gpu_assignment(kbdev);
1010
- mutex_lock(&js_devdata->runpool_mutex);
1011
- mutex_lock(&kbdev->pm.lock);
1012
+ kbase_pm_lock(kbdev);
10121013 mutex_lock(&arb_vm_state->vm_state_lock);
10131014 atomic_dec(&kbdev->pm.gpu_users_waiting);
10141015 }
....@@ -1020,8 +1021,8 @@
10201021 /**
10211022 * kbase_arbiter_pm_update_gpu_freq() - Updates GPU clock frequency received
10221023 * from arbiter.
1023
- * @arb_freq - Pointer to struchture holding GPU clock frequenecy data
1024
- * @freq - New frequency value in KHz
1024
+ * @arb_freq: Pointer to struchture holding GPU clock frequenecy data
1025
+ * @freq: New frequency value in KHz
10251026 */
10261027 void kbase_arbiter_pm_update_gpu_freq(struct kbase_arbiter_freq *arb_freq,
10271028 uint32_t freq)
....@@ -1030,8 +1031,8 @@
10301031
10311032 mutex_lock(&arb_freq->arb_freq_lock);
10321033 if (arb_freq->arb_freq != freq) {
1033
- ndata.new_rate = freq * KHZ_TO_HZ;
1034
- ndata.old_rate = arb_freq->arb_freq * KHZ_TO_HZ;
1034
+ ndata.new_rate = (unsigned long)freq * KHZ_TO_HZ;
1035
+ ndata.old_rate = (unsigned long)arb_freq->arb_freq * KHZ_TO_HZ;
10351036 ndata.gpu_clk_handle = arb_freq;
10361037 arb_freq->arb_freq = freq;
10371038 arb_freq->freq_updated = true;
....@@ -1044,14 +1045,14 @@
10441045 }
10451046
10461047 /**
1047
- * enumerate_arb_gpu_clk() - Enumerate a GPU clock on the given index
1048
- * @kbdev - kbase_device pointer
1049
- * @index - GPU clock index
1048
+ * get_arb_gpu_clk() - Enumerate a GPU clock on the given index
1049
+ * @kbdev: kbase_device pointer
1050
+ * @index: GPU clock index
10501051 *
1051
- * Returns pointer to structure holding GPU clock frequency data reported from
1052
+ * Return: Pointer to structure holding GPU clock frequency data reported from
10521053 * arbiter, only index 0 is valid.
10531054 */
1054
-static void *enumerate_arb_gpu_clk(struct kbase_device *kbdev,
1055
+static void *get_arb_gpu_clk(struct kbase_device *kbdev,
10551056 unsigned int index)
10561057 {
10571058 if (index == 0)
....@@ -1061,10 +1062,10 @@
10611062
10621063 /**
10631064 * get_arb_gpu_clk_rate() - Get the current rate of GPU clock frequency value
1064
- * @kbdev - kbase_device pointer
1065
- * @index - GPU clock index
1065
+ * @kbdev: kbase_device pointer
1066
+ * @gpu_clk_handle: Handle unique to the enumerated GPU clock
10661067 *
1067
- * Returns the GPU clock frequency value saved when gpu is granted from arbiter
1068
+ * Return: The GPU clock frequency value saved when gpu is granted from arbiter
10681069 */
10691070 static unsigned long get_arb_gpu_clk_rate(struct kbase_device *kbdev,
10701071 void *gpu_clk_handle)
....@@ -1082,14 +1083,14 @@
10821083
10831084 /**
10841085 * arb_gpu_clk_notifier_register() - Register a clock rate change notifier.
1085
- * @kbdev - kbase_device pointer
1086
- * @gpu_clk_handle - Handle unique to the enumerated GPU clock
1087
- * @nb - notifier block containing the callback function pointer
1088
- *
1089
- * Returns 0 on success, negative error code otherwise.
1086
+ * @kbdev: kbase_device pointer
1087
+ * @gpu_clk_handle: Handle unique to the enumerated GPU clock
1088
+ * @nb: notifier block containing the callback function pointer
10901089 *
10911090 * This function registers a callback function that is invoked whenever the
10921091 * frequency of the clock corresponding to @gpu_clk_handle changes.
1092
+ *
1093
+ * Return: 0 on success, negative error code otherwise.
10931094 */
10941095 static int arb_gpu_clk_notifier_register(struct kbase_device *kbdev,
10951096 void *gpu_clk_handle, struct notifier_block *nb)
....@@ -1107,10 +1108,10 @@
11071108 }
11081109
11091110 /**
1110
- * gpu_clk_notifier_unregister() - Unregister clock rate change notifier
1111
- * @kbdev - kbase_device pointer
1112
- * @gpu_clk_handle - Handle unique to the enumerated GPU clock
1113
- * @nb - notifier block containing the callback function pointer
1111
+ * arb_gpu_clk_notifier_unregister() - Unregister clock rate change notifier
1112
+ * @kbdev: kbase_device pointer
1113
+ * @gpu_clk_handle: Handle unique to the enumerated GPU clock
1114
+ * @nb: notifier block containing the callback function pointer
11141115 *
11151116 * This function pointer is used to unregister a callback function that
11161117 * was previously registered to get notified of a frequency change of the
....@@ -1131,7 +1132,7 @@
11311132
11321133 struct kbase_clk_rate_trace_op_conf arb_clk_rate_trace_ops = {
11331134 .get_gpu_clk_rate = get_arb_gpu_clk_rate,
1134
- .enumerate_gpu_clk = enumerate_arb_gpu_clk,
1135
+ .enumerate_gpu_clk = get_arb_gpu_clk,
11351136 .gpu_clk_notifier_register = arb_gpu_clk_notifier_register,
11361137 .gpu_clk_notifier_unregister = arb_gpu_clk_notifier_unregister
11371138 };