From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) (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 18C1F14F9D9; Tue, 15 Apr 2025 20:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744750470; cv=fail; b=jOEJrGhgTdEBFJqAlE0uPzNBr8cZ1YoJSqYPzMmyICrcWoB7SPd+883xgF1qlDUcpvwG1FK+qCGeh2DSndEP2rlJ2gRhh/8U2xGaf4eiH6aPol/WLMkjgbiCiZWPiYeLTD80pI44zmSH1u50CNOGeEk1g8wzTRhYheVecDGppVY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744750470; c=relaxed/simple; bh=HPuefG7bwLEOeAfj3QVkGmgH5ZdcHGDWmnolI/nktXc=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=lb7pLGnSWVJOei+xdS9Da1AvVEIYIj6J/CXF49Wl907FdRE+aqgHnTjzQURArgXwKDluCkyu96j/DgkPIzpT2CfdbyAuTb7lj+eNKTS1PE9yDx08MRomamewNbY/n194UTTuJFnvqxE2SQaWrLDfdFBFr5pIHGRhuHQGgtG3fcc= 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=AZS0/CdA; arc=fail smtp.client-ip=40.107.92.77 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="AZS0/CdA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cUCPy/Ie2IcNrdsAN1tVP5EIod++J5K/iCfP5pfuA2s+8BRS7gh6AIoRx+fR+gmh+WhWQ3dqBwuzBFUdNCKj3liVQ+lrjqLE4rDNBq83oC/uVAb3j6H6eR0GEuuDa8G67V37NMtldJe9Q1tEwSCq15U8L1J2BufJETdf+5xka03oKP89/iA4ZdkUVa6yxCN9HqqsjoXjJtytVh4LP4SEm/sgsJbO0ZM0f1WAbEenitXQ26TaUYyEUJYGT+TPF9DHEtPCd8Nx09uByv2/wijAAwsvllf4woblig7cBfu1iCa2/R3/KYsrKxRxO4ewH15NCUes4VI/dGT2yhmlSSu/Pw== 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=YbswS650lnCwarvvIgqXtIEZ3AJczG05X0Y/nrTkUn4=; b=VNPIU7jd0Ad3X09BwOBpKzfAP8n91Sp2CDpqzsaP4TgALBw9bTiyoDBdiYiXP0plVU60lMmaaoN+7o89+Z4e7xausW6YhONN3/cRolROQ4KojDzaz4NPX7bmyz5c730eamz0txi9iTRW0GsKkiaCJxVCPPgRZ6AIFb2c/1kfX5+SlcotbAmxRGtsvVHyfYtMh/0t8u7HZplN76pu3oAcuuXdYP84GNUh/LgbQrm47cKPZSZ4Dmi7jZVm4MFH/1CaHDHT9F0z+nuNVdr5m5rpupDcl4u/4jdlivWRt3C0cOPuatskhf382pF/M18gdjhfRCpUuzGLNU/DKy+XUugl5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=YbswS650lnCwarvvIgqXtIEZ3AJczG05X0Y/nrTkUn4=; b=AZS0/CdAYyy/qWVjH8m+CSNQNfbxiy8wirMcXDwnUImEwTPqMZawFiuWx9Qynf9Dcag0wbt8aU0v6lJOZP+GFAl8/HiwjgA6n7Oq6/sjoWg45lbAszyL08WVo5vEdi+WVgRaZ3sOC2N9mukZyxCzB/dViKrxYXTo1lpu6MsEcxg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from MN0PR12MB6101.namprd12.prod.outlook.com (2603:10b6:208:3cb::10) by SJ2PR12MB8035.namprd12.prod.outlook.com (2603:10b6:a03:4d3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.32; Tue, 15 Apr 2025 20:54:23 +0000 Received: from MN0PR12MB6101.namprd12.prod.outlook.com ([fe80::37ee:a763:6d04:81ca]) by MN0PR12MB6101.namprd12.prod.outlook.com ([fe80::37ee:a763:6d04:81ca%4]) with mapi id 15.20.8632.035; Tue, 15 Apr 2025 20:54:23 +0000 Message-ID: <1f8d08e5-8bc7-4a1a-a00b-505394a451bb@amd.com> Date: Tue, 15 Apr 2025 15:54:21 -0500 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option To: Dhananjay Ugwekar , gautham.shenoy@amd.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250415102118.694999-1-dhananjay.ugwekar@amd.com> <20250415102118.694999-3-dhananjay.ugwekar@amd.com> Content-Language: en-US From: Mario Limonciello In-Reply-To: <20250415102118.694999-3-dhananjay.ugwekar@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA1PR03CA0007.namprd03.prod.outlook.com (2603:10b6:806:2d3::16) To MN0PR12MB6101.namprd12.prod.outlook.com (2603:10b6:208:3cb::10) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN0PR12MB6101:EE_|SJ2PR12MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: d934bf6d-f848-4d43-f930-08dd7c5fb3b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?T3Eva1RkYXdMZENkNmcybXVhNG5NSHBMcWgwU1NEdWpmbmo4VWJEeWdBdVIr?= =?utf-8?B?dnpRNVY0dkU3eS9XL2g1ZG9XemYxTmRWUERBb3o0RldPN0J0c3B6ZXJncmJT?= =?utf-8?B?by9wdUdDRnpvQXhOMFE4WEFFY0pBRlFoQjJWOEovWGlXMGhYT1ZlWVE2ZStW?= =?utf-8?B?WGJOQ2ltR3VWdDMxRmpIdThMYmw5UHZobGdHWUdPUnVJV0R3K3QwZnp1aDlx?= =?utf-8?B?ZE5UajN1aXVkOXZjWjBMSzJyOGg5TkZnOG8wb05jelRIb2p3MU1PVFVUUWRL?= =?utf-8?B?dUFIT243OEVCMGxzSzJaV3dRMnJURGxBMUlLbVcxZytiSE16ai8va0xuWEQ0?= =?utf-8?B?aUppWXlYT0RjK0pjRDh0d0xMRUM5dG1CVm1IejFBSWxMQURtcFgvdy9PWHlo?= =?utf-8?B?K0I1RndqSWdVbGZ3aUhlcEhydmI1RUlkMUk1bDdlTnFXT2pCMXR1REVjaGZR?= =?utf-8?B?SkhsdnhaYXdYNXV4VXpSaGgwODBPZTZNOGRId2U1YzlFZHN1Nl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ZZZjhGOWZFd0IveXdEL1J4MjNPY1dBRkV0OWhPT2oz?= =?utf-8?B?alg3dEhHSzFrRHllem1IcHlmNDd6Y0tkbkhUT2RjZnUzczNZYXZZcXA4QWps?= =?utf-8?B?QjNXUDg2YUx3K1l5Q210aEJaT2haZHUvRU1BR09yMEM5WkhoQnJlVzA5eE40?= =?utf-8?B?Ym8rOHh5YXQxMXE0dnR2b1ZtMk9Oa2hxajJqSTJiVEVIVFhucGl0SkdKVTdW?= =?utf-8?B?Tmc2SkNpOUxJMm8xV0ZqV1VWNlBydHJLMnp1S3JVNHBRQXVNb1JFRmpvazNk?= =?utf-8?B?L1k1TDFhOTVTR2JRbk5ENW1qSVUyOE9kUVNqb1Bianl0Q2JyZWllQkI2SDFN?= =?utf-8?B?NFczc3llNUFQa0ljRTE1OEdLQzNpeThBMllpaXJ1ZE5SL1c5KytHNTNIMS9J?= =?utf-8?B?ai9QVzRTOHM1eVhlRFROSVN0QXA0ZEtWMnZSb3RsRVFVaHFPaU9zeUY1RTZ6?= =?utf-8?B?MGR5Q2d5ZnVIOGJHaU9Cc3dGamlqNWN3Q3FkOXFUbEUwWnNUVnpzSkNhT2VZ?= =?utf-8?Q?aXqeewpNVsg=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR12MB6101.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OExvaXJONk9ZZzBncUpBUUd2TnhoNVhtT3VpZ3BoUVg0SEQ1VXZvZHdPMW03?= =?utf-8?B?a3YzNmlvZkVwTlFlTjRDN1Jxc1ZnZ3oxT2lyU3g1YWNxOGErTDVEMGlFa2hm?= =?utf-8?B?UHlPejRpQjQ2azMzMTNiYVo3NkdIUjhER2ZmUlpsQ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f-8?B?R1hzbjJRR0phdVJOT0R1UTJDUFVDQVRWTk4zRklpMEQ4R0duaVppK1MzdDEr?= =?utf-8?B?d2V5eUI1N3hKbmk4RnRLcnZENEVRUWFleTZnWlY3Wm1PZk1TZjRFTEljN0w3?= =?utf-8?B?dFFwaWJuMzNwNjlRREVMcytsRDdHOFMxRjVQQW5OSVB0YUNjbkN0eUdYM29R?= =?utf-8?Q?DKWskreBziTnAMDG27xL71/w3?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d934bf6d-f848-4d43-f930-08dd7c5fb3b1 X-MS-Exchange-CrossTenant-AuthSource: MN0PR12MB6101.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2025 20:54:23.7285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vnwRPEa9zgT/5cl1kqrB+0wxfwdKC2PNPtiMp+00kBXlShAv+Gj//0gYRgttGsSr9Opy4UzcW7b/r1exHiwHXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8035 On 4/15/2025 5:21 AM, Dhananjay Ugwekar wrote: > Initialize lower frequency limit to the "Requested CPU Min frequency" > BIOS option (if it is set) value as part of the driver->init() > callback. The BIOS specified value is passed by the PMFW as min_perf in > CPPC_REQ MSR. To ensure that we don't mistake a stale min_perf value in > CPPC_REQ value as the "Requested CPU Min frequency" during a kexec wakeup, > reset the CPPC_REQ.min_perf value back to the BIOS specified one in the > offline, exit and suspend callbacks. > > amd_pstate_target() and amd_pstate_epp_update_limit() which are invoked > as part of the resume() and online() callbacks will take care of restoring > the CPPC_REQ back to the latest sane values. > > Signed-off-by: Dhananjay Ugwekar I'm generally fine with this, but I have one nit below. > --- > drivers/cpufreq/amd-pstate.c | 62 ++++++++++++++++++++++++++++-------- > drivers/cpufreq/amd-pstate.h | 2 ++ > 2 files changed, 51 insertions(+), 13 deletions(-) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 02de51001eba..d94fd2a38990 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -389,7 +389,8 @@ static inline int amd_pstate_cppc_enable(struct cpufreq_policy *policy) > static int msr_init_perf(struct amd_cpudata *cpudata) > { > union perf_cached perf = READ_ONCE(cpudata->perf); > - u64 cap1, numerator; > + u64 cap1, numerator, cppc_req; > + u8 min_perf; > > int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, > &cap1); > @@ -400,6 +401,22 @@ static int msr_init_perf(struct amd_cpudata *cpudata) > if (ret) > return ret; > > + ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &cppc_req); > + if (ret) > + return ret; > + > + WRITE_ONCE(cpudata->cppc_req_cached, cppc_req); > + min_perf = FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cppc_req); > + > + /* > + * Clear out the min_perf part to check if the rest of the MSR is 0, if yes, this is an > + * indication that the min_perf value is the one specified through the BIOS option > + */ > + cppc_req &= ~(AMD_CPPC_MIN_PERF_MASK); > + > + if (!cppc_req && min_perf) > + perf.bios_min_perf = min_perf; To avoid a risk of garbage being in perf.bios_min_perf leading to hard to root cause bugs could we initialize this to 0 in the non bios_min_perf case? something like this: cppc_req &= ~(AMD_CPPC_MIN_PERF_MASK); perf.bios_min_perf = (!cppc_req && min_perf) ? min_perf : 0; > + > perf.highest_perf = numerator; > perf.max_limit_perf = numerator; > perf.min_limit_perf = FIELD_GET(AMD_CPPC_LOWEST_PERF_MASK, cap1); > @@ -580,20 +597,26 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data) > { > /* > * Initialize lower frequency limit (i.e.policy->min) with > - * lowest_nonlinear_frequency which is the most energy efficient > - * frequency. Override the initial value set by cpufreq core and > - * amd-pstate qos_requests. > + * lowest_nonlinear_frequency or the min frequency (if) specified in BIOS, > + * Override the initial value set by cpufreq core and amd-pstate qos_requests. > */ > if (policy_data->min == FREQ_QOS_MIN_DEFAULT_VALUE) { > struct cpufreq_policy *policy __free(put_cpufreq_policy) = > cpufreq_cpu_get(policy_data->cpu); > struct amd_cpudata *cpudata; > + union perf_cached perf; > > if (!policy) > return -EINVAL; > > cpudata = policy->driver_data; > - policy_data->min = cpudata->lowest_nonlinear_freq; > + perf = READ_ONCE(cpudata->perf); > + > + if (perf.bios_min_perf) > + policy_data->min = perf_to_freq(perf, cpudata->nominal_freq, > + perf.bios_min_perf); > + else > + policy_data->min = cpudata->lowest_nonlinear_freq; > } > > cpufreq_verify_within_cpu_limits(policy_data); > @@ -1041,6 +1064,9 @@ static void amd_pstate_cpu_exit(struct cpufreq_policy *policy) > { > struct amd_cpudata *cpudata = policy->driver_data; > > + /* Reset CPPC_REQ MSR to the BIOS value */ > + amd_pstate_update_perf(policy, cpudata->perf.bios_min_perf, 0U, 0U, 0U, false); > + > freq_qos_remove_request(&cpudata->req[1]); > freq_qos_remove_request(&cpudata->req[0]); > policy->fast_switch_possible = false; > @@ -1428,7 +1454,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) > struct amd_cpudata *cpudata; > union perf_cached perf; > struct device *dev; > - u64 value; > int ret; > > /* > @@ -1493,12 +1518,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) > cpudata->epp_default = AMD_CPPC_EPP_BALANCE_PERFORMANCE; > } > > - if (cpu_feature_enabled(X86_FEATURE_CPPC)) { > - ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); > - if (ret) > - return ret; > - WRITE_ONCE(cpudata->cppc_req_cached, value); > - } > ret = amd_pstate_set_epp(policy, cpudata->epp_default); > if (ret) > return ret; > @@ -1518,6 +1537,9 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) > struct amd_cpudata *cpudata = policy->driver_data; > > if (cpudata) { > + /* Reset CPPC_REQ MSR to the BIOS value */ > + amd_pstate_update_perf(policy, cpudata->perf.bios_min_perf, 0U, 0U, 0U, false); > + > kfree(cpudata); > policy->driver_data = NULL; > } > @@ -1575,13 +1597,27 @@ static int amd_pstate_cpu_online(struct cpufreq_policy *policy) > > static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) > { > - return 0; > + struct amd_cpudata *cpudata = policy->driver_data; > + > + /* > + * Reset CPPC_REQ MSR to the BIOS value, this will allow us to retain the BIOS specified > + * min_perf value across kexec reboots. If this CPU is just onlined normally after this, the > + * limits, epp and desired perf will get reset to the cached values in cpudata struct > + */ > + return amd_pstate_update_perf(policy, cpudata->perf.bios_min_perf, 0U, 0U, 0U, false); > } > > static int amd_pstate_suspend(struct cpufreq_policy *policy) > { > struct amd_cpudata *cpudata = policy->driver_data; > > + /* > + * Reset CPPC_REQ MSR to the BIOS value, this will allow us to retain the BIOS specified > + * min_perf value across kexec reboots. If this CPU is just resumed back without kexec, > + * the limits, epp and desired perf will get reset to the cached values in cpudata struct > + */ > + amd_pstate_update_perf(policy, cpudata->perf.bios_min_perf, 0U, 0U, 0U, false); > + > /* invalidate to ensure it's rewritten during resume */ > cpudata->cppc_req_cached = 0; > > diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h > index fbe1c08d3f06..2f7ae364d331 100644 > --- a/drivers/cpufreq/amd-pstate.h > +++ b/drivers/cpufreq/amd-pstate.h > @@ -30,6 +30,7 @@ > * @lowest_perf: the absolute lowest performance level of the processor > * @min_limit_perf: Cached value of the performance corresponding to policy->min > * @max_limit_perf: Cached value of the performance corresponding to policy->max > + * @bios_min_perf: Cached perf value corresponding to the "Requested CPU Min Frequency" BIOS option > */ > union perf_cached { > struct { > @@ -39,6 +40,7 @@ union perf_cached { > u8 lowest_perf; > u8 min_limit_perf; > u8 max_limit_perf; > + u8 bios_min_perf; > }; > u64 val; > };