From patchwork Thu May 15 21:19:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 890802 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B302296737; Thu, 15 May 2025 21:20:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747344011; cv=none; b=cOuL3mraDQEFfWeSoM9he1lRX4ax6iDafy3sjJleRmRKChMsp0srqYKnKXHpkniS+fFmndFIyEYgmnh8xwja1A73+EozlQNq2KQ7QW+2CT/z8HSfH2aiDMNQBZhK2jbi4OuQLjuawuqjfqXDvaJ0yuKwBgthfZPiOgllOfTviWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747344011; c=relaxed/simple; bh=/cfo1Y9MT5Ycknbk7VmiPAVdi6UsMkFQ6EWvUahjUb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vAXh23qRhkqeJ3xRcocMVrAhoY/oqXePd8RuDI3YJUOPeyl9nKkB0JM8qO2GaJI2587p4+dzlilGUvefRjQZPLZ4Z1b/cGteZvV1zhc3qwwx2tumcSGowvxZ0s9uRGd7rcrs9FEQZlf4VS8rEkwYxJ5nyxpsO/ev8/w8Bf6sL9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XV2rrpGB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XV2rrpGB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3CADC4CEE7; Thu, 15 May 2025 21:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747344010; bh=/cfo1Y9MT5Ycknbk7VmiPAVdi6UsMkFQ6EWvUahjUb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XV2rrpGBzO87ZeBP2N65UEDqGzBU1I+Q+BKYzmQSfL08uZrMT5Bjm/pWhH9/JyI5t NGlYL73R76OWTWda6BmGvhwUyyvC7j8DEkjFCbmztgbdZBbglypf6vc9vSNrLfz+am 8r+KWS3eY33q2hjqG1OahofBXgzIg8UYdv7Os5btE1q5AzCj1MqScJYMUyYNMhmCF7 U74qFN1PGISnKZ57jLmWs8IU6NO9c/BBE280u3BfFJWYqDQgE73ILwNbh+pgdOSrKZ SovLDuO1wTGGOEPTQzEhqZb5Tguj1+SgDUpKp4lTjl1PFHPFURM2ZR8UNiwUUaVroL rhZcH7yvcITMw== From: Mario Limonciello To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: Mario Limonciello , Perry Yuan , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H . Peter Anvin" , Jonathan Corbet , Huang Rui , "Gautham R . Shenoy" , "Rafael J . Wysocki" , Viresh Kumar , platform-driver-x86@vger.kernel.org (open list:AMD HETERO CORE HARDWARE FEEDBACK DRIVER), linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-pm@vger.kernel.org (open list:AMD PSTATE DRIVER), Perry Yuan Subject: [PATCH v10 06/13] platform/x86: hfi: init per-cpu scores for each class Date: Thu, 15 May 2025 16:19:43 -0500 Message-ID: <20250515211950.3102922-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515211950.3102922-1-superm1@kernel.org> References: <20250515211950.3102922-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Perry Yuan Initialize per cpu score `amd_hfi_ipcc_scores` which store energy score and performance score data for each class. `Classic core` and `Dense core` are ranked according to those values as energy efficiency capability or performance capability. OS scheduler will pick cores from the ranking list on each class ID for the thread which provide the class id got from hardware feedback interface. Reviewed-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/hfi/hfi.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c index 17ce5302cb531..f63c6098b7d92 100644 --- a/drivers/platform/x86/amd/hfi/hfi.c +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -227,6 +227,31 @@ static int amd_hfi_alloc_class_data(struct platform_device *pdev) return 0; } +static int amd_set_hfi_ipcc_score(struct amd_hfi_cpuinfo *hfi_cpuinfo, int cpu) +{ + for (int i = 0; i < hfi_cpuinfo->nr_class; i++) + WRITE_ONCE(hfi_cpuinfo->ipcc_scores[i], + hfi_cpuinfo->amd_hfi_classes[i].perf); + + return 0; +} + +static int update_hfi_ipcc_scores(void) +{ + int cpu; + int ret; + + for_each_possible_cpu(cpu) { + struct amd_hfi_cpuinfo *hfi_cpuinfo = per_cpu_ptr(&amd_hfi_cpuinfo, cpu); + + ret = amd_set_hfi_ipcc_score(hfi_cpuinfo, cpu); + if (ret) + return ret; + } + + return 0; +} + static int amd_hfi_metadata_parser(struct platform_device *pdev, struct amd_hfi_data *amd_hfi_data) { @@ -309,6 +334,10 @@ static int amd_hfi_probe(struct platform_device *pdev) if (ret) return ret; + ret = update_hfi_ipcc_scores(); + if (ret) + return ret; + return 0; }