From patchwork Mon Jan 13 09:59:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sk Anirban X-Patchwork-Id: 13937124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 869E9C02180 for ; Mon, 13 Jan 2025 10:11:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2549410E62F; Mon, 13 Jan 2025 10:11:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="JrSMQByv"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 49BDF10E62E for ; Mon, 13 Jan 2025 10:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736763107; x=1768299107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=23p7VnlvVyeBclFC97YSLtj75yNZ/wvlmqcvIjSrjiY=; b=JrSMQByvl/bIUetQWYzFtFUdAE/nHZrJ9J7yBUH/OuI+NoJ6p0L49gtB CNuAZTgPSTssWb/ay0wLBd1KT+oHVPO54m+JeiRpJ6pBkeS25/B9DG+1/ 7sHmDftxNoJ09BFnX9kKwtcJ0dp6vuXwEsyur6BNHwQAPgla0NnCEGhoo xi/BxFaaBhSp04WmGvMS7jdGFRbytjnF64SE8/K9n0qfT3m2/OwoRFfQr YieOGsxCJRionijgd8DpXs+3X982NIXj911lV8u0aBCK++8O2MXSueWhb 3YM9JoFFqbmEvCB+3Srhn/lQ5qzso4DSqilPd5Htvk3wu/8eIlc49/83/ g==; X-CSE-ConnectionGUID: ESqsU/uZTci8hySxogFhSw== X-CSE-MsgGUID: qSilfo2jSvuhmeP2USIpBQ== X-IronPort-AV: E=McAfee;i="6700,10204,11313"; a="40696341" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="40696341" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2025 02:11:26 -0800 X-CSE-ConnectionGUID: iWXqsi9wToiH/XfaHcIIZA== X-CSE-MsgGUID: 3q50GUuzSAqUTpO2LwbcYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="127689550" Received: from anirban-z690i-a-ultra-plus.iind.intel.com ([10.145.169.150]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2025 02:11:23 -0800 From: Sk Anirban To: intel-gfx@lists.freedesktop.org Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com, riana.tauro@intel.com, karthik.poosa@intel.com, raag.jadav@intel.com, Sk Anirban Subject: [PATCH 1/2] drm/i915/selftests: Correct frequency handling in RPS power measurement Date: Mon, 13 Jan 2025 15:29:11 +0530 Message-Id: <20250113095912.356147-2-sk.anirban@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250113095912.356147-1-sk.anirban@intel.com> References: <20250113095912.356147-1-sk.anirban@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Fix the frequency calculation by ensuring it uses the raw frequency only. Update live_rps_power test to use the correct frequency values for logging and comparison. Signed-off-by: Sk Anirban --- drivers/gpu/drm/i915/gt/selftest_rps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_rps.c b/drivers/gpu/drm/i915/gt/selftest_rps.c index c207a4fb03bf..32a4b0aa710a 100644 --- a/drivers/gpu/drm/i915/gt/selftest_rps.c +++ b/drivers/gpu/drm/i915/gt/selftest_rps.c @@ -1115,7 +1115,7 @@ static u64 measure_power(struct intel_rps *rps, int *freq) for (i = 0; i < 5; i++) x[i] = __measure_power(5); - *freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2; + *freq = (*freq + read_cagf(rps)) / 2; /* A simple triangle filter for better result stability */ sort(x, 5, sizeof(*x), cmp_u64, NULL); From patchwork Mon Jan 13 09:59:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sk Anirban X-Patchwork-Id: 13937125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A49BE7719F for ; Mon, 13 Jan 2025 10:11:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A345410E630; Mon, 13 Jan 2025 10:11:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XkYltIYx"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 864DE10E630 for ; Mon, 13 Jan 2025 10:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736763107; x=1768299107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HWXJAfdoJR8YnQRCTlRDPU6CtxEXq+6ohbvUcMepGXc=; b=XkYltIYx9mM8+XS5CZhrs3nrLZYyA+xzvZagk2vPx3pOzthFoyUrrdzP QFmg7LUb7/pMJ8JzWnxPh8FkwGfIyD6/2xdRPP9KLh1uHjvUqKGMJ2U0o //ghURyTxIC/8KyXm9h4S88seQrSPKYioXqMSuZZqJq0UGfoINkcDF5v7 wkVtY+TxkCfrnhBAquuFUIsEqHyVTLM0X8DhQLyGtjZUZHhivFiYUKzW0 Ms+3ltMGrhlKkqrMR5ucKL1y0mP/jJgrlxw72a/9JNl+qmBCHhk5ZMpGy 50tucHG6kNIAjXW3N78Ip67UF+qgk+yJrCHkHW5AwoCLx7kk8gPuLVlUp A==; X-CSE-ConnectionGUID: zPhv/k07QsaMGZ0xCRYfhw== X-CSE-MsgGUID: B5QqYeMiQOG7LaFk3eF6bw== X-IronPort-AV: E=McAfee;i="6700,10204,11313"; a="40696349" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="40696349" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2025 02:11:28 -0800 X-CSE-ConnectionGUID: klUJerIjRSCxcRbl+jOUaA== X-CSE-MsgGUID: PGmaO+10Rxapk3TWWywM8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="127689604" Received: from anirban-z690i-a-ultra-plus.iind.intel.com ([10.145.169.150]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2025 02:11:26 -0800 From: Sk Anirban To: intel-gfx@lists.freedesktop.org Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com, riana.tauro@intel.com, karthik.poosa@intel.com, raag.jadav@intel.com, Sk Anirban Subject: [PATCH 2/2] drm/i915/guc/slpc: Add helper function slpc_measure_power Date: Mon, 13 Jan 2025 15:29:12 +0530 Message-Id: <20250113095912.356147-3-sk.anirban@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250113095912.356147-1-sk.anirban@intel.com> References: <20250113095912.356147-1-sk.anirban@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Previously, the RPS function was being used, which utilizes raw frequency to calculate measured power. This commit introduces a dedicated function specifically for measuring power in SLPC, ensuring more accurate and reliable power measurements. Signed-off-by: Sk Anirban --- drivers/gpu/drm/i915/gt/selftest_slpc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/selftest_slpc.c b/drivers/gpu/drm/i915/gt/selftest_slpc.c index 4ecc4ae74a54..cb5d5e2c5dbe 100644 --- a/drivers/gpu/drm/i915/gt/selftest_slpc.c +++ b/drivers/gpu/drm/i915/gt/selftest_slpc.c @@ -95,6 +95,21 @@ static int slpc_restore_freq(struct intel_guc_slpc *slpc, u32 min, u32 max) return 0; } +static u64 slpc_measure_power(struct intel_rps *rps, int *freq) +{ + u64 x[5]; + int i; + + for (i = 0; i < 5; i++) + x[i] = __measure_power(5); + + *freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2; + + /* A simple triangle filter for better result stability */ + sort(x, 5, sizeof(*x), cmp_u64, NULL); + return div_u64(x[1] + 2 * x[2] + x[3], 4); +} + static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) { int err = 0; @@ -103,7 +118,7 @@ static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power) if (err) return err; *freq = intel_rps_read_actual_frequency(>->rps); - *power = measure_power(>->rps, freq); + *power = slpc_measure_power(>->rps, freq); return err; }