hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/mali_kbase_core_linux.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2010-2023 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
....@@ -31,7 +31,8 @@
3131 #include <ipa/mali_kbase_ipa_debugfs.h>
3232 #endif /* CONFIG_DEVFREQ_THERMAL */
3333 #endif /* CONFIG_MALI_BIFROST_DEVFREQ */
34
-#include "mali_kbase_mem_profile_debugfs_buf_size.h"
34
+#include "backend/gpu/mali_kbase_model_linux.h"
35
+#include "uapi/gpu/arm/bifrost/mali_kbase_mem_profile_debugfs_buf_size.h"
3536 #include "mali_kbase_mem.h"
3637 #include "mali_kbase_mem_pool_debugfs.h"
3738 #include "mali_kbase_mem_pool_group.h"
....@@ -50,15 +51,16 @@
5051 #if !MALI_USE_CSF
5152 #include "mali_kbase_kinstr_jm.h"
5253 #endif
53
-#include "mali_kbase_hwcnt_context.h"
54
-#include "mali_kbase_hwcnt_virtualizer.h"
55
-#include "mali_kbase_hwcnt_legacy.h"
54
+#include "hwcnt/mali_kbase_hwcnt_context.h"
55
+#include "hwcnt/mali_kbase_hwcnt_virtualizer.h"
56
+#include "mali_kbase_kinstr_prfcnt.h"
5657 #include "mali_kbase_vinstr.h"
5758 #if MALI_USE_CSF
5859 #include "csf/mali_kbase_csf_firmware.h"
5960 #include "csf/mali_kbase_csf_tiler_heap.h"
6061 #include "csf/mali_kbase_csf_csg_debugfs.h"
6162 #include "csf/mali_kbase_csf_cpu_queue_debugfs.h"
63
+#include "csf/mali_kbase_csf_event.h"
6264 #endif
6365 #ifdef CONFIG_MALI_ARBITER_SUPPORT
6466 #include "arbiter/mali_kbase_arbiter_pm.h"
....@@ -71,6 +73,9 @@
7173 #endif
7274 #include "backend/gpu/mali_kbase_pm_internal.h"
7375 #include "mali_kbase_dvfs_debugfs.h"
76
+#if IS_ENABLED(CONFIG_DEBUG_FS)
77
+#include "mali_kbase_pbha_debugfs.h"
78
+#endif
7479
7580 #include <linux/module.h>
7681 #include <linux/init.h>
....@@ -78,6 +83,7 @@
7883 #include <linux/kernel.h>
7984 #include <linux/errno.h>
8085 #include <linux/of.h>
86
+#include <linux/of_address.h>
8187 #include <linux/platform_device.h>
8288 #include <linux/of_platform.h>
8389 #include <linux/miscdevice.h>
....@@ -86,14 +92,16 @@
8692 #include <linux/fs.h>
8793 #include <linux/uaccess.h>
8894 #include <linux/interrupt.h>
95
+#include <linux/irq.h>
8996 #include <linux/mm.h>
9097 #include <linux/compat.h> /* is_compat_task/in_compat_syscall */
9198 #include <linux/mman.h>
9299 #include <linux/version.h>
100
+#include <linux/version_compat_defs.h>
93101 #include <mali_kbase_hw.h>
94
-#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE)
102
+#if IS_ENABLED(CONFIG_SYNC_FILE)
95103 #include <mali_kbase_sync.h>
96
-#endif /* CONFIG_SYNC || CONFIG_SYNC_FILE */
104
+#endif /* CONFIG_SYNC_FILE */
97105 #include <linux/clk.h>
98106 #include <linux/clk-provider.h>
99107 #include <linux/delay.h>
....@@ -113,11 +121,6 @@
113121
114122 #include <mali_kbase_caps.h>
115123
116
-/* GPU IRQ Tags */
117
-#define JOB_IRQ_TAG 0
118
-#define MMU_IRQ_TAG 1
119
-#define GPU_IRQ_TAG 2
120
-
121124 #define KERNEL_SIDE_DDK_VERSION_STRING "K:" MALI_RELEASE_NAME "(GPL)"
122125
123126 /**
....@@ -129,16 +132,16 @@
129132 (((minor) & 0xFFF) << 8) | \
130133 ((0 & 0xFF) << 0))
131134
132
-#define KBASE_API_MIN(api_version) ((api_version >> 8) & 0xFFF)
133
-#define KBASE_API_MAJ(api_version) ((api_version >> 20) & 0xFFF)
134
-
135135 /**
136
- * typedef mali_kbase_capability_def - kbase capabilities table
136
+ * struct mali_kbase_capability_def - kbase capabilities table
137
+ *
138
+ * @required_major: required major
139
+ * @required_minor: required minor
137140 */
138
-typedef struct mali_kbase_capability_def {
141
+struct mali_kbase_capability_def {
139142 u16 required_major;
140143 u16 required_minor;
141
-} mali_kbase_capability_def;
144
+};
142145
143146 /*
144147 * This must be kept in-sync with mali_kbase_cap
....@@ -146,32 +149,46 @@
146149 * TODO: The alternative approach would be to embed the cap enum values
147150 * in the table. Less efficient but potentially safer.
148151 */
149
-static mali_kbase_capability_def kbase_caps_table[MALI_KBASE_NUM_CAPS] = {
152
+static const struct mali_kbase_capability_def kbase_caps_table[MALI_KBASE_NUM_CAPS] = {
150153 #if MALI_USE_CSF
151
- { 1, 0 }, /* SYSTEM_MONITOR */
152
- { 1, 0 }, /* JIT_PRESSURE_LIMIT */
153
- { 1, 0 }, /* MEM_GROW_ON_GPF */
154
- { 1, 0 } /* MEM_PROTECTED */
154
+ { 1, 0 }, /* SYSTEM_MONITOR */
155
+ { 1, 0 }, /* JIT_PRESSURE_LIMIT */
156
+ { 1, 0 }, /* MEM_GROW_ON_GPF */
157
+ { 1, 0 } /* MEM_PROTECTED */
155158 #else
156
- { 11, 15 }, /* SYSTEM_MONITOR */
157
- { 11, 25 }, /* JIT_PRESSURE_LIMIT */
158
- { 11, 2 }, /* MEM_GROW_ON_GPF */
159
- { 11, 2 } /* MEM_PROTECTED */
159
+ { 11, 15 }, /* SYSTEM_MONITOR */
160
+ { 11, 25 }, /* JIT_PRESSURE_LIMIT */
161
+ { 11, 2 }, /* MEM_GROW_ON_GPF */
162
+ { 11, 2 } /* MEM_PROTECTED */
160163 #endif
161164 };
165
+
166
+#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE)
167
+/* Mutex to synchronize the probe of multiple kbase instances */
168
+static struct mutex kbase_probe_mutex;
169
+#endif
170
+
171
+#ifndef CONFIG_MALI_BIFROST_DEVFREQ
172
+static inline int kbase_devfreq_opp_helper(struct dev_pm_set_opp_data *data)
173
+{
174
+ return -EOPNOTSUPP;
175
+}
176
+#endif
162177
163178 /**
164179 * mali_kbase_supports_cap - Query whether a kbase capability is supported
165180 *
166
- * @api_version: API version to convert
167
- * @cap: Capability to query for - see mali_kbase_caps.h
181
+ * @api_version: API version to convert
182
+ * @cap: Capability to query for - see mali_kbase_caps.h
183
+ *
184
+ * Return: true if the capability is supported
168185 */
169
-bool mali_kbase_supports_cap(unsigned long api_version, mali_kbase_cap cap)
186
+bool mali_kbase_supports_cap(unsigned long api_version, enum mali_kbase_cap cap)
170187 {
171188 bool supported = false;
172189 unsigned long required_ver;
173190
174
- mali_kbase_capability_def const *cap_def;
191
+ struct mali_kbase_capability_def const *cap_def;
175192
176193 if (WARN_ON(cap < 0))
177194 return false;
....@@ -198,7 +215,7 @@
198215 * address space) and no API version number. Both must be assigned before
199216 * kbase_file_get_kctx_if_setup_complete() can be used successfully.
200217 *
201
- * @return Address of an object representing a simulated device file, or NULL
218
+ * Return: Address of an object representing a simulated device file, or NULL
202219 * on failure.
203220 */
204221 static struct kbase_file *kbase_file_new(struct kbase_device *const kbdev,
....@@ -297,10 +314,9 @@
297314 *
298315 * @kfile: A device file created by kbase_file_new()
299316 *
300
- * This function returns an error code (encoded with ERR_PTR) if no context
301
- * has been created for the given @kfile. This makes it safe to use in
302
- * circumstances where the order of initialization cannot be enforced, but
303
- * only if the caller checks the return value.
317
+ * This function returns NULL if no context has been created for the given @kfile.
318
+ * This makes it safe to use in circumstances where the order of initialization
319
+ * cannot be enforced, but only if the caller checks the return value.
304320 *
305321 * Return: Address of the kernel base context associated with the @kfile, or
306322 * NULL if no context exists.
....@@ -339,15 +355,6 @@
339355 #if IS_ENABLED(CONFIG_DEBUG_FS)
340356 kbasep_mem_profile_debugfs_remove(kctx);
341357 #endif
342
-
343
- mutex_lock(&kctx->legacy_hwcnt_lock);
344
- /* If this client was performing hardware counter dumping and
345
- * did not explicitly detach itself, destroy it now
346
- */
347
- kbase_hwcnt_legacy_client_destroy(kctx->legacy_hwcnt_cli);
348
- kctx->legacy_hwcnt_cli = NULL;
349
- mutex_unlock(&kctx->legacy_hwcnt_lock);
350
-
351358 kbase_context_debugfs_term(kctx);
352359
353360 kbase_destroy_context(kctx);
....@@ -404,6 +411,22 @@
404411 return -EPERM;
405412 }
406413
414
+static int kbase_api_kinstr_prfcnt_enum_info(
415
+ struct kbase_file *kfile,
416
+ struct kbase_ioctl_kinstr_prfcnt_enum_info *prfcnt_enum_info)
417
+{
418
+ return kbase_kinstr_prfcnt_enum_info(kfile->kbdev->kinstr_prfcnt_ctx,
419
+ prfcnt_enum_info);
420
+}
421
+
422
+static int kbase_api_kinstr_prfcnt_setup(
423
+ struct kbase_file *kfile,
424
+ union kbase_ioctl_kinstr_prfcnt_setup *prfcnt_setup)
425
+{
426
+ return kbase_kinstr_prfcnt_setup(kfile->kbdev->kinstr_prfcnt_ctx,
427
+ prfcnt_setup);
428
+}
429
+
407430 static struct kbase_device *to_kbase_device(struct device *dev)
408431 {
409432 return dev_get_drvdata(dev);
....@@ -411,6 +434,12 @@
411434
412435 int assign_irqs(struct kbase_device *kbdev)
413436 {
437
+ static const char *const irq_names_caps[] = { "JOB", "MMU", "GPU" };
438
+
439
+#if IS_ENABLED(CONFIG_OF)
440
+ static const char *const irq_names[] = { "job", "mmu", "gpu" };
441
+#endif
442
+
414443 struct platform_device *pdev;
415444 int i;
416445
....@@ -418,34 +447,31 @@
418447 return -ENODEV;
419448
420449 pdev = to_platform_device(kbdev->dev);
421
- /* 3 IRQ resources */
422
- for (i = 0; i < 3; i++) {
423
- struct resource *irq_res;
424
- int irqtag;
425450
426
- irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
427
- if (!irq_res) {
428
- dev_err(kbdev->dev, "No IRQ resource at index %d\n", i);
429
- return -ENOENT;
430
- }
451
+ for (i = 0; i < ARRAY_SIZE(irq_names_caps); i++) {
452
+ int irq;
431453
432454 #if IS_ENABLED(CONFIG_OF)
433
- if (!strncasecmp(irq_res->name, "JOB", 4)) {
434
- irqtag = JOB_IRQ_TAG;
435
- } else if (!strncasecmp(irq_res->name, "MMU", 4)) {
436
- irqtag = MMU_IRQ_TAG;
437
- } else if (!strncasecmp(irq_res->name, "GPU", 4)) {
438
- irqtag = GPU_IRQ_TAG;
439
- } else {
440
- dev_err(&pdev->dev, "Invalid irq res name: '%s'\n",
441
- irq_res->name);
442
- return -EINVAL;
443
- }
455
+ /* We recommend using Upper case for the irq names in dts, but if
456
+ * there are devices in the world using Lower case then we should
457
+ * avoid breaking support for them. So try using names in Upper case
458
+ * first then try using Lower case names. If both attempts fail then
459
+ * we assume there is no IRQ resource specified for the GPU.
460
+ */
461
+ irq = platform_get_irq_byname(pdev, irq_names_caps[i]);
462
+ if (irq < 0)
463
+ irq = platform_get_irq_byname(pdev, irq_names[i]);
444464 #else
445
- irqtag = i;
465
+ irq = platform_get_irq(pdev, i);
446466 #endif /* CONFIG_OF */
447
- kbdev->irqs[irqtag].irq = irq_res->start;
448
- kbdev->irqs[irqtag].flags = irq_res->flags & IRQF_TRIGGER_MASK;
467
+
468
+ if (irq < 0) {
469
+ dev_err(kbdev->dev, "No IRQ resource '%s'\n", irq_names_caps[i]);
470
+ return irq;
471
+ }
472
+
473
+ kbdev->irqs[i].irq = irq;
474
+ kbdev->irqs[i].flags = irqd_get_trigger_type(irq_get_irq_data(irq));
449475 }
450476
451477 return 0;
....@@ -481,27 +507,6 @@
481507 EXPORT_SYMBOL(kbase_release_device);
482508
483509 #if IS_ENABLED(CONFIG_DEBUG_FS)
484
-#if KERNEL_VERSION(4, 6, 0) > LINUX_VERSION_CODE && \
485
- !(KERNEL_VERSION(4, 4, 28) <= LINUX_VERSION_CODE && \
486
- KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE)
487
-/*
488
- * Older versions, before v4.6, of the kernel doesn't have
489
- * kstrtobool_from_user(), except longterm 4.4.y which had it added in 4.4.28
490
- */
491
-static int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
492
-{
493
- char buf[4];
494
-
495
- count = min(count, sizeof(buf) - 1);
496
-
497
- if (copy_from_user(buf, s, count))
498
- return -EFAULT;
499
- buf[count] = '\0';
500
-
501
- return strtobool(buf, res);
502
-}
503
-#endif
504
-
505510 static ssize_t write_ctx_infinite_cache(struct file *f, const char __user *ubuf, size_t size, loff_t *off)
506511 {
507512 struct kbase_context *kctx = f->private_data;
....@@ -613,13 +618,8 @@
613618
614619 kbdev = kfile->kbdev;
615620
616
-#if (KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE)
617621 kctx = kbase_create_context(kbdev, in_compat_syscall(),
618622 flags, kfile->api_version, kfile->filp);
619
-#else
620
- kctx = kbase_create_context(kbdev, is_compat_task(),
621
- flags, kfile->api_version, kfile->filp);
622
-#endif /* (KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE) */
623623
624624 /* if bad flags, will stay stuck in setup mode */
625625 if (!kctx)
....@@ -629,7 +629,8 @@
629629 kbase_ctx_flag_set(kctx, KCTX_INFINITE_CACHE);
630630
631631 #if IS_ENABLED(CONFIG_DEBUG_FS)
632
- snprintf(kctx_name, 64, "%d_%d", kctx->tgid, kctx->id);
632
+ if (unlikely(!scnprintf(kctx_name, 64, "%d_%d", kctx->tgid, kctx->id)))
633
+ return -ENOMEM;
633634
634635 mutex_init(&kctx->mem_profile_lock);
635636
....@@ -640,16 +641,8 @@
640641 /* we don't treat this as a fail - just warn about it */
641642 dev_warn(kbdev->dev, "couldn't create debugfs dir for kctx\n");
642643 } else {
643
-#if (KERNEL_VERSION(4, 7, 0) > LINUX_VERSION_CODE)
644
- /* prevent unprivileged use of debug file system
645
- * in old kernel version
646
- */
647
- debugfs_create_file("infinite_cache", 0600, kctx->kctx_dentry,
648
- kctx, &kbase_infinite_cache_fops);
649
-#else
650644 debugfs_create_file("infinite_cache", 0644, kctx->kctx_dentry,
651645 kctx, &kbase_infinite_cache_fops);
652
-#endif
653646 debugfs_create_file("force_same_va", 0600, kctx->kctx_dentry,
654647 kctx, &kbase_force_same_va_fops);
655648
....@@ -675,6 +668,11 @@
675668
676669 if (!kbdev)
677670 return -ENODEV;
671
+
672
+#if (KERNEL_VERSION(6, 0, 0) > LINUX_VERSION_CODE)
673
+ /* Set address space operations for page migration */
674
+ kbase_mem_migrate_set_address_space_ops(kbdev, filp);
675
+#endif
678676
679677 /* Device-wide firmware load is moved here from probing to comply with
680678 * Android GKI vendor guideline.
....@@ -770,14 +768,14 @@
770768 }
771769 #endif /* !MALI_USE_CSF */
772770
773
-static int kbase_api_get_gpuprops(struct kbase_context *kctx,
771
+static int kbase_api_get_gpuprops(struct kbase_file *kfile,
774772 struct kbase_ioctl_get_gpuprops *get_props)
775773 {
776
- struct kbase_gpu_props *kprops = &kctx->kbdev->gpu_props;
774
+ struct kbase_gpu_props *kprops = &kfile->kbdev->gpu_props;
777775 int err;
778776
779777 if (get_props->flags != 0) {
780
- dev_err(kctx->kbdev->dev, "Unsupported flags to get_gpuprops");
778
+ dev_err(kfile->kbdev->dev, "Unsupported flags to get_gpuprops");
781779 return -EINVAL;
782780 }
783781
....@@ -802,23 +800,134 @@
802800 }
803801 #endif /* !MALI_USE_CSF */
804802
805
-static int kbase_api_mem_alloc(struct kbase_context *kctx,
806
- union kbase_ioctl_mem_alloc *alloc)
803
+#if MALI_USE_CSF
804
+static int kbase_api_mem_alloc_ex(struct kbase_context *kctx,
805
+ union kbase_ioctl_mem_alloc_ex *alloc_ex)
806
+{
807
+ struct kbase_va_region *reg;
808
+ u64 flags = alloc_ex->in.flags;
809
+ u64 gpu_va;
810
+
811
+ /* Calls to this function are inherently asynchronous, with respect to
812
+ * MMU operations.
813
+ */
814
+ const enum kbase_caller_mmu_sync_info mmu_sync_info = CALLER_MMU_ASYNC;
815
+
816
+ bool gpu_executable = (flags & BASE_MEM_PROT_GPU_EX) && kbase_has_exec_va_zone(kctx);
817
+ bool fixed_or_fixable = (flags & (BASE_MEM_FIXED | BASE_MEM_FIXABLE));
818
+
819
+ if (!kbase_mem_allow_alloc(kctx))
820
+ return -EINVAL;
821
+
822
+ /* The driver counts the number of FIXABLE and FIXED allocations because
823
+ * they're not supposed to happen at the same time. However, that is not
824
+ * a security concern: nothing bad happens if the two types of allocations
825
+ * are made at the same time. The only reason why the driver is guarding
826
+ * against them is because there's no client use case that is supposed
827
+ * to need both of them at the same time, and the driver wants to help
828
+ * the user space catch some obvious mistake.
829
+ *
830
+ * The driver is able to switch from FIXABLE allocations to FIXED and
831
+ * vice versa, if all the allocations of one kind are freed before trying
832
+ * to create allocations of a different kind.
833
+ */
834
+ if ((flags & BASE_MEM_FIXED) && (atomic64_read(&kctx->num_fixable_allocs) > 0))
835
+ return -EINVAL;
836
+
837
+ if ((flags & BASE_MEM_FIXABLE) && (atomic64_read(&kctx->num_fixed_allocs) > 0))
838
+ return -EINVAL;
839
+
840
+ if (flags & BASEP_MEM_FLAGS_KERNEL_ONLY)
841
+ return -ENOMEM;
842
+
843
+ /* The fixed_address parameter must be either a non-zero, page-aligned
844
+ * value for FIXED allocations or zero for any other kind of allocation.
845
+ */
846
+ if (flags & BASE_MEM_FIXED) {
847
+ u64 aligned_fixed_address = alloc_ex->in.fixed_address & PAGE_MASK;
848
+
849
+ if ((aligned_fixed_address == 0) ||
850
+ (aligned_fixed_address != alloc_ex->in.fixed_address))
851
+ return -EINVAL;
852
+
853
+ gpu_va = aligned_fixed_address;
854
+ } else if (alloc_ex->in.fixed_address != 0) {
855
+ return -EINVAL;
856
+ }
857
+
858
+ /* For 64-bit clients, force SAME_VA up to 2^(47)-1.
859
+ * For 32-bit clients, force SAME_VA up to 2^(32)-1.
860
+ *
861
+ * In both cases, the executable and fixed/fixable zones, and
862
+ * the executable+fixed/fixable zone, are all above this range.
863
+ */
864
+ if ((!kbase_ctx_flag(kctx, KCTX_COMPAT)) &&
865
+ kbase_ctx_flag(kctx, KCTX_FORCE_SAME_VA)) {
866
+ if (!gpu_executable && !fixed_or_fixable)
867
+ flags |= BASE_MEM_SAME_VA;
868
+ }
869
+
870
+ /* If CSF event memory allocation, need to force certain flags.
871
+ * SAME_VA - GPU address needs to be used as a CPU address, explicit
872
+ * mmap has to be avoided.
873
+ * CACHED_CPU - Frequent access to the event memory by CPU.
874
+ * COHERENT_SYSTEM - No explicit cache maintenance around the access
875
+ * to event memory so need to leverage the coherency support.
876
+ */
877
+ if (flags & BASE_MEM_CSF_EVENT) {
878
+ /* We cannot honor this request */
879
+ if (gpu_executable || fixed_or_fixable)
880
+ return -ENOMEM;
881
+
882
+ flags |= (BASE_MEM_SAME_VA |
883
+ BASE_MEM_CACHED_CPU |
884
+ BASE_MEM_COHERENT_SYSTEM);
885
+ }
886
+
887
+ reg = kbase_mem_alloc(kctx, alloc_ex->in.va_pages, alloc_ex->in.commit_pages,
888
+ alloc_ex->in.extension, &flags, &gpu_va, mmu_sync_info);
889
+
890
+ if (!reg)
891
+ return -ENOMEM;
892
+
893
+ alloc_ex->out.flags = flags;
894
+ alloc_ex->out.gpu_va = gpu_va;
895
+
896
+ return 0;
897
+}
898
+
899
+static int kbase_api_mem_alloc(struct kbase_context *kctx, union kbase_ioctl_mem_alloc *alloc)
900
+{
901
+ int ret;
902
+ union kbase_ioctl_mem_alloc_ex mem_alloc_ex = { { 0 } };
903
+
904
+ mem_alloc_ex.in.va_pages = alloc->in.va_pages;
905
+ mem_alloc_ex.in.commit_pages = alloc->in.commit_pages;
906
+ mem_alloc_ex.in.extension = alloc->in.extension;
907
+ mem_alloc_ex.in.flags = alloc->in.flags;
908
+ mem_alloc_ex.in.fixed_address = 0;
909
+
910
+ ret = kbase_api_mem_alloc_ex(kctx, &mem_alloc_ex);
911
+
912
+ alloc->out.flags = mem_alloc_ex.out.flags;
913
+ alloc->out.gpu_va = mem_alloc_ex.out.gpu_va;
914
+
915
+ return ret;
916
+}
917
+#else
918
+static int kbase_api_mem_alloc(struct kbase_context *kctx, union kbase_ioctl_mem_alloc *alloc)
807919 {
808920 struct kbase_va_region *reg;
809921 u64 flags = alloc->in.flags;
810922 u64 gpu_va;
811923
812
- rcu_read_lock();
813
- /* Don't allow memory allocation until user space has set up the
814
- * tracking page (which sets kctx->process_mm). Also catches when we've
815
- * forked.
924
+ /* Calls to this function are inherently asynchronous, with respect to
925
+ * MMU operations.
816926 */
817
- if (rcu_dereference(kctx->process_mm) != current->mm) {
818
- rcu_read_unlock();
927
+ const enum kbase_caller_mmu_sync_info mmu_sync_info = CALLER_MMU_ASYNC;
928
+
929
+ if (!kbase_mem_allow_alloc(kctx))
819930 return -EINVAL;
820
- }
821
- rcu_read_unlock();
822931
823932 if (flags & BASEP_MEM_FLAGS_KERNEL_ONLY)
824933 return -ENOMEM;
....@@ -828,29 +937,13 @@
828937 * has been initialized. In that case, GPU-executable memory may
829938 * or may not be SAME_VA.
830939 */
831
- if ((!kbase_ctx_flag(kctx, KCTX_COMPAT)) &&
832
- kbase_ctx_flag(kctx, KCTX_FORCE_SAME_VA)) {
940
+ if ((!kbase_ctx_flag(kctx, KCTX_COMPAT)) && kbase_ctx_flag(kctx, KCTX_FORCE_SAME_VA)) {
833941 if (!(flags & BASE_MEM_PROT_GPU_EX) || !kbase_has_exec_va_zone(kctx))
834942 flags |= BASE_MEM_SAME_VA;
835943 }
836944
837
-#if MALI_USE_CSF
838
- /* If CSF event memory allocation, need to force certain flags.
839
- * SAME_VA - GPU address needs to be used as a CPU address, explicit
840
- * mmap has to be avoided.
841
- * CACHED_CPU - Frequent access to the event memory by CPU.
842
- * COHERENT_SYSTEM - No explicit cache maintenance around the access
843
- * to event memory so need to leverage the coherency support.
844
- */
845
- if (flags & BASE_MEM_CSF_EVENT) {
846
- flags |= (BASE_MEM_SAME_VA |
847
- BASE_MEM_CACHED_CPU |
848
- BASE_MEM_COHERENT_SYSTEM);
849
- }
850
-#endif
851
-
852
- reg = kbase_mem_alloc(kctx, alloc->in.va_pages, alloc->in.commit_pages,
853
- alloc->in.extension, &flags, &gpu_va);
945
+ reg = kbase_mem_alloc(kctx, alloc->in.va_pages, alloc->in.commit_pages, alloc->in.extension,
946
+ &flags, &gpu_va, mmu_sync_info);
854947
855948 if (!reg)
856949 return -ENOMEM;
....@@ -860,6 +953,7 @@
860953
861954 return 0;
862955 }
956
+#endif /* MALI_USE_CSF */
863957
864958 static int kbase_api_mem_query(struct kbase_context *kctx,
865959 union kbase_ioctl_mem_query *query)
....@@ -888,69 +982,13 @@
888982 return kbase_vinstr_hwcnt_reader_setup(kctx->kbdev->vinstr_ctx, setup);
889983 }
890984
891
-static int kbase_api_hwcnt_enable(struct kbase_context *kctx,
892
- struct kbase_ioctl_hwcnt_enable *enable)
893
-{
894
- int ret;
895
-
896
- mutex_lock(&kctx->legacy_hwcnt_lock);
897
- if (enable->dump_buffer != 0) {
898
- /* Non-zero dump buffer, so user wants to create the client */
899
- if (kctx->legacy_hwcnt_cli == NULL) {
900
- ret = kbase_hwcnt_legacy_client_create(
901
- kctx->kbdev->hwcnt_gpu_virt,
902
- enable,
903
- &kctx->legacy_hwcnt_cli);
904
- } else {
905
- /* This context already has a client */
906
- ret = -EBUSY;
907
- }
908
- } else {
909
- /* Zero dump buffer, so user wants to destroy the client */
910
- if (kctx->legacy_hwcnt_cli != NULL) {
911
- kbase_hwcnt_legacy_client_destroy(
912
- kctx->legacy_hwcnt_cli);
913
- kctx->legacy_hwcnt_cli = NULL;
914
- ret = 0;
915
- } else {
916
- /* This context has no client to destroy */
917
- ret = -EINVAL;
918
- }
919
- }
920
- mutex_unlock(&kctx->legacy_hwcnt_lock);
921
-
922
- return ret;
923
-}
924
-
925
-static int kbase_api_hwcnt_dump(struct kbase_context *kctx)
926
-{
927
- int ret;
928
-
929
- mutex_lock(&kctx->legacy_hwcnt_lock);
930
- ret = kbase_hwcnt_legacy_client_dump(kctx->legacy_hwcnt_cli);
931
- mutex_unlock(&kctx->legacy_hwcnt_lock);
932
-
933
- return ret;
934
-}
935
-
936
-static int kbase_api_hwcnt_clear(struct kbase_context *kctx)
937
-{
938
- int ret;
939
-
940
- mutex_lock(&kctx->legacy_hwcnt_lock);
941
- ret = kbase_hwcnt_legacy_client_clear(kctx->legacy_hwcnt_cli);
942
- mutex_unlock(&kctx->legacy_hwcnt_lock);
943
-
944
- return ret;
945
-}
946
-
947985 static int kbase_api_get_cpu_gpu_timeinfo(struct kbase_context *kctx,
948986 union kbase_ioctl_get_cpu_gpu_timeinfo *timeinfo)
949987 {
950988 u32 flags = timeinfo->in.request_flags;
951
- struct timespec64 ts;
952
- u64 timestamp;
953
- u64 cycle_cnt;
989
+ struct timespec64 ts = { 0 };
990
+ u64 timestamp = 0;
991
+ u64 cycle_cnt = 0;
954992
955993 kbase_pm_context_active(kctx->kbdev);
956994
....@@ -975,6 +1013,13 @@
9751013 return 0;
9761014 }
9771015
1016
+#if IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
1017
+static int kbase_api_hwcnt_set(struct kbase_context *kctx,
1018
+ struct kbase_ioctl_hwcnt_values *values)
1019
+{
1020
+ return gpu_model_set_dummy_prfcnt_user_sample(u64_to_user_ptr(values->data), values->size);
1021
+}
1022
+#endif /* CONFIG_MALI_BIFROST_NO_MALI */
9781023
9791024 static int kbase_api_disjoint_query(struct kbase_context *kctx,
9801025 struct kbase_ioctl_disjoint_query *query)
....@@ -1006,51 +1051,10 @@
10061051 return len;
10071052 }
10081053
1009
-/* Defaults for legacy just-in-time memory allocator initialization
1010
- * kernel calls
1011
- */
1012
-#define DEFAULT_MAX_JIT_ALLOCATIONS 255
1013
-#define JIT_LEGACY_TRIM_LEVEL (0) /* No trimming */
1014
-
1015
-static int kbase_api_mem_jit_init_10_2(struct kbase_context *kctx,
1016
- struct kbase_ioctl_mem_jit_init_10_2 *jit_init)
1017
-{
1018
- kctx->jit_version = 1;
1019
-
1020
- /* since no phys_pages parameter, use the maximum: va_pages */
1021
- return kbase_region_tracker_init_jit(kctx, jit_init->va_pages,
1022
- DEFAULT_MAX_JIT_ALLOCATIONS,
1023
- JIT_LEGACY_TRIM_LEVEL, BASE_MEM_GROUP_DEFAULT,
1024
- jit_init->va_pages);
1025
-}
1026
-
1027
-static int kbase_api_mem_jit_init_11_5(struct kbase_context *kctx,
1028
- struct kbase_ioctl_mem_jit_init_11_5 *jit_init)
1029
-{
1030
- int i;
1031
-
1032
- kctx->jit_version = 2;
1033
-
1034
- for (i = 0; i < sizeof(jit_init->padding); i++) {
1035
- /* Ensure all padding bytes are 0 for potential future
1036
- * extension
1037
- */
1038
- if (jit_init->padding[i])
1039
- return -EINVAL;
1040
- }
1041
-
1042
- /* since no phys_pages parameter, use the maximum: va_pages */
1043
- return kbase_region_tracker_init_jit(kctx, jit_init->va_pages,
1044
- jit_init->max_allocations, jit_init->trim_level,
1045
- jit_init->group_id, jit_init->va_pages);
1046
-}
1047
-
10481054 static int kbase_api_mem_jit_init(struct kbase_context *kctx,
10491055 struct kbase_ioctl_mem_jit_init *jit_init)
10501056 {
10511057 int i;
1052
-
1053
- kctx->jit_version = 3;
10541058
10551059 for (i = 0; i < sizeof(jit_init->padding); i++) {
10561060 /* Ensure all padding bytes are 0 for potential future
....@@ -1209,7 +1213,7 @@
12091213 static int kbase_api_stream_create(struct kbase_context *kctx,
12101214 struct kbase_ioctl_stream_create *stream)
12111215 {
1212
-#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE)
1216
+#if IS_ENABLED(CONFIG_SYNC_FILE)
12131217 int fd, ret;
12141218
12151219 /* Name must be NULL-terminated and padded with NULLs, so check last
....@@ -1231,7 +1235,7 @@
12311235 static int kbase_api_fence_validate(struct kbase_context *kctx,
12321236 struct kbase_ioctl_fence_validate *validate)
12331237 {
1234
-#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE)
1238
+#if IS_ENABLED(CONFIG_SYNC_FILE)
12351239 return kbase_sync_fence_validate(validate->fd);
12361240 #else
12371241 return -ENOENT;
....@@ -1245,12 +1249,18 @@
12451249 int err;
12461250
12471251 if (data->len > KBASE_MEM_PROFILE_MAX_BUF_SIZE) {
1248
- dev_err(kctx->kbdev->dev, "mem_profile_add: buffer too big\n");
1252
+ dev_err(kctx->kbdev->dev, "mem_profile_add: buffer too big");
12491253 return -EINVAL;
12501254 }
12511255
1256
+ if (!data->len) {
1257
+ dev_err(kctx->kbdev->dev, "mem_profile_add: buffer size is 0");
1258
+ /* Should return -EINVAL, but returning -ENOMEM for backwards compat */
1259
+ return -ENOMEM;
1260
+ }
1261
+
12521262 buf = kmalloc(data->len, GFP_KERNEL);
1253
- if (ZERO_OR_NULL_PTR(buf))
1263
+ if (!buf)
12541264 return -ENOMEM;
12551265
12561266 err = copy_from_user(buf, u64_to_user_ptr(data->buffer),
....@@ -1398,6 +1408,30 @@
13981408 return kbase_csf_queue_kick(kctx, kick);
13991409 }
14001410
1411
+static int kbasep_cs_queue_group_create_1_6(
1412
+ struct kbase_context *kctx,
1413
+ union kbase_ioctl_cs_queue_group_create_1_6 *create)
1414
+{
1415
+ union kbase_ioctl_cs_queue_group_create
1416
+ new_create = { .in = {
1417
+ .tiler_mask = create->in.tiler_mask,
1418
+ .fragment_mask =
1419
+ create->in.fragment_mask,
1420
+ .compute_mask = create->in.compute_mask,
1421
+ .cs_min = create->in.cs_min,
1422
+ .priority = create->in.priority,
1423
+ .tiler_max = create->in.tiler_max,
1424
+ .fragment_max = create->in.fragment_max,
1425
+ .compute_max = create->in.compute_max,
1426
+ } };
1427
+
1428
+ int ret = kbase_csf_queue_group_create(kctx, &new_create);
1429
+
1430
+ create->out.group_handle = new_create.out.group_handle;
1431
+ create->out.group_uid = new_create.out.group_uid;
1432
+
1433
+ return ret;
1434
+}
14011435 static int kbasep_cs_queue_group_create(struct kbase_context *kctx,
14021436 union kbase_ioctl_cs_queue_group_create *create)
14031437 {
....@@ -1433,12 +1467,31 @@
14331467 static int kbasep_cs_tiler_heap_init(struct kbase_context *kctx,
14341468 union kbase_ioctl_cs_tiler_heap_init *heap_init)
14351469 {
1470
+ if (heap_init->in.group_id >= MEMORY_GROUP_MANAGER_NR_GROUPS)
1471
+ return -EINVAL;
1472
+
14361473 kctx->jit_group_id = heap_init->in.group_id;
14371474
14381475 return kbase_csf_tiler_heap_init(kctx, heap_init->in.chunk_size,
1439
- heap_init->in.initial_chunks, heap_init->in.max_chunks,
1440
- heap_init->in.target_in_flight,
1441
- &heap_init->out.gpu_heap_va, &heap_init->out.first_chunk_va);
1476
+ heap_init->in.initial_chunks, heap_init->in.max_chunks,
1477
+ heap_init->in.target_in_flight, heap_init->in.buf_desc_va,
1478
+ &heap_init->out.gpu_heap_va,
1479
+ &heap_init->out.first_chunk_va);
1480
+}
1481
+
1482
+static int kbasep_cs_tiler_heap_init_1_13(struct kbase_context *kctx,
1483
+ union kbase_ioctl_cs_tiler_heap_init_1_13 *heap_init)
1484
+{
1485
+ if (heap_init->in.group_id >= MEMORY_GROUP_MANAGER_NR_GROUPS)
1486
+ return -EINVAL;
1487
+
1488
+ kctx->jit_group_id = heap_init->in.group_id;
1489
+
1490
+ return kbase_csf_tiler_heap_init(kctx, heap_init->in.chunk_size,
1491
+ heap_init->in.initial_chunks, heap_init->in.max_chunks,
1492
+ heap_init->in.target_in_flight, 0,
1493
+ &heap_init->out.gpu_heap_va,
1494
+ &heap_init->out.first_chunk_va);
14421495 }
14431496
14441497 static int kbasep_cs_tiler_heap_term(struct kbase_context *kctx,
....@@ -1520,6 +1573,30 @@
15201573 cpu_queue_info->size);
15211574 }
15221575
1576
+static int kbase_ioctl_read_user_page(struct kbase_context *kctx,
1577
+ union kbase_ioctl_read_user_page *user_page)
1578
+{
1579
+ struct kbase_device *kbdev = kctx->kbdev;
1580
+ unsigned long flags;
1581
+
1582
+ /* As of now, only LATEST_FLUSH is supported */
1583
+ if (unlikely(user_page->in.offset != LATEST_FLUSH))
1584
+ return -EINVAL;
1585
+
1586
+ /* Validating padding that must be zero */
1587
+ if (unlikely(user_page->in.padding != 0))
1588
+ return -EINVAL;
1589
+
1590
+ spin_lock_irqsave(&kbdev->hwaccess_lock, flags);
1591
+ if (!kbdev->pm.backend.gpu_powered)
1592
+ user_page->out.val_lo = POWER_DOWN_LATEST_FLUSH_VALUE;
1593
+ else
1594
+ user_page->out.val_lo = kbase_reg_read(kbdev, USER_REG(LATEST_FLUSH));
1595
+ user_page->out.val_hi = 0;
1596
+ spin_unlock_irqrestore(&kbdev->hwaccess_lock, flags);
1597
+
1598
+ return 0;
1599
+}
15231600 #endif /* MALI_USE_CSF */
15241601
15251602 static int kbasep_ioctl_context_priority_check(struct kbase_context *kctx,
....@@ -1644,6 +1721,24 @@
16441721 struct kbase_ioctl_set_flags,
16451722 kfile);
16461723 break;
1724
+
1725
+ case KBASE_IOCTL_KINSTR_PRFCNT_ENUM_INFO:
1726
+ KBASE_HANDLE_IOCTL_INOUT(
1727
+ KBASE_IOCTL_KINSTR_PRFCNT_ENUM_INFO,
1728
+ kbase_api_kinstr_prfcnt_enum_info,
1729
+ struct kbase_ioctl_kinstr_prfcnt_enum_info, kfile);
1730
+ break;
1731
+
1732
+ case KBASE_IOCTL_KINSTR_PRFCNT_SETUP:
1733
+ KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_KINSTR_PRFCNT_SETUP,
1734
+ kbase_api_kinstr_prfcnt_setup,
1735
+ union kbase_ioctl_kinstr_prfcnt_setup,
1736
+ kfile);
1737
+ break;
1738
+ case KBASE_IOCTL_GET_GPUPROPS:
1739
+ KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_GPUPROPS, kbase_api_get_gpuprops,
1740
+ struct kbase_ioctl_get_gpuprops, kfile);
1741
+ break;
16471742 }
16481743
16491744 kctx = kbase_file_get_kctx_if_setup_complete(kfile);
....@@ -1660,12 +1755,6 @@
16601755 kctx);
16611756 break;
16621757 #endif /* !MALI_USE_CSF */
1663
- case KBASE_IOCTL_GET_GPUPROPS:
1664
- KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_GPUPROPS,
1665
- kbase_api_get_gpuprops,
1666
- struct kbase_ioctl_get_gpuprops,
1667
- kctx);
1668
- break;
16691758 #if !MALI_USE_CSF
16701759 case KBASE_IOCTL_POST_TERM:
16711760 KBASE_HANDLE_IOCTL(KBASE_IOCTL_POST_TERM,
....@@ -1679,6 +1768,12 @@
16791768 union kbase_ioctl_mem_alloc,
16801769 kctx);
16811770 break;
1771
+#if MALI_USE_CSF
1772
+ case KBASE_IOCTL_MEM_ALLOC_EX:
1773
+ KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_MEM_ALLOC_EX, kbase_api_mem_alloc_ex,
1774
+ union kbase_ioctl_mem_alloc_ex, kctx);
1775
+ break;
1776
+#endif
16821777 case KBASE_IOCTL_MEM_QUERY:
16831778 KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_MEM_QUERY,
16841779 kbase_api_mem_query,
....@@ -1701,18 +1796,6 @@
17011796 KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_DDK_VERSION,
17021797 kbase_api_get_ddk_version,
17031798 struct kbase_ioctl_get_ddk_version,
1704
- kctx);
1705
- break;
1706
- case KBASE_IOCTL_MEM_JIT_INIT_10_2:
1707
- KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_MEM_JIT_INIT_10_2,
1708
- kbase_api_mem_jit_init_10_2,
1709
- struct kbase_ioctl_mem_jit_init_10_2,
1710
- kctx);
1711
- break;
1712
- case KBASE_IOCTL_MEM_JIT_INIT_11_5:
1713
- KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_MEM_JIT_INIT_11_5,
1714
- kbase_api_mem_jit_init_11_5,
1715
- struct kbase_ioctl_mem_jit_init_11_5,
17161799 kctx);
17171800 break;
17181801 case KBASE_IOCTL_MEM_JIT_INIT:
....@@ -1842,28 +1925,20 @@
18421925 struct kbase_ioctl_hwcnt_reader_setup,
18431926 kctx);
18441927 break;
1845
- case KBASE_IOCTL_HWCNT_ENABLE:
1846
- KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_HWCNT_ENABLE,
1847
- kbase_api_hwcnt_enable,
1848
- struct kbase_ioctl_hwcnt_enable,
1849
- kctx);
1850
- break;
1851
- case KBASE_IOCTL_HWCNT_DUMP:
1852
- KBASE_HANDLE_IOCTL(KBASE_IOCTL_HWCNT_DUMP,
1853
- kbase_api_hwcnt_dump,
1854
- kctx);
1855
- break;
1856
- case KBASE_IOCTL_HWCNT_CLEAR:
1857
- KBASE_HANDLE_IOCTL(KBASE_IOCTL_HWCNT_CLEAR,
1858
- kbase_api_hwcnt_clear,
1859
- kctx);
1860
- break;
18611928 case KBASE_IOCTL_GET_CPU_GPU_TIMEINFO:
18621929 KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_GET_CPU_GPU_TIMEINFO,
18631930 kbase_api_get_cpu_gpu_timeinfo,
18641931 union kbase_ioctl_get_cpu_gpu_timeinfo,
18651932 kctx);
18661933 break;
1934
+#if IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
1935
+ case KBASE_IOCTL_HWCNT_SET:
1936
+ KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_HWCNT_SET,
1937
+ kbase_api_hwcnt_set,
1938
+ struct kbase_ioctl_hwcnt_values,
1939
+ kctx);
1940
+ break;
1941
+#endif /* CONFIG_MALI_BIFROST_NO_MALI */
18671942 #ifdef CONFIG_MALI_CINSTR_GWT
18681943 case KBASE_IOCTL_CINSTR_GWT_START:
18691944 KBASE_HANDLE_IOCTL(KBASE_IOCTL_CINSTR_GWT_START,
....@@ -1918,6 +1993,12 @@
19181993 struct kbase_ioctl_cs_queue_kick,
19191994 kctx);
19201995 break;
1996
+ case KBASE_IOCTL_CS_QUEUE_GROUP_CREATE_1_6:
1997
+ KBASE_HANDLE_IOCTL_INOUT(
1998
+ KBASE_IOCTL_CS_QUEUE_GROUP_CREATE_1_6,
1999
+ kbasep_cs_queue_group_create_1_6,
2000
+ union kbase_ioctl_cs_queue_group_create_1_6, kctx);
2001
+ break;
19212002 case KBASE_IOCTL_CS_QUEUE_GROUP_CREATE:
19222003 KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_CS_QUEUE_GROUP_CREATE,
19232004 kbasep_cs_queue_group_create,
....@@ -1954,6 +2035,11 @@
19542035 union kbase_ioctl_cs_tiler_heap_init,
19552036 kctx);
19562037 break;
2038
+ case KBASE_IOCTL_CS_TILER_HEAP_INIT_1_13:
2039
+ KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_CS_TILER_HEAP_INIT_1_13,
2040
+ kbasep_cs_tiler_heap_init_1_13,
2041
+ union kbase_ioctl_cs_tiler_heap_init_1_13, kctx);
2042
+ break;
19572043 case KBASE_IOCTL_CS_TILER_HEAP_TERM:
19582044 KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_CS_TILER_HEAP_TERM,
19592045 kbasep_cs_tiler_heap_term,
....@@ -1971,6 +2057,11 @@
19712057 kbasep_ioctl_cs_cpu_queue_dump,
19722058 struct kbase_ioctl_cs_cpu_queue_info,
19732059 kctx);
2060
+ break;
2061
+ /* This IOCTL will be kept for backward compatibility */
2062
+ case KBASE_IOCTL_READ_USER_PAGE:
2063
+ KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_READ_USER_PAGE, kbase_ioctl_read_user_page,
2064
+ union kbase_ioctl_read_user_page, kctx);
19742065 break;
19752066 #endif /* MALI_USE_CSF */
19762067 #if MALI_UNIT_TEST
....@@ -2014,10 +2105,13 @@
20142105 if (unlikely(!kctx))
20152106 return -EPERM;
20162107
2108
+ if (count < data_size)
2109
+ return -ENOBUFS;
2110
+
20172111 if (atomic_read(&kctx->event_count))
20182112 read_event = true;
20192113 else
2020
- read_error = kbase_csf_read_error(kctx, &event_data);
2114
+ read_error = kbase_csf_event_read_error(kctx, &event_data);
20212115
20222116 if (!read_event && !read_error) {
20232117 bool dump = kbase_csf_cpu_queue_read_dump_req(kctx,
....@@ -2059,6 +2153,8 @@
20592153 if (count < sizeof(uevent))
20602154 return -ENOBUFS;
20612155
2156
+ memset(&uevent, 0, sizeof(uevent));
2157
+
20622158 do {
20632159 while (kbase_event_dequeue(kctx, &uevent)) {
20642160 if (out_count > 0)
....@@ -2090,18 +2186,28 @@
20902186 }
20912187 #endif /* MALI_USE_CSF */
20922188
2093
-static unsigned int kbase_poll(struct file *filp, poll_table *wait)
2189
+static __poll_t kbase_poll(struct file *filp, poll_table *wait)
20942190 {
20952191 struct kbase_file *const kfile = filp->private_data;
20962192 struct kbase_context *const kctx =
20972193 kbase_file_get_kctx_if_setup_complete(kfile);
20982194
2099
- if (unlikely(!kctx))
2195
+ if (unlikely(!kctx)) {
2196
+#if (KERNEL_VERSION(4, 19, 0) > LINUX_VERSION_CODE)
21002197 return POLLERR;
2198
+#else
2199
+ return EPOLLERR;
2200
+#endif
2201
+ }
21012202
21022203 poll_wait(filp, &kctx->event_queue, wait);
2103
- if (kbase_event_pending(kctx))
2204
+ if (kbase_event_pending(kctx)) {
2205
+#if (KERNEL_VERSION(4, 19, 0) > LINUX_VERSION_CODE)
21042206 return POLLIN | POLLRDNORM;
2207
+#else
2208
+ return EPOLLIN | EPOLLRDNORM;
2209
+#endif
2210
+ }
21052211
21062212 return 0;
21072213 }
....@@ -2119,16 +2225,22 @@
21192225 #if MALI_USE_CSF
21202226 int kbase_event_pending(struct kbase_context *ctx)
21212227 {
2122
- WARN_ON_ONCE(!ctx);
2228
+ KBASE_DEBUG_ASSERT(ctx);
2229
+
2230
+ if (unlikely(!ctx))
2231
+ return -EPERM;
21232232
21242233 return (atomic_read(&ctx->event_count) != 0) ||
2125
- kbase_csf_error_pending(ctx) ||
2234
+ kbase_csf_event_error_pending(ctx) ||
21262235 kbase_csf_cpu_queue_dump_needed(ctx);
21272236 }
21282237 #else
21292238 int kbase_event_pending(struct kbase_context *ctx)
21302239 {
21312240 KBASE_DEBUG_ASSERT(ctx);
2241
+
2242
+ if (unlikely(!ctx))
2243
+ return -EPERM;
21322244
21332245 return (atomic_read(&ctx->event_count) != 0) ||
21342246 (atomic_read(&ctx->event_closed) != 0);
....@@ -2188,19 +2300,19 @@
21882300 };
21892301
21902302 /**
2191
- * show_policy - Show callback for the power_policy sysfs file.
2192
- *
2193
- * This function is called to get the contents of the power_policy sysfs
2194
- * file. This is a list of the available policies with the currently active one
2195
- * surrounded by square brackets.
2303
+ * power_policy_show - Show callback for the power_policy sysfs file.
21962304 *
21972305 * @dev: The device this sysfs file is for
21982306 * @attr: The attributes of the sysfs file
21992307 * @buf: The output buffer for the sysfs file contents
22002308 *
2309
+ * This function is called to get the contents of the power_policy sysfs
2310
+ * file. This is a list of the available policies with the currently active one
2311
+ * surrounded by square brackets.
2312
+ *
22012313 * Return: The number of bytes output to @buf.
22022314 */
2203
-static ssize_t show_policy(struct device *dev, struct device_attribute *attr, char *const buf)
2315
+static ssize_t power_policy_show(struct device *dev, struct device_attribute *attr, char *const buf)
22042316 {
22052317 struct kbase_device *kbdev;
22062318 const struct kbase_pm_policy *current_policy;
....@@ -2237,21 +2349,21 @@
22372349 }
22382350
22392351 /**
2240
- * set_policy - Store callback for the power_policy sysfs file.
2241
- *
2242
- * This function is called when the power_policy sysfs file is written to.
2243
- * It matches the requested policy against the available policies and if a
2244
- * matching policy is found calls kbase_pm_set_policy() to change the
2245
- * policy.
2352
+ * power_policy_store - Store callback for the power_policy sysfs file.
22462353 *
22472354 * @dev: The device with sysfs file is for
22482355 * @attr: The attributes of the sysfs file
22492356 * @buf: The value written to the sysfs file
22502357 * @count: The number of bytes to write to the sysfs file
22512358 *
2359
+ * This function is called when the power_policy sysfs file is written to.
2360
+ * It matches the requested policy against the available policies and if a
2361
+ * matching policy is found calls kbase_pm_set_policy() to change the
2362
+ * policy.
2363
+ *
22522364 * Return: @count if the function succeeded. An error code on failure.
22532365 */
2254
-static ssize_t set_policy(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2366
+static ssize_t power_policy_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
22552367 {
22562368 struct kbase_device *kbdev;
22572369 const struct kbase_pm_policy *new_policy = NULL;
....@@ -2290,20 +2402,20 @@
22902402 * determining which policy is currently active, and changing the active
22912403 * policy.
22922404 */
2293
-static DEVICE_ATTR(power_policy, S_IRUGO | S_IWUSR, show_policy, set_policy);
2405
+static DEVICE_ATTR_RW(power_policy);
22942406
22952407 /*
2296
- * show_core_mask - Show callback for the core_mask sysfs file.
2297
- *
2298
- * This function is called to get the contents of the core_mask sysfs file.
2408
+ * core_mask_show - Show callback for the core_mask sysfs file.
22992409 *
23002410 * @dev: The device this sysfs file is for
23012411 * @attr: The attributes of the sysfs file
23022412 * @buf: The output buffer for the sysfs file contents
23032413 *
2414
+ * This function is called to get the contents of the core_mask sysfs file.
2415
+ *
23042416 * Return: The number of bytes output to @buf.
23052417 */
2306
-static ssize_t show_core_mask(struct device *dev, struct device_attribute *attr, char * const buf)
2418
+static ssize_t core_mask_show(struct device *dev, struct device_attribute *attr, char * const buf)
23072419 {
23082420 struct kbase_device *kbdev;
23092421 unsigned long flags;
....@@ -2348,18 +2460,18 @@
23482460 }
23492461
23502462 /**
2351
- * set_core_mask - Store callback for the core_mask sysfs file.
2352
- *
2353
- * This function is called when the core_mask sysfs file is written to.
2463
+ * core_mask_store - Store callback for the core_mask sysfs file.
23542464 *
23552465 * @dev: The device with sysfs file is for
23562466 * @attr: The attributes of the sysfs file
23572467 * @buf: The value written to the sysfs file
23582468 * @count: The number of bytes to write to the sysfs file
23592469 *
2470
+ * This function is called when the core_mask sysfs file is written to.
2471
+ *
23602472 * Return: @count if the function succeeded. An error code on failure.
23612473 */
2362
-static ssize_t set_core_mask(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2474
+static ssize_t core_mask_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
23632475 {
23642476 struct kbase_device *kbdev;
23652477 #if MALI_USE_CSF
....@@ -2489,11 +2601,11 @@
24892601 * Reading it will show the current core mask and the mask of cores available.
24902602 * Writing to it will set the current core mask.
24912603 */
2492
-static DEVICE_ATTR(core_mask, S_IRUGO | S_IWUSR, show_core_mask, set_core_mask);
2604
+static DEVICE_ATTR_RW(core_mask);
24932605
24942606 #if !MALI_USE_CSF
24952607 /**
2496
- * set_soft_job_timeout - Store callback for the soft_job_timeout sysfs
2608
+ * soft_job_timeout_store - Store callback for the soft_job_timeout sysfs
24972609 * file.
24982610 *
24992611 * @dev: The device this sysfs file is for.
....@@ -2509,7 +2621,7 @@
25092621 *
25102622 * Return: count if the function succeeded. An error code on failure.
25112623 */
2512
-static ssize_t set_soft_job_timeout(struct device *dev,
2624
+static ssize_t soft_job_timeout_store(struct device *dev,
25132625 struct device_attribute *attr,
25142626 const char *buf, size_t count)
25152627 {
....@@ -2531,18 +2643,18 @@
25312643 }
25322644
25332645 /**
2534
- * show_soft_job_timeout - Show callback for the soft_job_timeout sysfs
2646
+ * soft_job_timeout_show - Show callback for the soft_job_timeout sysfs
25352647 * file.
2536
- *
2537
- * This will return the timeout for the software jobs.
25382648 *
25392649 * @dev: The device this sysfs file is for.
25402650 * @attr: The attributes of the sysfs file.
25412651 * @buf: The output buffer for the sysfs file contents.
25422652 *
2653
+ * This will return the timeout for the software jobs.
2654
+ *
25432655 * Return: The number of bytes output to buf.
25442656 */
2545
-static ssize_t show_soft_job_timeout(struct device *dev,
2657
+static ssize_t soft_job_timeout_show(struct device *dev,
25462658 struct device_attribute *attr,
25472659 char * const buf)
25482660 {
....@@ -2556,14 +2668,14 @@
25562668 atomic_read(&kbdev->js_data.soft_job_timeout_ms));
25572669 }
25582670
2559
-static DEVICE_ATTR(soft_job_timeout, S_IRUGO | S_IWUSR,
2560
- show_soft_job_timeout, set_soft_job_timeout);
2671
+static DEVICE_ATTR_RW(soft_job_timeout);
25612672
25622673 static u32 timeout_ms_to_ticks(struct kbase_device *kbdev, long timeout_ms,
25632674 int default_ticks, u32 old_ticks)
25642675 {
25652676 if (timeout_ms > 0) {
25662677 u64 ticks = timeout_ms * 1000000ULL;
2678
+
25672679 do_div(ticks, kbdev->js_data.scheduling_period_ns);
25682680 if (!ticks)
25692681 return 1;
....@@ -2576,7 +2688,12 @@
25762688 }
25772689
25782690 /**
2579
- * set_js_timeouts - Store callback for the js_timeouts sysfs file.
2691
+ * js_timeouts_store - Store callback for the js_timeouts sysfs file.
2692
+ *
2693
+ * @dev: The device with sysfs file is for
2694
+ * @attr: The attributes of the sysfs file
2695
+ * @buf: The value written to the sysfs file
2696
+ * @count: The number of bytes to write to the sysfs file
25802697 *
25812698 * This function is called to get the contents of the js_timeouts sysfs
25822699 * file. This file contains five values separated by whitespace. The values
....@@ -2589,14 +2706,9 @@
25892706 * use by the job scheduler to get override. Note that a value needs to
25902707 * be other than 0 for it to override the current job scheduler value.
25912708 *
2592
- * @dev: The device with sysfs file is for
2593
- * @attr: The attributes of the sysfs file
2594
- * @buf: The value written to the sysfs file
2595
- * @count: The number of bytes to write to the sysfs file
2596
- *
25972709 * Return: @count if the function succeeded. An error code on failure.
25982710 */
2599
-static ssize_t set_js_timeouts(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2711
+static ssize_t js_timeouts_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
26002712 {
26012713 struct kbase_device *kbdev;
26022714 int items;
....@@ -2676,19 +2788,20 @@
26762788 }
26772789
26782790 /**
2679
- * show_js_timeouts - Show callback for the js_timeouts sysfs file.
2791
+ * js_timeouts_show - Show callback for the js_timeouts sysfs file.
2792
+ *
2793
+ * @dev: The device this sysfs file is for
2794
+ * @attr: The attributes of the sysfs file
2795
+ * @buf: The output buffer for the sysfs file contents
26802796 *
26812797 * This function is called to get the contents of the js_timeouts sysfs
26822798 * file. It returns the last set values written to the js_timeouts sysfs file.
26832799 * If the file didn't get written yet, the values will be current setting in
26842800 * use.
2685
- * @dev: The device this sysfs file is for
2686
- * @attr: The attributes of the sysfs file
2687
- * @buf: The output buffer for the sysfs file contents
26882801 *
26892802 * Return: The number of bytes output to @buf.
26902803 */
2691
-static ssize_t show_js_timeouts(struct device *dev, struct device_attribute *attr, char * const buf)
2804
+static ssize_t js_timeouts_show(struct device *dev, struct device_attribute *attr, char * const buf)
26922805 {
26932806 struct kbase_device *kbdev;
26942807 ssize_t ret;
....@@ -2751,7 +2864,7 @@
27512864 * JS_RESET_TICKS_CL
27522865 * JS_RESET_TICKS_DUMPING.
27532866 */
2754
-static DEVICE_ATTR(js_timeouts, S_IRUGO | S_IWUSR, show_js_timeouts, set_js_timeouts);
2867
+static DEVICE_ATTR_RW(js_timeouts);
27552868
27562869 static u32 get_new_js_timeout(
27572870 u32 old_period,
....@@ -2759,12 +2872,13 @@
27592872 u32 new_scheduling_period_ns)
27602873 {
27612874 u64 ticks = (u64)old_period * (u64)old_ticks;
2875
+
27622876 do_div(ticks, new_scheduling_period_ns);
27632877 return ticks?ticks:1;
27642878 }
27652879
27662880 /**
2767
- * set_js_scheduling_period - Store callback for the js_scheduling_period sysfs
2881
+ * js_scheduling_period_store - Store callback for the js_scheduling_period sysfs
27682882 * file
27692883 * @dev: The device the sysfs file is for
27702884 * @attr: The attributes of the sysfs file
....@@ -2777,7 +2891,7 @@
27772891 *
27782892 * Return: @count if the function succeeded. An error code on failure.
27792893 */
2780
-static ssize_t set_js_scheduling_period(struct device *dev,
2894
+static ssize_t js_scheduling_period_store(struct device *dev,
27812895 struct device_attribute *attr, const char *buf, size_t count)
27822896 {
27832897 struct kbase_device *kbdev;
....@@ -2846,7 +2960,7 @@
28462960 }
28472961
28482962 /**
2849
- * show_js_scheduling_period - Show callback for the js_scheduling_period sysfs
2963
+ * js_scheduling_period_show - Show callback for the js_scheduling_period sysfs
28502964 * entry.
28512965 * @dev: The device this sysfs file is for.
28522966 * @attr: The attributes of the sysfs file.
....@@ -2857,7 +2971,7 @@
28572971 *
28582972 * Return: The number of bytes output to @buf.
28592973 */
2860
-static ssize_t show_js_scheduling_period(struct device *dev,
2974
+static ssize_t js_scheduling_period_show(struct device *dev,
28612975 struct device_attribute *attr, char * const buf)
28622976 {
28632977 struct kbase_device *kbdev;
....@@ -2876,12 +2990,11 @@
28762990 return ret;
28772991 }
28782992
2879
-static DEVICE_ATTR(js_scheduling_period, S_IRUGO | S_IWUSR,
2880
- show_js_scheduling_period, set_js_scheduling_period);
2993
+static DEVICE_ATTR_RW(js_scheduling_period);
28812994
28822995
28832996 #ifdef CONFIG_MALI_BIFROST_DEBUG
2884
-static ssize_t set_js_softstop_always(struct device *dev,
2997
+static ssize_t js_softstop_always_store(struct device *dev,
28852998 struct device_attribute *attr, const char *buf, size_t count)
28862999 {
28873000 struct kbase_device *kbdev;
....@@ -2906,7 +3019,7 @@
29063019 return count;
29073020 }
29083021
2909
-static ssize_t show_js_softstop_always(struct device *dev,
3022
+static ssize_t js_softstop_always_show(struct device *dev,
29103023 struct device_attribute *attr, char * const buf)
29113024 {
29123025 struct kbase_device *kbdev;
....@@ -2933,7 +3046,7 @@
29333046 * used for debug and unit-testing purposes.
29343047 * (see CL t6xx_stress_1 unit-test as an example whereby this feature is used.)
29353048 */
2936
-static DEVICE_ATTR(js_softstop_always, S_IRUGO | S_IWUSR, show_js_softstop_always, set_js_softstop_always);
3049
+static DEVICE_ATTR_RW(js_softstop_always);
29373050 #endif /* CONFIG_MALI_BIFROST_DEBUG */
29383051 #endif /* !MALI_USE_CSF */
29393052
....@@ -2952,7 +3065,7 @@
29523065 kbasep_debug_command_func *func;
29533066 };
29543067
2955
-void kbasep_ktrace_dump_wrapper(struct kbase_device *kbdev)
3068
+static void kbasep_ktrace_dump_wrapper(struct kbase_device *kbdev)
29563069 {
29573070 KBASE_KTRACE_DUMP(kbdev);
29583071 }
....@@ -2960,24 +3073,24 @@
29603073 /* Debug commands supported by the driver */
29613074 static const struct kbasep_debug_command debug_commands[] = {
29623075 {
2963
- .str = "dumptrace",
2964
- .func = &kbasep_ktrace_dump_wrapper,
2965
- }
3076
+ .str = "dumptrace",
3077
+ .func = &kbasep_ktrace_dump_wrapper,
3078
+ }
29663079 };
29673080
29683081 /**
2969
- * show_debug - Show callback for the debug_command sysfs file.
2970
- *
2971
- * This function is called to get the contents of the debug_command sysfs
2972
- * file. This is a list of the available debug commands, separated by newlines.
3082
+ * debug_command_show - Show callback for the debug_command sysfs file.
29733083 *
29743084 * @dev: The device this sysfs file is for
29753085 * @attr: The attributes of the sysfs file
29763086 * @buf: The output buffer for the sysfs file contents
29773087 *
3088
+ * This function is called to get the contents of the debug_command sysfs
3089
+ * file. This is a list of the available debug commands, separated by newlines.
3090
+ *
29783091 * Return: The number of bytes output to @buf.
29793092 */
2980
-static ssize_t show_debug(struct device *dev, struct device_attribute *attr, char * const buf)
3093
+static ssize_t debug_command_show(struct device *dev, struct device_attribute *attr, char * const buf)
29813094 {
29823095 struct kbase_device *kbdev;
29833096 int i;
....@@ -3001,21 +3114,21 @@
30013114 }
30023115
30033116 /**
3004
- * issue_debug - Store callback for the debug_command sysfs file.
3005
- *
3006
- * This function is called when the debug_command sysfs file is written to.
3007
- * It matches the requested command against the available commands, and if
3008
- * a matching command is found calls the associated function from
3009
- * @debug_commands to issue the command.
3117
+ * debug_command_store - Store callback for the debug_command sysfs file.
30103118 *
30113119 * @dev: The device with sysfs file is for
30123120 * @attr: The attributes of the sysfs file
30133121 * @buf: The value written to the sysfs file
30143122 * @count: The number of bytes written to the sysfs file
30153123 *
3124
+ * This function is called when the debug_command sysfs file is written to.
3125
+ * It matches the requested command against the available commands, and if
3126
+ * a matching command is found calls the associated function from
3127
+ * @debug_commands to issue the command.
3128
+ *
30163129 * Return: @count if the function succeeded. An error code on failure.
30173130 */
3018
-static ssize_t issue_debug(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
3131
+static ssize_t debug_command_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
30193132 {
30203133 struct kbase_device *kbdev;
30213134 int i;
....@@ -3043,11 +3156,11 @@
30433156 * Reading it will produce a list of debug commands, separated by newlines.
30443157 * Writing to it with one of those commands will issue said command.
30453158 */
3046
-static DEVICE_ATTR(debug_command, S_IRUGO | S_IWUSR, show_debug, issue_debug);
3159
+static DEVICE_ATTR_RW(debug_command);
30473160 #endif /* CONFIG_MALI_BIFROST_DEBUG */
30483161
30493162 /**
3050
- * kbase_show_gpuinfo - Show callback for the gpuinfo sysfs entry.
3163
+ * gpuinfo_show - Show callback for the gpuinfo sysfs entry.
30513164 * @dev: The device this sysfs file is for.
30523165 * @attr: The attributes of the sysfs file.
30533166 * @buf: The output buffer to receive the GPU information.
....@@ -3061,57 +3174,63 @@
30613174 *
30623175 * Return: The number of bytes output to @buf.
30633176 */
3064
-static ssize_t kbase_show_gpuinfo(struct device *dev,
3177
+static ssize_t gpuinfo_show(struct device *dev,
30653178 struct device_attribute *attr, char *buf)
30663179 {
30673180 static const struct gpu_product_id_name {
3068
- unsigned id;
3181
+ unsigned int id;
30693182 char *name;
30703183 } gpu_product_id_names[] = {
3071
- { .id = GPU_ID2_PRODUCT_TMIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3184
+ { .id = GPU_ID2_PRODUCT_TMIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30723185 .name = "Mali-G71" },
3073
- { .id = GPU_ID2_PRODUCT_THEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3186
+ { .id = GPU_ID2_PRODUCT_THEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30743187 .name = "Mali-G72" },
3075
- { .id = GPU_ID2_PRODUCT_TSIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3188
+ { .id = GPU_ID2_PRODUCT_TSIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30763189 .name = "Mali-G51" },
3077
- { .id = GPU_ID2_PRODUCT_TNOX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3190
+ { .id = GPU_ID2_PRODUCT_TNOX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30783191 .name = "Mali-G76" },
3079
- { .id = GPU_ID2_PRODUCT_TDVX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3192
+ { .id = GPU_ID2_PRODUCT_TDVX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30803193 .name = "Mali-G31" },
3081
- { .id = GPU_ID2_PRODUCT_TGOX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3194
+ { .id = GPU_ID2_PRODUCT_TGOX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30823195 .name = "Mali-G52" },
3083
- { .id = GPU_ID2_PRODUCT_TTRX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3196
+ { .id = GPU_ID2_PRODUCT_TTRX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30843197 .name = "Mali-G77" },
3085
- { .id = GPU_ID2_PRODUCT_TBEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3198
+ { .id = GPU_ID2_PRODUCT_TBEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30863199 .name = "Mali-G78" },
3087
- { .id = GPU_ID2_PRODUCT_TBAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3200
+ { .id = GPU_ID2_PRODUCT_TBAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30883201 .name = "Mali-G78AE" },
3089
- { .id = GPU_ID2_PRODUCT_LBEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3202
+ { .id = GPU_ID2_PRODUCT_LBEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30903203 .name = "Mali-G68" },
3091
- { .id = GPU_ID2_PRODUCT_TNAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3204
+ { .id = GPU_ID2_PRODUCT_TNAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30923205 .name = "Mali-G57" },
3093
- { .id = GPU_ID2_PRODUCT_TODX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3206
+ { .id = GPU_ID2_PRODUCT_TODX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30943207 .name = "Mali-G710" },
3095
- { .id = GPU_ID2_PRODUCT_LODX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3208
+ { .id = GPU_ID2_PRODUCT_LODX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30963209 .name = "Mali-G610" },
3097
- { .id = GPU_ID2_PRODUCT_TGRX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3210
+ { .id = GPU_ID2_PRODUCT_TGRX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
30983211 .name = "Mali-G510" },
3099
- { .id = GPU_ID2_PRODUCT_TVAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3212
+ { .id = GPU_ID2_PRODUCT_TVAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
31003213 .name = "Mali-G310" },
3214
+ { .id = GPU_ID2_PRODUCT_TTIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3215
+ .name = "Mali-TTIX" },
3216
+ { .id = GPU_ID2_PRODUCT_LTIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
3217
+ .name = "Mali-LTIX" },
31013218 };
31023219 const char *product_name = "(Unknown Mali GPU)";
31033220 struct kbase_device *kbdev;
31043221 u32 gpu_id;
3105
- unsigned product_id, product_id_mask;
3106
- unsigned i;
3222
+ unsigned int product_id, product_id_mask;
3223
+ unsigned int i;
3224
+ struct kbase_gpu_props *gpu_props;
31073225
31083226 kbdev = to_kbase_device(dev);
31093227 if (!kbdev)
31103228 return -ENODEV;
31113229
3112
- gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
3113
- product_id = gpu_id >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
3114
- product_id_mask = GPU_ID2_PRODUCT_MODEL >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
3230
+ gpu_props = &kbdev->gpu_props;
3231
+ gpu_id = gpu_props->props.raw_props.gpu_id;
3232
+ product_id = gpu_id >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
3233
+ product_id_mask = GPU_ID2_PRODUCT_MODEL >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
31153234
31163235 for (i = 0; i < ARRAY_SIZE(gpu_product_id_names); ++i) {
31173236 const struct gpu_product_id_name *p = &gpu_product_id_names[i];
....@@ -3123,16 +3242,42 @@
31233242 }
31243243 }
31253244
3126
- return scnprintf(buf, PAGE_SIZE, "%s %d cores r%dp%d 0x%04X\n",
3127
- product_name, kbdev->gpu_props.num_cores,
3128
- (gpu_id & GPU_ID_VERSION_MAJOR) >> GPU_ID_VERSION_MAJOR_SHIFT,
3129
- (gpu_id & GPU_ID_VERSION_MINOR) >> GPU_ID_VERSION_MINOR_SHIFT,
3130
- product_id);
3245
+#if MALI_USE_CSF
3246
+ if ((product_id & product_id_mask) ==
3247
+ ((GPU_ID2_PRODUCT_TTUX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT) & product_id_mask)) {
3248
+ const bool rt_supported =
3249
+ GPU_FEATURES_RAY_TRACING_GET(gpu_props->props.raw_props.gpu_features);
3250
+ const u8 nr_cores = gpu_props->num_cores;
3251
+
3252
+ /* Mali-G715-Immortalis if 10 < number of cores with ray tracing supproted.
3253
+ * Mali-G715 if 10 < number of cores without ray tracing supported.
3254
+ * Mali-G715 if 7 <= number of cores <= 10 regardless ray tracing.
3255
+ * Mali-G615 if number of cores < 7.
3256
+ */
3257
+ if ((nr_cores > 10) && rt_supported)
3258
+ product_name = "Mali-G715-Immortalis";
3259
+ else if (nr_cores >= 7)
3260
+ product_name = "Mali-G715";
3261
+
3262
+ if (nr_cores < 7) {
3263
+ dev_warn(kbdev->dev, "nr_cores(%u) GPU ID must be G615", nr_cores);
3264
+ product_name = "Mali-G615";
3265
+ } else
3266
+ dev_dbg(kbdev->dev, "GPU ID_Name: %s, nr_cores(%u)\n", product_name,
3267
+ nr_cores);
3268
+ }
3269
+#endif /* MALI_USE_CSF */
3270
+
3271
+ return scnprintf(buf, PAGE_SIZE, "%s %d cores r%dp%d 0x%04X\n", product_name,
3272
+ kbdev->gpu_props.num_cores,
3273
+ (gpu_id & GPU_ID_VERSION_MAJOR) >> KBASE_GPU_ID_VERSION_MAJOR_SHIFT,
3274
+ (gpu_id & GPU_ID_VERSION_MINOR) >> KBASE_GPU_ID_VERSION_MINOR_SHIFT,
3275
+ product_id);
31313276 }
3132
-static DEVICE_ATTR(gpuinfo, S_IRUGO, kbase_show_gpuinfo, NULL);
3277
+static DEVICE_ATTR_RO(gpuinfo);
31333278
31343279 /**
3135
- * set_dvfs_period - Store callback for the dvfs_period sysfs file.
3280
+ * dvfs_period_store - Store callback for the dvfs_period sysfs file.
31363281 * @dev: The device with sysfs file is for
31373282 * @attr: The attributes of the sysfs file
31383283 * @buf: The value written to the sysfs file
....@@ -3143,7 +3288,7 @@
31433288 *
31443289 * Return: @count if the function succeeded. An error code on failure.
31453290 */
3146
-static ssize_t set_dvfs_period(struct device *dev,
3291
+static ssize_t dvfs_period_store(struct device *dev,
31473292 struct device_attribute *attr, const char *buf, size_t count)
31483293 {
31493294 struct kbase_device *kbdev;
....@@ -3168,7 +3313,7 @@
31683313 }
31693314
31703315 /**
3171
- * show_dvfs_period - Show callback for the dvfs_period sysfs entry.
3316
+ * dvfs_period_show - Show callback for the dvfs_period sysfs entry.
31723317 * @dev: The device this sysfs file is for.
31733318 * @attr: The attributes of the sysfs file.
31743319 * @buf: The output buffer to receive the GPU information.
....@@ -3178,7 +3323,7 @@
31783323 *
31793324 * Return: The number of bytes output to @buf.
31803325 */
3181
-static ssize_t show_dvfs_period(struct device *dev,
3326
+static ssize_t dvfs_period_show(struct device *dev,
31823327 struct device_attribute *attr, char * const buf)
31833328 {
31843329 struct kbase_device *kbdev;
....@@ -3193,11 +3338,50 @@
31933338 return ret;
31943339 }
31953340
3196
-static DEVICE_ATTR(dvfs_period, S_IRUGO | S_IWUSR, show_dvfs_period,
3197
- set_dvfs_period);
3341
+static DEVICE_ATTR_RW(dvfs_period);
3342
+
3343
+int kbase_pm_lowest_gpu_freq_init(struct kbase_device *kbdev)
3344
+{
3345
+ /* Uses default reference frequency defined in below macro */
3346
+ u64 lowest_freq_khz = DEFAULT_REF_TIMEOUT_FREQ_KHZ;
3347
+
3348
+ /* Only check lowest frequency in cases when OPPs are used and
3349
+ * present in the device tree.
3350
+ */
3351
+#ifdef CONFIG_PM_OPP
3352
+ struct dev_pm_opp *opp_ptr;
3353
+ unsigned long found_freq = 0;
3354
+
3355
+ /* find lowest frequency OPP */
3356
+ opp_ptr = dev_pm_opp_find_freq_ceil(kbdev->dev, &found_freq);
3357
+ if (IS_ERR(opp_ptr)) {
3358
+ dev_err(kbdev->dev, "No OPPs found in device tree! Scaling timeouts using %llu kHz",
3359
+ (unsigned long long)lowest_freq_khz);
3360
+ } else {
3361
+#if KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE
3362
+ dev_pm_opp_put(opp_ptr); /* decrease OPP refcount */
3363
+#endif
3364
+ /* convert found frequency to KHz */
3365
+ found_freq /= 1000;
3366
+
3367
+ /* If lowest frequency in OPP table is still higher
3368
+ * than the reference, then keep the reference frequency
3369
+ * as the one to use for scaling .
3370
+ */
3371
+ if (found_freq < lowest_freq_khz)
3372
+ lowest_freq_khz = found_freq;
3373
+ }
3374
+#else
3375
+ dev_err(kbdev->dev, "No operating-points-v2 node or operating-points property in DT");
3376
+#endif
3377
+
3378
+ kbdev->lowest_gpu_freq_khz = lowest_freq_khz;
3379
+ dev_dbg(kbdev->dev, "Lowest frequency identified is %llu kHz", kbdev->lowest_gpu_freq_khz);
3380
+ return 0;
3381
+}
31983382
31993383 /**
3200
- * set_pm_poweroff - Store callback for the pm_poweroff sysfs file.
3384
+ * pm_poweroff_store - Store callback for the pm_poweroff sysfs file.
32013385 * @dev: The device with sysfs file is for
32023386 * @attr: The attributes of the sysfs file
32033387 * @buf: The value written to the sysfs file
....@@ -3213,7 +3397,7 @@
32133397 *
32143398 * Return: @count if the function succeeded. An error code on failure.
32153399 */
3216
-static ssize_t set_pm_poweroff(struct device *dev,
3400
+static ssize_t pm_poweroff_store(struct device *dev,
32173401 struct device_attribute *attr, const char *buf, size_t count)
32183402 {
32193403 struct kbase_device *kbdev;
....@@ -3252,7 +3436,7 @@
32523436 }
32533437
32543438 /**
3255
- * show_pm_poweroff - Show callback for the pm_poweroff sysfs entry.
3439
+ * pm_poweroff_show - Show callback for the pm_poweroff sysfs entry.
32563440 * @dev: The device this sysfs file is for.
32573441 * @attr: The attributes of the sysfs file.
32583442 * @buf: The output buffer to receive the GPU information.
....@@ -3262,7 +3446,7 @@
32623446 *
32633447 * Return: The number of bytes output to @buf.
32643448 */
3265
-static ssize_t show_pm_poweroff(struct device *dev,
3449
+static ssize_t pm_poweroff_show(struct device *dev,
32663450 struct device_attribute *attr, char * const buf)
32673451 {
32683452 struct kbase_device *kbdev;
....@@ -3286,80 +3470,10 @@
32863470 return ret;
32873471 }
32883472
3289
-static DEVICE_ATTR(pm_poweroff, S_IRUGO | S_IWUSR, show_pm_poweroff,
3290
- set_pm_poweroff);
3291
-
3292
-#if MALI_USE_CSF
3293
-/**
3294
- * set_idle_hysteresis_time - Store callback for CSF idle_hysteresis_time
3295
- * sysfs file.
3296
- * @dev: The device with sysfs file is for
3297
- * @attr: The attributes of the sysfs file
3298
- * @buf: The value written to the sysfs file
3299
- * @count: The number of bytes written to the sysfs file
3300
- *
3301
- * This function is called when the idle_hysteresis_time sysfs file is
3302
- * written to.
3303
- *
3304
- * This file contains values of the idle idle hysteresis duration.
3305
- *
3306
- * Return: @count if the function succeeded. An error code on failure.
3307
- */
3308
-static ssize_t set_idle_hysteresis_time(struct device *dev,
3309
- struct device_attribute *attr, const char *buf, size_t count)
3310
-{
3311
- struct kbase_device *kbdev;
3312
- u32 dur;
3313
-
3314
- kbdev = to_kbase_device(dev);
3315
- if (!kbdev)
3316
- return -ENODEV;
3317
-
3318
- if (kstrtou32(buf, 0, &dur)) {
3319
- dev_err(kbdev->dev, "Couldn't process idle_hysteresis_time write operation.\n"
3320
- "Use format <idle_hysteresis_time>\n");
3321
- return -EINVAL;
3322
- }
3323
-
3324
- kbase_csf_firmware_set_gpu_idle_hysteresis_time(kbdev, dur);
3325
-
3326
- return count;
3327
-}
3473
+static DEVICE_ATTR_RW(pm_poweroff);
33283474
33293475 /**
3330
- * show_idle_hysteresis_time - Show callback for CSF idle_hysteresis_time
3331
- * sysfs entry.
3332
- * @dev: The device this sysfs file is for.
3333
- * @attr: The attributes of the sysfs file.
3334
- * @buf: The output buffer to receive the GPU information.
3335
- *
3336
- * This function is called to get the current idle hysteresis duration in ms.
3337
- *
3338
- * Return: The number of bytes output to @buf.
3339
- */
3340
-static ssize_t show_idle_hysteresis_time(struct device *dev,
3341
- struct device_attribute *attr, char * const buf)
3342
-{
3343
- struct kbase_device *kbdev;
3344
- ssize_t ret;
3345
- u32 dur;
3346
-
3347
- kbdev = to_kbase_device(dev);
3348
- if (!kbdev)
3349
- return -ENODEV;
3350
-
3351
- dur = kbase_csf_firmware_get_gpu_idle_hysteresis_time(kbdev);
3352
- ret = scnprintf(buf, PAGE_SIZE, "%u\n", dur);
3353
-
3354
- return ret;
3355
-}
3356
-
3357
-static DEVICE_ATTR(idle_hysteresis_time, S_IRUGO | S_IWUSR,
3358
- show_idle_hysteresis_time, set_idle_hysteresis_time);
3359
-#endif
3360
-
3361
-/**
3362
- * set_reset_timeout - Store callback for the reset_timeout sysfs file.
3476
+ * reset_timeout_store - Store callback for the reset_timeout sysfs file.
33633477 * @dev: The device with sysfs file is for
33643478 * @attr: The attributes of the sysfs file
33653479 * @buf: The value written to the sysfs file
....@@ -3370,7 +3484,7 @@
33703484 *
33713485 * Return: @count if the function succeeded. An error code on failure.
33723486 */
3373
-static ssize_t set_reset_timeout(struct device *dev,
3487
+static ssize_t reset_timeout_store(struct device *dev,
33743488 struct device_attribute *attr, const char *buf, size_t count)
33753489 {
33763490 struct kbase_device *kbdev;
....@@ -3395,7 +3509,7 @@
33953509 }
33963510
33973511 /**
3398
- * show_reset_timeout - Show callback for the reset_timeout sysfs entry.
3512
+ * reset_timeout_show - Show callback for the reset_timeout sysfs entry.
33993513 * @dev: The device this sysfs file is for.
34003514 * @attr: The attributes of the sysfs file.
34013515 * @buf: The output buffer to receive the GPU information.
....@@ -3404,7 +3518,7 @@
34043518 *
34053519 * Return: The number of bytes output to @buf.
34063520 */
3407
-static ssize_t show_reset_timeout(struct device *dev,
3521
+static ssize_t reset_timeout_show(struct device *dev,
34083522 struct device_attribute *attr, char * const buf)
34093523 {
34103524 struct kbase_device *kbdev;
....@@ -3419,11 +3533,9 @@
34193533 return ret;
34203534 }
34213535
3422
-static DEVICE_ATTR(reset_timeout, S_IRUGO | S_IWUSR, show_reset_timeout,
3423
- set_reset_timeout);
3536
+static DEVICE_ATTR_RW(reset_timeout);
34243537
3425
-
3426
-static ssize_t show_mem_pool_size(struct device *dev,
3538
+static ssize_t mem_pool_size_show(struct device *dev,
34273539 struct device_attribute *attr, char * const buf)
34283540 {
34293541 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3436,7 +3548,7 @@
34363548 kbase_mem_pool_debugfs_size);
34373549 }
34383550
3439
-static ssize_t set_mem_pool_size(struct device *dev,
3551
+static ssize_t mem_pool_size_store(struct device *dev,
34403552 struct device_attribute *attr, const char *buf, size_t count)
34413553 {
34423554 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3452,10 +3564,9 @@
34523564 return err ? err : count;
34533565 }
34543566
3455
-static DEVICE_ATTR(mem_pool_size, S_IRUGO | S_IWUSR, show_mem_pool_size,
3456
- set_mem_pool_size);
3567
+static DEVICE_ATTR_RW(mem_pool_size);
34573568
3458
-static ssize_t show_mem_pool_max_size(struct device *dev,
3569
+static ssize_t mem_pool_max_size_show(struct device *dev,
34593570 struct device_attribute *attr, char * const buf)
34603571 {
34613572 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3468,7 +3579,7 @@
34683579 kbase_mem_pool_debugfs_max_size);
34693580 }
34703581
3471
-static ssize_t set_mem_pool_max_size(struct device *dev,
3582
+static ssize_t mem_pool_max_size_store(struct device *dev,
34723583 struct device_attribute *attr, const char *buf, size_t count)
34733584 {
34743585 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3484,11 +3595,10 @@
34843595 return err ? err : count;
34853596 }
34863597
3487
-static DEVICE_ATTR(mem_pool_max_size, S_IRUGO | S_IWUSR, show_mem_pool_max_size,
3488
- set_mem_pool_max_size);
3598
+static DEVICE_ATTR_RW(mem_pool_max_size);
34893599
34903600 /**
3491
- * show_lp_mem_pool_size - Show size of the large memory pages pool.
3601
+ * lp_mem_pool_size_show - Show size of the large memory pages pool.
34923602 * @dev: The device this sysfs file is for.
34933603 * @attr: The attributes of the sysfs file.
34943604 * @buf: The output buffer to receive the pool size.
....@@ -3497,7 +3607,7 @@
34973607 *
34983608 * Return: The number of bytes output to @buf.
34993609 */
3500
-static ssize_t show_lp_mem_pool_size(struct device *dev,
3610
+static ssize_t lp_mem_pool_size_show(struct device *dev,
35013611 struct device_attribute *attr, char * const buf)
35023612 {
35033613 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3511,7 +3621,7 @@
35113621 }
35123622
35133623 /**
3514
- * set_lp_mem_pool_size - Set size of the large memory pages pool.
3624
+ * lp_mem_pool_size_store - Set size of the large memory pages pool.
35153625 * @dev: The device this sysfs file is for.
35163626 * @attr: The attributes of the sysfs file.
35173627 * @buf: The value written to the sysfs file.
....@@ -3522,7 +3632,7 @@
35223632 *
35233633 * Return: @count if the function succeeded. An error code on failure.
35243634 */
3525
-static ssize_t set_lp_mem_pool_size(struct device *dev,
3635
+static ssize_t lp_mem_pool_size_store(struct device *dev,
35263636 struct device_attribute *attr, const char *buf, size_t count)
35273637 {
35283638 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3538,11 +3648,10 @@
35383648 return err ? err : count;
35393649 }
35403650
3541
-static DEVICE_ATTR(lp_mem_pool_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_size,
3542
- set_lp_mem_pool_size);
3651
+static DEVICE_ATTR_RW(lp_mem_pool_size);
35433652
35443653 /**
3545
- * show_lp_mem_pool_max_size - Show maximum size of the large memory pages pool.
3654
+ * lp_mem_pool_max_size_show - Show maximum size of the large memory pages pool.
35463655 * @dev: The device this sysfs file is for.
35473656 * @attr: The attributes of the sysfs file.
35483657 * @buf: The output buffer to receive the pool size.
....@@ -3551,7 +3660,7 @@
35513660 *
35523661 * Return: The number of bytes output to @buf.
35533662 */
3554
-static ssize_t show_lp_mem_pool_max_size(struct device *dev,
3663
+static ssize_t lp_mem_pool_max_size_show(struct device *dev,
35553664 struct device_attribute *attr, char * const buf)
35563665 {
35573666 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3565,7 +3674,7 @@
35653674 }
35663675
35673676 /**
3568
- * set_lp_mem_pool_max_size - Set maximum size of the large memory pages pool.
3677
+ * lp_mem_pool_max_size_store - Set maximum size of the large memory pages pool.
35693678 * @dev: The device this sysfs file is for.
35703679 * @attr: The attributes of the sysfs file.
35713680 * @buf: The value written to the sysfs file.
....@@ -3575,7 +3684,7 @@
35753684 *
35763685 * Return: @count if the function succeeded. An error code on failure.
35773686 */
3578
-static ssize_t set_lp_mem_pool_max_size(struct device *dev,
3687
+static ssize_t lp_mem_pool_max_size_store(struct device *dev,
35793688 struct device_attribute *attr, const char *buf, size_t count)
35803689 {
35813690 struct kbase_device *const kbdev = to_kbase_device(dev);
....@@ -3591,8 +3700,7 @@
35913700 return err ? err : count;
35923701 }
35933702
3594
-static DEVICE_ATTR(lp_mem_pool_max_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_max_size,
3595
- set_lp_mem_pool_max_size);
3703
+static DEVICE_ATTR_RW(lp_mem_pool_max_size);
35963704
35973705 /**
35983706 * show_simplified_mem_pool_max_size - Show the maximum size for the memory
....@@ -3793,7 +3901,7 @@
37933901
37943902 #if !MALI_USE_CSF
37953903 /**
3796
- * show_js_ctx_scheduling_mode - Show callback for js_ctx_scheduling_mode sysfs
3904
+ * js_ctx_scheduling_mode_show - Show callback for js_ctx_scheduling_mode sysfs
37973905 * entry.
37983906 * @dev: The device this sysfs file is for.
37993907 * @attr: The attributes of the sysfs file.
....@@ -3803,7 +3911,7 @@
38033911 *
38043912 * Return: The number of bytes output to @buf.
38053913 */
3806
-static ssize_t show_js_ctx_scheduling_mode(struct device *dev,
3914
+static ssize_t js_ctx_scheduling_mode_show(struct device *dev,
38073915 struct device_attribute *attr, char * const buf)
38083916 {
38093917 struct kbase_device *kbdev;
....@@ -3816,7 +3924,7 @@
38163924 }
38173925
38183926 /**
3819
- * set_js_ctx_scheduling_mode - Set callback for js_ctx_scheduling_mode sysfs
3927
+ * js_ctx_scheduling_mode_store - Set callback for js_ctx_scheduling_mode sysfs
38203928 * entry.
38213929 * @dev: The device this sysfs file is for.
38223930 * @attr: The attributes of the sysfs file.
....@@ -3829,7 +3937,7 @@
38293937 *
38303938 * Return: @count if the function succeeded. An error code on failure.
38313939 */
3832
-static ssize_t set_js_ctx_scheduling_mode(struct device *dev,
3940
+static ssize_t js_ctx_scheduling_mode_store(struct device *dev,
38333941 struct device_attribute *attr, const char *buf, size_t count)
38343942 {
38353943 struct kbase_context *kctx;
....@@ -3871,11 +3979,7 @@
38713979 return count;
38723980 }
38733981
3874
-static DEVICE_ATTR(js_ctx_scheduling_mode, S_IRUGO | S_IWUSR,
3875
- show_js_ctx_scheduling_mode,
3876
- set_js_ctx_scheduling_mode);
3877
-
3878
-#ifdef MALI_KBASE_BUILD
3982
+static DEVICE_ATTR_RW(js_ctx_scheduling_mode);
38793983
38803984 /* Number of entries in serialize_jobs_settings[] */
38813985 #define NR_SERIALIZE_JOBS_SETTINGS 5
....@@ -3899,14 +4003,14 @@
38994003 * update_serialize_jobs_setting - Update the serialization setting for the
39004004 * submission of GPU jobs.
39014005 *
3902
- * This function is called when the serialize_jobs sysfs/debugfs file is
3903
- * written to. It matches the requested setting against the available settings
3904
- * and if a matching setting is found updates kbdev->serialize_jobs.
3905
- *
39064006 * @kbdev: An instance of the GPU platform device, allocated from the probe
39074007 * method of the driver.
39084008 * @buf: Buffer containing the value written to the sysfs/debugfs file.
39094009 * @count: The number of bytes to write to the sysfs/debugfs file.
4010
+ *
4011
+ * This function is called when the serialize_jobs sysfs/debugfs file is
4012
+ * written to. It matches the requested setting against the available settings
4013
+ * and if a matching setting is found updates kbdev->serialize_jobs.
39104014 *
39114015 * Return: @count if the function succeeded. An error code on failure.
39124016 */
....@@ -4029,13 +4133,13 @@
40294133 /**
40304134 * show_serialize_jobs_sysfs - Show callback for serialize_jobs sysfs file.
40314135 *
4032
- * This function is called to get the contents of the serialize_jobs sysfs
4033
- * file. This is a list of the available settings with the currently active
4034
- * one surrounded by square brackets.
4035
- *
40364136 * @dev: The device this sysfs file is for
40374137 * @attr: The attributes of the sysfs file
40384138 * @buf: The output buffer for the sysfs file contents
4139
+ *
4140
+ * This function is called to get the contents of the serialize_jobs sysfs
4141
+ * file. This is a list of the available settings with the currently active
4142
+ * one surrounded by square brackets.
40394143 *
40404144 * Return: The number of bytes output to @buf.
40414145 */
....@@ -4071,14 +4175,14 @@
40714175 /**
40724176 * store_serialize_jobs_sysfs - Store callback for serialize_jobs sysfs file.
40734177 *
4074
- * This function is called when the serialize_jobs sysfs file is written to.
4075
- * It matches the requested setting against the available settings and if a
4076
- * matching setting is found updates kbdev->serialize_jobs.
4077
- *
40784178 * @dev: The device this sysfs file is for
40794179 * @attr: The attributes of the sysfs file
40804180 * @buf: The value written to the sysfs file
40814181 * @count: The number of bytes to write to the sysfs file
4182
+ *
4183
+ * This function is called when the serialize_jobs sysfs file is written to.
4184
+ * It matches the requested setting against the available settings and if a
4185
+ * matching setting is found updates kbdev->serialize_jobs.
40824186 *
40834187 * Return: @count if the function succeeded. An error code on failure.
40844188 */
....@@ -4091,7 +4195,6 @@
40914195
40924196 static DEVICE_ATTR(serialize_jobs, 0600, show_serialize_jobs_sysfs,
40934197 store_serialize_jobs_sysfs);
4094
-#endif /* MALI_KBASE_BUILD */
40954198 #endif /* !MALI_USE_CSF */
40964199
40974200 static void kbasep_protected_mode_hwcnt_disable_worker(struct work_struct *data)
....@@ -4187,6 +4290,15 @@
41874290 kfree(kbdev->protected_dev);
41884291 }
41894292
4293
+#if IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
4294
+static int kbase_common_reg_map(struct kbase_device *kbdev)
4295
+{
4296
+ return 0;
4297
+}
4298
+static void kbase_common_reg_unmap(struct kbase_device * const kbdev)
4299
+{
4300
+}
4301
+#else /* !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) */
41904302 static int kbase_common_reg_map(struct kbase_device *kbdev)
41914303 {
41924304 int err = 0;
....@@ -4222,6 +4334,7 @@
42224334 kbdev->reg_size = 0;
42234335 }
42244336 }
4337
+#endif /* !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) */
42254338
42264339 int registers_map(struct kbase_device * const kbdev)
42274340 {
....@@ -4350,8 +4463,8 @@
43504463 kbase_pm_register_access_enable(kbdev);
43514464 gpu_id = kbase_reg_read(kbdev, GPU_CONTROL_REG(GPU_ID));
43524465 kbase_pm_register_access_disable(kbdev);
4353
- product_id = KBASE_UBFX32(gpu_id,
4354
- GPU_ID_VERSION_PRODUCT_ID_SHIFT, 16);
4466
+ product_id =
4467
+ KBASE_UBFX32(gpu_id, KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT, 16);
43554468 gpu_model_id = GPU_ID2_MODEL_MATCH_VALUE(product_id);
43564469
43574470 if (gpu_model_id != GPU_ID2_PRODUCT_TGOX
....@@ -4403,10 +4516,9 @@
44034516 int err = 0;
44044517 unsigned int i;
44054518 #if defined(CONFIG_REGULATOR)
4406
- static const char *regulator_names[] = {
4407
- "mali", "shadercores"
4519
+ static const char * const regulator_names[] = {
4520
+ "mali", "mem"
44084521 };
4409
- BUILD_BUG_ON(ARRAY_SIZE(regulator_names) < BASE_MAX_NR_CLOCKS_REGULATORS);
44104522 #endif /* CONFIG_REGULATOR */
44114523
44124524 if (!kbdev)
....@@ -4422,17 +4534,17 @@
44224534 * Any other error is ignored and the driver will continue
44234535 * operating with a partial initialization of regulators.
44244536 */
4425
- for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
4537
+ for (i = 0; i < ARRAY_SIZE(regulator_names); i++) {
44264538 kbdev->regulators[i] = regulator_get_optional(kbdev->dev,
44274539 regulator_names[i]);
4428
- if (IS_ERR_OR_NULL(kbdev->regulators[i])) {
4540
+ if (IS_ERR(kbdev->regulators[i])) {
44294541 err = PTR_ERR(kbdev->regulators[i]);
44304542 kbdev->regulators[i] = NULL;
44314543 break;
44324544 }
44334545 }
44344546 if (err == -EPROBE_DEFER) {
4435
- while ((i > 0) && (i < BASE_MAX_NR_CLOCKS_REGULATORS))
4547
+ while (i > 0)
44364548 regulator_put(kbdev->regulators[--i]);
44374549 return err;
44384550 }
....@@ -4453,7 +4565,7 @@
44534565 */
44544566 for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
44554567 kbdev->clocks[i] = of_clk_get(kbdev->dev->of_node, i);
4456
- if (IS_ERR_OR_NULL(kbdev->clocks[i])) {
4568
+ if (IS_ERR(kbdev->clocks[i])) {
44574569 err = PTR_ERR(kbdev->clocks[i]);
44584570 kbdev->clocks[i] = NULL;
44594571 break;
....@@ -4469,8 +4581,8 @@
44694581 }
44704582 }
44714583 if (err == -EPROBE_DEFER) {
4472
- while ((i > 0) && (i < BASE_MAX_NR_CLOCKS_REGULATORS)) {
4473
- clk_unprepare(kbdev->clocks[--i]);
4584
+ while (i > 0) {
4585
+ clk_disable_unprepare(kbdev->clocks[--i]);
44744586 clk_put(kbdev->clocks[i]);
44754587 }
44764588 goto clocks_probe_defer;
....@@ -4485,13 +4597,39 @@
44854597 * from completing its initialization.
44864598 */
44874599 #if defined(CONFIG_PM_OPP)
4488
-#if ((KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE) && \
4489
- defined(CONFIG_REGULATOR))
4600
+#if defined(CONFIG_REGULATOR)
4601
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
44904602 if (kbdev->nr_regulators > 0) {
4491
- kbdev->opp_table = dev_pm_opp_set_regulators(kbdev->dev,
4492
- regulator_names, BASE_MAX_NR_CLOCKS_REGULATORS);
4603
+ kbdev->token = dev_pm_opp_set_regulators(kbdev->dev, regulator_names);
4604
+
4605
+ if (kbdev->token < 0) {
4606
+ err = kbdev->token;
4607
+ goto regulators_probe_defer;
4608
+ }
4609
+
44934610 }
4494
-#endif /* (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE */
4611
+#elif (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE)
4612
+ if (kbdev->nr_regulators > 0) {
4613
+ kbdev->opp_table =
4614
+ dev_pm_opp_set_regulators(kbdev->dev, regulator_names,
4615
+ kbdev->nr_regulators);
4616
+ if (IS_ERR(kbdev->opp_table)) {
4617
+ dev_err(kbdev->dev, "Failed to set regulators\n");
4618
+ return 0;
4619
+ }
4620
+ kbdev->opp_table =
4621
+ dev_pm_opp_register_set_opp_helper(kbdev->dev,
4622
+ kbase_devfreq_opp_helper);
4623
+ if (IS_ERR(kbdev->opp_table)) {
4624
+ dev_pm_opp_put_regulators(kbdev->opp_table);
4625
+ kbdev->opp_table = NULL;
4626
+ dev_err(kbdev->dev, "Failed to set opp helper\n");
4627
+ return 0;
4628
+ }
4629
+ }
4630
+#endif /* (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE) */
4631
+#endif /* CONFIG_REGULATOR */
4632
+
44954633 #ifdef CONFIG_ARCH_ROCKCHIP
44964634 err = kbase_platform_rk_init_opp_table(kbdev);
44974635 if (err)
....@@ -4502,6 +4640,19 @@
45024640 #endif
45034641 #endif /* CONFIG_PM_OPP */
45044642 return 0;
4643
+
4644
+#if defined(CONFIG_PM_OPP) && \
4645
+ ((KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE) && defined(CONFIG_REGULATOR))
4646
+ for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
4647
+ if (kbdev->clocks[i]) {
4648
+ if (__clk_is_enabled(kbdev->clocks[i]))
4649
+ clk_disable_unprepare(kbdev->clocks[i]);
4650
+ clk_put(kbdev->clocks[i]);
4651
+ kbdev->clocks[i] = NULL;
4652
+ } else
4653
+ break;
4654
+ }
4655
+#endif
45054656
45064657 clocks_probe_defer:
45074658 #if defined(CONFIG_REGULATOR)
....@@ -4518,11 +4669,17 @@
45184669
45194670 #if defined(CONFIG_PM_OPP)
45204671 dev_pm_opp_of_remove_table(kbdev->dev);
4521
-#if ((KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE) && \
4522
- defined(CONFIG_REGULATOR))
4672
+#if defined(CONFIG_REGULATOR)
4673
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
4674
+ if (kbdev->token > -EPERM) {
4675
+ dev_pm_opp_unregister_set_opp_helper(kbdev->opp_table);
4676
+ dev_pm_opp_put_regulators(kbdev->token);
4677
+ }
4678
+#elif (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE)
45234679 if (!IS_ERR_OR_NULL(kbdev->opp_table))
45244680 dev_pm_opp_put_regulators(kbdev->opp_table);
4525
-#endif /* (KERNEL_VERSION(4, 10, 0) <= LINUX_VERSION_CODE */
4681
+#endif /* (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE) */
4682
+#endif /* CONFIG_REGULATOR */
45264683 #endif /* CONFIG_PM_OPP */
45274684
45284685 for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) {
....@@ -4544,7 +4701,6 @@
45444701 #endif
45454702 }
45464703
4547
-#ifdef MALI_KBASE_BUILD
45484704 #if IS_ENABLED(CONFIG_DEBUG_FS)
45494705
45504706 static void trigger_reset(struct kbase_device *kbdev)
....@@ -4562,43 +4718,48 @@
45624718 kbdev = (struct kbase_device *)data; \
45634719 kbdev->hw_quirks_##type = (u32)val; \
45644720 trigger_reset(kbdev); \
4565
- return 0;\
4721
+ return 0; \
45664722 } \
45674723 \
45684724 static int type##_quirks_get(void *data, u64 *val) \
45694725 { \
4570
- struct kbase_device *kbdev;\
4571
- kbdev = (struct kbase_device *)data;\
4572
- *val = kbdev->hw_quirks_##type;\
4573
- return 0;\
4726
+ struct kbase_device *kbdev; \
4727
+ kbdev = (struct kbase_device *)data; \
4728
+ *val = kbdev->hw_quirks_##type; \
4729
+ return 0; \
45744730 } \
4575
-DEFINE_SIMPLE_ATTRIBUTE(fops_##type##_quirks, type##_quirks_get,\
4576
- type##_quirks_set, "%llu\n")
4731
+DEFINE_DEBUGFS_ATTRIBUTE(fops_##type##_quirks, type##_quirks_get, \
4732
+ type##_quirks_set, "%llu\n")
45774733
45784734 MAKE_QUIRK_ACCESSORS(sc);
45794735 MAKE_QUIRK_ACCESSORS(tiler);
45804736 MAKE_QUIRK_ACCESSORS(mmu);
45814737 MAKE_QUIRK_ACCESSORS(gpu);
45824738
4583
-static ssize_t kbase_device_debugfs_reset_write(struct file *file,
4584
- const char __user *ubuf, size_t count, loff_t *ppos)
4739
+/**
4740
+ * kbase_device_debugfs_reset_write() - Reset the GPU
4741
+ *
4742
+ * @data: Pointer to the Kbase device.
4743
+ * @wait_for_reset: Value written to the file.
4744
+ *
4745
+ * This function will perform the GPU reset, and if the value written to
4746
+ * the file is 1 it will also wait for the reset to complete.
4747
+ *
4748
+ * Return: 0 in case of no error otherwise a negative value.
4749
+ */
4750
+static int kbase_device_debugfs_reset_write(void *data, u64 wait_for_reset)
45854751 {
4586
- struct kbase_device *kbdev = file->private_data;
4587
- CSTD_UNUSED(ubuf);
4588
- CSTD_UNUSED(count);
4589
- CSTD_UNUSED(ppos);
4752
+ struct kbase_device *kbdev = data;
45904753
45914754 trigger_reset(kbdev);
45924755
4593
- return count;
4756
+ if (wait_for_reset == 1)
4757
+ return kbase_reset_gpu_wait(kbdev);
4758
+
4759
+ return 0;
45944760 }
45954761
4596
-static const struct file_operations fops_trigger_reset = {
4597
- .owner = THIS_MODULE,
4598
- .open = simple_open,
4599
- .write = kbase_device_debugfs_reset_write,
4600
- .llseek = default_llseek,
4601
-};
4762
+DEFINE_DEBUGFS_ATTRIBUTE(fops_trigger_reset, NULL, &kbase_device_debugfs_reset_write, "%llu\n");
46024763
46034764 /**
46044765 * debugfs_protected_debug_mode_read - "protected_debug_mode" debugfs read
....@@ -4682,57 +4843,84 @@
46824843 .release = single_release,
46834844 };
46844845
4685
-int kbase_device_debugfs_init(struct kbase_device *kbdev)
4846
+/**
4847
+ * debugfs_ctx_defaults_init - Create the default configuration of new contexts in debugfs
4848
+ * @kbdev: An instance of the GPU platform device, allocated from the probe method of the driver.
4849
+ * Return: A pointer to the last dentry that it tried to create, whether successful or not.
4850
+ * Could be NULL or encode another error value.
4851
+ */
4852
+static struct dentry *debugfs_ctx_defaults_init(struct kbase_device *const kbdev)
46864853 {
4687
- struct dentry *debugfs_ctx_defaults_directory;
4688
- int err;
46894854 /* prevent unprivileged use of debug file system
46904855 * in old kernel version
46914856 */
4692
-#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE)
4693
- /* only for newer kernel version debug file system is safe */
46944857 const mode_t mode = 0644;
4695
-#else
4696
- const mode_t mode = 0600;
4697
-#endif
4858
+ struct dentry *dentry = debugfs_create_dir("defaults", kbdev->debugfs_ctx_directory);
4859
+ struct dentry *debugfs_ctx_defaults_directory = dentry;
46984860
4699
- kbdev->mali_debugfs_directory = debugfs_create_dir(kbdev->devname,
4700
- NULL);
4701
- if (!kbdev->mali_debugfs_directory) {
4861
+ if (IS_ERR_OR_NULL(dentry)) {
4862
+ dev_err(kbdev->dev, "Couldn't create mali debugfs ctx defaults directory\n");
4863
+ return dentry;
4864
+ }
4865
+
4866
+ debugfs_create_bool("infinite_cache", mode,
4867
+ debugfs_ctx_defaults_directory,
4868
+ &kbdev->infinite_cache_active_default);
4869
+
4870
+ dentry = debugfs_create_file("mem_pool_max_size", mode, debugfs_ctx_defaults_directory,
4871
+ &kbdev->mem_pool_defaults.small,
4872
+ &kbase_device_debugfs_mem_pool_max_size_fops);
4873
+ if (IS_ERR_OR_NULL(dentry)) {
4874
+ dev_err(kbdev->dev, "Unable to create mem_pool_max_size debugfs entry\n");
4875
+ return dentry;
4876
+ }
4877
+
4878
+ dentry = debugfs_create_file("lp_mem_pool_max_size", mode, debugfs_ctx_defaults_directory,
4879
+ &kbdev->mem_pool_defaults.large,
4880
+ &kbase_device_debugfs_mem_pool_max_size_fops);
4881
+ if (IS_ERR_OR_NULL(dentry))
4882
+ dev_err(kbdev->dev, "Unable to create lp_mem_pool_max_size debugfs entry\n");
4883
+
4884
+ return dentry;
4885
+}
4886
+
4887
+/**
4888
+ * init_debugfs - Create device-wide debugfs directories and files for the Mali driver
4889
+ * @kbdev: An instance of the GPU platform device, allocated from the probe method of the driver.
4890
+ * Return: A pointer to the last dentry that it tried to create, whether successful or not.
4891
+ * Could be NULL or encode another error value.
4892
+ */
4893
+static struct dentry *init_debugfs(struct kbase_device *kbdev)
4894
+{
4895
+ struct dentry *dentry = debugfs_create_dir(kbdev->devname, NULL);
4896
+
4897
+ kbdev->mali_debugfs_directory = dentry;
4898
+ if (IS_ERR_OR_NULL(dentry)) {
47024899 dev_err(kbdev->dev,
47034900 "Couldn't create mali debugfs directory: %s\n",
47044901 kbdev->devname);
4705
- err = -ENOMEM;
4706
- goto out;
4902
+ return dentry;
47074903 }
47084904
4709
- kbdev->debugfs_ctx_directory = debugfs_create_dir("ctx",
4710
- kbdev->mali_debugfs_directory);
4711
- if (!kbdev->debugfs_ctx_directory) {
4905
+ dentry = debugfs_create_dir("ctx", kbdev->mali_debugfs_directory);
4906
+ kbdev->debugfs_ctx_directory = dentry;
4907
+ if (IS_ERR_OR_NULL(dentry)) {
47124908 dev_err(kbdev->dev, "Couldn't create mali debugfs ctx directory\n");
4713
- err = -ENOMEM;
4714
- goto out;
4909
+ return dentry;
47154910 }
47164911
4717
- kbdev->debugfs_instr_directory = debugfs_create_dir("instrumentation",
4718
- kbdev->mali_debugfs_directory);
4719
- if (!kbdev->debugfs_instr_directory) {
4912
+ dentry = debugfs_create_dir("instrumentation", kbdev->mali_debugfs_directory);
4913
+ kbdev->debugfs_instr_directory = dentry;
4914
+ if (IS_ERR_OR_NULL(dentry)) {
47204915 dev_err(kbdev->dev, "Couldn't create mali debugfs instrumentation directory\n");
4721
- err = -ENOMEM;
4722
- goto out;
4723
- }
4724
-
4725
- debugfs_ctx_defaults_directory = debugfs_create_dir("defaults",
4726
- kbdev->debugfs_ctx_directory);
4727
- if (!debugfs_ctx_defaults_directory) {
4728
- dev_err(kbdev->dev, "Couldn't create mali debugfs ctx defaults directory\n");
4729
- err = -ENOMEM;
4730
- goto out;
4916
+ return dentry;
47314917 }
47324918
47334919 kbasep_regs_history_debugfs_init(kbdev);
47344920
4735
-#if !MALI_USE_CSF
4921
+#if MALI_USE_CSF
4922
+ kbase_debug_csf_fault_debugfs_init(kbdev);
4923
+#else /* MALI_USE_CSF */
47364924 kbase_debug_job_fault_debugfs_init(kbdev);
47374925 #endif /* !MALI_USE_CSF */
47384926
....@@ -4741,67 +4929,99 @@
47414929 #ifdef CONFIG_MALI_PRFCNT_SET_SELECT_VIA_DEBUG_FS
47424930 kbase_instr_backend_debugfs_init(kbdev);
47434931 #endif
4932
+ kbase_pbha_debugfs_init(kbdev);
4933
+
47444934 /* fops_* variables created by invocations of macro
47454935 * MAKE_QUIRK_ACCESSORS() above.
47464936 */
4747
- debugfs_create_file("quirks_sc", 0644,
4937
+ dentry = debugfs_create_file("quirks_sc", 0644,
47484938 kbdev->mali_debugfs_directory, kbdev,
47494939 &fops_sc_quirks);
4750
- debugfs_create_file("quirks_tiler", 0644,
4751
- kbdev->mali_debugfs_directory, kbdev,
4752
- &fops_tiler_quirks);
4753
- debugfs_create_file("quirks_mmu", 0644,
4754
- kbdev->mali_debugfs_directory, kbdev,
4755
- &fops_mmu_quirks);
4756
- debugfs_create_file("quirks_gpu", 0644, kbdev->mali_debugfs_directory,
4757
- kbdev, &fops_gpu_quirks);
4758
-
4759
- debugfs_create_bool("infinite_cache", mode,
4760
- debugfs_ctx_defaults_directory,
4761
- &kbdev->infinite_cache_active_default);
4762
-
4763
- debugfs_create_file("mem_pool_max_size", mode,
4764
- debugfs_ctx_defaults_directory,
4765
- &kbdev->mem_pool_defaults.small,
4766
- &kbase_device_debugfs_mem_pool_max_size_fops);
4767
-
4768
- debugfs_create_file("lp_mem_pool_max_size", mode,
4769
- debugfs_ctx_defaults_directory,
4770
- &kbdev->mem_pool_defaults.large,
4771
- &kbase_device_debugfs_mem_pool_max_size_fops);
4772
-
4773
- if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_PROTECTED_DEBUG_MODE)) {
4774
- debugfs_create_file("protected_debug_mode", S_IRUGO,
4775
- kbdev->mali_debugfs_directory, kbdev,
4776
- &fops_protected_debug_mode);
4940
+ if (IS_ERR_OR_NULL(dentry)) {
4941
+ dev_err(kbdev->dev, "Unable to create quirks_sc debugfs entry\n");
4942
+ return dentry;
47774943 }
47784944
4779
- debugfs_create_file("reset", 0644,
4945
+ dentry = debugfs_create_file("quirks_tiler", 0644,
4946
+ kbdev->mali_debugfs_directory, kbdev,
4947
+ &fops_tiler_quirks);
4948
+ if (IS_ERR_OR_NULL(dentry)) {
4949
+ dev_err(kbdev->dev, "Unable to create quirks_tiler debugfs entry\n");
4950
+ return dentry;
4951
+ }
4952
+
4953
+ dentry = debugfs_create_file("quirks_mmu", 0644,
4954
+ kbdev->mali_debugfs_directory, kbdev,
4955
+ &fops_mmu_quirks);
4956
+ if (IS_ERR_OR_NULL(dentry)) {
4957
+ dev_err(kbdev->dev, "Unable to create quirks_mmu debugfs entry\n");
4958
+ return dentry;
4959
+ }
4960
+
4961
+ dentry = debugfs_create_file("quirks_gpu", 0644, kbdev->mali_debugfs_directory,
4962
+ kbdev, &fops_gpu_quirks);
4963
+ if (IS_ERR_OR_NULL(dentry)) {
4964
+ dev_err(kbdev->dev, "Unable to create quirks_gpu debugfs entry\n");
4965
+ return dentry;
4966
+ }
4967
+
4968
+ dentry = debugfs_ctx_defaults_init(kbdev);
4969
+ if (IS_ERR_OR_NULL(dentry))
4970
+ return dentry;
4971
+
4972
+ if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_PROTECTED_DEBUG_MODE)) {
4973
+ dentry = debugfs_create_file("protected_debug_mode", 0444,
4974
+ kbdev->mali_debugfs_directory, kbdev,
4975
+ &fops_protected_debug_mode);
4976
+ if (IS_ERR_OR_NULL(dentry)) {
4977
+ dev_err(kbdev->dev, "Unable to create protected_debug_mode debugfs entry\n");
4978
+ return dentry;
4979
+ }
4980
+ }
4981
+
4982
+ dentry = debugfs_create_file("reset", 0644,
47804983 kbdev->mali_debugfs_directory, kbdev,
47814984 &fops_trigger_reset);
4985
+ if (IS_ERR_OR_NULL(dentry)) {
4986
+ dev_err(kbdev->dev, "Unable to create reset debugfs entry\n");
4987
+ return dentry;
4988
+ }
47824989
47834990 kbase_ktrace_debugfs_init(kbdev);
47844991
47854992 #ifdef CONFIG_MALI_BIFROST_DEVFREQ
47864993 #if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
4787
- if (kbdev->devfreq && !kbdev->model_data)
4994
+ if (kbdev->devfreq && !kbdev->model_data &&
4995
+ !kbdev->dfc_power.dyn_power_coeff)
47884996 kbase_ipa_debugfs_init(kbdev);
47894997 #endif /* CONFIG_DEVFREQ_THERMAL */
47904998 #endif /* CONFIG_MALI_BIFROST_DEVFREQ */
47914999
47925000 #if !MALI_USE_CSF
4793
- debugfs_create_file("serialize_jobs", S_IRUGO | S_IWUSR,
5001
+ dentry = debugfs_create_file("serialize_jobs", 0644,
47945002 kbdev->mali_debugfs_directory, kbdev,
47955003 &kbasep_serialize_jobs_debugfs_fops);
4796
-
5004
+ if (IS_ERR_OR_NULL(dentry)) {
5005
+ dev_err(kbdev->dev, "Unable to create serialize_jobs debugfs entry\n");
5006
+ return dentry;
5007
+ }
5008
+ kbase_timeline_io_debugfs_init(kbdev);
47975009 #endif
47985010 kbase_dvfs_status_debugfs_init(kbdev);
47995011
4800
- return 0;
48015012
4802
-out:
4803
- debugfs_remove_recursive(kbdev->mali_debugfs_directory);
4804
- return err;
5013
+ return dentry;
5014
+}
5015
+
5016
+int kbase_device_debugfs_init(struct kbase_device *kbdev)
5017
+{
5018
+ struct dentry *dentry = init_debugfs(kbdev);
5019
+
5020
+ if (IS_ERR_OR_NULL(dentry)) {
5021
+ debugfs_remove_recursive(kbdev->mali_debugfs_directory);
5022
+ return IS_ERR(dentry) ? PTR_ERR(dentry) : -ENOMEM;
5023
+ }
5024
+ return 0;
48055025 }
48065026
48075027 void kbase_device_debugfs_term(struct kbase_device *kbdev)
....@@ -4809,7 +5029,6 @@
48095029 debugfs_remove_recursive(kbdev->mali_debugfs_directory);
48105030 }
48115031 #endif /* CONFIG_DEBUG_FS */
4812
-#endif /* MALI_KBASE_BUILD */
48135032
48145033 int kbase_device_coherency_init(struct kbase_device *kbdev)
48155034 {
....@@ -4817,12 +5036,13 @@
48175036 u32 supported_coherency_bitmap =
48185037 kbdev->gpu_props.props.raw_props.coherency_mode;
48195038 const void *coherency_override_dts;
5039
+ bool dma_coherent;
48205040 u32 override_coherency, gpu_id;
48215041 unsigned int prod_id;
48225042
48235043 gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
48245044 gpu_id &= GPU_ID_VERSION_PRODUCT_ID;
4825
- prod_id = gpu_id >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
5045
+ prod_id = gpu_id >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
48265046
48275047 /* Only for tMIx :
48285048 * (COHERENCY_ACE_LITE | COHERENCY_ACE) was incorrectly
....@@ -4841,12 +5061,23 @@
48415061
48425062 /* device tree may override the coherency */
48435063 #if IS_ENABLED(CONFIG_OF)
5064
+ /* treat "dma-coherency" as a synonym for ACE-lite */
5065
+ dma_coherent = of_dma_is_coherent(kbdev->dev->of_node);
48445066 coherency_override_dts = of_get_property(kbdev->dev->of_node,
48455067 "system-coherency",
48465068 NULL);
4847
- if (coherency_override_dts) {
4848
-
4849
- override_coherency = be32_to_cpup(coherency_override_dts);
5069
+ if (coherency_override_dts || dma_coherent) {
5070
+ if (coherency_override_dts) {
5071
+ override_coherency = be32_to_cpup(coherency_override_dts);
5072
+ if (dma_coherent && override_coherency != COHERENCY_ACE_LITE) {
5073
+ dev_err(kbdev->dev,
5074
+ "system-coherency needs to be 0 when dma-coherent is set\n");
5075
+ return -EINVAL;
5076
+ }
5077
+ } else {
5078
+ /* dma-coherent set and system-coherency not specified */
5079
+ override_coherency = COHERENCY_ACE_LITE;
5080
+ }
48505081
48515082 #if MALI_USE_CSF && !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
48525083 /* ACE coherency mode is not supported by Driver on CSF GPUs.
....@@ -4954,8 +5185,7 @@
49545185 return ret;
49555186 }
49565187
4957
-static DEVICE_ATTR(csg_scheduling_period, 0644, csg_scheduling_period_show,
4958
- csg_scheduling_period_store);
5188
+static DEVICE_ATTR_RW(csg_scheduling_period);
49595189
49605190 /**
49615191 * fw_timeout_store - Store callback for the fw_timeout sysfs file.
....@@ -4983,10 +5213,11 @@
49835213
49845214 ret = kstrtouint(buf, 0, &fw_timeout);
49855215 if (ret || fw_timeout == 0) {
4986
- dev_err(kbdev->dev, "%s\n%s\n%u",
4987
- "Couldn't process fw_timeout write operation.",
4988
- "Use format 'fw_timeout_ms', and fw_timeout_ms > 0",
4989
- FIRMWARE_PING_INTERVAL_MS);
5216
+ dev_err(kbdev->dev,
5217
+ "Couldn't process fw_timeout write operation.\n"
5218
+ "Use format 'fw_timeout_ms', and fw_timeout_ms > 0\n"
5219
+ "Default fw_timeout: %u",
5220
+ kbase_get_timeout_ms(kbdev, CSF_FIRMWARE_PING_TIMEOUT));
49905221 return -EINVAL;
49915222 }
49925223
....@@ -5023,7 +5254,133 @@
50235254 return ret;
50245255 }
50255256
5026
-static DEVICE_ATTR(fw_timeout, 0644, fw_timeout_show, fw_timeout_store);
5257
+static DEVICE_ATTR_RW(fw_timeout);
5258
+
5259
+/**
5260
+ * idle_hysteresis_time_store - Store callback for CSF idle_hysteresis_time
5261
+ * sysfs file.
5262
+ * @dev: The device with sysfs file is for
5263
+ * @attr: The attributes of the sysfs file
5264
+ * @buf: The value written to the sysfs file
5265
+ * @count: The number of bytes written to the sysfs file
5266
+ *
5267
+ * This function is called when the idle_hysteresis_time sysfs file is
5268
+ * written to.
5269
+ *
5270
+ * This file contains values of the idle hysteresis duration.
5271
+ *
5272
+ * Return: @count if the function succeeded. An error code on failure.
5273
+ */
5274
+static ssize_t idle_hysteresis_time_store(struct device *dev,
5275
+ struct device_attribute *attr, const char *buf, size_t count)
5276
+{
5277
+ struct kbase_device *kbdev;
5278
+ u32 dur = 0;
5279
+
5280
+ kbdev = to_kbase_device(dev);
5281
+ if (!kbdev)
5282
+ return -ENODEV;
5283
+
5284
+ if (kstrtou32(buf, 0, &dur)) {
5285
+ dev_err(kbdev->dev, "Couldn't process idle_hysteresis_time write operation.\n"
5286
+ "Use format <idle_hysteresis_time>\n");
5287
+ return -EINVAL;
5288
+ }
5289
+
5290
+ kbase_csf_firmware_set_gpu_idle_hysteresis_time(kbdev, dur);
5291
+
5292
+ return count;
5293
+}
5294
+
5295
+/**
5296
+ * idle_hysteresis_time_show - Show callback for CSF idle_hysteresis_time
5297
+ * sysfs entry.
5298
+ * @dev: The device this sysfs file is for.
5299
+ * @attr: The attributes of the sysfs file.
5300
+ * @buf: The output buffer to receive the GPU information.
5301
+ *
5302
+ * This function is called to get the current idle hysteresis duration in ms.
5303
+ *
5304
+ * Return: The number of bytes output to @buf.
5305
+ */
5306
+static ssize_t idle_hysteresis_time_show(struct device *dev,
5307
+ struct device_attribute *attr, char * const buf)
5308
+{
5309
+ struct kbase_device *kbdev;
5310
+ ssize_t ret;
5311
+ u32 dur;
5312
+
5313
+ kbdev = to_kbase_device(dev);
5314
+ if (!kbdev)
5315
+ return -ENODEV;
5316
+
5317
+ dur = kbase_csf_firmware_get_gpu_idle_hysteresis_time(kbdev);
5318
+ ret = scnprintf(buf, PAGE_SIZE, "%u\n", dur);
5319
+
5320
+ return ret;
5321
+}
5322
+
5323
+static DEVICE_ATTR_RW(idle_hysteresis_time);
5324
+
5325
+/**
5326
+ * mcu_shader_pwroff_timeout_show - Get the MCU shader Core power-off time value.
5327
+ *
5328
+ * @dev: The device this sysfs file is for.
5329
+ * @attr: The attributes of the sysfs file.
5330
+ * @buf: The output buffer for the sysfs file contents
5331
+ *
5332
+ * Get the internally recorded MCU shader Core power-off (nominal) timeout value.
5333
+ * The unit of the value is in micro-seconds.
5334
+ *
5335
+ * Return: The number of bytes output to @buf if the
5336
+ * function succeeded. A Negative value on failure.
5337
+ */
5338
+static ssize_t mcu_shader_pwroff_timeout_show(struct device *dev, struct device_attribute *attr,
5339
+ char *const buf)
5340
+{
5341
+ struct kbase_device *kbdev = dev_get_drvdata(dev);
5342
+ u32 pwroff;
5343
+
5344
+ if (!kbdev)
5345
+ return -ENODEV;
5346
+
5347
+ pwroff = kbase_csf_firmware_get_mcu_core_pwroff_time(kbdev);
5348
+ return scnprintf(buf, PAGE_SIZE, "%u\n", pwroff);
5349
+}
5350
+
5351
+/**
5352
+ * mcu_shader_pwroff_timeout_store - Set the MCU shader core power-off time value.
5353
+ *
5354
+ * @dev: The device with sysfs file is for
5355
+ * @attr: The attributes of the sysfs file
5356
+ * @buf: The value written to the sysfs file
5357
+ * @count: The number of bytes to write to the sysfs file
5358
+ *
5359
+ * The duration value (unit: micro-seconds) for configuring MCU Shader Core
5360
+ * timer, when the shader cores' power transitions are delegated to the
5361
+ * MCU (normal operational mode)
5362
+ *
5363
+ * Return: @count if the function succeeded. An error code on failure.
5364
+ */
5365
+static ssize_t mcu_shader_pwroff_timeout_store(struct device *dev, struct device_attribute *attr,
5366
+ const char *buf, size_t count)
5367
+{
5368
+ struct kbase_device *kbdev = dev_get_drvdata(dev);
5369
+ u32 dur;
5370
+
5371
+ if (!kbdev)
5372
+ return -ENODEV;
5373
+
5374
+ if (kstrtouint(buf, 0, &dur))
5375
+ return -EINVAL;
5376
+
5377
+ kbase_csf_firmware_set_mcu_core_pwroff_time(kbdev, dur);
5378
+
5379
+ return count;
5380
+}
5381
+
5382
+static DEVICE_ATTR_RW(mcu_shader_pwroff_timeout);
5383
+
50275384 #endif /* MALI_USE_CSF */
50285385
50295386 static struct attribute *kbase_scheduling_attrs[] = {
....@@ -5047,15 +5404,14 @@
50475404 &dev_attr_gpuinfo.attr,
50485405 &dev_attr_dvfs_period.attr,
50495406 &dev_attr_pm_poweroff.attr,
5050
-#if MALI_USE_CSF
5051
- &dev_attr_idle_hysteresis_time.attr,
5052
-#endif
50535407 &dev_attr_reset_timeout.attr,
50545408 #if !MALI_USE_CSF
50555409 &dev_attr_js_scheduling_period.attr,
50565410 #else
50575411 &dev_attr_csg_scheduling_period.attr,
50585412 &dev_attr_fw_timeout.attr,
5413
+ &dev_attr_idle_hysteresis_time.attr,
5414
+ &dev_attr_mcu_shader_pwroff_timeout.attr,
50595415 #endif /* !MALI_USE_CSF */
50605416 &dev_attr_power_policy.attr,
50615417 &dev_attr_core_mask.attr,
....@@ -5186,8 +5542,15 @@
51865542 }
51875543
51885544 kbdev->dev = &pdev->dev;
5189
- dev_set_drvdata(kbdev->dev, kbdev);
51905545
5546
+#if (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE)
5547
+ kbdev->token = -EPERM;
5548
+#endif /* (KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE) */
5549
+
5550
+ dev_set_drvdata(kbdev->dev, kbdev);
5551
+#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE)
5552
+ mutex_lock(&kbase_probe_mutex);
5553
+#endif
51915554 err = kbase_device_init(kbdev);
51925555
51935556 if (err) {
....@@ -5199,12 +5562,16 @@
51995562
52005563 dev_set_drvdata(kbdev->dev, NULL);
52015564 kbase_device_free(kbdev);
5565
+#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE)
5566
+ mutex_unlock(&kbase_probe_mutex);
5567
+#endif
52025568 } else {
5203
-#ifdef MALI_KBASE_BUILD
52045569 dev_info(kbdev->dev,
52055570 "Probed as %s\n", dev_name(kbdev->mdev.this_device));
5206
-#endif /* MALI_KBASE_BUILD */
52075571 kbase_increment_device_id();
5572
+#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE)
5573
+ mutex_unlock(&kbase_probe_mutex);
5574
+#endif
52085575 #ifdef CONFIG_MALI_ARBITER_SUPPORT
52095576 mutex_lock(&kbdev->pm.lock);
52105577 kbase_arbiter_pm_vm_event(kbdev, KBASE_VM_GPU_INITIALIZED_EVT);
....@@ -5220,11 +5587,11 @@
52205587 /**
52215588 * kbase_device_suspend - Suspend callback from the OS.
52225589 *
5223
- * This is called by Linux when the device should suspend.
5224
- *
52255590 * @dev: The device to suspend
52265591 *
5227
- * Return: A standard Linux error code
5592
+ * This is called by Linux when the device should suspend.
5593
+ *
5594
+ * Return: A standard Linux error code on failure, 0 otherwise.
52285595 */
52295596 static int kbase_device_suspend(struct device *dev)
52305597 {
....@@ -5233,7 +5600,10 @@
52335600 if (!kbdev)
52345601 return -ENODEV;
52355602
5236
- kbase_pm_suspend(kbdev);
5603
+ if (kbase_pm_suspend(kbdev)) {
5604
+ dev_warn(kbdev->dev, "Abort suspend as GPU suspension failed");
5605
+ return -EBUSY;
5606
+ }
52375607
52385608 #ifdef CONFIG_MALI_BIFROST_DVFS
52395609 kbase_pm_metrics_stop(kbdev);
....@@ -5246,15 +5616,27 @@
52465616 flush_workqueue(kbdev->devfreq_queue.workq);
52475617 }
52485618 #endif
5619
+
5620
+#ifdef CONFIG_ARCH_ROCKCHIP
5621
+ kbase_platform_rk_enable_regulator(kbdev);
5622
+#endif
5623
+
5624
+#ifdef KBASE_PM_RUNTIME
5625
+ if (kbdev->is_runtime_resumed) {
5626
+ if (kbdev->pm.backend.callback_power_runtime_off)
5627
+ kbdev->pm.backend.callback_power_runtime_off(kbdev);
5628
+ }
5629
+#endif /* KBASE_PM_RUNTIME */
5630
+
52495631 return 0;
52505632 }
52515633
52525634 /**
52535635 * kbase_device_resume - Resume callback from the OS.
52545636 *
5255
- * This is called by Linux when the device should resume from suspension.
5256
- *
52575637 * @dev: The device to resume
5638
+ *
5639
+ * This is called by Linux when the device should resume from suspension.
52585640 *
52595641 * Return: A standard Linux error code
52605642 */
....@@ -5265,6 +5647,13 @@
52655647 if (!kbdev)
52665648 return -ENODEV;
52675649
5650
+#ifdef KBASE_PM_RUNTIME
5651
+ if (kbdev->is_runtime_resumed) {
5652
+ if (kbdev->pm.backend.callback_power_runtime_on)
5653
+ kbdev->pm.backend.callback_power_runtime_on(kbdev);
5654
+ }
5655
+#endif /* KBASE_PM_RUNTIME */
5656
+
52685657 kbase_pm_resume(kbdev);
52695658
52705659 #ifdef CONFIG_MALI_BIFROST_DVFS
....@@ -5273,25 +5662,25 @@
52735662
52745663 #ifdef CONFIG_MALI_BIFROST_DEVFREQ
52755664 dev_dbg(dev, "Callback %s\n", __func__);
5276
- if (kbdev->devfreq) {
5277
- mutex_lock(&kbdev->pm.lock);
5278
- if (kbdev->pm.active_count > 0)
5279
- kbase_devfreq_enqueue_work(kbdev, DEVFREQ_WORK_RESUME);
5280
- mutex_unlock(&kbdev->pm.lock);
5281
- flush_workqueue(kbdev->devfreq_queue.workq);
5282
- }
5665
+ if (kbdev->devfreq)
5666
+ kbase_devfreq_enqueue_work(kbdev, DEVFREQ_WORK_RESUME);
52835667 #endif
5668
+
5669
+#if !MALI_USE_CSF
5670
+ kbase_enable_quick_reset(kbdev);
5671
+#endif
5672
+
52845673 return 0;
52855674 }
52865675
52875676 /**
52885677 * kbase_device_runtime_suspend - Runtime suspend callback from the OS.
52895678 *
5679
+ * @dev: The device to suspend
5680
+ *
52905681 * This is called by Linux when the device should prepare for a condition in
52915682 * which it will not be able to communicate with the CPU(s) and RAM due to
52925683 * power management.
5293
- *
5294
- * @dev: The device to suspend
52955684 *
52965685 * Return: A standard Linux error code
52975686 */
....@@ -5299,11 +5688,19 @@
52995688 static int kbase_device_runtime_suspend(struct device *dev)
53005689 {
53015690 struct kbase_device *kbdev = to_kbase_device(dev);
5691
+ int ret = 0;
53025692
53035693 if (!kbdev)
53045694 return -ENODEV;
53055695
53065696 dev_dbg(dev, "Callback %s\n", __func__);
5697
+ KBASE_KTRACE_ADD(kbdev, PM_RUNTIME_SUSPEND_CALLBACK, NULL, 0);
5698
+
5699
+#if MALI_USE_CSF
5700
+ ret = kbase_pm_handle_runtime_suspend(kbdev);
5701
+ if (ret)
5702
+ return ret;
5703
+#endif
53075704
53085705 #ifdef CONFIG_MALI_BIFROST_DVFS
53095706 kbase_pm_metrics_stop(kbdev);
....@@ -5316,18 +5713,19 @@
53165713
53175714 if (kbdev->pm.backend.callback_power_runtime_off) {
53185715 kbdev->pm.backend.callback_power_runtime_off(kbdev);
5716
+ kbdev->is_runtime_resumed = false;
53195717 dev_dbg(dev, "runtime suspend\n");
53205718 }
5321
- return 0;
5719
+ return ret;
53225720 }
53235721 #endif /* KBASE_PM_RUNTIME */
53245722
53255723 /**
53265724 * kbase_device_runtime_resume - Runtime resume callback from the OS.
53275725 *
5328
- * This is called by Linux when the device should go into a fully active state.
5329
- *
53305726 * @dev: The device to suspend
5727
+ *
5728
+ * This is called by Linux when the device should go into a fully active state.
53315729 *
53325730 * Return: A standard Linux error code
53335731 */
....@@ -5342,8 +5740,10 @@
53425740 return -ENODEV;
53435741
53445742 dev_dbg(dev, "Callback %s\n", __func__);
5743
+ // KBASE_KTRACE_ADD(kbdev, PM_RUNTIME_RESUME_CALLBACK, NULL, 0);
53455744 if (kbdev->pm.backend.callback_power_runtime_on) {
53465745 ret = kbdev->pm.backend.callback_power_runtime_on(kbdev);
5746
+ kbdev->is_runtime_resumed = true;
53475747 dev_dbg(dev, "runtime resume\n");
53485748 }
53495749
....@@ -5405,10 +5805,11 @@
54055805 };
54065806
54075807 #if IS_ENABLED(CONFIG_OF)
5408
-static const struct of_device_id kbase_dt_ids[] = {
5409
- { .compatible = "arm,mali-bifrost" },
5410
- { /* sentinel */ }
5411
-};
5808
+static const struct of_device_id kbase_dt_ids[] = { { .compatible = "arm,malit6xx" },
5809
+ { .compatible = "arm,mali-midgard" },
5810
+ { .compatible = "arm,mali-bifrost" },
5811
+ { .compatible = "arm,mali-valhall" },
5812
+ { /* sentinel */ } };
54125813 MODULE_DEVICE_TABLE(of, kbase_dt_ids);
54135814 #endif
54145815
....@@ -5423,26 +5824,29 @@
54235824 },
54245825 };
54255826
5426
-/*
5427
- * The driver will not provide a shortcut to create the Mali platform device
5428
- * anymore when using Device Tree.
5429
- */
5430
-#if IS_ENABLED(CONFIG_OF)
5827
+#if (KERNEL_VERSION(5, 3, 0) > LINUX_VERSION_CODE) && IS_ENABLED(CONFIG_OF)
54315828 module_platform_driver(kbase_platform_driver);
54325829 #else
5433
-
54345830 static int __init kbase_driver_init(void)
54355831 {
54365832 int ret;
54375833
5834
+#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE)
5835
+ mutex_init(&kbase_probe_mutex);
5836
+#endif
5837
+
5838
+#ifndef CONFIG_OF
54385839 ret = kbase_platform_register();
54395840 if (ret)
54405841 return ret;
5441
-
5842
+#endif
54425843 ret = platform_driver_register(&kbase_platform_driver);
5443
-
5444
- if (ret)
5844
+#ifndef CONFIG_OF
5845
+ if (ret) {
54455846 kbase_platform_unregister();
5847
+ return ret;
5848
+ }
5849
+#endif
54465850
54475851 return ret;
54485852 }
....@@ -5450,19 +5854,20 @@
54505854 static void __exit kbase_driver_exit(void)
54515855 {
54525856 platform_driver_unregister(&kbase_platform_driver);
5857
+#ifndef CONFIG_OF
54535858 kbase_platform_unregister();
5859
+#endif
54545860 }
54555861
54565862 module_init(kbase_driver_init);
54575863 module_exit(kbase_driver_exit);
5458
-
5459
-#endif /* CONFIG_OF */
5460
-
5864
+#endif
54615865 MODULE_LICENSE("GPL");
54625866 MODULE_VERSION(MALI_RELEASE_NAME " (UK version " \
54635867 __stringify(BASE_UK_VERSION_MAJOR) "." \
54645868 __stringify(BASE_UK_VERSION_MINOR) ")");
54655869 MODULE_SOFTDEP("pre: memory_group_manager");
5870
+MODULE_INFO(import_ns, "DMA_BUF");
54665871
54675872 #define CREATE_TRACE_POINTS
54685873 /* Create the trace points (otherwise we just get code to call a tracepoint) */
....@@ -5492,7 +5897,7 @@
54925897 trace_mali_page_fault_insert_pages(dev_id, event, value);
54935898 }
54945899
5495
-void kbase_trace_mali_total_alloc_pages_change(u32 dev_id, long long int event)
5900
+void kbase_trace_mali_total_alloc_pages_change(u32 dev_id, long long event)
54965901 {
54975902 trace_mali_total_alloc_pages_change(dev_id, event);
54985903 }