diff options
Diffstat (limited to 'mali_kbase/device/mali_kbase_device.c')
-rw-r--r-- | mali_kbase/device/mali_kbase_device.c | 96 |
1 files changed, 60 insertions, 36 deletions
diff --git a/mali_kbase/device/mali_kbase_device.c b/mali_kbase/device/mali_kbase_device.c index c123010..e5b3e2b 100644 --- a/mali_kbase/device/mali_kbase_device.c +++ b/mali_kbase/device/mali_kbase_device.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2010-2022 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2010-2023 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the * GNU General Public License version 2 as published by the Free Software @@ -35,6 +35,7 @@ #include <mali_kbase.h> #include <mali_kbase_defs.h> #include <mali_kbase_hwaccess_instr.h> +#include <mali_kbase_hwaccess_time.h> #include <mali_kbase_hw.h> #include <mali_kbase_config_defaults.h> #include <linux/priority_control_manager.h> @@ -42,8 +43,8 @@ #include <tl/mali_kbase_timeline.h> #include "mali_kbase_kinstr_prfcnt.h" #include "mali_kbase_vinstr.h" -#include "mali_kbase_hwcnt_context.h" -#include "mali_kbase_hwcnt_virtualizer.h" +#include "hwcnt/mali_kbase_hwcnt_context.h" +#include "hwcnt/mali_kbase_hwcnt_virtualizer.h" #include "mali_kbase_device.h" #include "mali_kbase_device_internal.h" @@ -56,17 +57,15 @@ #include "arbiter/mali_kbase_arbiter_pm.h" #endif /* CONFIG_MALI_ARBITER_SUPPORT */ -/* NOTE: Magic - 0x45435254 (TRCE in ASCII). - * Supports tracing feature provided in the base module. - * Please keep it in sync with the value of base module. - */ -#define TRACE_BUFFER_HEADER_SPECIAL 0x45435254 +#if defined(CONFIG_DEBUG_FS) && !IS_ENABLED(CONFIG_MALI_NO_MALI) /* Number of register accesses for the buffer that we allocate during * initialization time. The buffer size can be changed later via debugfs. */ #define KBASEP_DEFAULT_REGISTER_HISTORY_SIZE ((u16)512) +#endif /* defined(CONFIG_DEBUG_FS) && !IS_ENABLED(CONFIG_MALI_NO_MALI) */ + static DEFINE_MUTEX(kbase_dev_list_lock); static LIST_HEAD(kbase_dev_list); static int kbase_dev_nr; @@ -187,8 +186,8 @@ static int mali_oom_notifier_handler(struct notifier_block *nb, kbdev_alloc_total = KBASE_PAGES_TO_KIB(atomic_read(&(kbdev->memdev.used_pages))); - dev_err(kbdev->dev, "OOM notifier: dev %s %lu kB\n", kbdev->devname, - kbdev_alloc_total); + dev_info(kbdev->dev, + "System reports low memory, GPU memory usage summary:\n"); mutex_lock(&kbdev->kctx_list_lock); @@ -202,15 +201,18 @@ static int mali_oom_notifier_handler(struct notifier_block *nb, pid_struct = find_get_pid(kctx->pid); task = pid_task(pid_struct, PIDTYPE_PID); - dev_err(kbdev->dev, - "OOM notifier: tsk %s tgid (%u) pid (%u) %lu kB\n", - task ? task->comm : "[null task]", kctx->tgid, - kctx->pid, task_alloc_total); + dev_info(kbdev->dev, + " tsk %s tgid %u pid %u has allocated %lu kB GPU memory\n", + task ? task->comm : "[null task]", kctx->tgid, kctx->pid, + task_alloc_total); put_pid(pid_struct); rcu_read_unlock(); } + dev_info(kbdev->dev, "End of summary, device usage is %lu kB\n", + kbdev_alloc_total); + mutex_unlock(&kbdev->kctx_list_lock); return NOTIFY_OK; } @@ -228,11 +230,14 @@ int kbase_device_misc_init(struct kbase_device * const kbdev) kbdev->cci_snoop_enabled = false; np = kbdev->dev->of_node; if (np != NULL) { - if (of_property_read_u32(np, "snoop_enable_smc", - &kbdev->snoop_enable_smc)) + /* Read "-" versions of the properties and fallback to "_" + * if these are not found + */ + if (of_property_read_u32(np, "snoop-enable-smc", &kbdev->snoop_enable_smc) && + of_property_read_u32(np, "snoop_enable_smc", &kbdev->snoop_enable_smc)) kbdev->snoop_enable_smc = 0; - if (of_property_read_u32(np, "snoop_disable_smc", - &kbdev->snoop_disable_smc)) + if (of_property_read_u32(np, "snoop-disable-smc", &kbdev->snoop_disable_smc) && + of_property_read_u32(np, "snoop_disable_smc", &kbdev->snoop_disable_smc)) kbdev->snoop_disable_smc = 0; /* Either both or none of the calls should be provided. */ if (!((kbdev->snoop_disable_smc == 0 @@ -279,9 +284,7 @@ int kbase_device_misc_init(struct kbase_device * const kbdev) goto dma_set_mask_failed; - /* There is no limit for Mali, so set to max. We only do this if dma_parms - * is already allocated by the platform. - */ + /* There is no limit for Mali, so set to max. */ if (kbdev->dev->dma_parms) err = dma_set_max_seg_size(kbdev->dev, UINT_MAX); if (err) @@ -293,12 +296,9 @@ int kbase_device_misc_init(struct kbase_device * const kbdev) if (err) goto dma_set_mask_failed; - err = kbase_ktrace_init(kbdev); - if (err) - goto term_as; err = kbase_pbha_read_dtb(kbdev); if (err) - goto term_ktrace; + goto term_as; init_waitqueue_head(&kbdev->cache_clean_wait); @@ -308,10 +308,15 @@ int kbase_device_misc_init(struct kbase_device * const kbdev) kbdev->pm.dvfs_period = DEFAULT_PM_DVFS_PERIOD; - kbdev->reset_timeout_ms = DEFAULT_RESET_TIMEOUT_MS; +#if MALI_USE_CSF + kbdev->reset_timeout_ms = kbase_get_timeout_ms(kbdev, CSF_GPU_RESET_TIMEOUT); +#else /* MALI_USE_CSF */ + kbdev->reset_timeout_ms = JM_DEFAULT_RESET_TIMEOUT_MS; +#endif /* !MALI_USE_CSF */ kbdev->mmu_mode = kbase_mmu_mode_get_aarch64(); - + kbdev->mmu_or_gpu_cache_op_wait_time_ms = + kbase_get_timeout_ms(kbdev, MMU_AS_INACTIVE_WAIT_TIMEOUT); mutex_init(&kbdev->kctx_list_lock); INIT_LIST_HEAD(&kbdev->kctx_list); @@ -324,10 +329,16 @@ int kbase_device_misc_init(struct kbase_device * const kbdev) "Unable to register OOM notifier for Mali - but will continue\n"); kbdev->oom_notifier_block.notifier_call = NULL; } + +#if MALI_USE_CSF +#if IS_ENABLED(CONFIG_SYNC_FILE) + atomic_set(&kbdev->live_fence_metadata, 0); +#endif /* IS_ENABLED(CONFIG_SYNC_FILE) */ + atomic_set(&kbdev->fence_signal_timeout_enabled, 1); +#endif + return 0; -term_ktrace: - kbase_ktrace_term(kbdev); term_as: kbase_device_all_as_term(kbdev); dma_set_mask_failed: @@ -344,14 +355,16 @@ void kbase_device_misc_term(struct kbase_device *kbdev) #if KBASE_KTRACE_ENABLE kbase_debug_assert_register_hook(NULL, NULL); #endif - - kbase_ktrace_term(kbdev); - kbase_device_all_as_term(kbdev); if (kbdev->oom_notifier_block.notifier_call) unregister_oom_notifier(&kbdev->oom_notifier_block); + +#if MALI_USE_CSF && IS_ENABLED(CONFIG_SYNC_FILE) + if (atomic_read(&kbdev->live_fence_metadata) > 0) + dev_warn(kbdev->dev, "Terminating Kbase device with live fence metadata!"); +#endif } void kbase_device_free(struct kbase_device *kbdev) @@ -361,8 +374,7 @@ void kbase_device_free(struct kbase_device *kbdev) void kbase_device_id_init(struct kbase_device *kbdev) { - scnprintf(kbdev->devname, DEVNAME_SIZE, "%s%d", kbase_drv_name, - kbase_dev_nr); + scnprintf(kbdev->devname, DEVNAME_SIZE, "%s%d", KBASE_DRV_NAME, kbase_dev_nr); kbdev->id = kbase_dev_nr; } @@ -484,10 +496,14 @@ int kbase_device_early_init(struct kbase_device *kbdev) { int err; + err = kbase_ktrace_init(kbdev); + if (err) + return err; + err = kbasep_platform_device_init(kbdev); if (err) - return err; + goto ktrace_term; err = kbase_pm_runtime_init(kbdev); if (err) @@ -501,7 +517,12 @@ int kbase_device_early_init(struct kbase_device *kbdev) /* Ensure we can access the GPU registers */ kbase_pm_register_access_enable(kbdev); - /* Find out GPU properties based on the GPU feature registers */ + /* + * Find out GPU properties based on the GPU feature registers. + * Note that this does not populate the few properties that depend on + * hw_features being initialized. Those are set by kbase_gpuprops_set_features + * soon after this in the init process. + */ kbase_gpuprops_set(kbdev); /* We're done accessing the GPU registers for now. */ @@ -524,6 +545,8 @@ fail_interrupts: kbase_pm_runtime_term(kbdev); fail_runtime_pm: kbasep_platform_device_term(kbdev); +ktrace_term: + kbase_ktrace_term(kbdev); return err; } @@ -540,6 +563,7 @@ void kbase_device_early_term(struct kbase_device *kbdev) #endif /* CONFIG_MALI_ARBITER_SUPPORT */ kbase_pm_runtime_term(kbdev); kbasep_platform_device_term(kbdev); + kbase_ktrace_term(kbdev); } int kbase_device_late_init(struct kbase_device *kbdev) |