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 <tu.vuong@arm.com>
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 <chenzhen@rock-chips.com>
This commit is contained in:
Zhen Chen
2022-02-16 10:06:40 +08:00
parent cad4034955
commit c019aa3cbf
3 changed files with 22 additions and 16 deletions

View File

@@ -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 <mali_kbase.h>
#include <mali_kbase_config_defaults.h>
#include <mali_kbase_pm.h>
#include <backend/gpu/mali_kbase_pm_internal.h>
@@ -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",

View File

@@ -20,6 +20,7 @@
*/
#include <mali_kbase.h>
#include <mali_kbase_config_defaults.h>
#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.

View File

@@ -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)
*/