From patchwork Thu Oct 3 08:39:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 13820799 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) (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 555CE2232A; Thu, 3 Oct 2024 08:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945065; cv=fail; b=YzbPSORekMjDDkl7CUU9YlIM+IPsCqHinsNyLysDFmMOOW6Ak3k41KnN/Y/qsSLJx+mgGSO3m8xqcEdCUaOz3pTgJURrr3vXxuAKIJizVcRSOLkN9IChw2Zeu5QauRj3sucOHbZ/lc8Vhpta4Ga55n9MiLAOzyr84AwoZRUXxJ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945065; c=relaxed/simple; bh=MLZjQpjJnF8ZG9AmnC0nMR4qa1qq081eaYw0+LqCrLU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fTyT2/8I02uaKZiArsYTA0UvuzZHuRlKygqUrhkG+Y+UBISSBTcn0E8UKlb7zpmL5PEG+puzDI6vK02RP5pmO4aDrfs5WHOf76KttV4BFx3gZhmXVXFmHLfI3leZ+ZDZcBZVD/IbOLMcto2BkUzFdKTI4iv0QRBa/YytXy133dE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=1i+Xw5pp; arc=fail smtp.client-ip=40.107.220.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1i+Xw5pp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UdZX11LVCu01A4G9qVE5KPevoQlh3f3VQdiU3vOVMNz1pdSXYi/Z75ukJEBEBFemp1V5h0+ReLOAEu1sibwE9u+m0nrvHVC1/66vdXf3X44VoT8gyBvnHiMoqr0g27fiwMtOcoFQLsbr38gDsvuPasnAe1iow819Cxwi0uWFycVfS/Of17Kbp9JbUrlRysoFng26q/MYt3OkzIoQZjPP13eBgoYjD9UrOEPeXiXMb4LIiR6LKIt+A8PMBqW7LVU52dn1WeC1VE+HcWA+0SS2crxHrtqNONaDLlTePcn6Cd8YzzkwG+c53hajR8Ul5q0u84zZcDusjuu8m0WwK+JJPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CpdU2YjvH87ZsHFGogC85X3ne5AfGIrGwKcUYR0D/1A=; b=GQQ4XAruRKRyiie6F5dNo5Do/EVsGpx5SA93yZZRhAldJFtNgFVC7WYjQX3ZxDO9GeDGYsJynpw1gfrlU9iowyoKsBzvUfpH3ssTpRdpycX2AFezQoUKW67qLL7CYQxsPDdff9qw6aUzhWVqY8Xjv3cYZCzJb4nkhSUu0gmoj07r7ovNzDVt4rNVI7YS+egqPMMm+WBZ2FHMnaCFrtfRNCCwSZpRTLD+C5tJLOqbClMM/Ai5i7FEYJJ3fZ1U12Nbn5NiOrZb4q0xonw5eMcoyc828SbrFyS0fmleih5N1nEeLatOyhZyqJ0+fyYqpUscax6Eq1AKhwnQ9vnE6ustsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CpdU2YjvH87ZsHFGogC85X3ne5AfGIrGwKcUYR0D/1A=; b=1i+Xw5ppsLp2FVn3n0HiwOcFqilxSM5N7ifBz9TcWgJmkqPjyqCOIQx/mfzv+NrnanNU8V1EmyCqeRbU+fVYX7FDg7JDhB71BrKwMcJtnpa2/YGLo5uQby/tVClR13JNvlAcJD596oJOmf5EnswrG1a/a60AGoWBTfR0jO94IqI= Received: from DM6PR03CA0013.namprd03.prod.outlook.com (2603:10b6:5:40::26) by PH7PR12MB6787.namprd12.prod.outlook.com (2603:10b6:510:1ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 08:44:21 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:5:40:cafe::a9) by DM6PR03CA0013.outlook.office365.com (2603:10b6:5:40::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 08:44:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 08:44:20 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 03:44:16 -0500 From: Dhananjay Ugwekar To: , , , , , CC: , , "Dhananjay Ugwekar" Subject: [PATCH 1/3] cpufreq: Add a callback to update the min_freq_req from drivers Date: Thu, 3 Oct 2024 08:39:52 +0000 Message-ID: <20241003083952.3186-2-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> References: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE33:EE_|PH7PR12MB6787:EE_ X-MS-Office365-Filtering-Correlation-Id: 87bfa2c1-6d52-4577-0595-08dce38792ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: wIprc10Kg1ONxMaanef+boy2xSQmaOWhM8vsVE178+QBVseabFViODCnIw2pbhjJFBQM66HshE662RhZhas+kealUg08JOkDHp/XfvI4Ot28TrH0oMuuIfOfp3eqdJy8GPeYNsULWSpGcJ1dfvVopo/+2uwUAn8iVybXko5jE2a7qFCoAM+gUT+MxbfuBlVFADnskq+gprQOXRL3DLcV2FwcwlcC44U2EYT4/yJImiGZIPomDxHsdVzJYIjQaLbH0cEc3yLl1nCEMDmSUYXsEG2EPlHhxdUO/zY2Kyt5lsMc6lNA4hvVlShdujCKzGshk9sTN59460eaOqg3YcCwmwsKNMfROW10/mDOhzEGCu1TPu3gXhBIInwRosKjNwc+C638QgYc98ELmA3L09l+a8wvYKTAzMgrsQthp/xhcYd1FVaijjXIBrazvPuXOQe4MN1gGsoWDjVNXHF8dcBhmOyJHnBuuIUdZL8oycvbnzYH1ILtqnjRFuFVhN/yV6QG9Fx9jrzgw2JByGJH+jZxhzCmnqndmpa7uNmqxbBOoRviXzU9IETPFFsC7DIxOaE+X7nF3ckX3PHhbOSgWnmVhKlJLuY4rfvDD/kwhCXXS3YwWSRpj1AD7A2iB/uCf87azF+cWiiLNQqEaSsPtBKZOOyUxC0zi1fOo1xieBOIiLAcPbToSOz+iZx1oXkQL7xskk2pyrRYKb/rFjVYDwR7ioW3dIFTIAZmrh9Oh0mnvLgbFDqD0xqeheh8DZy8u5J3WMgteUzbuJ7Dk5ugYH6WvJTSPFUKx601Rx8tYz7mbTDtkG95EW100DKFUQ2hCdriHHFRIhgP8LgR5nxhG1VlP+DqYU0msJ+QHK/nHPivOfbGCXBmP3+gyaLzrGRIJjjSqmrX8VSp88dYWx5zDMz+0T1dwN5op50DMUXLtX+DpO7P2EtHj9h22lqnaCfvJNvSIVSgZHklmrSBqCJenDqgCM2I/onC6sDeEZdKA2S6ab3Bph9RKk8uMhf0ZI2resWYjq/Z84xqiDZPU0gcHRCzJjy/jShFYdKdDx7SpiFAO2VfX4BTMg/f+j6iwJMIsYOk0pCpTUegBAq0/4mTd2Q0/LYwDL4GNQB0zM5t5jLWxss7XgdKsCoHnxidXRZX0Sl+iJMsg1kVQGBqR8GkpYsqkznI1Xjwaw/F8c+BnAuzBPTJsHha3dq5+M2MCxk3l8H0mPh5lHsjGcJtQPAcWm8sPfHZF8m7mjDqOvBo4h0/HGRr2gf+l+Vw4BSi7144rK3pLxsnpBr0kF5+8x67cITchs5gvYGt8K9bLu4jnOrCdhA8NsiAWPLCnsrENhmHGqhLS8zbnD8SitG077qi4gVeCj32na2acmrItY991uxINJV00xLde4v3zvG5UqQRvDrx X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 08:44:20.2793 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87bfa2c1-6d52-4577-0595-08dce38792ea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6787 Currently, there is no proper way to update the initial lower frequency limit from cpufreq drivers. Only way is to add a new min_freq qos request from the driver side, but it leads to the issue explained below. The QoS infrastructure collates the constraints from multiple subsystems and saves them in a plist. The "current value" is defined to be the highest value in the plist for min_freq constraint. The cpufreq core adds a qos_request for min_freq to be 0 and the amd-pstate driver today adds qos request for min_freq to be lowest_freq, where lowest_freq corresponds to CPPC.lowest_perf. Eg: Suppose WLOG considering amd-pstate driver, lowest_freq is 400000 KHz, lowest_non_linear_freq is 1200000 KHz. At this point of time, the min_freq QoS plist looks like: head--> 400000 KHz (registered by amd-pstate) --> 0 KHz (registered by cpufreq core) When a user updates /sys/devices/system/cpu/cpuX/cpufreq/scaling_min_freq, it only results in updating the cpufreq-core's node in the plist, where say 0 becomes the newly echoed value. Now, if the user echoes a value 1000000 KHz, to scaling_min_freq, then the new list would be head--> 1000000 KHz (registered by cpufreq core) --> 400000 KHz (registered by amd-pstate) and the new "current value" of the min_freq QoS constraint will be 1000000 KHz, this is the scenario where it works as expected. Suppose we change the amd-pstate driver code's min_freq qos constraint to lowest_non_linear_freq instead of lowest_freq, then the user will never be able to request a value below that, due to the following: At boot time, the min_freq QoS plist would be head--> 1200000 KHz (registered by amd-pstate) --> 0 KHz (registered by cpufreq core) When the user echoes a value of 1000000 KHz, to /sys/devices/..../scaling_min_freq, then the new list would be head--> 1200000 KHz (registered by amd-pstate) --> 1000000 KHz (registered by cpufreq core) with the new "current value" of the min_freq QoS remaining 1200000 KHz. Since the current value has not changed, there won't be any notifications sent to the subsystems which have added their QoS constraints. In particular, the amd-pstate driver will not get the notification, and thus, the user's request to lower the scaling_min_freq will be ineffective. Hence, it is advisable to have a single source of truth for the min and max freq QoS constraints between the cpufreq and the cpufreq drivers. So add a new callback get_init_min_freq() add in struct cpufreq_driver, which allows amd-pstate (or any other cpufreq driver) to override the default min_freq value being set in the policy->min_freq_req. Now scaling_min_freq can be modified by the user to any value (lower or higher than the init value) later on if desired. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/cpufreq.c | 6 +++++- include/linux/cpufreq.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f98c9438760c..2923068cf5f4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1361,6 +1361,7 @@ static int cpufreq_online(unsigned int cpu) bool new_policy; unsigned long flags; unsigned int j; + u32 init_min_freq = FREQ_QOS_MIN_DEFAULT_VALUE; int ret; pr_debug("%s: bringing CPU%u online\n", __func__, cpu); @@ -1445,9 +1446,12 @@ static int cpufreq_online(unsigned int cpu) goto out_destroy_policy; } + if (cpufreq_driver->get_init_min_freq) + init_min_freq = cpufreq_driver->get_init_min_freq(policy); + ret = freq_qos_add_request(&policy->constraints, policy->min_freq_req, FREQ_QOS_MIN, - FREQ_QOS_MIN_DEFAULT_VALUE); + init_min_freq); if (ret < 0) { /* * So we don't call freq_qos_remove_request() for an diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index e0e19d9c1323..b20488b55f6c 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -414,6 +414,12 @@ struct cpufreq_driver { * policy is properly initialized, but before the governor is started. */ void (*register_em)(struct cpufreq_policy *policy); + + /* + * Set by drivers that want to initialize the policy->min_freq_req with + * a value different from the default value (0) in cpufreq core. + */ + int (*get_init_min_freq)(struct cpufreq_policy *policy); }; /* flags */ From patchwork Thu Oct 3 08:39:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 13820802 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.78]) (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 2586E482ED; Thu, 3 Oct 2024 08:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945171; cv=fail; b=pL2ODap7FaxCRMBxEr7TsLUWJPN3hRcm7j+2pMs/8GYn2NfI2cLNiyDUGc5yBlDIgDQekGXqsQuamQ+cwBWd8slJwdF5sUuTwEGLZE9jbThqY9Yz5U/gvMwmJQiTG37yzegRaKzFnTmFHuw2DMWBCg67WpN/RUpzLf2tAj8GhB0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945171; c=relaxed/simple; bh=4Ve6i4Rv3Mwn88STU8da3QNPK6uVAlggZRA168oFL7A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SnV9CrazzilfOa8LecW4qH5snavRJ+B4ASovQI43AcuEaqgswNbC+5jAtKDktCEOJLF+i8x5EIgMVGZaAMFLX7STyIqq87rQ91+JkJeo9U956OGKFxFc0yk8qIYnX7i/79SKJ3s7mQTrnVNo4JayKk+3CkZAVScISOQB9JFe62o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=lT2rwUBg; arc=fail smtp.client-ip=40.107.244.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="lT2rwUBg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DiYZicawj4MFTWSKpn8dB90LWhsSuvkSPFdf9FyQIy7NGtOJgNvA6FFnrqmmmOGKFARvyQGE7b75twZ0q+wA/ixv45GLRTrqatRpHULcY4mm3rqKWaE19eLd3cJ2pytaJiR0OXTaIvWFWeo/gPPxj0vNX828/Y0rlV7d5gKWwg6GHbVsZwNskXy4j0xlktl2Gtowbn7AjfoTtJ5QIQTlSI/caizuNA9m3xtP555zv9wqmjxp08OrnbbVNoSiklATqyoZb1b1IygTrW3PQ3B7XKXjNQDBY+oT16Jo71ZIGA5emRPdoLkKNkvCgRjlHTXx8JzFfUJRpSjukLpuPBHSpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rM15UiT3u2QbAYi3rT/oD6jbgjwQb5wY1LJWn2+vBL0=; b=aqYDSIlyzCmBgkRt06gBW3JDr3y87ez+iPb3pZItbqTjmllNxf1BvGqaLr+Hqy6rjCWLn5IuGAlGt3nGOIIPEhryRuzLU+n2kfXYj7F0XWK0GTwBkbJmNPZL6dIawDvmAUWVinn5MuCnr8QhKxbZaRwejxerS2Q/RnmT/FpIb1W9xCSQ261uZfHW1/b7VYqXkeHrYnhTgajGPWkG8u6ZelHCYygDw57Y16oceSo7dlcW6dA37ssyTs222dAZRqe5kZKR4pc4Sp2ReeE90tHfHW4u43iPOw1aWiS70HtN2dUIc+A4F1hS8PMztVRTV/jOXe/Dt39ORmrftl9IGKynDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rM15UiT3u2QbAYi3rT/oD6jbgjwQb5wY1LJWn2+vBL0=; b=lT2rwUBgy+iHwZyfYQjklmTB9CS8yr5Qk+XZYy7bY1hxlxF3DIFym82nbcVfZK65OkTl4PX4LbbUNB3jtwFM1PzrzrSnYq4/WKfungy0ZgLsZ/XfxWgdL7ULacog86F5uMOs3gATdg5wJ4WiRY2iSqcJAfcvf7tJU9WavYxrbX0= Received: from DM6PR06CA0051.namprd06.prod.outlook.com (2603:10b6:5:54::28) by DS0PR12MB6654.namprd12.prod.outlook.com (2603:10b6:8:d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 08:46:03 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:5:54:cafe::39) by DM6PR06CA0051.outlook.office365.com (2603:10b6:5:54::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 08:46:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 08:46:03 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 03:45:59 -0500 From: Dhananjay Ugwekar To: , , , , , CC: , , "Dhananjay Ugwekar" Subject: [PATCH 2/3] cpufreq/amd-pstate: Set the initial min_freq to lowest_nonlinear_freq Date: Thu, 3 Oct 2024 08:39:54 +0000 Message-ID: <20241003083952.3186-3-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> References: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|DS0PR12MB6654:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f38b0db-f658-4aa3-cb60-08dce387d03c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|30052699003; X-Microsoft-Antispam-Message-Info: iaF3O0HewwlfveIA6+jLb/aFTk7myaHjiYTT5ZYVADjYtlhpStbE+EmLxvZTHWcitNsBx6HtYPBmfZ7UKNoThaafztfWElsqwRE/78t9b6a+mVKvVhfT+c8GHMlquBDaH1ECqSzIZ/QREvw3hvST6pLTJZmqkGq9yrngv2rzBdhw/jaSnWMhL33y9HCzwnguYJ4yBjLHaaMXxrBeJ+RohTPnOzpg8neuifUI0EMB2Wyym8MpOTmZVHDWykOMWzJfOt4EB7amrMPDalmx9ZNe7zI+DleXLBDmwyY9NJg83LcusnlXp0nJ/8f1fpXdBLvyTRVsEyoHE6EIU1F/XcuCMPeTkp6cyulL5duM0BZPPbgELOYjc8DYF7SGy+79yxXli1DCQWY+dbTKWnf0ay94Riu28qCOq9Tral3t4XYPCPnKHYVvHok3fHxvAQAnizlEKE8vOf9Eq0bmeLa9CYOtcG0tFT9o1Ms42EnHCv8TkNHUYMGztyGt12396n7UxQs3OWewJ7Myd1/1e7yoZ5cPkkfzy7AODzkute6C5Qnu5ypgts9irHgUat9fsUJgP7Rg2QC4IP8kjkLMi03781a0r8JWcTszhA6pHYDh1dNPt8kipOq5qG4HjXxWOytcuv4vf7K4yM2iZkhZuC3OdvoqW83licDqMvwaFxn0gvKaeCK0uacwl2e8115QXjz7vrMV8CQMclGlN+MgDxbfpyNyv1KO8E9s53un/neXtnb3XPVajkgOstV85MyDV7pe1gRxbahxaPYH8pqTsexKgVCsCMh7DDtVM0gI4+jhJZL22pzKpm52PCFlZjxd7sc3vdJQ9+TwDiYGQjJvC4lEN9kTIJmMUuH88VPw7pDwws8cp3dnFSQMG+RPdvnA8Gj24vMq5KmdFd9BVW7rl1+1vVZXVgC7yor/ZBEdyBXqsWbe0IEZW94qpBVB0QTzEZDtqNv2OYUsJlyN35KjQWnILxNsBPRzzqwaIc+Sia+Vfi0UIJl6ofQLf3fyKOZAs50LRxIm8bbdbVHSH/hgOER4DXk4Ia1faLwyVpW16dndFFZLDMns9KzPAHkaAbAG0J+kFDvFkNjkIYR+Z5CIgBC6qJvpo1lN+Pjnr/fXbAdkezCrxGto2+YbNJcLfHUs9okkXyRwnQRCKbJJ6FwAflt6oepiPAcCxE7ZaMdvQEMmwpkP1GJLpSbM4nwveDPI79cIh6ZUUkEIBZGPuHqREzmj1d+va+vFYQak66T0EVyfQt3FxIgBTu6HprUxZsJffJPtZQhXn4idVZT1x1PS+S0AxSxLFZ213LTzoLyJrrOsWUpwP3axUJANDj55JMtnO8hoUaRfEPWjExcCTjL3U9xhwkS26zJoV471HpnrP5uSdcO6HSvtUugputOeMis8DqKtBwol X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024)(30052699003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 08:46:03.1628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f38b0db-f658-4aa3-cb60-08dce387d03c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6654 According to the AMD architectural programmer's manual volume 2 [1], in section "17.6.4.1 CPPC_CAPABILITY_1" lowest_nonlinear_perf is described as "Reports the most energy efficient performance level (in terms of performance per watt). Above this threshold, lower performance levels generally result in increased energy efficiency. Reducing performance below this threshold does not result in total energy savings for a given computation, although it reduces instantaneous power consumption". So lowest_nonlinear_perf is the most power efficient performance level, and going below that would lead to a worse performance/watt. Also, setting the minimum frequency to lowest_nonlinear_freq (instead of lowest_freq) allows the CPU to idle at a higher frequency which leads to more time being spent in a deeper idle state (as trivial idle tasks are completed sooner). This has shown a power benefit in some systems, in other systems, power consumption has increased but so has the throughput/watt. Use the get_init_min_freq() callback to set the initial lower limit for amd-pstate driver to lowest_nonlinear_freq instead of lowest_freq. Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf [1] Signed-off-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b7a17a3ef122..f8abae9a0156 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -995,13 +995,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) if (cpu_feature_enabled(X86_FEATURE_CPPC)) policy->fast_switch_possible = true; - ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0], - FREQ_QOS_MIN, policy->cpuinfo.min_freq); - if (ret < 0) { - dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); - goto free_cpudata1; - } - ret = freq_qos_add_request(&policy->constraints, &cpudata->req[1], FREQ_QOS_MAX, policy->cpuinfo.max_freq); if (ret < 0) { @@ -1706,6 +1699,13 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy) return 0; } +static int amd_pstate_get_init_min_freq(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata = policy->driver_data; + + return READ_ONCE(cpudata->lowest_nonlinear_freq); +} + static struct cpufreq_driver amd_pstate_driver = { .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify = amd_pstate_verify, @@ -1719,6 +1719,7 @@ static struct cpufreq_driver amd_pstate_driver = { .update_limits = amd_pstate_update_limits, .name = "amd-pstate", .attr = amd_pstate_attr, + .get_init_min_freq = amd_pstate_get_init_min_freq, }; static struct cpufreq_driver amd_pstate_epp_driver = { @@ -1735,6 +1736,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .set_boost = amd_pstate_set_boost, .name = "amd-pstate-epp", .attr = amd_pstate_epp_attr, + .get_init_min_freq = amd_pstate_get_init_min_freq, }; static int __init amd_pstate_set_driver(int mode_idx) From patchwork Thu Oct 3 08:39:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 13820803 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) (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 4DEC3482ED; Thu, 3 Oct 2024 08:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945205; cv=fail; b=VX1fv+koFl7MfRP6/2Dl9YKgYJsXs+baGTm0IUPSBms/ECMbOjnZc/Up9oinwVqW5kWDbnA9M838vAb51yUfMNX/+vKuWSAOmDmb+RaUmy2aqCZAI1ktc5rvMifd5y1Vvxb/pHBXi9JatU6QjXhP+C/y0FJtqlpCyTUeZpAUowk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945205; c=relaxed/simple; bh=syqBg/BiHojtTZhVA3ErNEbK223lK+APjIhM3AUnR5k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CH3/To9gGob/oi03Tc6dworBTYH3uMFqw1wEej8y9cebzHcOAMUOHYDKV2PeFCvineKQDqpjReELMb10rTN6KGcl1tEyqtRWF/ai4WgPQcbgmubLu1ro4wfXe7JLnGiSbl+5chwuQGsFTw9EGgKckiTK416XX+Qe1ac5NpG/P8Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=3AjduqNx; arc=fail smtp.client-ip=40.107.236.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="3AjduqNx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qIFpX86ZBGg2sPwP/WDd6FpadLwmFfb+80xaevC2vN467DnlOPKIvDwvLP7/bLwiWbjtIp9f0WBIEZwFInY1ib9yAIRH10jfd6nbi8DSBK58a/69YNXZM/xdSWkf83HE2Ds/XbHR79msC5sLWJ6WOyRATVSPZ0/iBTj2BFkOt1emKxHgrDlpTF9C9QvA8HYXcdKYZNWYvtVouET+z9ifTJ/+oY2bYj3BWayJbRiwT10uDd75KEVG5SKlnD93HDaGp+K9Jo/fR16hghaRt8K6Gpv0jn+qrYx42NSH9+d3tgCEmjE/CYvEVTRYm5RLYPmIe4ip+JD1IKlaojs6EB0blQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Hkcq0w1o0GK77QGsu+bKbA/cAyb0bpUrcB8TJZC3AMk=; b=LtksVsKRwiEBEypDIEpNeAuHF8TUIia+rLEZPBvMa02/RwK4EDx7OEyToKdlj2PgjqinIIBnI+CQR1yPo613HaHgzjKqDgnrtizVsF6Tp/vWHa5LL65ey8FS8swdAoiIQ7YZDi3gHrzm2KMOn7Ge0QobpnxmRHuYvIYkaLEkhv5xPR6B3rySb62x+kzuOc5kL/PWwhIz5pwrjY3p7F6Ls1xhhaufj6v0l1ABvtpJ+SgvluljkwktIreuAbOxBS3N6XN1nVqill7k/CeS9lOULVOmoSPkSbUwMAMzHCilhBCH7Fn6sBbkTKMqDqOICRSbYdjbCDDewQjN8BMESsXl4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hkcq0w1o0GK77QGsu+bKbA/cAyb0bpUrcB8TJZC3AMk=; b=3AjduqNxOXPRndQtr7EJvvXn5ZFweHfp7a+DQfuU1wYCpZBH9sSwSg4Y2pqpyL/tf8WjWqkd8vdqH+OKiUme6HuIpmXpdTgnyWVSXjlIH0d0Cr9Nj0+b4bFLyTTxXSOFCgvV8n3Dizsmyp/pf5TctwVIOwkTvK7FoUkXuwzvzJk= Received: from CY5PR13CA0011.namprd13.prod.outlook.com (2603:10b6:930::16) by SA3PR12MB8803.namprd12.prod.outlook.com (2603:10b6:806:317::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 08:46:39 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:930:0:cafe::d3) by CY5PR13CA0011.outlook.office365.com (2603:10b6:930::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.9 via Frontend Transport; Thu, 3 Oct 2024 08:46:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 08:46:39 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 03:46:35 -0500 From: Dhananjay Ugwekar To: , , , , , CC: , , "Dhananjay Ugwekar" Subject: [PATCH 3/3] cpufreq/amd-pstate: Cleanup the old min_freq qos request remnants Date: Thu, 3 Oct 2024 08:39:56 +0000 Message-ID: <20241003083952.3186-4-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> References: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE31:EE_|SA3PR12MB8803:EE_ X-MS-Office365-Filtering-Correlation-Id: f0406083-d0bc-4822-1df4-08dce387e5b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: bXcLbrvjKpN0t7MpoZIf99sjOG3auNl1kh+iJ9IfkD5ASpwXG1GsE+eduaUu/bcjqxbZtGu1Jref1t2z6WNFbBw5S7KPxR4cuhYHYwMEnJZyAjvOlaT4jV5BlCBxQlLlNecehtBor6nyOjZd52W+hAP5o9U0m4Pe7aDwouXnkZAAhvKYwIDVGEu10QzleDsXgNq/fl1lRlT+yCfQm9BAlHpoFnff75IzSdDDvAt0H2mzIeJ5sbF/vU+kC7OmmqRzCBQzklS4GCQrmR8ZZkhKu7tcAIfymctcvmSHgIJVr4tNIA5datHcvI+j/vY1DJc3z5GfZFNoCyfjcjqztSeA3CBwXa3Sg5bmJPot/WhuzuapAhUJ12tS0civN38PPuoEp4qVWAZVfexj+jw+6o1HkogmZEz68B4IrkjM954ps05LeoXl+hMyX3psy2joIklXSRW8dugx9p8KwXyVGchkeSKujQ7RLVcVZkVw/+4ZUMzuaZbDIDWaRnl8ZFffb9VJnD1B8gNjvpNa9EaHcV4NLMzRSuV3ixAG7AUtMVX8y26tFZTtxWZivpLwlHkJK1VdcC3YXu+MWypJh4EMFSdVvteQysPskad04m8o9wKHZNILY0bQqFVmv71Q85EoXC7KYr5awuYRn9paTnXVh2T7K0mZBUsj+4aFxXVkBtL6vnVXh6L8AaAQVoZTh/17PdxqPlEA8wfVofKQBd46ARhIiMqOkroOqv2Zty1BtbpX0MH9LYONvHgvCYQgi5NGFVRPCgokDULf+6ApCjDl/WrPjLzKvV4CuMF0ProOcPHJurwlRfEz5jilDLWqW+4OvUN9Lddhn+6Q/DHisKjG4Xc+ubdjyOS+fjbZ6QjObt+xrHkVurM1oJ5XBu4JxZeoQ4ZU9t26CR12SrCbpMKOMNg26/jZSVEqNhKDTAbqHAz93CBpyQ3nx1tGlIaMDnGQrEWrSzgNTEQ98l+GJUBHGqPprG8+bWO3GsDFC2ChvyOjUuvU9bX0DE5uICrX7q3AdsKjMEyxgRKg433qwc4h8oZk1P6c3dqY9RWj9nI91y9Nheywcr4Pj2usbz2D7CNHHo6xyZMWYAFStoJNHEZ61VpIzL41TDjbvdoraelPiV6pjdhBt79nlVVq9DnvylnbdAsLUmbIMm3SlPS4cVM2E/rHaUaz2kC7RuULgYIDT0O6ubSelbYw1gEozUGJnXpvWKNLSNOlnKpU3j+Rq/x0C/UzUD8C40GtMB4ddRWr9IsPn/m/SleGBJU4xV6skA02EYTRvYaO2+2ZWyYM/+E7QP44qo+IQOPV5bFLq6hyLIUAp3yBWr6XJjahRxasqgKR9mElSo6o+KuxJEJzjCa8tILZcYs5eVXizak+Rz3/m014aEP2oErtvKyI+b5XVlL+sra4 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 08:46:39.1572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0406083-d0bc-4822-1df4-08dce387e5b1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8803 Convert the freq_qos_request array in struct amd_cpudata to a single variable (only for max_freq request). Remove the references to cpudata->req array. Remove and rename the jump labels accordingly. Signed-off-by: Dhananjay Ugwekar --- drivers/cpufreq/amd-pstate.c | 19 ++++++++----------- drivers/cpufreq/amd-pstate.h | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index f8abae9a0156..cdc08d2ddd52 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -696,7 +696,7 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on) policy->max = policy->cpuinfo.max_freq; if (cppc_state == AMD_PSTATE_PASSIVE) { - ret = freq_qos_update_request(&cpudata->req[1], policy->cpuinfo.max_freq); + ret = freq_qos_update_request(&cpudata->max_freq_req, policy->cpuinfo.max_freq); if (ret < 0) pr_debug("Failed to update freq constraint: CPU%d\n", cpudata->cpu); } @@ -963,17 +963,17 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) ret = amd_pstate_init_perf(cpudata); if (ret) - goto free_cpudata1; + goto free_cpudata; amd_pstate_init_prefcore(cpudata); ret = amd_pstate_init_freq(cpudata); if (ret) - goto free_cpudata1; + goto free_cpudata; ret = amd_pstate_init_boost_support(cpudata); if (ret) - goto free_cpudata1; + goto free_cpudata; min_freq = READ_ONCE(cpudata->min_freq); max_freq = READ_ONCE(cpudata->max_freq); @@ -995,11 +995,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) if (cpu_feature_enabled(X86_FEATURE_CPPC)) policy->fast_switch_possible = true; - ret = freq_qos_add_request(&policy->constraints, &cpudata->req[1], + ret = freq_qos_add_request(&policy->constraints, &cpudata->max_freq_req, FREQ_QOS_MAX, policy->cpuinfo.max_freq); if (ret < 0) { dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); - goto free_cpudata2; + goto free_cpudata; } cpudata->max_limit_freq = max_freq; @@ -1012,9 +1012,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) return 0; -free_cpudata2: - freq_qos_remove_request(&cpudata->req[0]); -free_cpudata1: +free_cpudata: kfree(cpudata); return ret; } @@ -1023,8 +1021,7 @@ static void amd_pstate_cpu_exit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; - freq_qos_remove_request(&cpudata->req[1]); - freq_qos_remove_request(&cpudata->req[0]); + freq_qos_remove_request(&cpudata->max_freq_req); policy->fast_switch_possible = false; kfree(cpudata); } diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index cd573bc6b6db..643e2a71827d 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -28,7 +28,7 @@ struct amd_aperf_mperf { /** * struct amd_cpudata - private CPU data for AMD P-State * @cpu: CPU number - * @req: constraint request to apply + * @max_freq_req: maximum frequency constraint request to apply * @cppc_req_cached: cached performance request hints * @highest_perf: the maximum performance an individual processor may reach, * assuming ideal conditions @@ -68,7 +68,7 @@ struct amd_aperf_mperf { struct amd_cpudata { int cpu; - struct freq_qos_request req[2]; + struct freq_qos_request max_freq_req; u64 cppc_req_cached; u32 highest_perf;