From patchwork Wed Jun 12 14:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13695166 X-Patchwork-Delegate: mario.limonciello@amd.com Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2077.outbound.protection.outlook.com [40.107.243.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 A62E417A931 for ; Wed, 12 Jun 2024 14:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204281; cv=fail; b=V44UQsQJfB7b/kowO9Tb94uIy7IMmVGVfgo8I4KP23h6N28VaRnH9f9+jRhuKOy/eyiUmJlZ+3KqCBYCNKuYcoDCvzhVsQLFP3WyHuiolGIzpWk9iDtWZ7gLWyoA7CDoORnP+FVgOdnCuATvFjpCrT3nVJQpkZby9e1l5HoFL/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204281; c=relaxed/simple; bh=nXhi0tG7DMQn5cPdJ06QyVP/nEgKtu5Hwzo1yM+qeUc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=h52A49MoK8k1mFr8wtNSjwqNvoCcQ/owc/UvcOaJJ+zxDzXgR1i+ZywRIvknqX7ICjH4JH6FNQmZE8FSoHLBQ3Dw9mgM8aH83+M8DnOrUU6xZCCAndue2y9AQxIEyoAe0lGQ/+qOztBo4KZjd1EluL4VwEYJTIEONvcNBHULKiY= 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=X/qklaEK; arc=fail smtp.client-ip=40.107.243.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="X/qklaEK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Js6SQrGqjrRgyLJGIUntDn8IrfRoG3e+9RfTAf6F4ZfwLXZJyy8xfM/GqMr/zVyp5AQLTNcxPPM7Qk3Wn/NAw1P0lfy5btQtEttrPfUx8ZALXapWroDT8vCgDnEcQrgGl2fiomOwfTqh+gzqmABOYLMNUGTSZATPdbmkYLE6x+GX5gISuJHoh0P99kH9ZyEG34vlHykTE+vb2GVTVZ0OXHTMyPuM3gVBVGFAaLVUQRVu7L2rM8C6jGMytNjsjYxbAq/J5L/PqorjuoHODOUSmpHDZMsE9pFL8eT7Iv9MlJ1T+OpwnNsjeIhjaOYCimDG91FPtjJYOyJ2cEyWLVUm3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=dHiZaZL4QyYdnbqG8yPoALKL/Nkum/YRoEHdzVucs5I=; b=I9pgqBntyRtSPqXzT4D+blQhXC7epAwV/a7NfW9PXQGANkuPSqTW+D2ujwg9bVWrlAeCOzYV6Fu8pIGL3pVCl5flQjzuqbMJYkuqCuFVMnY3uKJiO7gD1RlgNWsZa5ay0MZjKLPHYXOD4cw6OrLrUfh20OkuNdMO3eGHvzRVWJhDUZV+SiGmzv7RgBvh/GHBzgopiG7wRWuzy3aDo41XNr+agaWRW9K4bGPZlSyeZnyg1EnysVL4iYl3mEQwUCx0MjHaJDHwxchNTtFfM3nhrVHRk/r4mDU6hLLX93amHbHEsFAJbeGdPxfATm9AYZ5R7BUPt4/pnHX5pxMzp5zZag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=dHiZaZL4QyYdnbqG8yPoALKL/Nkum/YRoEHdzVucs5I=; b=X/qklaEK0uFxEyZmGWtwkZ/7MC/zAdhTCOdth9yPGICUrWYy4/hlDorssCPUVjI0pBzFiVFEh+84ly35wcr3dlY5qaXNY8mMnpxQcCDUIjT/GvNRDMTVYaJK+ra1ORBFC+BZtzouEXL+IaOzs+sjL2MGw2aAuhP4C0hTv4UtYec= Received: from BL1PR13CA0107.namprd13.prod.outlook.com (2603:10b6:208:2b9::22) by SN7PR12MB7419.namprd12.prod.outlook.com (2603:10b6:806:2a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Wed, 12 Jun 2024 14:57:50 +0000 Received: from BL02EPF0001A103.namprd05.prod.outlook.com (2603:10b6:208:2b9:cafe::bf) by BL1PR13CA0107.outlook.office365.com (2603:10b6:208:2b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.19 via Frontend Transport; Wed, 12 Jun 2024 14:57:50 +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 BL02EPF0001A103.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Wed, 12 Jun 2024 14:57:50 +0000 Received: from AUS-P9-MLIMONCI.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; Wed, 12 Jun 2024 09:57:48 -0500 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , "Mario Limonciello" , "Artem S . Tashkinov" Subject: [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string Date: Wed, 12 Jun 2024 09:57:37 -0500 Message-ID: <20240612145737.1618-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 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: BL02EPF0001A103:EE_|SN7PR12MB7419:EE_ X-MS-Office365-Filtering-Correlation-Id: 054b3e50-d0e7-4b40-2f2c-08dc8af0078a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|1800799016|82310400018|376006|36860700005; X-Microsoft-Antispam-Message-Info: Iwj+3xMaYrA4rqM9kGOR40S6+nIaWLtJ8DCrY9hSX/nSVOSkoLoh0HkVXVAA1UyYzmJoTr3FLkJBYls9X6yQxBUTfhs3GQWLymFBRk/Ci9aF0+TG+yBpiAI/5ocDcbkzTpVNgmM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AjLbVxps/fR1Ep3knjfVXKZIu/xdiRWsk8RWHHkvxvc/LNAl/TZJ0Z8fvwb9lQJVmS9SMtNtbL9X4MDknbjMMLBr5BKvJEIHknFbYs8Q26SuPa85mUf/n1irlFvZknl4RUKvSZKo/C8T3wuIVDqsmTbLV310I= 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:(13230032)(1800799016)(82310400018)(376006)(36860700005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 14:57:50.0860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 054b3e50-d0e7-4b40-2f2c-08dc8af0078a 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: BL02EPF0001A103.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7419 The EPP string for 'default' represents what the firmware had configured as the default EPP value but once a user changes EPP to another string they can't reset it back to 'default'. Cache the firmware EPP value and allow the user to write 'default' using this value. Reported-by: Artem S. Tashkinov Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61 Signed-off-by: Mario Limonciello Reviewed-by: Perry Yuan Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 8 +++----- drivers/cpufreq/amd-pstate.h | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index fda8f86c90e0..5bdcdd3ea163 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, int epp = -EINVAL; int ret; - if (!pref_index) { - pr_debug("EPP pref_index is invalid\n"); - return -EINVAL; - } + if (!pref_index) + epp = cpudata->epp_default; if (epp == -EINVAL) epp = epp_values[pref_index]; @@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; - cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0); + cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0); policy->min = policy->cpuinfo.min_freq; policy->max = policy->cpuinfo.max_freq; diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index e6a28e7f4dbf..f80b33fa5d43 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -99,6 +99,7 @@ struct amd_cpudata { u32 policy; u64 cppc_cap1_cached; bool suspended; + s16 epp_default; }; #endif /* _LINUX_AMD_PSTATE_H */