.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
---|
2 | 2 | /* |
---|
3 | 3 | * |
---|
4 | | - * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved. |
---|
| 4 | + * (C) COPYRIGHT 2010-2023 ARM Limited. All rights reserved. |
---|
5 | 5 | * |
---|
6 | 6 | * This program is free software and is provided to you under the terms of the |
---|
7 | 7 | * GNU General Public License version 2 as published by the Free Software |
---|
.. | .. |
---|
31 | 31 | #include <ipa/mali_kbase_ipa_debugfs.h> |
---|
32 | 32 | #endif /* CONFIG_DEVFREQ_THERMAL */ |
---|
33 | 33 | #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" |
---|
35 | 36 | #include "mali_kbase_mem.h" |
---|
36 | 37 | #include "mali_kbase_mem_pool_debugfs.h" |
---|
37 | 38 | #include "mali_kbase_mem_pool_group.h" |
---|
.. | .. |
---|
50 | 51 | #if !MALI_USE_CSF |
---|
51 | 52 | #include "mali_kbase_kinstr_jm.h" |
---|
52 | 53 | #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" |
---|
56 | 57 | #include "mali_kbase_vinstr.h" |
---|
57 | 58 | #if MALI_USE_CSF |
---|
58 | 59 | #include "csf/mali_kbase_csf_firmware.h" |
---|
59 | 60 | #include "csf/mali_kbase_csf_tiler_heap.h" |
---|
60 | 61 | #include "csf/mali_kbase_csf_csg_debugfs.h" |
---|
61 | 62 | #include "csf/mali_kbase_csf_cpu_queue_debugfs.h" |
---|
| 63 | +#include "csf/mali_kbase_csf_event.h" |
---|
62 | 64 | #endif |
---|
63 | 65 | #ifdef CONFIG_MALI_ARBITER_SUPPORT |
---|
64 | 66 | #include "arbiter/mali_kbase_arbiter_pm.h" |
---|
.. | .. |
---|
71 | 73 | #endif |
---|
72 | 74 | #include "backend/gpu/mali_kbase_pm_internal.h" |
---|
73 | 75 | #include "mali_kbase_dvfs_debugfs.h" |
---|
| 76 | +#if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
| 77 | +#include "mali_kbase_pbha_debugfs.h" |
---|
| 78 | +#endif |
---|
74 | 79 | |
---|
75 | 80 | #include <linux/module.h> |
---|
76 | 81 | #include <linux/init.h> |
---|
.. | .. |
---|
78 | 83 | #include <linux/kernel.h> |
---|
79 | 84 | #include <linux/errno.h> |
---|
80 | 85 | #include <linux/of.h> |
---|
| 86 | +#include <linux/of_address.h> |
---|
81 | 87 | #include <linux/platform_device.h> |
---|
82 | 88 | #include <linux/of_platform.h> |
---|
83 | 89 | #include <linux/miscdevice.h> |
---|
.. | .. |
---|
86 | 92 | #include <linux/fs.h> |
---|
87 | 93 | #include <linux/uaccess.h> |
---|
88 | 94 | #include <linux/interrupt.h> |
---|
| 95 | +#include <linux/irq.h> |
---|
89 | 96 | #include <linux/mm.h> |
---|
90 | 97 | #include <linux/compat.h> /* is_compat_task/in_compat_syscall */ |
---|
91 | 98 | #include <linux/mman.h> |
---|
92 | 99 | #include <linux/version.h> |
---|
| 100 | +#include <linux/version_compat_defs.h> |
---|
93 | 101 | #include <mali_kbase_hw.h> |
---|
94 | | -#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) |
---|
| 102 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
---|
95 | 103 | #include <mali_kbase_sync.h> |
---|
96 | | -#endif /* CONFIG_SYNC || CONFIG_SYNC_FILE */ |
---|
| 104 | +#endif /* CONFIG_SYNC_FILE */ |
---|
97 | 105 | #include <linux/clk.h> |
---|
98 | 106 | #include <linux/clk-provider.h> |
---|
99 | 107 | #include <linux/delay.h> |
---|
.. | .. |
---|
113 | 121 | |
---|
114 | 122 | #include <mali_kbase_caps.h> |
---|
115 | 123 | |
---|
116 | | -/* GPU IRQ Tags */ |
---|
117 | | -#define JOB_IRQ_TAG 0 |
---|
118 | | -#define MMU_IRQ_TAG 1 |
---|
119 | | -#define GPU_IRQ_TAG 2 |
---|
120 | | - |
---|
121 | 124 | #define KERNEL_SIDE_DDK_VERSION_STRING "K:" MALI_RELEASE_NAME "(GPL)" |
---|
122 | 125 | |
---|
123 | 126 | /** |
---|
.. | .. |
---|
129 | 132 | (((minor) & 0xFFF) << 8) | \ |
---|
130 | 133 | ((0 & 0xFF) << 0)) |
---|
131 | 134 | |
---|
132 | | -#define KBASE_API_MIN(api_version) ((api_version >> 8) & 0xFFF) |
---|
133 | | -#define KBASE_API_MAJ(api_version) ((api_version >> 20) & 0xFFF) |
---|
134 | | - |
---|
135 | 135 | /** |
---|
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 |
---|
137 | 140 | */ |
---|
138 | | -typedef struct mali_kbase_capability_def { |
---|
| 141 | +struct mali_kbase_capability_def { |
---|
139 | 142 | u16 required_major; |
---|
140 | 143 | u16 required_minor; |
---|
141 | | -} mali_kbase_capability_def; |
---|
| 144 | +}; |
---|
142 | 145 | |
---|
143 | 146 | /* |
---|
144 | 147 | * This must be kept in-sync with mali_kbase_cap |
---|
.. | .. |
---|
146 | 149 | * TODO: The alternative approach would be to embed the cap enum values |
---|
147 | 150 | * in the table. Less efficient but potentially safer. |
---|
148 | 151 | */ |
---|
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] = { |
---|
150 | 153 | #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 */ |
---|
155 | 158 | #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 */ |
---|
160 | 163 | #endif |
---|
161 | 164 | }; |
---|
| 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 |
---|
162 | 177 | |
---|
163 | 178 | /** |
---|
164 | 179 | * mali_kbase_supports_cap - Query whether a kbase capability is supported |
---|
165 | 180 | * |
---|
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 |
---|
168 | 185 | */ |
---|
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) |
---|
170 | 187 | { |
---|
171 | 188 | bool supported = false; |
---|
172 | 189 | unsigned long required_ver; |
---|
173 | 190 | |
---|
174 | | - mali_kbase_capability_def const *cap_def; |
---|
| 191 | + struct mali_kbase_capability_def const *cap_def; |
---|
175 | 192 | |
---|
176 | 193 | if (WARN_ON(cap < 0)) |
---|
177 | 194 | return false; |
---|
.. | .. |
---|
198 | 215 | * address space) and no API version number. Both must be assigned before |
---|
199 | 216 | * kbase_file_get_kctx_if_setup_complete() can be used successfully. |
---|
200 | 217 | * |
---|
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 |
---|
202 | 219 | * on failure. |
---|
203 | 220 | */ |
---|
204 | 221 | static struct kbase_file *kbase_file_new(struct kbase_device *const kbdev, |
---|
.. | .. |
---|
297 | 314 | * |
---|
298 | 315 | * @kfile: A device file created by kbase_file_new() |
---|
299 | 316 | * |
---|
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. |
---|
304 | 320 | * |
---|
305 | 321 | * Return: Address of the kernel base context associated with the @kfile, or |
---|
306 | 322 | * NULL if no context exists. |
---|
.. | .. |
---|
339 | 355 | #if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
340 | 356 | kbasep_mem_profile_debugfs_remove(kctx); |
---|
341 | 357 | #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 | | - |
---|
351 | 358 | kbase_context_debugfs_term(kctx); |
---|
352 | 359 | |
---|
353 | 360 | kbase_destroy_context(kctx); |
---|
.. | .. |
---|
404 | 411 | return -EPERM; |
---|
405 | 412 | } |
---|
406 | 413 | |
---|
| 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 | + |
---|
407 | 430 | static struct kbase_device *to_kbase_device(struct device *dev) |
---|
408 | 431 | { |
---|
409 | 432 | return dev_get_drvdata(dev); |
---|
.. | .. |
---|
411 | 434 | |
---|
412 | 435 | int assign_irqs(struct kbase_device *kbdev) |
---|
413 | 436 | { |
---|
| 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 | + |
---|
414 | 443 | struct platform_device *pdev; |
---|
415 | 444 | int i; |
---|
416 | 445 | |
---|
.. | .. |
---|
418 | 447 | return -ENODEV; |
---|
419 | 448 | |
---|
420 | 449 | 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; |
---|
425 | 450 | |
---|
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; |
---|
431 | 453 | |
---|
432 | 454 | #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]); |
---|
444 | 464 | #else |
---|
445 | | - irqtag = i; |
---|
| 465 | + irq = platform_get_irq(pdev, i); |
---|
446 | 466 | #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)); |
---|
449 | 475 | } |
---|
450 | 476 | |
---|
451 | 477 | return 0; |
---|
.. | .. |
---|
481 | 507 | EXPORT_SYMBOL(kbase_release_device); |
---|
482 | 508 | |
---|
483 | 509 | #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 | | - |
---|
505 | 510 | static ssize_t write_ctx_infinite_cache(struct file *f, const char __user *ubuf, size_t size, loff_t *off) |
---|
506 | 511 | { |
---|
507 | 512 | struct kbase_context *kctx = f->private_data; |
---|
.. | .. |
---|
613 | 618 | |
---|
614 | 619 | kbdev = kfile->kbdev; |
---|
615 | 620 | |
---|
616 | | -#if (KERNEL_VERSION(4, 6, 0) <= LINUX_VERSION_CODE) |
---|
617 | 621 | kctx = kbase_create_context(kbdev, in_compat_syscall(), |
---|
618 | 622 | 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) */ |
---|
623 | 623 | |
---|
624 | 624 | /* if bad flags, will stay stuck in setup mode */ |
---|
625 | 625 | if (!kctx) |
---|
.. | .. |
---|
629 | 629 | kbase_ctx_flag_set(kctx, KCTX_INFINITE_CACHE); |
---|
630 | 630 | |
---|
631 | 631 | #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; |
---|
633 | 634 | |
---|
634 | 635 | mutex_init(&kctx->mem_profile_lock); |
---|
635 | 636 | |
---|
.. | .. |
---|
640 | 641 | /* we don't treat this as a fail - just warn about it */ |
---|
641 | 642 | dev_warn(kbdev->dev, "couldn't create debugfs dir for kctx\n"); |
---|
642 | 643 | } 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 |
---|
650 | 644 | debugfs_create_file("infinite_cache", 0644, kctx->kctx_dentry, |
---|
651 | 645 | kctx, &kbase_infinite_cache_fops); |
---|
652 | | -#endif |
---|
653 | 646 | debugfs_create_file("force_same_va", 0600, kctx->kctx_dentry, |
---|
654 | 647 | kctx, &kbase_force_same_va_fops); |
---|
655 | 648 | |
---|
.. | .. |
---|
675 | 668 | |
---|
676 | 669 | if (!kbdev) |
---|
677 | 670 | 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 |
---|
678 | 676 | |
---|
679 | 677 | /* Device-wide firmware load is moved here from probing to comply with |
---|
680 | 678 | * Android GKI vendor guideline. |
---|
.. | .. |
---|
770 | 768 | } |
---|
771 | 769 | #endif /* !MALI_USE_CSF */ |
---|
772 | 770 | |
---|
773 | | -static int kbase_api_get_gpuprops(struct kbase_context *kctx, |
---|
| 771 | +static int kbase_api_get_gpuprops(struct kbase_file *kfile, |
---|
774 | 772 | struct kbase_ioctl_get_gpuprops *get_props) |
---|
775 | 773 | { |
---|
776 | | - struct kbase_gpu_props *kprops = &kctx->kbdev->gpu_props; |
---|
| 774 | + struct kbase_gpu_props *kprops = &kfile->kbdev->gpu_props; |
---|
777 | 775 | int err; |
---|
778 | 776 | |
---|
779 | 777 | 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"); |
---|
781 | 779 | return -EINVAL; |
---|
782 | 780 | } |
---|
783 | 781 | |
---|
.. | .. |
---|
802 | 800 | } |
---|
803 | 801 | #endif /* !MALI_USE_CSF */ |
---|
804 | 802 | |
---|
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) |
---|
807 | 919 | { |
---|
808 | 920 | struct kbase_va_region *reg; |
---|
809 | 921 | u64 flags = alloc->in.flags; |
---|
810 | 922 | u64 gpu_va; |
---|
811 | 923 | |
---|
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. |
---|
816 | 926 | */ |
---|
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)) |
---|
819 | 930 | return -EINVAL; |
---|
820 | | - } |
---|
821 | | - rcu_read_unlock(); |
---|
822 | 931 | |
---|
823 | 932 | if (flags & BASEP_MEM_FLAGS_KERNEL_ONLY) |
---|
824 | 933 | return -ENOMEM; |
---|
.. | .. |
---|
828 | 937 | * has been initialized. In that case, GPU-executable memory may |
---|
829 | 938 | * or may not be SAME_VA. |
---|
830 | 939 | */ |
---|
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)) { |
---|
833 | 941 | if (!(flags & BASE_MEM_PROT_GPU_EX) || !kbase_has_exec_va_zone(kctx)) |
---|
834 | 942 | flags |= BASE_MEM_SAME_VA; |
---|
835 | 943 | } |
---|
836 | 944 | |
---|
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); |
---|
854 | 947 | |
---|
855 | 948 | if (!reg) |
---|
856 | 949 | return -ENOMEM; |
---|
.. | .. |
---|
860 | 953 | |
---|
861 | 954 | return 0; |
---|
862 | 955 | } |
---|
| 956 | +#endif /* MALI_USE_CSF */ |
---|
863 | 957 | |
---|
864 | 958 | static int kbase_api_mem_query(struct kbase_context *kctx, |
---|
865 | 959 | union kbase_ioctl_mem_query *query) |
---|
.. | .. |
---|
888 | 982 | return kbase_vinstr_hwcnt_reader_setup(kctx->kbdev->vinstr_ctx, setup); |
---|
889 | 983 | } |
---|
890 | 984 | |
---|
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 | | - |
---|
947 | 985 | static int kbase_api_get_cpu_gpu_timeinfo(struct kbase_context *kctx, |
---|
948 | 986 | union kbase_ioctl_get_cpu_gpu_timeinfo *timeinfo) |
---|
949 | 987 | { |
---|
950 | 988 | 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; |
---|
954 | 992 | |
---|
955 | 993 | kbase_pm_context_active(kctx->kbdev); |
---|
956 | 994 | |
---|
.. | .. |
---|
975 | 1013 | return 0; |
---|
976 | 1014 | } |
---|
977 | 1015 | |
---|
| 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 */ |
---|
978 | 1023 | |
---|
979 | 1024 | static int kbase_api_disjoint_query(struct kbase_context *kctx, |
---|
980 | 1025 | struct kbase_ioctl_disjoint_query *query) |
---|
.. | .. |
---|
1006 | 1051 | return len; |
---|
1007 | 1052 | } |
---|
1008 | 1053 | |
---|
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 | | - |
---|
1048 | 1054 | static int kbase_api_mem_jit_init(struct kbase_context *kctx, |
---|
1049 | 1055 | struct kbase_ioctl_mem_jit_init *jit_init) |
---|
1050 | 1056 | { |
---|
1051 | 1057 | int i; |
---|
1052 | | - |
---|
1053 | | - kctx->jit_version = 3; |
---|
1054 | 1058 | |
---|
1055 | 1059 | for (i = 0; i < sizeof(jit_init->padding); i++) { |
---|
1056 | 1060 | /* Ensure all padding bytes are 0 for potential future |
---|
.. | .. |
---|
1209 | 1213 | static int kbase_api_stream_create(struct kbase_context *kctx, |
---|
1210 | 1214 | struct kbase_ioctl_stream_create *stream) |
---|
1211 | 1215 | { |
---|
1212 | | -#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) |
---|
| 1216 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
---|
1213 | 1217 | int fd, ret; |
---|
1214 | 1218 | |
---|
1215 | 1219 | /* Name must be NULL-terminated and padded with NULLs, so check last |
---|
.. | .. |
---|
1231 | 1235 | static int kbase_api_fence_validate(struct kbase_context *kctx, |
---|
1232 | 1236 | struct kbase_ioctl_fence_validate *validate) |
---|
1233 | 1237 | { |
---|
1234 | | -#if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) |
---|
| 1238 | +#if IS_ENABLED(CONFIG_SYNC_FILE) |
---|
1235 | 1239 | return kbase_sync_fence_validate(validate->fd); |
---|
1236 | 1240 | #else |
---|
1237 | 1241 | return -ENOENT; |
---|
.. | .. |
---|
1245 | 1249 | int err; |
---|
1246 | 1250 | |
---|
1247 | 1251 | 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"); |
---|
1249 | 1253 | return -EINVAL; |
---|
1250 | 1254 | } |
---|
1251 | 1255 | |
---|
| 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 | + |
---|
1252 | 1262 | buf = kmalloc(data->len, GFP_KERNEL); |
---|
1253 | | - if (ZERO_OR_NULL_PTR(buf)) |
---|
| 1263 | + if (!buf) |
---|
1254 | 1264 | return -ENOMEM; |
---|
1255 | 1265 | |
---|
1256 | 1266 | err = copy_from_user(buf, u64_to_user_ptr(data->buffer), |
---|
.. | .. |
---|
1398 | 1408 | return kbase_csf_queue_kick(kctx, kick); |
---|
1399 | 1409 | } |
---|
1400 | 1410 | |
---|
| 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 | +} |
---|
1401 | 1435 | static int kbasep_cs_queue_group_create(struct kbase_context *kctx, |
---|
1402 | 1436 | union kbase_ioctl_cs_queue_group_create *create) |
---|
1403 | 1437 | { |
---|
.. | .. |
---|
1433 | 1467 | static int kbasep_cs_tiler_heap_init(struct kbase_context *kctx, |
---|
1434 | 1468 | union kbase_ioctl_cs_tiler_heap_init *heap_init) |
---|
1435 | 1469 | { |
---|
| 1470 | + if (heap_init->in.group_id >= MEMORY_GROUP_MANAGER_NR_GROUPS) |
---|
| 1471 | + return -EINVAL; |
---|
| 1472 | + |
---|
1436 | 1473 | kctx->jit_group_id = heap_init->in.group_id; |
---|
1437 | 1474 | |
---|
1438 | 1475 | 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); |
---|
1442 | 1495 | } |
---|
1443 | 1496 | |
---|
1444 | 1497 | static int kbasep_cs_tiler_heap_term(struct kbase_context *kctx, |
---|
.. | .. |
---|
1520 | 1573 | cpu_queue_info->size); |
---|
1521 | 1574 | } |
---|
1522 | 1575 | |
---|
| 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 | +} |
---|
1523 | 1600 | #endif /* MALI_USE_CSF */ |
---|
1524 | 1601 | |
---|
1525 | 1602 | static int kbasep_ioctl_context_priority_check(struct kbase_context *kctx, |
---|
.. | .. |
---|
1644 | 1721 | struct kbase_ioctl_set_flags, |
---|
1645 | 1722 | kfile); |
---|
1646 | 1723 | 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; |
---|
1647 | 1742 | } |
---|
1648 | 1743 | |
---|
1649 | 1744 | kctx = kbase_file_get_kctx_if_setup_complete(kfile); |
---|
.. | .. |
---|
1660 | 1755 | kctx); |
---|
1661 | 1756 | break; |
---|
1662 | 1757 | #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; |
---|
1669 | 1758 | #if !MALI_USE_CSF |
---|
1670 | 1759 | case KBASE_IOCTL_POST_TERM: |
---|
1671 | 1760 | KBASE_HANDLE_IOCTL(KBASE_IOCTL_POST_TERM, |
---|
.. | .. |
---|
1679 | 1768 | union kbase_ioctl_mem_alloc, |
---|
1680 | 1769 | kctx); |
---|
1681 | 1770 | 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 |
---|
1682 | 1777 | case KBASE_IOCTL_MEM_QUERY: |
---|
1683 | 1778 | KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_MEM_QUERY, |
---|
1684 | 1779 | kbase_api_mem_query, |
---|
.. | .. |
---|
1701 | 1796 | KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_DDK_VERSION, |
---|
1702 | 1797 | kbase_api_get_ddk_version, |
---|
1703 | 1798 | 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, |
---|
1716 | 1799 | kctx); |
---|
1717 | 1800 | break; |
---|
1718 | 1801 | case KBASE_IOCTL_MEM_JIT_INIT: |
---|
.. | .. |
---|
1842 | 1925 | struct kbase_ioctl_hwcnt_reader_setup, |
---|
1843 | 1926 | kctx); |
---|
1844 | 1927 | 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; |
---|
1861 | 1928 | case KBASE_IOCTL_GET_CPU_GPU_TIMEINFO: |
---|
1862 | 1929 | KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_GET_CPU_GPU_TIMEINFO, |
---|
1863 | 1930 | kbase_api_get_cpu_gpu_timeinfo, |
---|
1864 | 1931 | union kbase_ioctl_get_cpu_gpu_timeinfo, |
---|
1865 | 1932 | kctx); |
---|
1866 | 1933 | 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 */ |
---|
1867 | 1942 | #ifdef CONFIG_MALI_CINSTR_GWT |
---|
1868 | 1943 | case KBASE_IOCTL_CINSTR_GWT_START: |
---|
1869 | 1944 | KBASE_HANDLE_IOCTL(KBASE_IOCTL_CINSTR_GWT_START, |
---|
.. | .. |
---|
1918 | 1993 | struct kbase_ioctl_cs_queue_kick, |
---|
1919 | 1994 | kctx); |
---|
1920 | 1995 | 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; |
---|
1921 | 2002 | case KBASE_IOCTL_CS_QUEUE_GROUP_CREATE: |
---|
1922 | 2003 | KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_CS_QUEUE_GROUP_CREATE, |
---|
1923 | 2004 | kbasep_cs_queue_group_create, |
---|
.. | .. |
---|
1954 | 2035 | union kbase_ioctl_cs_tiler_heap_init, |
---|
1955 | 2036 | kctx); |
---|
1956 | 2037 | 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; |
---|
1957 | 2043 | case KBASE_IOCTL_CS_TILER_HEAP_TERM: |
---|
1958 | 2044 | KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_CS_TILER_HEAP_TERM, |
---|
1959 | 2045 | kbasep_cs_tiler_heap_term, |
---|
.. | .. |
---|
1971 | 2057 | kbasep_ioctl_cs_cpu_queue_dump, |
---|
1972 | 2058 | struct kbase_ioctl_cs_cpu_queue_info, |
---|
1973 | 2059 | 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); |
---|
1974 | 2065 | break; |
---|
1975 | 2066 | #endif /* MALI_USE_CSF */ |
---|
1976 | 2067 | #if MALI_UNIT_TEST |
---|
.. | .. |
---|
2014 | 2105 | if (unlikely(!kctx)) |
---|
2015 | 2106 | return -EPERM; |
---|
2016 | 2107 | |
---|
| 2108 | + if (count < data_size) |
---|
| 2109 | + return -ENOBUFS; |
---|
| 2110 | + |
---|
2017 | 2111 | if (atomic_read(&kctx->event_count)) |
---|
2018 | 2112 | read_event = true; |
---|
2019 | 2113 | else |
---|
2020 | | - read_error = kbase_csf_read_error(kctx, &event_data); |
---|
| 2114 | + read_error = kbase_csf_event_read_error(kctx, &event_data); |
---|
2021 | 2115 | |
---|
2022 | 2116 | if (!read_event && !read_error) { |
---|
2023 | 2117 | bool dump = kbase_csf_cpu_queue_read_dump_req(kctx, |
---|
.. | .. |
---|
2059 | 2153 | if (count < sizeof(uevent)) |
---|
2060 | 2154 | return -ENOBUFS; |
---|
2061 | 2155 | |
---|
| 2156 | + memset(&uevent, 0, sizeof(uevent)); |
---|
| 2157 | + |
---|
2062 | 2158 | do { |
---|
2063 | 2159 | while (kbase_event_dequeue(kctx, &uevent)) { |
---|
2064 | 2160 | if (out_count > 0) |
---|
.. | .. |
---|
2090 | 2186 | } |
---|
2091 | 2187 | #endif /* MALI_USE_CSF */ |
---|
2092 | 2188 | |
---|
2093 | | -static unsigned int kbase_poll(struct file *filp, poll_table *wait) |
---|
| 2189 | +static __poll_t kbase_poll(struct file *filp, poll_table *wait) |
---|
2094 | 2190 | { |
---|
2095 | 2191 | struct kbase_file *const kfile = filp->private_data; |
---|
2096 | 2192 | struct kbase_context *const kctx = |
---|
2097 | 2193 | kbase_file_get_kctx_if_setup_complete(kfile); |
---|
2098 | 2194 | |
---|
2099 | | - if (unlikely(!kctx)) |
---|
| 2195 | + if (unlikely(!kctx)) { |
---|
| 2196 | +#if (KERNEL_VERSION(4, 19, 0) > LINUX_VERSION_CODE) |
---|
2100 | 2197 | return POLLERR; |
---|
| 2198 | +#else |
---|
| 2199 | + return EPOLLERR; |
---|
| 2200 | +#endif |
---|
| 2201 | + } |
---|
2101 | 2202 | |
---|
2102 | 2203 | 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) |
---|
2104 | 2206 | return POLLIN | POLLRDNORM; |
---|
| 2207 | +#else |
---|
| 2208 | + return EPOLLIN | EPOLLRDNORM; |
---|
| 2209 | +#endif |
---|
| 2210 | + } |
---|
2105 | 2211 | |
---|
2106 | 2212 | return 0; |
---|
2107 | 2213 | } |
---|
.. | .. |
---|
2119 | 2225 | #if MALI_USE_CSF |
---|
2120 | 2226 | int kbase_event_pending(struct kbase_context *ctx) |
---|
2121 | 2227 | { |
---|
2122 | | - WARN_ON_ONCE(!ctx); |
---|
| 2228 | + KBASE_DEBUG_ASSERT(ctx); |
---|
| 2229 | + |
---|
| 2230 | + if (unlikely(!ctx)) |
---|
| 2231 | + return -EPERM; |
---|
2123 | 2232 | |
---|
2124 | 2233 | return (atomic_read(&ctx->event_count) != 0) || |
---|
2125 | | - kbase_csf_error_pending(ctx) || |
---|
| 2234 | + kbase_csf_event_error_pending(ctx) || |
---|
2126 | 2235 | kbase_csf_cpu_queue_dump_needed(ctx); |
---|
2127 | 2236 | } |
---|
2128 | 2237 | #else |
---|
2129 | 2238 | int kbase_event_pending(struct kbase_context *ctx) |
---|
2130 | 2239 | { |
---|
2131 | 2240 | KBASE_DEBUG_ASSERT(ctx); |
---|
| 2241 | + |
---|
| 2242 | + if (unlikely(!ctx)) |
---|
| 2243 | + return -EPERM; |
---|
2132 | 2244 | |
---|
2133 | 2245 | return (atomic_read(&ctx->event_count) != 0) || |
---|
2134 | 2246 | (atomic_read(&ctx->event_closed) != 0); |
---|
.. | .. |
---|
2188 | 2300 | }; |
---|
2189 | 2301 | |
---|
2190 | 2302 | /** |
---|
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. |
---|
2196 | 2304 | * |
---|
2197 | 2305 | * @dev: The device this sysfs file is for |
---|
2198 | 2306 | * @attr: The attributes of the sysfs file |
---|
2199 | 2307 | * @buf: The output buffer for the sysfs file contents |
---|
2200 | 2308 | * |
---|
| 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 | + * |
---|
2201 | 2313 | * Return: The number of bytes output to @buf. |
---|
2202 | 2314 | */ |
---|
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) |
---|
2204 | 2316 | { |
---|
2205 | 2317 | struct kbase_device *kbdev; |
---|
2206 | 2318 | const struct kbase_pm_policy *current_policy; |
---|
.. | .. |
---|
2237 | 2349 | } |
---|
2238 | 2350 | |
---|
2239 | 2351 | /** |
---|
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. |
---|
2246 | 2353 | * |
---|
2247 | 2354 | * @dev: The device with sysfs file is for |
---|
2248 | 2355 | * @attr: The attributes of the sysfs file |
---|
2249 | 2356 | * @buf: The value written to the sysfs file |
---|
2250 | 2357 | * @count: The number of bytes to write to the sysfs file |
---|
2251 | 2358 | * |
---|
| 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 | + * |
---|
2252 | 2364 | * Return: @count if the function succeeded. An error code on failure. |
---|
2253 | 2365 | */ |
---|
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) |
---|
2255 | 2367 | { |
---|
2256 | 2368 | struct kbase_device *kbdev; |
---|
2257 | 2369 | const struct kbase_pm_policy *new_policy = NULL; |
---|
.. | .. |
---|
2290 | 2402 | * determining which policy is currently active, and changing the active |
---|
2291 | 2403 | * policy. |
---|
2292 | 2404 | */ |
---|
2293 | | -static DEVICE_ATTR(power_policy, S_IRUGO | S_IWUSR, show_policy, set_policy); |
---|
| 2405 | +static DEVICE_ATTR_RW(power_policy); |
---|
2294 | 2406 | |
---|
2295 | 2407 | /* |
---|
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. |
---|
2299 | 2409 | * |
---|
2300 | 2410 | * @dev: The device this sysfs file is for |
---|
2301 | 2411 | * @attr: The attributes of the sysfs file |
---|
2302 | 2412 | * @buf: The output buffer for the sysfs file contents |
---|
2303 | 2413 | * |
---|
| 2414 | + * This function is called to get the contents of the core_mask sysfs file. |
---|
| 2415 | + * |
---|
2304 | 2416 | * Return: The number of bytes output to @buf. |
---|
2305 | 2417 | */ |
---|
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) |
---|
2307 | 2419 | { |
---|
2308 | 2420 | struct kbase_device *kbdev; |
---|
2309 | 2421 | unsigned long flags; |
---|
.. | .. |
---|
2348 | 2460 | } |
---|
2349 | 2461 | |
---|
2350 | 2462 | /** |
---|
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. |
---|
2354 | 2464 | * |
---|
2355 | 2465 | * @dev: The device with sysfs file is for |
---|
2356 | 2466 | * @attr: The attributes of the sysfs file |
---|
2357 | 2467 | * @buf: The value written to the sysfs file |
---|
2358 | 2468 | * @count: The number of bytes to write to the sysfs file |
---|
2359 | 2469 | * |
---|
| 2470 | + * This function is called when the core_mask sysfs file is written to. |
---|
| 2471 | + * |
---|
2360 | 2472 | * Return: @count if the function succeeded. An error code on failure. |
---|
2361 | 2473 | */ |
---|
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) |
---|
2363 | 2475 | { |
---|
2364 | 2476 | struct kbase_device *kbdev; |
---|
2365 | 2477 | #if MALI_USE_CSF |
---|
.. | .. |
---|
2489 | 2601 | * Reading it will show the current core mask and the mask of cores available. |
---|
2490 | 2602 | * Writing to it will set the current core mask. |
---|
2491 | 2603 | */ |
---|
2492 | | -static DEVICE_ATTR(core_mask, S_IRUGO | S_IWUSR, show_core_mask, set_core_mask); |
---|
| 2604 | +static DEVICE_ATTR_RW(core_mask); |
---|
2493 | 2605 | |
---|
2494 | 2606 | #if !MALI_USE_CSF |
---|
2495 | 2607 | /** |
---|
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 |
---|
2497 | 2609 | * file. |
---|
2498 | 2610 | * |
---|
2499 | 2611 | * @dev: The device this sysfs file is for. |
---|
.. | .. |
---|
2509 | 2621 | * |
---|
2510 | 2622 | * Return: count if the function succeeded. An error code on failure. |
---|
2511 | 2623 | */ |
---|
2512 | | -static ssize_t set_soft_job_timeout(struct device *dev, |
---|
| 2624 | +static ssize_t soft_job_timeout_store(struct device *dev, |
---|
2513 | 2625 | struct device_attribute *attr, |
---|
2514 | 2626 | const char *buf, size_t count) |
---|
2515 | 2627 | { |
---|
.. | .. |
---|
2531 | 2643 | } |
---|
2532 | 2644 | |
---|
2533 | 2645 | /** |
---|
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 |
---|
2535 | 2647 | * file. |
---|
2536 | | - * |
---|
2537 | | - * This will return the timeout for the software jobs. |
---|
2538 | 2648 | * |
---|
2539 | 2649 | * @dev: The device this sysfs file is for. |
---|
2540 | 2650 | * @attr: The attributes of the sysfs file. |
---|
2541 | 2651 | * @buf: The output buffer for the sysfs file contents. |
---|
2542 | 2652 | * |
---|
| 2653 | + * This will return the timeout for the software jobs. |
---|
| 2654 | + * |
---|
2543 | 2655 | * Return: The number of bytes output to buf. |
---|
2544 | 2656 | */ |
---|
2545 | | -static ssize_t show_soft_job_timeout(struct device *dev, |
---|
| 2657 | +static ssize_t soft_job_timeout_show(struct device *dev, |
---|
2546 | 2658 | struct device_attribute *attr, |
---|
2547 | 2659 | char * const buf) |
---|
2548 | 2660 | { |
---|
.. | .. |
---|
2556 | 2668 | atomic_read(&kbdev->js_data.soft_job_timeout_ms)); |
---|
2557 | 2669 | } |
---|
2558 | 2670 | |
---|
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); |
---|
2561 | 2672 | |
---|
2562 | 2673 | static u32 timeout_ms_to_ticks(struct kbase_device *kbdev, long timeout_ms, |
---|
2563 | 2674 | int default_ticks, u32 old_ticks) |
---|
2564 | 2675 | { |
---|
2565 | 2676 | if (timeout_ms > 0) { |
---|
2566 | 2677 | u64 ticks = timeout_ms * 1000000ULL; |
---|
| 2678 | + |
---|
2567 | 2679 | do_div(ticks, kbdev->js_data.scheduling_period_ns); |
---|
2568 | 2680 | if (!ticks) |
---|
2569 | 2681 | return 1; |
---|
.. | .. |
---|
2576 | 2688 | } |
---|
2577 | 2689 | |
---|
2578 | 2690 | /** |
---|
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 |
---|
2580 | 2697 | * |
---|
2581 | 2698 | * This function is called to get the contents of the js_timeouts sysfs |
---|
2582 | 2699 | * file. This file contains five values separated by whitespace. The values |
---|
.. | .. |
---|
2589 | 2706 | * use by the job scheduler to get override. Note that a value needs to |
---|
2590 | 2707 | * be other than 0 for it to override the current job scheduler value. |
---|
2591 | 2708 | * |
---|
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 | | - * |
---|
2597 | 2709 | * Return: @count if the function succeeded. An error code on failure. |
---|
2598 | 2710 | */ |
---|
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) |
---|
2600 | 2712 | { |
---|
2601 | 2713 | struct kbase_device *kbdev; |
---|
2602 | 2714 | int items; |
---|
.. | .. |
---|
2676 | 2788 | } |
---|
2677 | 2789 | |
---|
2678 | 2790 | /** |
---|
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 |
---|
2680 | 2796 | * |
---|
2681 | 2797 | * This function is called to get the contents of the js_timeouts sysfs |
---|
2682 | 2798 | * file. It returns the last set values written to the js_timeouts sysfs file. |
---|
2683 | 2799 | * If the file didn't get written yet, the values will be current setting in |
---|
2684 | 2800 | * 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 |
---|
2688 | 2801 | * |
---|
2689 | 2802 | * Return: The number of bytes output to @buf. |
---|
2690 | 2803 | */ |
---|
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) |
---|
2692 | 2805 | { |
---|
2693 | 2806 | struct kbase_device *kbdev; |
---|
2694 | 2807 | ssize_t ret; |
---|
.. | .. |
---|
2751 | 2864 | * JS_RESET_TICKS_CL |
---|
2752 | 2865 | * JS_RESET_TICKS_DUMPING. |
---|
2753 | 2866 | */ |
---|
2754 | | -static DEVICE_ATTR(js_timeouts, S_IRUGO | S_IWUSR, show_js_timeouts, set_js_timeouts); |
---|
| 2867 | +static DEVICE_ATTR_RW(js_timeouts); |
---|
2755 | 2868 | |
---|
2756 | 2869 | static u32 get_new_js_timeout( |
---|
2757 | 2870 | u32 old_period, |
---|
.. | .. |
---|
2759 | 2872 | u32 new_scheduling_period_ns) |
---|
2760 | 2873 | { |
---|
2761 | 2874 | u64 ticks = (u64)old_period * (u64)old_ticks; |
---|
| 2875 | + |
---|
2762 | 2876 | do_div(ticks, new_scheduling_period_ns); |
---|
2763 | 2877 | return ticks?ticks:1; |
---|
2764 | 2878 | } |
---|
2765 | 2879 | |
---|
2766 | 2880 | /** |
---|
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 |
---|
2768 | 2882 | * file |
---|
2769 | 2883 | * @dev: The device the sysfs file is for |
---|
2770 | 2884 | * @attr: The attributes of the sysfs file |
---|
.. | .. |
---|
2777 | 2891 | * |
---|
2778 | 2892 | * Return: @count if the function succeeded. An error code on failure. |
---|
2779 | 2893 | */ |
---|
2780 | | -static ssize_t set_js_scheduling_period(struct device *dev, |
---|
| 2894 | +static ssize_t js_scheduling_period_store(struct device *dev, |
---|
2781 | 2895 | struct device_attribute *attr, const char *buf, size_t count) |
---|
2782 | 2896 | { |
---|
2783 | 2897 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
2846 | 2960 | } |
---|
2847 | 2961 | |
---|
2848 | 2962 | /** |
---|
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 |
---|
2850 | 2964 | * entry. |
---|
2851 | 2965 | * @dev: The device this sysfs file is for. |
---|
2852 | 2966 | * @attr: The attributes of the sysfs file. |
---|
.. | .. |
---|
2857 | 2971 | * |
---|
2858 | 2972 | * Return: The number of bytes output to @buf. |
---|
2859 | 2973 | */ |
---|
2860 | | -static ssize_t show_js_scheduling_period(struct device *dev, |
---|
| 2974 | +static ssize_t js_scheduling_period_show(struct device *dev, |
---|
2861 | 2975 | struct device_attribute *attr, char * const buf) |
---|
2862 | 2976 | { |
---|
2863 | 2977 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
2876 | 2990 | return ret; |
---|
2877 | 2991 | } |
---|
2878 | 2992 | |
---|
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); |
---|
2881 | 2994 | |
---|
2882 | 2995 | |
---|
2883 | 2996 | #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, |
---|
2885 | 2998 | struct device_attribute *attr, const char *buf, size_t count) |
---|
2886 | 2999 | { |
---|
2887 | 3000 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
2906 | 3019 | return count; |
---|
2907 | 3020 | } |
---|
2908 | 3021 | |
---|
2909 | | -static ssize_t show_js_softstop_always(struct device *dev, |
---|
| 3022 | +static ssize_t js_softstop_always_show(struct device *dev, |
---|
2910 | 3023 | struct device_attribute *attr, char * const buf) |
---|
2911 | 3024 | { |
---|
2912 | 3025 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
2933 | 3046 | * used for debug and unit-testing purposes. |
---|
2934 | 3047 | * (see CL t6xx_stress_1 unit-test as an example whereby this feature is used.) |
---|
2935 | 3048 | */ |
---|
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); |
---|
2937 | 3050 | #endif /* CONFIG_MALI_BIFROST_DEBUG */ |
---|
2938 | 3051 | #endif /* !MALI_USE_CSF */ |
---|
2939 | 3052 | |
---|
.. | .. |
---|
2952 | 3065 | kbasep_debug_command_func *func; |
---|
2953 | 3066 | }; |
---|
2954 | 3067 | |
---|
2955 | | -void kbasep_ktrace_dump_wrapper(struct kbase_device *kbdev) |
---|
| 3068 | +static void kbasep_ktrace_dump_wrapper(struct kbase_device *kbdev) |
---|
2956 | 3069 | { |
---|
2957 | 3070 | KBASE_KTRACE_DUMP(kbdev); |
---|
2958 | 3071 | } |
---|
.. | .. |
---|
2960 | 3073 | /* Debug commands supported by the driver */ |
---|
2961 | 3074 | static const struct kbasep_debug_command debug_commands[] = { |
---|
2962 | 3075 | { |
---|
2963 | | - .str = "dumptrace", |
---|
2964 | | - .func = &kbasep_ktrace_dump_wrapper, |
---|
2965 | | - } |
---|
| 3076 | + .str = "dumptrace", |
---|
| 3077 | + .func = &kbasep_ktrace_dump_wrapper, |
---|
| 3078 | + } |
---|
2966 | 3079 | }; |
---|
2967 | 3080 | |
---|
2968 | 3081 | /** |
---|
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. |
---|
2973 | 3083 | * |
---|
2974 | 3084 | * @dev: The device this sysfs file is for |
---|
2975 | 3085 | * @attr: The attributes of the sysfs file |
---|
2976 | 3086 | * @buf: The output buffer for the sysfs file contents |
---|
2977 | 3087 | * |
---|
| 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 | + * |
---|
2978 | 3091 | * Return: The number of bytes output to @buf. |
---|
2979 | 3092 | */ |
---|
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) |
---|
2981 | 3094 | { |
---|
2982 | 3095 | struct kbase_device *kbdev; |
---|
2983 | 3096 | int i; |
---|
.. | .. |
---|
3001 | 3114 | } |
---|
3002 | 3115 | |
---|
3003 | 3116 | /** |
---|
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. |
---|
3010 | 3118 | * |
---|
3011 | 3119 | * @dev: The device with sysfs file is for |
---|
3012 | 3120 | * @attr: The attributes of the sysfs file |
---|
3013 | 3121 | * @buf: The value written to the sysfs file |
---|
3014 | 3122 | * @count: The number of bytes written to the sysfs file |
---|
3015 | 3123 | * |
---|
| 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 | + * |
---|
3016 | 3129 | * Return: @count if the function succeeded. An error code on failure. |
---|
3017 | 3130 | */ |
---|
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) |
---|
3019 | 3132 | { |
---|
3020 | 3133 | struct kbase_device *kbdev; |
---|
3021 | 3134 | int i; |
---|
.. | .. |
---|
3043 | 3156 | * Reading it will produce a list of debug commands, separated by newlines. |
---|
3044 | 3157 | * Writing to it with one of those commands will issue said command. |
---|
3045 | 3158 | */ |
---|
3046 | | -static DEVICE_ATTR(debug_command, S_IRUGO | S_IWUSR, show_debug, issue_debug); |
---|
| 3159 | +static DEVICE_ATTR_RW(debug_command); |
---|
3047 | 3160 | #endif /* CONFIG_MALI_BIFROST_DEBUG */ |
---|
3048 | 3161 | |
---|
3049 | 3162 | /** |
---|
3050 | | - * kbase_show_gpuinfo - Show callback for the gpuinfo sysfs entry. |
---|
| 3163 | + * gpuinfo_show - Show callback for the gpuinfo sysfs entry. |
---|
3051 | 3164 | * @dev: The device this sysfs file is for. |
---|
3052 | 3165 | * @attr: The attributes of the sysfs file. |
---|
3053 | 3166 | * @buf: The output buffer to receive the GPU information. |
---|
.. | .. |
---|
3061 | 3174 | * |
---|
3062 | 3175 | * Return: The number of bytes output to @buf. |
---|
3063 | 3176 | */ |
---|
3064 | | -static ssize_t kbase_show_gpuinfo(struct device *dev, |
---|
| 3177 | +static ssize_t gpuinfo_show(struct device *dev, |
---|
3065 | 3178 | struct device_attribute *attr, char *buf) |
---|
3066 | 3179 | { |
---|
3067 | 3180 | static const struct gpu_product_id_name { |
---|
3068 | | - unsigned id; |
---|
| 3181 | + unsigned int id; |
---|
3069 | 3182 | char *name; |
---|
3070 | 3183 | } 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, |
---|
3072 | 3185 | .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, |
---|
3074 | 3187 | .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, |
---|
3076 | 3189 | .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, |
---|
3078 | 3191 | .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, |
---|
3080 | 3193 | .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, |
---|
3082 | 3195 | .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, |
---|
3084 | 3197 | .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, |
---|
3086 | 3199 | .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, |
---|
3088 | 3201 | .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, |
---|
3090 | 3203 | .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, |
---|
3092 | 3205 | .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, |
---|
3094 | 3207 | .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, |
---|
3096 | 3209 | .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, |
---|
3098 | 3211 | .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, |
---|
3100 | 3213 | .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" }, |
---|
3101 | 3218 | }; |
---|
3102 | 3219 | const char *product_name = "(Unknown Mali GPU)"; |
---|
3103 | 3220 | struct kbase_device *kbdev; |
---|
3104 | 3221 | 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; |
---|
3107 | 3225 | |
---|
3108 | 3226 | kbdev = to_kbase_device(dev); |
---|
3109 | 3227 | if (!kbdev) |
---|
3110 | 3228 | return -ENODEV; |
---|
3111 | 3229 | |
---|
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; |
---|
3115 | 3234 | |
---|
3116 | 3235 | for (i = 0; i < ARRAY_SIZE(gpu_product_id_names); ++i) { |
---|
3117 | 3236 | const struct gpu_product_id_name *p = &gpu_product_id_names[i]; |
---|
.. | .. |
---|
3123 | 3242 | } |
---|
3124 | 3243 | } |
---|
3125 | 3244 | |
---|
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); |
---|
3131 | 3276 | } |
---|
3132 | | -static DEVICE_ATTR(gpuinfo, S_IRUGO, kbase_show_gpuinfo, NULL); |
---|
| 3277 | +static DEVICE_ATTR_RO(gpuinfo); |
---|
3133 | 3278 | |
---|
3134 | 3279 | /** |
---|
3135 | | - * set_dvfs_period - Store callback for the dvfs_period sysfs file. |
---|
| 3280 | + * dvfs_period_store - Store callback for the dvfs_period sysfs file. |
---|
3136 | 3281 | * @dev: The device with sysfs file is for |
---|
3137 | 3282 | * @attr: The attributes of the sysfs file |
---|
3138 | 3283 | * @buf: The value written to the sysfs file |
---|
.. | .. |
---|
3143 | 3288 | * |
---|
3144 | 3289 | * Return: @count if the function succeeded. An error code on failure. |
---|
3145 | 3290 | */ |
---|
3146 | | -static ssize_t set_dvfs_period(struct device *dev, |
---|
| 3291 | +static ssize_t dvfs_period_store(struct device *dev, |
---|
3147 | 3292 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3148 | 3293 | { |
---|
3149 | 3294 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3168 | 3313 | } |
---|
3169 | 3314 | |
---|
3170 | 3315 | /** |
---|
3171 | | - * show_dvfs_period - Show callback for the dvfs_period sysfs entry. |
---|
| 3316 | + * dvfs_period_show - Show callback for the dvfs_period sysfs entry. |
---|
3172 | 3317 | * @dev: The device this sysfs file is for. |
---|
3173 | 3318 | * @attr: The attributes of the sysfs file. |
---|
3174 | 3319 | * @buf: The output buffer to receive the GPU information. |
---|
.. | .. |
---|
3178 | 3323 | * |
---|
3179 | 3324 | * Return: The number of bytes output to @buf. |
---|
3180 | 3325 | */ |
---|
3181 | | -static ssize_t show_dvfs_period(struct device *dev, |
---|
| 3326 | +static ssize_t dvfs_period_show(struct device *dev, |
---|
3182 | 3327 | struct device_attribute *attr, char * const buf) |
---|
3183 | 3328 | { |
---|
3184 | 3329 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3193 | 3338 | return ret; |
---|
3194 | 3339 | } |
---|
3195 | 3340 | |
---|
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 | +} |
---|
3198 | 3382 | |
---|
3199 | 3383 | /** |
---|
3200 | | - * set_pm_poweroff - Store callback for the pm_poweroff sysfs file. |
---|
| 3384 | + * pm_poweroff_store - Store callback for the pm_poweroff sysfs file. |
---|
3201 | 3385 | * @dev: The device with sysfs file is for |
---|
3202 | 3386 | * @attr: The attributes of the sysfs file |
---|
3203 | 3387 | * @buf: The value written to the sysfs file |
---|
.. | .. |
---|
3213 | 3397 | * |
---|
3214 | 3398 | * Return: @count if the function succeeded. An error code on failure. |
---|
3215 | 3399 | */ |
---|
3216 | | -static ssize_t set_pm_poweroff(struct device *dev, |
---|
| 3400 | +static ssize_t pm_poweroff_store(struct device *dev, |
---|
3217 | 3401 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3218 | 3402 | { |
---|
3219 | 3403 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3252 | 3436 | } |
---|
3253 | 3437 | |
---|
3254 | 3438 | /** |
---|
3255 | | - * show_pm_poweroff - Show callback for the pm_poweroff sysfs entry. |
---|
| 3439 | + * pm_poweroff_show - Show callback for the pm_poweroff sysfs entry. |
---|
3256 | 3440 | * @dev: The device this sysfs file is for. |
---|
3257 | 3441 | * @attr: The attributes of the sysfs file. |
---|
3258 | 3442 | * @buf: The output buffer to receive the GPU information. |
---|
.. | .. |
---|
3262 | 3446 | * |
---|
3263 | 3447 | * Return: The number of bytes output to @buf. |
---|
3264 | 3448 | */ |
---|
3265 | | -static ssize_t show_pm_poweroff(struct device *dev, |
---|
| 3449 | +static ssize_t pm_poweroff_show(struct device *dev, |
---|
3266 | 3450 | struct device_attribute *attr, char * const buf) |
---|
3267 | 3451 | { |
---|
3268 | 3452 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3286 | 3470 | return ret; |
---|
3287 | 3471 | } |
---|
3288 | 3472 | |
---|
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); |
---|
3328 | 3474 | |
---|
3329 | 3475 | /** |
---|
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. |
---|
3363 | 3477 | * @dev: The device with sysfs file is for |
---|
3364 | 3478 | * @attr: The attributes of the sysfs file |
---|
3365 | 3479 | * @buf: The value written to the sysfs file |
---|
.. | .. |
---|
3370 | 3484 | * |
---|
3371 | 3485 | * Return: @count if the function succeeded. An error code on failure. |
---|
3372 | 3486 | */ |
---|
3373 | | -static ssize_t set_reset_timeout(struct device *dev, |
---|
| 3487 | +static ssize_t reset_timeout_store(struct device *dev, |
---|
3374 | 3488 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3375 | 3489 | { |
---|
3376 | 3490 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3395 | 3509 | } |
---|
3396 | 3510 | |
---|
3397 | 3511 | /** |
---|
3398 | | - * show_reset_timeout - Show callback for the reset_timeout sysfs entry. |
---|
| 3512 | + * reset_timeout_show - Show callback for the reset_timeout sysfs entry. |
---|
3399 | 3513 | * @dev: The device this sysfs file is for. |
---|
3400 | 3514 | * @attr: The attributes of the sysfs file. |
---|
3401 | 3515 | * @buf: The output buffer to receive the GPU information. |
---|
.. | .. |
---|
3404 | 3518 | * |
---|
3405 | 3519 | * Return: The number of bytes output to @buf. |
---|
3406 | 3520 | */ |
---|
3407 | | -static ssize_t show_reset_timeout(struct device *dev, |
---|
| 3521 | +static ssize_t reset_timeout_show(struct device *dev, |
---|
3408 | 3522 | struct device_attribute *attr, char * const buf) |
---|
3409 | 3523 | { |
---|
3410 | 3524 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3419 | 3533 | return ret; |
---|
3420 | 3534 | } |
---|
3421 | 3535 | |
---|
3422 | | -static DEVICE_ATTR(reset_timeout, S_IRUGO | S_IWUSR, show_reset_timeout, |
---|
3423 | | - set_reset_timeout); |
---|
| 3536 | +static DEVICE_ATTR_RW(reset_timeout); |
---|
3424 | 3537 | |
---|
3425 | | - |
---|
3426 | | -static ssize_t show_mem_pool_size(struct device *dev, |
---|
| 3538 | +static ssize_t mem_pool_size_show(struct device *dev, |
---|
3427 | 3539 | struct device_attribute *attr, char * const buf) |
---|
3428 | 3540 | { |
---|
3429 | 3541 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3436 | 3548 | kbase_mem_pool_debugfs_size); |
---|
3437 | 3549 | } |
---|
3438 | 3550 | |
---|
3439 | | -static ssize_t set_mem_pool_size(struct device *dev, |
---|
| 3551 | +static ssize_t mem_pool_size_store(struct device *dev, |
---|
3440 | 3552 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3441 | 3553 | { |
---|
3442 | 3554 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3452 | 3564 | return err ? err : count; |
---|
3453 | 3565 | } |
---|
3454 | 3566 | |
---|
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); |
---|
3457 | 3568 | |
---|
3458 | | -static ssize_t show_mem_pool_max_size(struct device *dev, |
---|
| 3569 | +static ssize_t mem_pool_max_size_show(struct device *dev, |
---|
3459 | 3570 | struct device_attribute *attr, char * const buf) |
---|
3460 | 3571 | { |
---|
3461 | 3572 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3468 | 3579 | kbase_mem_pool_debugfs_max_size); |
---|
3469 | 3580 | } |
---|
3470 | 3581 | |
---|
3471 | | -static ssize_t set_mem_pool_max_size(struct device *dev, |
---|
| 3582 | +static ssize_t mem_pool_max_size_store(struct device *dev, |
---|
3472 | 3583 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3473 | 3584 | { |
---|
3474 | 3585 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3484 | 3595 | return err ? err : count; |
---|
3485 | 3596 | } |
---|
3486 | 3597 | |
---|
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); |
---|
3489 | 3599 | |
---|
3490 | 3600 | /** |
---|
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. |
---|
3492 | 3602 | * @dev: The device this sysfs file is for. |
---|
3493 | 3603 | * @attr: The attributes of the sysfs file. |
---|
3494 | 3604 | * @buf: The output buffer to receive the pool size. |
---|
.. | .. |
---|
3497 | 3607 | * |
---|
3498 | 3608 | * Return: The number of bytes output to @buf. |
---|
3499 | 3609 | */ |
---|
3500 | | -static ssize_t show_lp_mem_pool_size(struct device *dev, |
---|
| 3610 | +static ssize_t lp_mem_pool_size_show(struct device *dev, |
---|
3501 | 3611 | struct device_attribute *attr, char * const buf) |
---|
3502 | 3612 | { |
---|
3503 | 3613 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3511 | 3621 | } |
---|
3512 | 3622 | |
---|
3513 | 3623 | /** |
---|
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. |
---|
3515 | 3625 | * @dev: The device this sysfs file is for. |
---|
3516 | 3626 | * @attr: The attributes of the sysfs file. |
---|
3517 | 3627 | * @buf: The value written to the sysfs file. |
---|
.. | .. |
---|
3522 | 3632 | * |
---|
3523 | 3633 | * Return: @count if the function succeeded. An error code on failure. |
---|
3524 | 3634 | */ |
---|
3525 | | -static ssize_t set_lp_mem_pool_size(struct device *dev, |
---|
| 3635 | +static ssize_t lp_mem_pool_size_store(struct device *dev, |
---|
3526 | 3636 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3527 | 3637 | { |
---|
3528 | 3638 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3538 | 3648 | return err ? err : count; |
---|
3539 | 3649 | } |
---|
3540 | 3650 | |
---|
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); |
---|
3543 | 3652 | |
---|
3544 | 3653 | /** |
---|
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. |
---|
3546 | 3655 | * @dev: The device this sysfs file is for. |
---|
3547 | 3656 | * @attr: The attributes of the sysfs file. |
---|
3548 | 3657 | * @buf: The output buffer to receive the pool size. |
---|
.. | .. |
---|
3551 | 3660 | * |
---|
3552 | 3661 | * Return: The number of bytes output to @buf. |
---|
3553 | 3662 | */ |
---|
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, |
---|
3555 | 3664 | struct device_attribute *attr, char * const buf) |
---|
3556 | 3665 | { |
---|
3557 | 3666 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3565 | 3674 | } |
---|
3566 | 3675 | |
---|
3567 | 3676 | /** |
---|
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. |
---|
3569 | 3678 | * @dev: The device this sysfs file is for. |
---|
3570 | 3679 | * @attr: The attributes of the sysfs file. |
---|
3571 | 3680 | * @buf: The value written to the sysfs file. |
---|
.. | .. |
---|
3575 | 3684 | * |
---|
3576 | 3685 | * Return: @count if the function succeeded. An error code on failure. |
---|
3577 | 3686 | */ |
---|
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, |
---|
3579 | 3688 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3580 | 3689 | { |
---|
3581 | 3690 | struct kbase_device *const kbdev = to_kbase_device(dev); |
---|
.. | .. |
---|
3591 | 3700 | return err ? err : count; |
---|
3592 | 3701 | } |
---|
3593 | 3702 | |
---|
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); |
---|
3596 | 3704 | |
---|
3597 | 3705 | /** |
---|
3598 | 3706 | * show_simplified_mem_pool_max_size - Show the maximum size for the memory |
---|
.. | .. |
---|
3793 | 3901 | |
---|
3794 | 3902 | #if !MALI_USE_CSF |
---|
3795 | 3903 | /** |
---|
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 |
---|
3797 | 3905 | * entry. |
---|
3798 | 3906 | * @dev: The device this sysfs file is for. |
---|
3799 | 3907 | * @attr: The attributes of the sysfs file. |
---|
.. | .. |
---|
3803 | 3911 | * |
---|
3804 | 3912 | * Return: The number of bytes output to @buf. |
---|
3805 | 3913 | */ |
---|
3806 | | -static ssize_t show_js_ctx_scheduling_mode(struct device *dev, |
---|
| 3914 | +static ssize_t js_ctx_scheduling_mode_show(struct device *dev, |
---|
3807 | 3915 | struct device_attribute *attr, char * const buf) |
---|
3808 | 3916 | { |
---|
3809 | 3917 | struct kbase_device *kbdev; |
---|
.. | .. |
---|
3816 | 3924 | } |
---|
3817 | 3925 | |
---|
3818 | 3926 | /** |
---|
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 |
---|
3820 | 3928 | * entry. |
---|
3821 | 3929 | * @dev: The device this sysfs file is for. |
---|
3822 | 3930 | * @attr: The attributes of the sysfs file. |
---|
.. | .. |
---|
3829 | 3937 | * |
---|
3830 | 3938 | * Return: @count if the function succeeded. An error code on failure. |
---|
3831 | 3939 | */ |
---|
3832 | | -static ssize_t set_js_ctx_scheduling_mode(struct device *dev, |
---|
| 3940 | +static ssize_t js_ctx_scheduling_mode_store(struct device *dev, |
---|
3833 | 3941 | struct device_attribute *attr, const char *buf, size_t count) |
---|
3834 | 3942 | { |
---|
3835 | 3943 | struct kbase_context *kctx; |
---|
.. | .. |
---|
3871 | 3979 | return count; |
---|
3872 | 3980 | } |
---|
3873 | 3981 | |
---|
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); |
---|
3879 | 3983 | |
---|
3880 | 3984 | /* Number of entries in serialize_jobs_settings[] */ |
---|
3881 | 3985 | #define NR_SERIALIZE_JOBS_SETTINGS 5 |
---|
.. | .. |
---|
3899 | 4003 | * update_serialize_jobs_setting - Update the serialization setting for the |
---|
3900 | 4004 | * submission of GPU jobs. |
---|
3901 | 4005 | * |
---|
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 | | - * |
---|
3906 | 4006 | * @kbdev: An instance of the GPU platform device, allocated from the probe |
---|
3907 | 4007 | * method of the driver. |
---|
3908 | 4008 | * @buf: Buffer containing the value written to the sysfs/debugfs file. |
---|
3909 | 4009 | * @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. |
---|
3910 | 4014 | * |
---|
3911 | 4015 | * Return: @count if the function succeeded. An error code on failure. |
---|
3912 | 4016 | */ |
---|
.. | .. |
---|
4029 | 4133 | /** |
---|
4030 | 4134 | * show_serialize_jobs_sysfs - Show callback for serialize_jobs sysfs file. |
---|
4031 | 4135 | * |
---|
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 | | - * |
---|
4036 | 4136 | * @dev: The device this sysfs file is for |
---|
4037 | 4137 | * @attr: The attributes of the sysfs file |
---|
4038 | 4138 | * @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. |
---|
4039 | 4143 | * |
---|
4040 | 4144 | * Return: The number of bytes output to @buf. |
---|
4041 | 4145 | */ |
---|
.. | .. |
---|
4071 | 4175 | /** |
---|
4072 | 4176 | * store_serialize_jobs_sysfs - Store callback for serialize_jobs sysfs file. |
---|
4073 | 4177 | * |
---|
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 | | - * |
---|
4078 | 4178 | * @dev: The device this sysfs file is for |
---|
4079 | 4179 | * @attr: The attributes of the sysfs file |
---|
4080 | 4180 | * @buf: The value written to the sysfs file |
---|
4081 | 4181 | * @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. |
---|
4082 | 4186 | * |
---|
4083 | 4187 | * Return: @count if the function succeeded. An error code on failure. |
---|
4084 | 4188 | */ |
---|
.. | .. |
---|
4091 | 4195 | |
---|
4092 | 4196 | static DEVICE_ATTR(serialize_jobs, 0600, show_serialize_jobs_sysfs, |
---|
4093 | 4197 | store_serialize_jobs_sysfs); |
---|
4094 | | -#endif /* MALI_KBASE_BUILD */ |
---|
4095 | 4198 | #endif /* !MALI_USE_CSF */ |
---|
4096 | 4199 | |
---|
4097 | 4200 | static void kbasep_protected_mode_hwcnt_disable_worker(struct work_struct *data) |
---|
.. | .. |
---|
4187 | 4290 | kfree(kbdev->protected_dev); |
---|
4188 | 4291 | } |
---|
4189 | 4292 | |
---|
| 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) */ |
---|
4190 | 4302 | static int kbase_common_reg_map(struct kbase_device *kbdev) |
---|
4191 | 4303 | { |
---|
4192 | 4304 | int err = 0; |
---|
.. | .. |
---|
4222 | 4334 | kbdev->reg_size = 0; |
---|
4223 | 4335 | } |
---|
4224 | 4336 | } |
---|
| 4337 | +#endif /* !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) */ |
---|
4225 | 4338 | |
---|
4226 | 4339 | int registers_map(struct kbase_device * const kbdev) |
---|
4227 | 4340 | { |
---|
.. | .. |
---|
4350 | 4463 | kbase_pm_register_access_enable(kbdev); |
---|
4351 | 4464 | gpu_id = kbase_reg_read(kbdev, GPU_CONTROL_REG(GPU_ID)); |
---|
4352 | 4465 | 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); |
---|
4355 | 4468 | gpu_model_id = GPU_ID2_MODEL_MATCH_VALUE(product_id); |
---|
4356 | 4469 | |
---|
4357 | 4470 | if (gpu_model_id != GPU_ID2_PRODUCT_TGOX |
---|
.. | .. |
---|
4403 | 4516 | int err = 0; |
---|
4404 | 4517 | unsigned int i; |
---|
4405 | 4518 | #if defined(CONFIG_REGULATOR) |
---|
4406 | | - static const char *regulator_names[] = { |
---|
4407 | | - "mali", "shadercores" |
---|
| 4519 | + static const char * const regulator_names[] = { |
---|
| 4520 | + "mali", "mem" |
---|
4408 | 4521 | }; |
---|
4409 | | - BUILD_BUG_ON(ARRAY_SIZE(regulator_names) < BASE_MAX_NR_CLOCKS_REGULATORS); |
---|
4410 | 4522 | #endif /* CONFIG_REGULATOR */ |
---|
4411 | 4523 | |
---|
4412 | 4524 | if (!kbdev) |
---|
.. | .. |
---|
4422 | 4534 | * Any other error is ignored and the driver will continue |
---|
4423 | 4535 | * operating with a partial initialization of regulators. |
---|
4424 | 4536 | */ |
---|
4425 | | - for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { |
---|
| 4537 | + for (i = 0; i < ARRAY_SIZE(regulator_names); i++) { |
---|
4426 | 4538 | kbdev->regulators[i] = regulator_get_optional(kbdev->dev, |
---|
4427 | 4539 | regulator_names[i]); |
---|
4428 | | - if (IS_ERR_OR_NULL(kbdev->regulators[i])) { |
---|
| 4540 | + if (IS_ERR(kbdev->regulators[i])) { |
---|
4429 | 4541 | err = PTR_ERR(kbdev->regulators[i]); |
---|
4430 | 4542 | kbdev->regulators[i] = NULL; |
---|
4431 | 4543 | break; |
---|
4432 | 4544 | } |
---|
4433 | 4545 | } |
---|
4434 | 4546 | if (err == -EPROBE_DEFER) { |
---|
4435 | | - while ((i > 0) && (i < BASE_MAX_NR_CLOCKS_REGULATORS)) |
---|
| 4547 | + while (i > 0) |
---|
4436 | 4548 | regulator_put(kbdev->regulators[--i]); |
---|
4437 | 4549 | return err; |
---|
4438 | 4550 | } |
---|
.. | .. |
---|
4453 | 4565 | */ |
---|
4454 | 4566 | for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { |
---|
4455 | 4567 | 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])) { |
---|
4457 | 4569 | err = PTR_ERR(kbdev->clocks[i]); |
---|
4458 | 4570 | kbdev->clocks[i] = NULL; |
---|
4459 | 4571 | break; |
---|
.. | .. |
---|
4469 | 4581 | } |
---|
4470 | 4582 | } |
---|
4471 | 4583 | 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]); |
---|
4474 | 4586 | clk_put(kbdev->clocks[i]); |
---|
4475 | 4587 | } |
---|
4476 | 4588 | goto clocks_probe_defer; |
---|
.. | .. |
---|
4485 | 4597 | * from completing its initialization. |
---|
4486 | 4598 | */ |
---|
4487 | 4599 | #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) |
---|
4490 | 4602 | 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 | + |
---|
4493 | 4610 | } |
---|
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 | + |
---|
4495 | 4633 | #ifdef CONFIG_ARCH_ROCKCHIP |
---|
4496 | 4634 | err = kbase_platform_rk_init_opp_table(kbdev); |
---|
4497 | 4635 | if (err) |
---|
.. | .. |
---|
4502 | 4640 | #endif |
---|
4503 | 4641 | #endif /* CONFIG_PM_OPP */ |
---|
4504 | 4642 | 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 |
---|
4505 | 4656 | |
---|
4506 | 4657 | clocks_probe_defer: |
---|
4507 | 4658 | #if defined(CONFIG_REGULATOR) |
---|
.. | .. |
---|
4518 | 4669 | |
---|
4519 | 4670 | #if defined(CONFIG_PM_OPP) |
---|
4520 | 4671 | 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) |
---|
4523 | 4679 | if (!IS_ERR_OR_NULL(kbdev->opp_table)) |
---|
4524 | 4680 | 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 */ |
---|
4526 | 4683 | #endif /* CONFIG_PM_OPP */ |
---|
4527 | 4684 | |
---|
4528 | 4685 | for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { |
---|
.. | .. |
---|
4544 | 4701 | #endif |
---|
4545 | 4702 | } |
---|
4546 | 4703 | |
---|
4547 | | -#ifdef MALI_KBASE_BUILD |
---|
4548 | 4704 | #if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
4549 | 4705 | |
---|
4550 | 4706 | static void trigger_reset(struct kbase_device *kbdev) |
---|
.. | .. |
---|
4562 | 4718 | kbdev = (struct kbase_device *)data; \ |
---|
4563 | 4719 | kbdev->hw_quirks_##type = (u32)val; \ |
---|
4564 | 4720 | trigger_reset(kbdev); \ |
---|
4565 | | - return 0;\ |
---|
| 4721 | + return 0; \ |
---|
4566 | 4722 | } \ |
---|
4567 | 4723 | \ |
---|
4568 | 4724 | static int type##_quirks_get(void *data, u64 *val) \ |
---|
4569 | 4725 | { \ |
---|
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; \ |
---|
4574 | 4730 | } \ |
---|
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") |
---|
4577 | 4733 | |
---|
4578 | 4734 | MAKE_QUIRK_ACCESSORS(sc); |
---|
4579 | 4735 | MAKE_QUIRK_ACCESSORS(tiler); |
---|
4580 | 4736 | MAKE_QUIRK_ACCESSORS(mmu); |
---|
4581 | 4737 | MAKE_QUIRK_ACCESSORS(gpu); |
---|
4582 | 4738 | |
---|
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) |
---|
4585 | 4751 | { |
---|
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; |
---|
4590 | 4753 | |
---|
4591 | 4754 | trigger_reset(kbdev); |
---|
4592 | 4755 | |
---|
4593 | | - return count; |
---|
| 4756 | + if (wait_for_reset == 1) |
---|
| 4757 | + return kbase_reset_gpu_wait(kbdev); |
---|
| 4758 | + |
---|
| 4759 | + return 0; |
---|
4594 | 4760 | } |
---|
4595 | 4761 | |
---|
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"); |
---|
4602 | 4763 | |
---|
4603 | 4764 | /** |
---|
4604 | 4765 | * debugfs_protected_debug_mode_read - "protected_debug_mode" debugfs read |
---|
.. | .. |
---|
4682 | 4843 | .release = single_release, |
---|
4683 | 4844 | }; |
---|
4684 | 4845 | |
---|
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) |
---|
4686 | 4853 | { |
---|
4687 | | - struct dentry *debugfs_ctx_defaults_directory; |
---|
4688 | | - int err; |
---|
4689 | 4854 | /* prevent unprivileged use of debug file system |
---|
4690 | 4855 | * in old kernel version |
---|
4691 | 4856 | */ |
---|
4692 | | -#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE) |
---|
4693 | | - /* only for newer kernel version debug file system is safe */ |
---|
4694 | 4857 | 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; |
---|
4698 | 4860 | |
---|
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)) { |
---|
4702 | 4899 | dev_err(kbdev->dev, |
---|
4703 | 4900 | "Couldn't create mali debugfs directory: %s\n", |
---|
4704 | 4901 | kbdev->devname); |
---|
4705 | | - err = -ENOMEM; |
---|
4706 | | - goto out; |
---|
| 4902 | + return dentry; |
---|
4707 | 4903 | } |
---|
4708 | 4904 | |
---|
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)) { |
---|
4712 | 4908 | dev_err(kbdev->dev, "Couldn't create mali debugfs ctx directory\n"); |
---|
4713 | | - err = -ENOMEM; |
---|
4714 | | - goto out; |
---|
| 4909 | + return dentry; |
---|
4715 | 4910 | } |
---|
4716 | 4911 | |
---|
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)) { |
---|
4720 | 4915 | 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; |
---|
4731 | 4917 | } |
---|
4732 | 4918 | |
---|
4733 | 4919 | kbasep_regs_history_debugfs_init(kbdev); |
---|
4734 | 4920 | |
---|
4735 | | -#if !MALI_USE_CSF |
---|
| 4921 | +#if MALI_USE_CSF |
---|
| 4922 | + kbase_debug_csf_fault_debugfs_init(kbdev); |
---|
| 4923 | +#else /* MALI_USE_CSF */ |
---|
4736 | 4924 | kbase_debug_job_fault_debugfs_init(kbdev); |
---|
4737 | 4925 | #endif /* !MALI_USE_CSF */ |
---|
4738 | 4926 | |
---|
.. | .. |
---|
4741 | 4929 | #ifdef CONFIG_MALI_PRFCNT_SET_SELECT_VIA_DEBUG_FS |
---|
4742 | 4930 | kbase_instr_backend_debugfs_init(kbdev); |
---|
4743 | 4931 | #endif |
---|
| 4932 | + kbase_pbha_debugfs_init(kbdev); |
---|
| 4933 | + |
---|
4744 | 4934 | /* fops_* variables created by invocations of macro |
---|
4745 | 4935 | * MAKE_QUIRK_ACCESSORS() above. |
---|
4746 | 4936 | */ |
---|
4747 | | - debugfs_create_file("quirks_sc", 0644, |
---|
| 4937 | + dentry = debugfs_create_file("quirks_sc", 0644, |
---|
4748 | 4938 | kbdev->mali_debugfs_directory, kbdev, |
---|
4749 | 4939 | &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; |
---|
4777 | 4943 | } |
---|
4778 | 4944 | |
---|
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, |
---|
4780 | 4983 | kbdev->mali_debugfs_directory, kbdev, |
---|
4781 | 4984 | &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 | + } |
---|
4782 | 4989 | |
---|
4783 | 4990 | kbase_ktrace_debugfs_init(kbdev); |
---|
4784 | 4991 | |
---|
4785 | 4992 | #ifdef CONFIG_MALI_BIFROST_DEVFREQ |
---|
4786 | 4993 | #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) |
---|
4788 | 4996 | kbase_ipa_debugfs_init(kbdev); |
---|
4789 | 4997 | #endif /* CONFIG_DEVFREQ_THERMAL */ |
---|
4790 | 4998 | #endif /* CONFIG_MALI_BIFROST_DEVFREQ */ |
---|
4791 | 4999 | |
---|
4792 | 5000 | #if !MALI_USE_CSF |
---|
4793 | | - debugfs_create_file("serialize_jobs", S_IRUGO | S_IWUSR, |
---|
| 5001 | + dentry = debugfs_create_file("serialize_jobs", 0644, |
---|
4794 | 5002 | kbdev->mali_debugfs_directory, kbdev, |
---|
4795 | 5003 | &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); |
---|
4797 | 5009 | #endif |
---|
4798 | 5010 | kbase_dvfs_status_debugfs_init(kbdev); |
---|
4799 | 5011 | |
---|
4800 | | - return 0; |
---|
4801 | 5012 | |
---|
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; |
---|
4805 | 5025 | } |
---|
4806 | 5026 | |
---|
4807 | 5027 | void kbase_device_debugfs_term(struct kbase_device *kbdev) |
---|
.. | .. |
---|
4809 | 5029 | debugfs_remove_recursive(kbdev->mali_debugfs_directory); |
---|
4810 | 5030 | } |
---|
4811 | 5031 | #endif /* CONFIG_DEBUG_FS */ |
---|
4812 | | -#endif /* MALI_KBASE_BUILD */ |
---|
4813 | 5032 | |
---|
4814 | 5033 | int kbase_device_coherency_init(struct kbase_device *kbdev) |
---|
4815 | 5034 | { |
---|
.. | .. |
---|
4817 | 5036 | u32 supported_coherency_bitmap = |
---|
4818 | 5037 | kbdev->gpu_props.props.raw_props.coherency_mode; |
---|
4819 | 5038 | const void *coherency_override_dts; |
---|
| 5039 | + bool dma_coherent; |
---|
4820 | 5040 | u32 override_coherency, gpu_id; |
---|
4821 | 5041 | unsigned int prod_id; |
---|
4822 | 5042 | |
---|
4823 | 5043 | gpu_id = kbdev->gpu_props.props.raw_props.gpu_id; |
---|
4824 | 5044 | 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; |
---|
4826 | 5046 | |
---|
4827 | 5047 | /* Only for tMIx : |
---|
4828 | 5048 | * (COHERENCY_ACE_LITE | COHERENCY_ACE) was incorrectly |
---|
.. | .. |
---|
4841 | 5061 | |
---|
4842 | 5062 | /* device tree may override the coherency */ |
---|
4843 | 5063 | #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); |
---|
4844 | 5066 | coherency_override_dts = of_get_property(kbdev->dev->of_node, |
---|
4845 | 5067 | "system-coherency", |
---|
4846 | 5068 | 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 | + } |
---|
4850 | 5081 | |
---|
4851 | 5082 | #if MALI_USE_CSF && !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) |
---|
4852 | 5083 | /* ACE coherency mode is not supported by Driver on CSF GPUs. |
---|
.. | .. |
---|
4954 | 5185 | return ret; |
---|
4955 | 5186 | } |
---|
4956 | 5187 | |
---|
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); |
---|
4959 | 5189 | |
---|
4960 | 5190 | /** |
---|
4961 | 5191 | * fw_timeout_store - Store callback for the fw_timeout sysfs file. |
---|
.. | .. |
---|
4983 | 5213 | |
---|
4984 | 5214 | ret = kstrtouint(buf, 0, &fw_timeout); |
---|
4985 | 5215 | 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)); |
---|
4990 | 5221 | return -EINVAL; |
---|
4991 | 5222 | } |
---|
4992 | 5223 | |
---|
.. | .. |
---|
5023 | 5254 | return ret; |
---|
5024 | 5255 | } |
---|
5025 | 5256 | |
---|
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 | + |
---|
5027 | 5384 | #endif /* MALI_USE_CSF */ |
---|
5028 | 5385 | |
---|
5029 | 5386 | static struct attribute *kbase_scheduling_attrs[] = { |
---|
.. | .. |
---|
5047 | 5404 | &dev_attr_gpuinfo.attr, |
---|
5048 | 5405 | &dev_attr_dvfs_period.attr, |
---|
5049 | 5406 | &dev_attr_pm_poweroff.attr, |
---|
5050 | | -#if MALI_USE_CSF |
---|
5051 | | - &dev_attr_idle_hysteresis_time.attr, |
---|
5052 | | -#endif |
---|
5053 | 5407 | &dev_attr_reset_timeout.attr, |
---|
5054 | 5408 | #if !MALI_USE_CSF |
---|
5055 | 5409 | &dev_attr_js_scheduling_period.attr, |
---|
5056 | 5410 | #else |
---|
5057 | 5411 | &dev_attr_csg_scheduling_period.attr, |
---|
5058 | 5412 | &dev_attr_fw_timeout.attr, |
---|
| 5413 | + &dev_attr_idle_hysteresis_time.attr, |
---|
| 5414 | + &dev_attr_mcu_shader_pwroff_timeout.attr, |
---|
5059 | 5415 | #endif /* !MALI_USE_CSF */ |
---|
5060 | 5416 | &dev_attr_power_policy.attr, |
---|
5061 | 5417 | &dev_attr_core_mask.attr, |
---|
.. | .. |
---|
5186 | 5542 | } |
---|
5187 | 5543 | |
---|
5188 | 5544 | kbdev->dev = &pdev->dev; |
---|
5189 | | - dev_set_drvdata(kbdev->dev, kbdev); |
---|
5190 | 5545 | |
---|
| 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 |
---|
5191 | 5554 | err = kbase_device_init(kbdev); |
---|
5192 | 5555 | |
---|
5193 | 5556 | if (err) { |
---|
.. | .. |
---|
5199 | 5562 | |
---|
5200 | 5563 | dev_set_drvdata(kbdev->dev, NULL); |
---|
5201 | 5564 | kbase_device_free(kbdev); |
---|
| 5565 | +#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE) |
---|
| 5566 | + mutex_unlock(&kbase_probe_mutex); |
---|
| 5567 | +#endif |
---|
5202 | 5568 | } else { |
---|
5203 | | -#ifdef MALI_KBASE_BUILD |
---|
5204 | 5569 | dev_info(kbdev->dev, |
---|
5205 | 5570 | "Probed as %s\n", dev_name(kbdev->mdev.this_device)); |
---|
5206 | | -#endif /* MALI_KBASE_BUILD */ |
---|
5207 | 5571 | kbase_increment_device_id(); |
---|
| 5572 | +#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE) |
---|
| 5573 | + mutex_unlock(&kbase_probe_mutex); |
---|
| 5574 | +#endif |
---|
5208 | 5575 | #ifdef CONFIG_MALI_ARBITER_SUPPORT |
---|
5209 | 5576 | mutex_lock(&kbdev->pm.lock); |
---|
5210 | 5577 | kbase_arbiter_pm_vm_event(kbdev, KBASE_VM_GPU_INITIALIZED_EVT); |
---|
.. | .. |
---|
5220 | 5587 | /** |
---|
5221 | 5588 | * kbase_device_suspend - Suspend callback from the OS. |
---|
5222 | 5589 | * |
---|
5223 | | - * This is called by Linux when the device should suspend. |
---|
5224 | | - * |
---|
5225 | 5590 | * @dev: The device to suspend |
---|
5226 | 5591 | * |
---|
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. |
---|
5228 | 5595 | */ |
---|
5229 | 5596 | static int kbase_device_suspend(struct device *dev) |
---|
5230 | 5597 | { |
---|
.. | .. |
---|
5233 | 5600 | if (!kbdev) |
---|
5234 | 5601 | return -ENODEV; |
---|
5235 | 5602 | |
---|
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 | + } |
---|
5237 | 5607 | |
---|
5238 | 5608 | #ifdef CONFIG_MALI_BIFROST_DVFS |
---|
5239 | 5609 | kbase_pm_metrics_stop(kbdev); |
---|
.. | .. |
---|
5246 | 5616 | flush_workqueue(kbdev->devfreq_queue.workq); |
---|
5247 | 5617 | } |
---|
5248 | 5618 | #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 | + |
---|
5249 | 5631 | return 0; |
---|
5250 | 5632 | } |
---|
5251 | 5633 | |
---|
5252 | 5634 | /** |
---|
5253 | 5635 | * kbase_device_resume - Resume callback from the OS. |
---|
5254 | 5636 | * |
---|
5255 | | - * This is called by Linux when the device should resume from suspension. |
---|
5256 | | - * |
---|
5257 | 5637 | * @dev: The device to resume |
---|
| 5638 | + * |
---|
| 5639 | + * This is called by Linux when the device should resume from suspension. |
---|
5258 | 5640 | * |
---|
5259 | 5641 | * Return: A standard Linux error code |
---|
5260 | 5642 | */ |
---|
.. | .. |
---|
5265 | 5647 | if (!kbdev) |
---|
5266 | 5648 | return -ENODEV; |
---|
5267 | 5649 | |
---|
| 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 | + |
---|
5268 | 5657 | kbase_pm_resume(kbdev); |
---|
5269 | 5658 | |
---|
5270 | 5659 | #ifdef CONFIG_MALI_BIFROST_DVFS |
---|
.. | .. |
---|
5273 | 5662 | |
---|
5274 | 5663 | #ifdef CONFIG_MALI_BIFROST_DEVFREQ |
---|
5275 | 5664 | 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); |
---|
5283 | 5667 | #endif |
---|
| 5668 | + |
---|
| 5669 | +#if !MALI_USE_CSF |
---|
| 5670 | + kbase_enable_quick_reset(kbdev); |
---|
| 5671 | +#endif |
---|
| 5672 | + |
---|
5284 | 5673 | return 0; |
---|
5285 | 5674 | } |
---|
5286 | 5675 | |
---|
5287 | 5676 | /** |
---|
5288 | 5677 | * kbase_device_runtime_suspend - Runtime suspend callback from the OS. |
---|
5289 | 5678 | * |
---|
| 5679 | + * @dev: The device to suspend |
---|
| 5680 | + * |
---|
5290 | 5681 | * This is called by Linux when the device should prepare for a condition in |
---|
5291 | 5682 | * which it will not be able to communicate with the CPU(s) and RAM due to |
---|
5292 | 5683 | * power management. |
---|
5293 | | - * |
---|
5294 | | - * @dev: The device to suspend |
---|
5295 | 5684 | * |
---|
5296 | 5685 | * Return: A standard Linux error code |
---|
5297 | 5686 | */ |
---|
.. | .. |
---|
5299 | 5688 | static int kbase_device_runtime_suspend(struct device *dev) |
---|
5300 | 5689 | { |
---|
5301 | 5690 | struct kbase_device *kbdev = to_kbase_device(dev); |
---|
| 5691 | + int ret = 0; |
---|
5302 | 5692 | |
---|
5303 | 5693 | if (!kbdev) |
---|
5304 | 5694 | return -ENODEV; |
---|
5305 | 5695 | |
---|
5306 | 5696 | 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 |
---|
5307 | 5704 | |
---|
5308 | 5705 | #ifdef CONFIG_MALI_BIFROST_DVFS |
---|
5309 | 5706 | kbase_pm_metrics_stop(kbdev); |
---|
.. | .. |
---|
5316 | 5713 | |
---|
5317 | 5714 | if (kbdev->pm.backend.callback_power_runtime_off) { |
---|
5318 | 5715 | kbdev->pm.backend.callback_power_runtime_off(kbdev); |
---|
| 5716 | + kbdev->is_runtime_resumed = false; |
---|
5319 | 5717 | dev_dbg(dev, "runtime suspend\n"); |
---|
5320 | 5718 | } |
---|
5321 | | - return 0; |
---|
| 5719 | + return ret; |
---|
5322 | 5720 | } |
---|
5323 | 5721 | #endif /* KBASE_PM_RUNTIME */ |
---|
5324 | 5722 | |
---|
5325 | 5723 | /** |
---|
5326 | 5724 | * kbase_device_runtime_resume - Runtime resume callback from the OS. |
---|
5327 | 5725 | * |
---|
5328 | | - * This is called by Linux when the device should go into a fully active state. |
---|
5329 | | - * |
---|
5330 | 5726 | * @dev: The device to suspend |
---|
| 5727 | + * |
---|
| 5728 | + * This is called by Linux when the device should go into a fully active state. |
---|
5331 | 5729 | * |
---|
5332 | 5730 | * Return: A standard Linux error code |
---|
5333 | 5731 | */ |
---|
.. | .. |
---|
5342 | 5740 | return -ENODEV; |
---|
5343 | 5741 | |
---|
5344 | 5742 | dev_dbg(dev, "Callback %s\n", __func__); |
---|
| 5743 | + // KBASE_KTRACE_ADD(kbdev, PM_RUNTIME_RESUME_CALLBACK, NULL, 0); |
---|
5345 | 5744 | if (kbdev->pm.backend.callback_power_runtime_on) { |
---|
5346 | 5745 | ret = kbdev->pm.backend.callback_power_runtime_on(kbdev); |
---|
| 5746 | + kbdev->is_runtime_resumed = true; |
---|
5347 | 5747 | dev_dbg(dev, "runtime resume\n"); |
---|
5348 | 5748 | } |
---|
5349 | 5749 | |
---|
.. | .. |
---|
5405 | 5805 | }; |
---|
5406 | 5806 | |
---|
5407 | 5807 | #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 */ } }; |
---|
5412 | 5813 | MODULE_DEVICE_TABLE(of, kbase_dt_ids); |
---|
5413 | 5814 | #endif |
---|
5414 | 5815 | |
---|
.. | .. |
---|
5423 | 5824 | }, |
---|
5424 | 5825 | }; |
---|
5425 | 5826 | |
---|
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) |
---|
5431 | 5828 | module_platform_driver(kbase_platform_driver); |
---|
5432 | 5829 | #else |
---|
5433 | | - |
---|
5434 | 5830 | static int __init kbase_driver_init(void) |
---|
5435 | 5831 | { |
---|
5436 | 5832 | int ret; |
---|
5437 | 5833 | |
---|
| 5834 | +#if (KERNEL_VERSION(5, 3, 0) <= LINUX_VERSION_CODE) |
---|
| 5835 | + mutex_init(&kbase_probe_mutex); |
---|
| 5836 | +#endif |
---|
| 5837 | + |
---|
| 5838 | +#ifndef CONFIG_OF |
---|
5438 | 5839 | ret = kbase_platform_register(); |
---|
5439 | 5840 | if (ret) |
---|
5440 | 5841 | return ret; |
---|
5441 | | - |
---|
| 5842 | +#endif |
---|
5442 | 5843 | ret = platform_driver_register(&kbase_platform_driver); |
---|
5443 | | - |
---|
5444 | | - if (ret) |
---|
| 5844 | +#ifndef CONFIG_OF |
---|
| 5845 | + if (ret) { |
---|
5445 | 5846 | kbase_platform_unregister(); |
---|
| 5847 | + return ret; |
---|
| 5848 | + } |
---|
| 5849 | +#endif |
---|
5446 | 5850 | |
---|
5447 | 5851 | return ret; |
---|
5448 | 5852 | } |
---|
.. | .. |
---|
5450 | 5854 | static void __exit kbase_driver_exit(void) |
---|
5451 | 5855 | { |
---|
5452 | 5856 | platform_driver_unregister(&kbase_platform_driver); |
---|
| 5857 | +#ifndef CONFIG_OF |
---|
5453 | 5858 | kbase_platform_unregister(); |
---|
| 5859 | +#endif |
---|
5454 | 5860 | } |
---|
5455 | 5861 | |
---|
5456 | 5862 | module_init(kbase_driver_init); |
---|
5457 | 5863 | module_exit(kbase_driver_exit); |
---|
5458 | | - |
---|
5459 | | -#endif /* CONFIG_OF */ |
---|
5460 | | - |
---|
| 5864 | +#endif |
---|
5461 | 5865 | MODULE_LICENSE("GPL"); |
---|
5462 | 5866 | MODULE_VERSION(MALI_RELEASE_NAME " (UK version " \ |
---|
5463 | 5867 | __stringify(BASE_UK_VERSION_MAJOR) "." \ |
---|
5464 | 5868 | __stringify(BASE_UK_VERSION_MINOR) ")"); |
---|
5465 | 5869 | MODULE_SOFTDEP("pre: memory_group_manager"); |
---|
| 5870 | +MODULE_INFO(import_ns, "DMA_BUF"); |
---|
5466 | 5871 | |
---|
5467 | 5872 | #define CREATE_TRACE_POINTS |
---|
5468 | 5873 | /* Create the trace points (otherwise we just get code to call a tracepoint) */ |
---|
.. | .. |
---|
5492 | 5897 | trace_mali_page_fault_insert_pages(dev_id, event, value); |
---|
5493 | 5898 | } |
---|
5494 | 5899 | |
---|
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) |
---|
5496 | 5901 | { |
---|
5497 | 5902 | trace_mali_total_alloc_pages_change(dev_id, event); |
---|
5498 | 5903 | } |
---|