From c019aa3cbf2994a530dc4f78b6dbe17c2cde7fb8 Mon Sep 17 00:00:00 2001 From: Zhen Chen Date: Wed, 16 Feb 2022 10:06:40 +0800 Subject: [PATCH] MALI: bifrost: Fix incorrect dmesg warning for unexpected GPU activities The warning logs fixed are "GPU activity takes longer than time interval, ...". This fix is provided as 496f5e3.diff by Zhigang.Yao@arm.com of support_mali. The original commit message within 496f5e3.diff: { From 496f5e37a803266e71cbf7b6eb5871fe2fcd8931 Mon Sep 17 00:00:00 2001 From: Tu Vuong Date: Wed, 09 Feb 2022 09:31:20 +0000 Subject: [PATCH] GPUCORE-30123 Fix incorrect dmesg warning for unexpected GPU activities The DVFS utilisation calculation detects when the GPU has expended more cycles than expected compared to the actual time passed. This margin was not sufficient as it didn't take into account the worst-case scenario where samples are taken TIMER_DEFAULT_VALUE_MS apart. } Change-Id: I16bb904fd77006f6ab1e4419e44a9834550e4c07 Signed-off-by: Zhen Chen --- .../arm/bifrost/backend/gpu/mali_kbase_pm_metrics.c | 13 ++++++++----- .../csf/ipa_control/mali_kbase_csf_ipa_control.c | 13 ++----------- .../gpu/arm/bifrost/mali_kbase_config_defaults.h | 12 ++++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_pm_metrics.c b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_pm_metrics.c index 551bf44a1775..5f48dfbcfc67 100644 --- a/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_pm_metrics.c +++ b/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_pm_metrics.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2011-2021 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2011-2022 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 @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -231,11 +232,13 @@ static void kbase_pm_get_dvfs_utilisation_calc(struct kbase_device *kbdev) * time. */ if (!kbdev->pm.backend.metrics.skip_gpu_active_sanity_check) { - /* Use a margin value that is approximately 1% of the time - * difference. + /* The margin is scaled to allow for the worst-case + * scenario where the samples are maximally separated, + * plus a small offset for sampling errors. */ - u64 margin_ns = diff_ns >> 6; - if (gpu_active_counter > (diff_ns + margin_ns)) { + u64 const MARGIN_NS = + IPA_CONTROL_TIMER_DEFAULT_VALUE_MS * NSEC_PER_MSEC * 3 / 2; + if (gpu_active_counter > (diff_ns + MARGIN_NS)) { dev_info( kbdev->dev, "GPU activity takes longer than time interval: %llu ns > %llu ns", diff --git a/drivers/gpu/arm/bifrost/csf/ipa_control/mali_kbase_csf_ipa_control.c b/drivers/gpu/arm/bifrost/csf/ipa_control/mali_kbase_csf_ipa_control.c index 546e18dbe315..8b79fbdfa567 100644 --- a/drivers/gpu/arm/bifrost/csf/ipa_control/mali_kbase_csf_ipa_control.c +++ b/drivers/gpu/arm/bifrost/csf/ipa_control/mali_kbase_csf_ipa_control.c @@ -20,6 +20,7 @@ */ #include +#include #include "backend/gpu/mali_kbase_clk_rate_trace_mgr.h" #include "mali_kbase_csf_ipa_control.h" @@ -43,20 +44,10 @@ #define COMMAND_PROTECTED_ACK ((u32)4) #define COMMAND_RESET_ACK ((u32)5) -/* - * Default value for the TIMER register of the IPA Control interface, - * expressed in milliseconds. - * - * The chosen value is a trade off between two requirements: the IPA Control - * interface should sample counters with a resolution in the order of - * milliseconds, while keeping GPU overhead as limited as possible. - */ -#define TIMER_DEFAULT_VALUE_MS ((u32)10) /* 10 milliseconds */ - /* * Number of timer events per second. */ -#define TIMER_EVENTS_PER_SECOND ((u32)1000 / TIMER_DEFAULT_VALUE_MS) +#define TIMER_EVENTS_PER_SECOND ((u32)1000 / IPA_CONTROL_TIMER_DEFAULT_VALUE_MS) /* * Maximum number of loops polling the GPU before we assume the GPU has hung. diff --git a/drivers/gpu/arm/bifrost/mali_kbase_config_defaults.h b/drivers/gpu/arm/bifrost/mali_kbase_config_defaults.h index 8d64184de386..5ae6346a7658 100644 --- a/drivers/gpu/arm/bifrost/mali_kbase_config_defaults.h +++ b/drivers/gpu/arm/bifrost/mali_kbase_config_defaults.h @@ -84,6 +84,18 @@ enum { KBASE_3BIT_AID_4 = 0x7 }; +#if MALI_USE_CSF +/* + * Default value for the TIMER register of the IPA Control interface, + * expressed in milliseconds. + * + * The chosen value is a trade off between two requirements: the IPA Control + * interface should sample counters with a resolution in the order of + * milliseconds, while keeping GPU overhead as limited as possible. + */ +#define IPA_CONTROL_TIMER_DEFAULT_VALUE_MS ((u32)10) /* 10 milliseconds */ +#endif /* MALI_USE_CSF */ + /** * Default period for DVFS sampling (can be overridden by platform header) */