From patchwork Tue Feb 18 19:08:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 866345 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 D9A2F274278; Tue, 18 Feb 2025 19:09:02 +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=1739905743; cv=none; b=YLBrPLTExHdbUuK73rrTnaTqFSvai8xaFii00v6C/4uHEDIPpZuzc+wcOHFd7SkpwF2NkMratAsTH6/Vs7AcxoKszcYpbGhd4YRd1A2E42ev33DyEh8v5O++El8LpJizOeNt+1FpwBYGSd5jXq562UN1Zj/CR8RMYhoS06dPMS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739905743; c=relaxed/simple; bh=JwZzNLB2QqcUOeCrjAAn6dpWhk01EyVf8Q70EMwrqU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jJcSrM4Sv2HDfvISlNWiR1GuMlGoT44ZhLENq9DR6Lw2lAeJHxQJh7rjqZ5d1ngkPsVKM3HDApW1bDrghJOP8i2ZNWmpgWkOwaezYDhdfOGzgIY+rO+ukPaUkwbCVGE20rvWs8JJMezzSKrGkwBmKIpa/DDX2XBqwfr4JYWOvBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IY5JCGHm; 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="IY5JCGHm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAD25C4CEE8; Tue, 18 Feb 2025 19:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739905742; bh=JwZzNLB2QqcUOeCrjAAn6dpWhk01EyVf8Q70EMwrqU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IY5JCGHmmWA3mp0uZpN6GVETeo6+fsk4HmwdJFuSQWyc/fgf1+7FlDj5iJ2hDYWUi j0OMeuYxzfqLJZI3SlDPtXguNOeffRdWeTIrvk31ViNw4dRJc7V/eY58oVbNGYsGsl 6IoYiK2BrIUa825DjJTRoPOXJZGTXO8yqQvtumapfkv/Im2q7cGS/94X/zHOhQEyZX AtFmvZDPRFKaARt7I5P2FgnEI+oebcSR1N8ufeCKoHDPFYCgtc1oGmn9x234tWpu4v YCxN+6zKjafYalyJB2wcIugXR7vbr1i8m6ShE3YfiDRPhaDbnUV24uh2qGnmnyEBLh dz8r+Uk52bKVQ== From: Mario Limonciello To: Hans de Goede , =?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 v8 06/13] platform/x86: hfi: init per-cpu scores for each class Date: Tue, 18 Feb 2025 13:08:15 -0600 Message-ID: <20250218190822.1039982-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250218190822.1039982-1-superm1@kernel.org> References: <20250218190822.1039982-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 --- v8: * s,for_each_present_cpu,for_each_possible_cpu, v7: * Drop mutex, move to proper patch --- 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 7ab7ae0ec72ca..e1550f4463275 100644 --- a/drivers/platform/x86/amd/hfi/hfi.c +++ b/drivers/platform/x86/amd/hfi/hfi.c @@ -225,6 +225,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) { @@ -310,6 +335,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; }