From patchwork Thu Dec 5 22:28:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848670 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 EA79D1D5AA0; Thu, 5 Dec 2024 22:29:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733437754; cv=fail; b=I2TucJrZoSFDTFUUbuIkp0UoPwY+2iSDwsWh1EgMmOETUD4OXf8OI1eJlSWJtMsn263tEsMT5fBbe991OMULP86X2q+MlsQzYTGsRyKF6q5VpcCbom5CScXR9jeNMj4GdTPNIo3akuak9glrWbWcAqBjqM5L8ucXIBPTUXbmIa8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733437754; c=relaxed/simple; bh=EQLshVMaycjeUNdIqlK420hfCQtukgEMCunu8u2J1to=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NBLPT0XFhW4C3/8OFnhQOn4NXsjRgz6DyPIRDm+LA5TAV22Z57VJhe4TrhKg9aQib2RG1OMDx+btwcC0AlQDmZo8Am3bjOlAHskjWMJL9jT8tMybh4kfcNEGf4GhGyeGH15mlv/xGdwi9Fh7MaNNgIWcmT2PSEj7FRmGNTmlJWc= 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=gatPYLn1; arc=fail smtp.client-ip=40.107.237.50 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="gatPYLn1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OYkucAALEVsI+xbbt1UNYnkmSFy+0K/CS5k6KwAkBpw4FEf/ThzSEt29gbN2S2qfKwXIYCbldFBCOMwEOv2MwamHYKvo+7zBTQvyWFS8H8+3qOLIX9anBmD8GAqcODHEHWnR/qE+JPB7oAUEhY07BxRZEBRGVQGjCS+n/1K48WtuA0S7BOl6Ylkcyd0uQ/chKSDv+y5L8nM54YXaDIS5EHliEc9pbFSWMJmghWV0VVsNPacvtDsEk4NMyALwkW9VDWHBUbu3w9a30unzp1RtchbfMtdQDEbmimuiO+2X8IRWJXuQGjm2m8/I9eIaDyuTIITXHl4YwvdJD+xrJQlbnQ== 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=nCqscFL6iUHHRyLiU8OMhbG3Zjdd6/wZV2DAPHGPnLI=; b=PqfzoYMu1/L7qQLsPDyaf/LZcEhrmHIbtS6THMDlzaOGr2gQD0ni6YEfX9hqU+s35JXJpneIwwpWX7y/6GNoLAiiIagHfugNLcDwRxWVgTXZiORA1vgEdQoV6a/l0xROzW9kjJge/Dp4JeuLk7zYN7PZsGj+7pzKNBGkOt6ZDv/5hDN/5hOxSxukEYYtf07i4PPDWdugtcqM1LqNo//QqpD2kuDJQBJtY0DjHM1SfI77colWjNLKMflAKrHISkjrZMnLOCjoi503q/0iA/jJjp2F3HncWFo8lWz+DE993pp6VldrpByCK1ViMvmpHW4WA1088En05CCEntEfxzXbcw== 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=nCqscFL6iUHHRyLiU8OMhbG3Zjdd6/wZV2DAPHGPnLI=; b=gatPYLn1hM7u3DsX6VO7BSA+F8o8FRp9ViRsEvG92uGHLCitRSUvlx0VphMYsfCvC/NLMmBYeGRQq9Z84pWeZ1of+aF06qkxCAW3zgDcBrLLsB8eMBD6oKZF9XZWqoLLYypGM/U58Nyl0HVFt6sX2IISY3NOU+7SMJfmq1awjak= Received: from CH0PR03CA0221.namprd03.prod.outlook.com (2603:10b6:610:e7::16) by CY5PR12MB6348.namprd12.prod.outlook.com (2603:10b6:930:f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Thu, 5 Dec 2024 22:29:09 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:e7:cafe::64) by CH0PR03CA0221.outlook.office365.com (2603:10b6:610:e7::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Thu, 5 Dec 2024 22:29:09 +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 CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 22:29:09 +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; Thu, 5 Dec 2024 16:29:04 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH 07/15] cpufreq/amd-pstate: Only update the cached value in msr_set_epp() on success Date: Thu, 5 Dec 2024 16:28:39 -0600 Message-ID: <20241205222847.7889-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241205222847.7889-1-mario.limonciello@amd.com> References: <20241205222847.7889-1-mario.limonciello@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: CH1PEPF0000A349:EE_|CY5PR12MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: af32b759-4cfa-4926-3ca1-08dd157c3c8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: 6TNHE7GSgPOmKx4bIG0NX8OLAvnXLr9ftkWqGuvgPauJ3ciLxXEqhMb6jjiN+V/1Abz/fVR6Dpcx/+p++081J7bQdQRK46icFMQ/RMaY79JFFpK9JxdyKICfr+N4XAHJJuGue4Q/TWONF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mFC7a9NTzhn1QtsL1S+4iCinV04rfV5nZPqufWFtb5HG1fzTMgDf8XvbunRh3YzGPs0dY8RzYQGhXgZuK2ZNaTEf0fzHKgy3UktpXTJ+jGcsrftsSSEpX/z2TDHnGQhYA+5c5o8GM4GgKb1wIB9P5kUzSIVFSv+OVY9fiRan70h3MpK+7i/5diJzHKTmrLeG0IX+Eb8fCl6Zgas287y4jVs4Lh/3hoJ78+KNNeSJt0M6d3Stys/AklMqb2y 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)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 22:29:09.1558 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af32b759-4cfa-4926-3ca1-08dd157c3c8d 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: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6348 If writing the MSR MSR_AMD_CPPC_REQ fails then the cached value in the amd_cpudata structure should not be updated. Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 14bd6faa3d730..ce70d1bfa55d0 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -278,11 +278,15 @@ static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) value &= ~AMD_PSTATE_EPP_PERF_MASK; value |= FIELD_PREP(AMD_PSTATE_EPP_PERF_MASK, epp); - WRITE_ONCE(cpudata->cppc_req_cached, value); ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); - if (!ret) - cpudata->epp_cached = epp; + if (ret) { + pr_err("failed to set energy perf value (%d)\n", ret); + return ret; + } + + cpudata->epp_cached = epp; + WRITE_ONCE(cpudata->cppc_req_cached, value); return ret; }