From mboxrd@z Thu Jan 1 00:00:00 1970 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 43355265CC8; Wed, 23 Apr 2025 01:47:09 +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=1745372830; cv=none; b=V2Zlg5hPIDpS0tJQTxlkAIysYZ8yo5UV2b+PDNgyzl+b8DATqYXgkrwbABuiChFuj7ggh4sWy95Ufb2YXirRK3j5xLDv4Hg0qPeNCunYuX0+Kbil7/9EStryN27+eqfwyIv5N9SP8xoqb6mjKBR/PSzWBFP/0/Fgsovk+9F4A54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745372830; c=relaxed/simple; bh=/cfo1Y9MT5Ycknbk7VmiPAVdi6UsMkFQ6EWvUahjUb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lq97wgbsdoo25QNZ7s5pgCkpMTS7etgKiHQJ6XEqoRrRNPhcn2yXgjCLaV4dOTSvQyruRs+HuhzFb8LQybsDYsd1YjSATA8O2tQ9/XeXjY5GczZwfodDwVvoYb+ZnNhC8o5ezMIiKTh9V8QemXI6EXRNq8cB+oMHwpkr+2nH0SM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Of76CVdk; 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="Of76CVdk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC4AEC4CEED; Wed, 23 Apr 2025 01:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745372829; bh=/cfo1Y9MT5Ycknbk7VmiPAVdi6UsMkFQ6EWvUahjUb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Of76CVdkj7KELn/cHtmntHIG+g7/0dwMAT/DP/0XMYyyNkQRc8kFcfssmcN5ZFPxz h2fQQVMfgJ7pXUlZDTGXl8HH51iAUSs6x+gBUZJNTHafRjE9r36DLJwoK2RrNKH4y7 dvlrHXMvcvZsloHgEnmBhbXYj0sU7T5QBAUnUVj7AzYvT7/jPtfDiAcDLegwLcDuj7 ohIrKteiX5xcPRjXl3c7vjct0TNDLYlHXoBjirWGfQf7FyngO8p4QLZ+WLZyufI6eT SHMN4FLUqeUbrqiO9mxk5lisAHPdALzSUGvBQTwOzZYqTTVBgMP7Yore8valIA1rCG Ahh4j0pArcv8w== From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=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 v9 06/13] platform/x86: hfi: init per-cpu scores for each class Date: Tue, 22 Apr 2025 20:46:24 -0500 Message-ID: <20250423014631.3224338-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250423014631.3224338-1-superm1@kernel.org> References: <20250423014631.3224338-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; } -- 2.43.0