From patchwork Mon Mar 25 03:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601219 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) (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 A9A7138F72D; Mon, 25 Mar 2024 03:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335856; cv=fail; b=TpQYkP/VeviEJK6Nc4HLOODojir1FU/N6tK93ekTCt/vhrtq+9DD/1oHtOa5FqyK3NurYFeWL/ONH99Ez2c0iQqu6Wm82aDoNhYsEPzUhEWD2nB2A1aGaZL4NPgkRzXoMDiksf5IOJhwqsmEKUpFLbRkTO0gZsAwTyFCMW71zCg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335856; c=relaxed/simple; bh=XMwTTO4/bPO+ySOez9eTILEkPi7sQoi/IWbBR2sbI3o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RhUdzw/Pjwmmm2XQoWHFCwGKW9iDVInAwmi/U+L6OyIKuzuXSYoE2vPAdZ9tV9Hchl1S4HCbnKiGtUH2Tj0zQdmjA3elqpXaQOVtMasy1PM/sSZeJGZAKJDQB+jetoezWslhXj67JhG8Tu3vIBJDaEV0C9Ii5r9nFQHut6DpPzY= 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=Nub4fOJB; arc=fail smtp.client-ip=40.107.220.45 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="Nub4fOJB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JD3mApfSZ5QWTdQ7RQjSIpAIVlkbQu//BIlTtHoR5WBMweJjrwIp2fT7t5ianf/FWAr6ppEcuuwkCkxpy3PJu7p3b5qYnckdausX6Krrj7CRBsUlRjAwE3ZrLNHM8Z8xIkPd+Rf04uBNFEXcIfm8Ylj2INb5RmZrDNrmO2k+tmbQRTiOOfTsnzZCWVRJhHi6gG9rrJ/BY7pVRdr5jf1+rEO5YkjspUkSbd2qVN2NpQLOvSkQ0lDjlJUTeomn0sKt/3u2XEACCf7Gtezw5SuxRfUBIcWHq173cVor+1Keaj0QuKsJeqnavdv+Vz0cpzTmofdwTyoBGii9fiSVPMblXA== 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=DCOhPQqNxvE6zGrQ7PZtmjPqFjFqKmB7RVPXtyNtEVQ=; b=HCZFeUSQuFVOaCesjAI+WCMZWa4dkTv6CGWUQxhc+gXSCkBTI2gpF5K5ybPBN6LXizzY2Z1Vg6FCQtfLII1roYdfv7pS8UhYoM254nYwQoorOj6RsenQ5h/ZC3M+FXEEh1gtmzaLBUr7jIgxMKQFKAVwD8/mzRxS6w6HDam3WeMwuz6F7hsOADM+t+V9O3gY4DXDJVToQg5lirtLepekqhBLsv810+uMKTkkpgrXtp4tiJpXFPekFzMlBKI67akMQs/LJxJER1iRtXvXi820dXjoWQFaUpp0Dmpui4Tq7aprxKbYvr54XIwGkSF0COzfd1y6xz4wYIo/H3KfnSuy/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=DCOhPQqNxvE6zGrQ7PZtmjPqFjFqKmB7RVPXtyNtEVQ=; b=Nub4fOJBd+AnXeC1FgThN/oxli3mDW2yM7r32ahs3hrPROfyZoLM02DdOgV4BDYOGWg7l+QZnQQNBCd9Wm3BH+X/d+/rNjG56wsH7Ea943tbOXDnfo+5tsvQTERphbIuGXolVvYux4caSdP6vg/8NRh5c0jTjalubLArS62/jOM= Received: from PH8PR20CA0014.namprd20.prod.outlook.com (2603:10b6:510:23c::24) by SA1PR12MB7200.namprd12.prod.outlook.com (2603:10b6:806:2bb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:09 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::7d) by PH8PR20CA0014.outlook.office365.com (2603:10b6:510:23c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04: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 CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:09 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:05 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 1/8] cpufreq: amd-pstate: Document *_limit_* fields in struct amd_cpudata Date: Mon, 25 Mar 2024 11:03:21 +0800 Message-ID: <6b8432f302165e686a01ffe7d1d98852d5e88609.1711335714.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD0:EE_|SA1PR12MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 2631e266-e06e-4b73-b576-08dc4c783d8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIw1rbzWfCK9cySc1BIyqpW61cQBzBgdMo3+YamswoaK6CQyPaOYC+6oMnuYgPq48J5aQoD4fBASrGglx9VnLTTY76mJj/PfSokYZCKw6drE261ZMe/Mip/JKKLOoF/cH+h4oCQV6LwmwPlIL1DhfE6MFzBFaYeeB+WGIQ1gYsjzues+WHWlWemIXnw3H/PRY+VgdGA4MJzdjBsmkKm5vgPyua6viOGPxpMD65C++sIxBs6Jg3cJEw5xOYaTAzFLJyG8LMcBcavqjzL+gb1Lu7jW3i3OHaDSyCB71/DW3ykcYpeOmMnd+B1JijRY3iLnNnSMif2GKf7tEi5neTJdw95lvMqrCVWfA1Bb+pNOEF5xEHPfb2S3uRZfZ/HX4Z/iWkG/BNdFwNwXL/JVonJ4kpxJnt4/E6exDI2agHhQPIYKWyiczXt5Zf7tem278gwX5wuHvoo9c8DR71gUjBNMgmmAGClp9bDkeSZgM79zmFZzdAb2TXE1D5qIuF15wb7Fx7dB7NP3j/3w+EbaqUrGrYhVJe177ZFtF2FSj063x60o00I+PY08y5gyV0Ldnd5piCFfGpwbQpsS2iRgKRVB9hB0lGV2L7qWwBFhIPzdVy1gW/UBRC2lmMnH9ubZac5R4SyDRWrspevt491vRdqZLHw6hARJ1yWBc3gzv1MWo+cPPefyCXaaX4mXaJbqfQ8/KQxsg+rI8ak5DV9Z1TKjI0xrW8t1IIpomms4N1t7BTVPssQFyPrw8rmSA3SgMNkc 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:(13230031)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:09.1288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2631e266-e06e-4b73-b576-08dc4c783d8f 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: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7200 From: "Gautham R. Shenoy" The four fields of struct cpudata namely min_limit_perf, max_limit_perf, min_limit_freq, max_limit_freq introduced in the commit febab20caeba("cpufreq/amd-pstate: Fix scaling_min_freq and scaling_max_freq update") are currently undocumented Add comments describing these fields Fixes: febab20caeba("cpufreq/amd-pstate: Fix scaling_min_freq and scaling_max_freq update") Reviewed-by: Li Meng Tested-by: Dhananjay Ugwekar Signed-off-by: Gautham R. Shenoy Signed-off-by: Perry Yuan --- include/linux/amd-pstate.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index d21838835abd..212f377d615b 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -49,6 +49,10 @@ struct amd_aperf_mperf { * @lowest_perf: the absolute lowest performance level of the processor * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher * priority. + * @min_limit_perf: Cached value of the perf corresponding to policy->min + * @max_limit_perf: Cached value of the perf corresponding to policy->max + * @min_limit_freq: Cached value of policy->min + * @max_limit_freq: Cached value of policy->max * @max_freq: the frequency that mapped to highest_perf * @min_freq: the frequency that mapped to lowest_perf * @nominal_freq: the frequency that mapped to nominal_perf From patchwork Mon Mar 25 03:03:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601525 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2084.outbound.protection.outlook.com [40.107.94.84]) (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 8065439000C; Mon, 25 Mar 2024 03:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335858; cv=fail; b=YEV/HthA08kAZbbaX1FZYmHoZoZTb0Z9+hx7GXofNRqjm6nh4RA8oEP9s4GEuDGk2t4U/CLsr+xXagywd581EO6Tb+SamMgvpp9yrmFcZgD3+4eneIbpbdxK149/USzJ3Md+vSOTfMbX+By2hanABmsSyqpCE3+9MXxJG1A6V1k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335858; c=relaxed/simple; bh=UeWWdRtmXpWnFKXehz2zu1BULegoqqUWOsJeyXwPLtU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m9vpNFeTtFCcFj3/FzxtKpCDg11odwZo/VMLNNB2qNy0+CzAWNNmOlol5bXOyyDlZBttldEeOn67zTCrds/LChPzCoJFGyog2DOk8bG+a0wPzAK4EXUDYzkAWuHZZScbjoe5Jm6nfXB+SeQLFDjuNsSoplVnOLiN9ZHGu8ZYrgs= 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=rQPwXJBF; arc=fail smtp.client-ip=40.107.94.84 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="rQPwXJBF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HxGt1PNprOUXO8CRLZfUEbf2+lN44MGa1ZmcuWQitihg8LwwIDQ9zmF5n4WEdg1pmjGTNmOyOAj/l+iI7dURcMyYtUsSvtOUcS4QDitHnUzAJHcVjciFO8/9mWeAgIKxiD5wgPgxOCJAxuTA1HNuMo+Z70sJ2g7EZWiBwJcVH2FdQLOZ0IF42FTjW5Ue2ytykPL7PmVeFshUJ5NuDYnbcJZ7s+uUG2W8/hclI4gPnMjq7FLgtVmE5OtJOSQeQ+rLnTUK8i3by7lTj4HJWDDMgrPskAme0Lmr1eKg6XnKLPi0LvKkpNx99VQgHgw7X6WWxJwqHiTD/xNYpzOMlKodTw== 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=3PdaOYmZ9vrYq+WiGhyBTG4wUJIEr5G3HmebMTWeCOI=; b=HJCFiSbuLhcrSuPaiW+LcyuguMn3TodybZ891O1qlN5IBs2/BdTRQ11oO0Ca/h7c5a3WN7AbDcZ7h3g1h5A+qJ0pyqeCkUKMSCIJuxKnzKLfSaXcpYYBbRSw78DZTsMMpOz2BGVaHlCau0vGuXKQ4il8Ym0JX63WYhVx+KXhRvFQX/teFkIXX46z4cVwvgG8eqdeE6TJRtMby5JPTX5P53kQ52s6oKd1WN65U6ocMkQc7G9EIbyMY8SNTLV2XD+amTARGkZgBgH45rmMIySs6Jh5ZO4Flme9fzQVSqIdq1NVwbHuepNXojemIDL6KEoFNl7biE/BL5Fv2nKKYQHkZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=3PdaOYmZ9vrYq+WiGhyBTG4wUJIEr5G3HmebMTWeCOI=; b=rQPwXJBFrf52z2U9G1OsZ7U9OpwRGqCfLjnMeNQysPMpRZDb0KGfXcAuVkP4fPMMa3zbduQnX0viVMYCBtN6qRQPN8HGbAuUhTv1UWY4PtZC7kKct6NPtrk2SciIIRUx6pj1QpsQIiwp9uAsnUpnRSn8ynN7lpghfm++xdzX5vo= Received: from PH3PEPF000040B0.namprd05.prod.outlook.com (2603:10b6:518:1::5c) by CY5PR12MB6252.namprd12.prod.outlook.com (2603:10b6:930:20::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:12 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2a01:111:f403:f912::) by PH3PEPF000040B0.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.12 via Frontend Transport; Mon, 25 Mar 2024 03:04:12 +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 CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:11 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:08 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 2/8] cpufreq: amd-pstate: Document the units for freq variables in amd_cpudata Date: Mon, 25 Mar 2024 11:03:22 +0800 Message-ID: <87c6aeb265a0281b3abebd07ba2069d80da21944.1711335714.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD2:EE_|CY5PR12MB6252:EE_ X-MS-Office365-Filtering-Correlation-Id: c19f74e7-66ab-43e6-e881-08dc4c783f33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: spyg1Me2qcNtqodwAFSVUXyfeMxs0Sty6Y74O+nkxBWyK3uqYTywHxe9dQ22v5As/hguEXE2FdSxBHNyVKqh98C+9CaEE6ZVFiqJW4+7mCoOx6VI3OeSt0nvuxM2hQfDmvBX08EeqSa0i5SBKtBHsR4KRFTUda5dGZRhy9oBUIvBSD+W63OOy5luxVQ/Khhu8qaPuHPakJY/43IpRFjrVvlF2s8Frx/IJ3KOsb7A/FyidFNhaG+77vLskpfViYXe2LyaLUKKlPcAFMg0bEXSG9kS8JJCRfK3J2qb0omKIJCJDQXNUBIjHmMcMexoA4o5QwGKu/muK5cCK89MYjTYKwac6eOGgDbMI6ObtILaPjqpmvIurqZy/0wBpkkHYpjSX6UpEw7u0gcFo8Exl8XXD9UQiUHNJUVkRrexUxHoDh8/ZUjcP4zle7ahWmi4MlS+jkmc1EJM1EeMP4tLmWFRxltBoC+ROX3I0rl9+T1TNtddbItRmAzrvCOSb7JNAgIg7v5S9L6lGftNTKMBjifYsfCmZjuUwxXALqunWuhsUZttgGBIZTmtaOmEDJ94khU/idoSBPNymSsiV0R3LJzOlFXKluUcahGRoJaVeWdMv35m9DV4s68Y8LIZEm6AxBi7dbs1kSoM+CgsKlAgyAsr/R/OL+sLqz2ACY3puwO7nWeg9j8lYctvBy4riK+impcWxpP+XGo79o0z5Sb40RMx86cQuulVbTgk5cQB5h4l17XBU/oZ9watQbt5jT5ycIiv 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:(13230031)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:11.8826 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c19f74e7-66ab-43e6-e881-08dc4c783f33 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: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6252 From: "Gautham R. Shenoy" The min_limit_freq, max_limit_freq, min_freq, max_freq, nominal_freq and the lowest_nominal_freq members of struct cpudata store the frequency value in khz to be consistent with the cpufreq core. Update the comment to document this. Reviewed-by: Li Meng Tested-by: Dhananjay Ugwekar Signed-off-by: Gautham R. Shenoy Signed-off-by: Perry Yuan Acked-by: Huang Rui --- include/linux/amd-pstate.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 212f377d615b..ab7e82533718 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -51,15 +51,15 @@ struct amd_aperf_mperf { * priority. * @min_limit_perf: Cached value of the perf corresponding to policy->min * @max_limit_perf: Cached value of the perf corresponding to policy->max - * @min_limit_freq: Cached value of policy->min - * @max_limit_freq: Cached value of policy->max - * @max_freq: the frequency that mapped to highest_perf - * @min_freq: the frequency that mapped to lowest_perf - * @nominal_freq: the frequency that mapped to nominal_perf - * @lowest_nonlinear_freq: the frequency that mapped to lowest_nonlinear_perf + * @min_limit_freq: Cached value of policy->min (in khz) + * @max_limit_freq: Cached value of policy->max (in khz) + * @max_freq: the frequency (in khz) that mapped to highest_perf + * @min_freq: the frequency (in khz) that mapped to lowest_perf + * @nominal_freq: the frequency (in khz) that mapped to nominal_perf + * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf * @cur: Difference of Aperf/Mperf/tsc count between last and current sample * @prev: Last Aperf/Mperf/tsc count value read from register - * @freq: current cpu frequency value + * @freq: current cpu frequency value (in khz) * @boost_supported: check whether the Processor or SBIOS supports boost mode * @hw_prefcore: check whether HW supports preferred core featue. * Only when hw_prefcore and early prefcore param are true, From patchwork Mon Mar 25 03:03:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601222 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) (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 3AD1F390971; Mon, 25 Mar 2024 03:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335863; cv=fail; b=rUG+LlqDA8W2DwppMuyxfEqSvcEWdc+W/SeJCR6+lnzZ61ru3tGjHcWlZaFvPt3SedaRFlv/dKcSAVFpe/Yau8dKpV30pBKvNLujUbXm7unWvrPHzP6Vbawdw1C3C3/6DwVfr+wbyPXFo+ELwi+fK3oOYcP3j8lg7P10dRkmBR8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335863; c=relaxed/simple; bh=uzzjkhT9pBH98t4WOmRLcjrnmFo/yJP0trhMkQ6ySY8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vFiqG/TbZvd7IdvgoO516wl5An212GJpezV+RQt1sDqkxYluT6k2vTC61LtFeIJiS3lkqM/kIStjCtSIoKihpWGCNZ93YPrwr1JSYnAy3xJ9t3F4Txwo7+swx0hi2QV/1b4I6OyE2tI7E45DYn4lVWVbmwWju17sQQLZMhlVamU= 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=MkvlmkHT; arc=fail smtp.client-ip=40.107.236.40 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="MkvlmkHT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=futdfCtDyZOsGOxlkEJGog5mcwxwNN6j279lGAQ7IoeImf18CNkLTAdJr4kSawNiu1cmB8FAxHTvRMfvVjoVxS2NGQ/TCXXuJQ7WwKOCgkbaMB5RBLpROTrPGQq1/bDr5pBMXzbUKurdHkueAIL8Ls3LP633s2Vnm+WQiojVdirmiQsXHnISmzccvi5wRumNPozCXavk8t05HhhbDtCNCJ9BAfjmkTCYviS/+vXvZtpdhc2Bh7End6E6Y8qFt2R6G7AjsJ1Ln9wAEV5giSE2ADLzfqeuG/ABMgkkX/JxtHqlqCKHSq8tXg5uBY4y0cRAy44GnArl60Nofg1mktKtLw== 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=qzn0Kw16DE0mU2ipdaLQdpGelPAgYDhtB5W9Exa3Wqs=; b=cILOGtBc5EmmWVO5roqcpHOFoHz/F2SjtPQF0MM9bNwCeVCQ3GUJSedVM2Qzh1cJoIlYPPGJw8xSTPQDdzqDDMUbP26WhLSiphLLc4uxy3LLLHkFY/+tq/vvqK2tTzN4OXlkHuFx52S3mHhBYcQdHEakUotyRkoXO9htaIAf2VLGNbSMDmjHuDQcObAOJ/G4wK0pMYEFoMEbpfP01NEmOa2THb2abfW8Wt6XEzIEhCLnU4x4KgyDaCWxLOuKRlzNq/YRvvL26oaRJzG+TXlTfE6nyUJ5zuW6UGRnwk/vsfJsNxJWUzWSHQV6XoSdxG7XsoyHobSdCk1sbzObB1uddw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=qzn0Kw16DE0mU2ipdaLQdpGelPAgYDhtB5W9Exa3Wqs=; b=MkvlmkHTgTXm9Ml7LZtrPyWjfDH9z2qihKzjMUf5V//Ed0+p9b5cZRbk13M4sLZxEeZtHO0WoVN3jQNlJg7DG7ahBuy+B1jzj5KTVaN7ZvMmKjj6ZyUaePDj+/EleOOg/HcrEUBq8dR+P9DGzTH6gUGbFRH0RmL3ImG+NEwopxo= Received: from CYXPR02CA0091.namprd02.prod.outlook.com (2603:10b6:930:ce::6) by SN7PR12MB7180.namprd12.prod.outlook.com (2603:10b6:806:2a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:15 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:ce:cafe::98) by CYXPR02CA0091.outlook.office365.com (2603:10b6:930:ce::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:15 +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 CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:15 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:11 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 3/8] cpufreq: amd-pstate: Unify computation of {max,min,nominal,lowest_nonlinear}_freq Date: Mon, 25 Mar 2024 11:03:23 +0800 Message-ID: <31e4c97f791837c97c0b2caca61bcdfeabc3f97f.1711335714.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD5:EE_|SN7PR12MB7180:EE_ X-MS-Office365-Filtering-Correlation-Id: a9ce1f02-53ef-4d7b-5535-08dc4c784126 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ao1lQ6SJhMf1fsS4ZPUZyXkVSf7ezUj+f6FVBJecXwizi4DHDFtIAxDGhx03M4L9cQ5kZ9VsshxxwV2JjNkLzR39aq3BuwBVS1EYb1XmwqLTJSKDcqnw94ti0tULxvghXxvWuKYFyZgWNY88pEFrGUkjaCfIntmjYZByBHt/NsnXWiJtd3KCALEPi89KG0HRAREivfbI3ZldTtX+2CFTv31RYGPGA61uMePfkxcCmqGhOR2wZXsM2RajiVDPK0N9srcmqbOs6njsq7a7zrlhttSvEpMf2Zef2cTwEv3PBpG6Xo7uugMP6fKTGsnnsm2/ZZuHUfWP1XtQZBuv/3bKw8rB+4aHgNXT9Vx/RFWnMJwrUWNR5SINdwAWIDstrjDuat6u5S2nFJ8CzTKKQBn7YX5H+kQTvYs7aM3pv/cS0RHIk0SVU6qtZ4dXAqdDYEwR9gPIkytOX7Hqyvv2DicpXpue/b3bJEZGVW59d9tabFQEIiFmfmdnFIEJybytTdR/KT9vIX5FKmuwLwCb3Uk3bJ6mzlg7jwnqEi4XisONuEu2eAr3RFut3ErnDyBKyYST2ue9kbknALaKsXBhp89KNN/eRRXvKJVjGQfuBHgk25KouLxG/PekNvSJA+E7hMyTtjhGj9iwXwxflxakjK1ph1GuCMmnZ+VWvUF3KL97SamOQQfi9IWh+n9/Slsrco35TehEjIptm7HgzE3NzZIrxJPmq6BGrlxM/OYSGaPmDTG4075mMbHz1fr8coCmF02K 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:(13230031)(1800799015)(376005)(36860700004)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:15.1491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9ce1f02-53ef-4d7b-5535-08dc4c784126 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7180 Currently the amd_get_{min, max, nominal, lowest_nonlinear}_freq() helpers computes the values of min_freq, max_freq, nominal_freq and lowest_nominal_freq respectively afresh from cppc_get_perf_caps(). This is not necessary as there are fields in cpudata to cache these values. To simplify this, add a single helper function named amd_pstate_init_freq() which computes all these frequencies at once, and caches it in cpudata. Use the cached values everywhere else in the code. Reviewed-by: Li Meng Tested-by: Dhananjay Ugwekar Co-developed-by: Gautham R. Shenoy Signed-off-by: Gautham R. Shenoy Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 126 ++++++++++++++++------------------- 1 file changed, 59 insertions(+), 67 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 2015c9fcc3c9..ba1baa6733e6 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -606,74 +606,22 @@ static void amd_pstate_adjust_perf(unsigned int cpu, static int amd_get_min_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; - - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - - /* Switch to khz */ - return cppc_perf.lowest_freq * 1000; + return READ_ONCE(cpudata->min_freq); } static int amd_get_max_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; - u32 max_perf, max_freq, nominal_freq, nominal_perf; - u64 boost_ratio; - - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - - nominal_freq = cppc_perf.nominal_freq; - nominal_perf = READ_ONCE(cpudata->nominal_perf); - max_perf = READ_ONCE(cpudata->highest_perf); - - boost_ratio = div_u64(max_perf << SCHED_CAPACITY_SHIFT, - nominal_perf); - - max_freq = nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT; - - /* Switch to khz */ - return max_freq * 1000; + return READ_ONCE(cpudata->max_freq); } static int amd_get_nominal_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; - - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - - /* Switch to khz */ - return cppc_perf.nominal_freq * 1000; + return READ_ONCE(cpudata->nominal_freq); } static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; - u32 lowest_nonlinear_freq, lowest_nonlinear_perf, - nominal_freq, nominal_perf; - u64 lowest_nonlinear_ratio; - - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - - nominal_freq = cppc_perf.nominal_freq; - nominal_perf = READ_ONCE(cpudata->nominal_perf); - - lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; - - lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT, - nominal_perf); - - lowest_nonlinear_freq = nominal_freq * lowest_nonlinear_ratio >> SCHED_CAPACITY_SHIFT; - - /* Switch to khz */ - return lowest_nonlinear_freq * 1000; + return READ_ONCE(cpudata->lowest_nonlinear_freq); } static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) @@ -828,6 +776,53 @@ static void amd_pstate_update_limits(unsigned int cpu) mutex_unlock(&amd_pstate_driver_lock); } +/** + * amd_pstate_init_freq: Initialize the max_freq, min_freq, + * nominal_freq and lowest_nonlinear_freq for + * the @cpudata object. + * + * Requires: highest_perf, lowest_perf, nominal_perf and + * lowest_nonlinear_perf members of @cpudata to be + * initialized. + * + * Returns 0 on success, non-zero value on failure. + */ +static int amd_pstate_init_freq(struct amd_cpudata *cpudata) +{ + int ret; + u32 min_freq; + u32 highest_perf, max_freq; + u32 nominal_perf, nominal_freq; + u32 lowest_nonlinear_perf, lowest_nonlinear_freq; + u32 boost_ratio, lowest_nonlinear_ratio; + struct cppc_perf_caps cppc_perf; + + + ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + + min_freq = cppc_perf.lowest_freq * 1000; + nominal_freq = cppc_perf.nominal_freq * 1000; + nominal_perf = READ_ONCE(cpudata->nominal_perf); + + highest_perf = READ_ONCE(cpudata->highest_perf); + boost_ratio = div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); + max_freq = nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT; + + lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); + lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT, + nominal_perf); + lowest_nonlinear_freq = nominal_freq * lowest_nonlinear_ratio >> SCHED_CAPACITY_SHIFT; + + WRITE_ONCE(cpudata->min_freq, min_freq); + WRITE_ONCE(cpudata->lowest_nonlinear_freq, lowest_nonlinear_freq); + WRITE_ONCE(cpudata->nominal_freq, nominal_freq); + WRITE_ONCE(cpudata->max_freq, max_freq); + + return 0; +} + static int amd_pstate_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; @@ -855,6 +850,10 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) if (ret) goto free_cpudata1; + ret = amd_pstate_init_freq(cpudata); + if (ret) + goto free_cpudata1; + min_freq = amd_get_min_freq(cpudata); max_freq = amd_get_max_freq(cpudata); nominal_freq = amd_get_nominal_freq(cpudata); @@ -896,13 +895,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) goto free_cpudata2; } - /* Initial processor data capability frequencies */ - cpudata->max_freq = max_freq; - cpudata->min_freq = min_freq; cpudata->max_limit_freq = max_freq; cpudata->min_limit_freq = min_freq; - cpudata->nominal_freq = nominal_freq; - cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; policy->driver_data = cpudata; @@ -1317,6 +1311,10 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) if (ret) goto free_cpudata1; + ret = amd_pstate_init_freq(cpudata); + if (ret) + goto free_cpudata1; + min_freq = amd_get_min_freq(cpudata); max_freq = amd_get_max_freq(cpudata); nominal_freq = amd_get_nominal_freq(cpudata); @@ -1333,12 +1331,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) /* It will be updated by governor */ policy->cur = policy->cpuinfo.min_freq; - /* Initial processor data capability frequencies */ - cpudata->max_freq = max_freq; - cpudata->min_freq = min_freq; - cpudata->nominal_freq = nominal_freq; - cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; - policy->driver_data = cpudata; cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0); From patchwork Mon Mar 25 03:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601221 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2058.outbound.protection.outlook.com [40.107.100.58]) (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 1286E3913FF; Mon, 25 Mar 2024 03:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335866; cv=fail; b=OHuh7o7zmJC43wFNzLGrTTp0qodOVVc+xOe2XmV0VkvocK+M9VGeZ/h4vHQtmoJ/EHwj9KJkU2gZrZNcH3mvea/t5KmDCb/5qGUJ5vhYejuiaWniqyskLVIhM0eYpaQIVWwjTuXGSa1pMXSYnyqVP4lHc25maYFAMaQ759dCenI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335866; c=relaxed/simple; bh=NSbpme1T8MOtsY1RLqWQ67dSJJSvZY8kuwkXKOGThws=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WCX//7juerkl3Ia5hWJnogikc8maOP+aMf9l+t3M1w55shBBtf56Huv8VsHHi5asEXF705W5JV20aPJvJXa+Jx+/IZhrXE/D9jE2kQslL83zlbgv4P5pgN3IF5JICv9bgLEAM5WluEYulKq6rMs0yrv/FtiCgUbSSRokf4xPk3s= 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=46kB2EqH; arc=fail smtp.client-ip=40.107.100.58 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="46kB2EqH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+C5/Ba7IJmcxfYnzuEVqlcHImSx4fkG/SxLGSiDH0CbQ1/HXHE6q0+774e1OeYhBkLnEEc2+BOt8x5kcSO9YXlWfM/5021hTuQMmdAeHWfnPFaTIxK6DvlZUx9MQULYoJiJHo6PBRxa5KoACn9AoG/kFwfBDwGE2w7L4Lh6pyrAZohX+P2eWKlO4JQSLcuZMUh6hfBUHn/YjWW78fITtX8IFJHLW3D6RSvWkfXUkJ+8/CZ+3BlaXj/V7wH6jeJDhnuwA2hh2WXLNvy8GSevOVuPCSyFTeiC42Dg9pjqRO7YmFS8S/rIFPe7BNc2+DhWjLBePvfsA6ab9dTdR7f1PA== 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=yWZwfqXIFikTKndf3BuvlpfOFL6BIiF6IyUmyHI09G4=; b=VijMrsDccHg1E1+rg7pmLZpE+kWlGTT+EpbQ/PuAu14W6oNAEcCjtBojDQdNPTcbHvl3vjq9ZueMNg6T/D/mlxN6EfgjMTc79vMwB1+mQdbcezoBTTadrN8zlqXP8OrzdueQFRtLjX/PcOk4xsigMx4Oq0VVZRqdZQEVguCrnk1G1mU2ZU6CgqSaudf8BWqGovHnnwWTbh3SkkLBhJlU0jbgEOQ40VYUkfKAPEKv/2Y/fA8gvKsbQ9CDtqe9DvF6UjTb2kxU8PfOzvS8wbnL4hN7gg3MkKvjy2SKueyBIQ2RarirSwpnR4oRaljSyS0U9sv/1HKHaQUdfJuL2hCqtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=yWZwfqXIFikTKndf3BuvlpfOFL6BIiF6IyUmyHI09G4=; b=46kB2EqHDVMyLSanqut60JaxW+QMWYkw1tlmn3QURV/dYcGbXPY2VEAeNB4z8XNTVGiFoMr7xWVGSx3wVlrBVIvhKvt8l8ODA1qnkNg3LHUpM/kmaowUfgQT0yjOyQiEhtFVfguOTd7YHs6QYiJ3dEgSI7HNeEaKm0vZBQxN0KU= Received: from CY8PR12CA0064.namprd12.prod.outlook.com (2603:10b6:930:4c::10) by DM4PR12MB9071.namprd12.prod.outlook.com (2603:10b6:8:bd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:18 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:930:4c:cafe::27) by CY8PR12CA0064.outlook.office365.com (2603:10b6:930:4c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:18 +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 CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:18 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:14 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 4/8] cpufreq: amd-pstate: Remove amd_get_{min,max,nominal,lowest_nonlinear}_freq() Date: Mon, 25 Mar 2024 11:03:24 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD7:EE_|DM4PR12MB9071:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a9d63ad-8a40-4a35-8350-08dc4c784316 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWQK7DABz5fTEcJHUr+QteLiESvLT4sL94L04Joy9uiFBsAw2Ytt+xymNnbXbDuceZp/JJan7YlWcncpxS1jPXc90YJ+HH8zl/QHUGuaHwcNfUftYgUX5WTi0ZC3r1MIaXQh3dHWmJWdSNsHoYOzP2GRbQHz4FwHFhpiWJ5HPaG4Tq/4BcrgF4ZLzMhRk8x+FL8RG/MY3C6KAPwAcNPLlXvwwIl8WHtywCFkrpyyh/j2ceOWOQsxM1Zvrx3ArHa+vp1O00QvV1iTolD9wD9l7soFZ6pq5k8r/b9CPz86vilhEsJQeeYEdbgcmZksb7lQ0tn5tam7809dNXAc+znUz2mreo9quXmWs3NvV/IR45KKe5LHzVKmjFyNQs2HV1UYNYCTaYZhzNDGYlFyS2iO1QBagZlcLiR5HN9PGQm2sZlEZXLXiEMhKgp+cOLiTcRELHglZVi2IWeBWY6vArapnem1UHErB8pFP/yqS3bcY/UmyLbwtzUfHM5hJZkfBkc4iWXjopPzYkTVm2Z4KrqVDiu8+YPd1R7PX6lsAvj3gkng0qPWOi6aaIihBJ0JpEi6RpcGp8DqF8p0Jdx2jTHUiSDB76jbbHx6UBidz0ZC40LIkxWVRKs3EjRR6exp6ErOw3ZRyYYsNjQdaiSjsrrX9MIZepcVsjJ/fpzWVwjdPPZHby7fY6WnD96HVnGljW0tP0p/PFByLSqQbPikbmSnMj70qgflIGRxtdH9e1zXL4ASZNghQyZcY1xUjTdLJm3x 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:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:18.4165 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a9d63ad-8a40-4a35-8350-08dc4c784316 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: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB9071 From: "Gautham R. Shenoy" amd_get_{min,max,nominal,lowest_nonlinear}_freq() functions merely return cpudata->{min,max,nominal,lowest_nonlinear}_freq values. There is no loss in readability in replacing their invocations by accesses to the corresponding members of cpudata. Do so and remove these helper functions. Reviewed-by: Li Meng Tested-by: Dhananjay Ugwekar Signed-off-by: Gautham R. Shenoy Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 40 +++++++++--------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index ba1baa6733e6..132330b4942f 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -604,26 +604,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu, cpufreq_cpu_put(policy); } -static int amd_get_min_freq(struct amd_cpudata *cpudata) -{ - return READ_ONCE(cpudata->min_freq); -} - -static int amd_get_max_freq(struct amd_cpudata *cpudata) -{ - return READ_ONCE(cpudata->max_freq); -} - -static int amd_get_nominal_freq(struct amd_cpudata *cpudata) -{ - return READ_ONCE(cpudata->nominal_freq); -} - -static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) -{ - return READ_ONCE(cpudata->lowest_nonlinear_freq); -} - static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) { struct amd_cpudata *cpudata = policy->driver_data; @@ -854,10 +834,10 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) if (ret) goto free_cpudata1; - min_freq = amd_get_min_freq(cpudata); - max_freq = amd_get_max_freq(cpudata); - nominal_freq = amd_get_nominal_freq(cpudata); - lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); + min_freq = READ_ONCE(cpudata->min_freq); + max_freq = READ_ONCE(cpudata->max_freq); + nominal_freq = READ_ONCE(cpudata->nominal_freq); + lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", @@ -960,7 +940,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, int max_freq; struct amd_cpudata *cpudata = policy->driver_data; - max_freq = amd_get_max_freq(cpudata); + max_freq = READ_ONCE(cpudata->max_freq); if (max_freq < 0) return max_freq; @@ -973,7 +953,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli int freq; struct amd_cpudata *cpudata = policy->driver_data; - freq = amd_get_lowest_nonlinear_freq(cpudata); + freq = READ_ONCE(cpudata->lowest_nonlinear_freq); if (freq < 0) return freq; @@ -1315,10 +1295,10 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) if (ret) goto free_cpudata1; - min_freq = amd_get_min_freq(cpudata); - max_freq = amd_get_max_freq(cpudata); - nominal_freq = amd_get_nominal_freq(cpudata); - lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); + min_freq = READ_ONCE(cpudata->min_freq); + max_freq = READ_ONCE(cpudata->max_freq); + nominal_freq = READ_ONCE(cpudata->nominal_freq); + lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", min_freq, max_freq); From patchwork Mon Mar 25 03:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601223 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) (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 8C62B266A1B; Mon, 25 Mar 2024 03:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335867; cv=fail; b=gTWY/cZ8a2AlW6gA1fSLFoaN2WfFcF9xo0mODGwP7zfg0z2kbjKPA4CElgMef8x9+K3Wmp2rV/zX31+3KCRBAtJpKVdoPKo0tuCbNwPOMPE6TuRfOD8wOpTHPuCVEzkNlzaF598Jgzs3FjkruDWGkICCxITerpZzAcutLsYdqVU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335867; c=relaxed/simple; bh=QuIbzAZ+8WhO8LCCuU2DU2IkfXpm5HMzoRBcXpfUkM8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hl/0Sb2lGwPEycte/SEGiB3v0BpR7OnujzqrjX5352g7b+I67LkYUXHMxdfGg6f+m4Q2ACJcqTiwOuCbrJpTo1SxF7GLL7zjq4z5a6de5YFj2n/T1Lmug+aQdQepEhzrZ71YbrKS4gLdE1hMahULkNbLHXu91pBJ6/0hsxhM2vQ= 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=3QTvOtNu; arc=fail smtp.client-ip=40.107.93.75 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="3QTvOtNu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/89DlOH4+X6JUskmHmC+WhUDKm34PlEfvmYldCbhlgpskDJ3HiGHKBQJSnAWf64fXZZDf00qeoqZH/vkiGSAJtLbZJXBFXDweBdUCHwwXEy1aLFOdpmqzzQAPJrUL7M46HeTPfr4kZ9FclXE+5MhphoJZo7yjsbhGKxtOfawRqHRPD/e2Jq1cW71lTMj3WJnGSZBsCvn9elg8u+OiKnQ6g2Fz0RD66CcKpgC+IjkXx3ZPlRlA2fBj+ssmVRobT5m7tyyO8l45K/N0+8iXv5ozyZ7d3dZRBKfLSv19k3hI9hy3eQEXXEXZQpHTu2KN0lAnzCc401fmjytq9d5LlvEA== 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=zkw80FHPivvzMHp/KDoBrZesEDc6mbdd3HLhIwc665Y=; b=cJk+jB2/UZKxAtvlJ8+rAIBpwHebPS9WBQ8xjn4OORm8ANeSjt/niJ09rAwp6LoUj73cyyff6ddt1FlZ50QnTv2XLVirCtBg7Cw9b/YvrPyJgx6GSCaoZif0puiefsdVkhqFHTihDubGTmvwZZWnyyLSdTfKfh9A1rbEsGVVy8ohc67WO+tcBdw405s+R74oD8SO7i16RU5MvKcG7kaIZLBUAx+tOshFTFx0ys7QgPs12YuDKf5wy9D009BIonRrQgO8gywDhZaRG5bmVQcZF0ZX7IWw7z4ofIxFpgbXQ+64C6gkhUUHRx4OoQMBI6gBoTD2Oqrv1wqOOyIgErPgXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=zkw80FHPivvzMHp/KDoBrZesEDc6mbdd3HLhIwc665Y=; b=3QTvOtNuKZMNKohFEau+d9uxu8J5dGFUyiRkzrlDBt+rcS2o+20MSwZZHXtK9voPLnVKbDPjd7g+10Vx5Yweb62ZQpvdNeOsRBkzE4vau8zc+p/hUmrEMPL3DEzwyY+0cEizBBljAIE20D+7sodnUptUaigqCUgbHVdIjx60WqI= Received: from PH8PR20CA0021.namprd20.prod.outlook.com (2603:10b6:510:23c::26) by PH7PR12MB9224.namprd12.prod.outlook.com (2603:10b6:510:2e7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:22 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::ee) by PH8PR20CA0021.outlook.office365.com (2603:10b6:510:23c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:21 +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 CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:21 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:18 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 5/8] cpufreq: amd-pstate: Bail out if min/max/nominal_freq is 0 Date: Mon, 25 Mar 2024 11:03:25 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD0:EE_|PH7PR12MB9224:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f2652fe-82fc-4b8c-e4ee-08dc4c78451a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uAeR8xIl8TSJ26MIeFC4lUuWkyHhsWce0TtNkZMZ6iPXKtfn1qzl+Lb/1Qkv1OeentWJQ9w1EbCI7P7qUXbylm6CkQFXNcVDjwMxolYhYWsrLkQHMd0drljUJbgyEyq00dH3qEuYl31WJjakQ+0QOewjSbeJj8MCaAlWV/nodYyoUt3Ob77pOrMtDK/tavc1W8rHz51/sOfzTbL/mVbYa9GUmVSf0p2OV8+5OFSUrBeUDfrB/Tx2RJt6QEdTcBoY3q3n5jaLG2TCr3iCnFE3/tBhpexRh97xqarx4lmO+5FW5Zq/DYOLJ1DVbVvoTXSfzwZkCWDGE557jK9RQgPB62YfhD5WDXfunjVLXjTcNBD0guqKoNjS+ko++EJoUTFLQ7TCCoBA6m9cf82I6l4jIve06qPiQ+bQjokxdrmgegSrsONuSOFGsBH9zWVHMRQC67ckZlP5Sg2AeI+0wDYaicwifLPv/iBGlsOIV0rs1HWM9fSyUk2/Paww5eaICFQ+wTu41kAczAGJ/BUKo5W98rzytX7sfkAYSWDQ1ZSRpSc4pFhNYp73wz3RrSdxTSHytVAKz32t/tRb3/S2LWQV8KPBUVdRZjDvIus0vAuxahoxVBMomIV42Dakg2RlZrKh9t/PXu/joe7k0su3Hdi+5i/kZSA+Pj/rYAKl10I1OH2PlgPi5Uxa32UDFnZ/QIqwhFa0crI8TsyJc5/kVR28/DO3nZBGYYX/IreA/QCbxIyMs3cpRukfhgbJAj3ZxiYd 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:(13230031)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:21.8007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f2652fe-82fc-4b8c-e4ee-08dc4c78451a 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: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9224 The amd-pstate driver cannot work when the min_freq, nominal_freq or the max_freq is zero. When this happens it is prudent to error out early on rather than waiting failing at the time of the governor initialization. Reviewed-by: Gautham R. Shenoy Tested-by: Dhananjay Ugwekar Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 132330b4942f..6708c436e1a2 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -839,9 +839,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq <= 0 || max_freq <= 0 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq (%d) value is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } @@ -1299,9 +1301,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) max_freq = READ_ONCE(cpudata->max_freq); nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq <= 0 || max_freq <= 0 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } From patchwork Mon Mar 25 03:03:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601225 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (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 B895315ADAF; Mon, 25 Mar 2024 03:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335870; cv=fail; b=LIQ7KQSH3sNihtPvZoZXz8E9MwNtEt5aij0WIxeKQ3B6uGWX0VIqxM8asYG4wLxz5q8Etr3TlLGtWudB5k9n9vLV62GPaEMXuVanj2POdPUybLb0UIgrdbhHhpLNUe9bSyqvAHjaQiWriyUBqNCL1uVSHcYJIethHlJxit9TxOo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335870; c=relaxed/simple; bh=u/29lxx6P3jJY06y/MlO0KNSHgH0dFJm/PTw0ln0roQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JR3Eix/1/Kn1q0O9iEMXX+97Q7pXsH2v2DQdLDgi/Apmkc2Z0Y/eDsQM6M5wio1XasZ5Ksrx/IpB7g/6dk9Ye+Fx6Qh8CU4CDcnMgmlccyvltc05HqeOa3SAgrUFW18PAAl8fCTc09DSEfxbBlCCnwqqhk+aYBpMH0He+eQGlS0= 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=jbtkbAki; arc=fail smtp.client-ip=40.107.236.41 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="jbtkbAki" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mj1DC4tqH4mUFibRcv6n8epOdpQeFmvwF2XOt2Ld0BDJYPw8kHXZhPSzBzAthJpDprvlKGfy3vOpPNMXRQ6vCAbtPFxHmpVlYjmTv4KPWY6usSWB7vKk2yRQOkeZFV4ESfE0QYsZg4lPp+pB6lEmi8G/DWfEcS6MWzj1VXT4Ep62nN9zUYt5t9GLT3REB5cJHXV+QtyzC+mXETfjQri6hLr39Sie0CXSGogCz/vFr05de589oak10mN/IbYH7bz7//rWlCpbSPVeWRUL7Z7gDU4Qq/IvoArdpc08mxHqjW4BdgaA6mUiGtyK8fCWvt4aG8Q4XBA7G5NS9ZugXHZeqQ== 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=DyHZI/NbrFxwgpyH6bobGsGnDM43kezAw9cH+FygoJk=; b=iGMJtUCJ9PLZ/4WB9OZJs01Sk6e0T3AH7a7P2AMjs1gGtsmTSgzD2fg7I1NGBDPb+jkiwmempwVWuvlQzM1K+dLlvLWJuqmf1JAVpOAHloy8xeplTVCdwJhM2UqjxPK8oBhe/0oos6VIiUUffP/XA/P1qmm6mFwqSK5hlVNfxlfxJj0wppxCZ4y9wd67zRKbFjqqAyt0Hst18SjLXTKYgCLbMKEGp1GV3lyHF1FM/oxJvlyoIJgDUDsxQGnqKoz6dK4tGfoiigEI426AgypFETlmD84G+ln36uEjwO9vCP09XFe8Wcu47GFZQudYujYjTdiN32hkSK1IKixL3rIKiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=DyHZI/NbrFxwgpyH6bobGsGnDM43kezAw9cH+FygoJk=; b=jbtkbAkihW839ZfO6q2Fq1j7mPzTNM5gpKC+LS7ZS+vTLOKG7Z5vavQx61JUBSAS//T5r0q0NqaU3J4i1Pw6O+W/wYzLG15cyou1J6zHwbCcJ93lHGNXE+XrKbJLncdjt+DlssmSiFPRnbIGvQ6DUQEBk6CLF+TEam6Leb61/o8= Received: from PH8PR20CA0014.namprd20.prod.outlook.com (2603:10b6:510:23c::24) by CY8PR12MB7516.namprd12.prod.outlook.com (2603:10b6:930:94::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:25 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::67) by PH8PR20CA0014.outlook.office365.com (2603:10b6:510:23c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:25 +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 CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:24 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:21 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 6/8] cpufreq: amd-pstate: get transition delay and latency value from ACPI tables Date: Mon, 25 Mar 2024 11:03:26 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD0:EE_|CY8PR12MB7516:EE_ X-MS-Office365-Filtering-Correlation-Id: 08ec493b-dc1f-4f1a-a687-08dc4c784703 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZbmnxRJnePZLZPXyN+0W1wzwcFCZa8BxB9pjPL0LEetO5cePw3Tc/W8oNI5c/QYyOEzjFCnvA8/REMtPva8eeG0Wu6G2YAEQm/AjLjL+z1cxz5QywhsGkAmrUkIIO3l3lLlOkjv4FAF0DNfYs3AwmP8Lc6wIsZjz7VZUK9KjuCXrEHxsq7MWRmG6vQBppVyPJdQECeRP9LRMpQmz3C8Xxg/y28kya8a1kYQ6PvaKqLlwrR8X40VnnKsi2LqTH2bRugzGfm5BTX/Hrol086/ttMQAh6noY9Cr8A/ip/JrRB9dm1wURExzVWzXd0SO0DN9hvQVMcmbc9SKVft+nQFhVXNp1qxpg66m+ldICVGcFSRZ2NnW/mWttsPjx6Mo0l/APo9ZSBsYyW2zn0mi8yOafvY9dE71thrVJpY6e5bVqxwvODjqnlz2cJmsWcIJkJl0P/TiDvZPgANDwtnG0JIFysNNX/s0P31jtUqUMmWUsbcmZ9qw13whwaryrZ91g7g+1fukHPHK3ka5cM/pNn+LkhrMM5Qb+98+77PDmNIXcRGolplNdqrEiweVFd5rKnaeb7fh8FxCa9Kuq9W+Iz5b3nRFoGh2UWbyev/HLc7rE0u+YeuQcW87mJTPkB4CzZEVjWz8/GauOVkMcm5gk+KeBCHtqr4BGB5ZoRLg1q2dsaZzRq9T029awsXPKAfkUCfw3/Pk2IOtGc/FOuQxVbReZc5IP6CPIyNRyaB7xTb2MjVfJ8vQZgogDmBu+Ncc/gyr 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:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:24.9882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08ec493b-dc1f-4f1a-a687-08dc4c784703 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: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7516 Make pstate driver initially retrieve the P-state transition delay and latency values from the BIOS ACPI tables which has more reasonable delay and latency values according to the platform design and requirements. Previously there values were hardcoded at specific value which may have conflicted with platform and it might not reflect the most accurate or optimized setting for the processor. [054h 0084 8] Preserve Mask : FFFFFFFF00000000 [05Ch 0092 8] Write Mask : 0000000000000001 [064h 0100 4] Command Latency : 00000FA0 [068h 0104 4] Maximum Access Rate : 0000EA60 [06Ch 0108 2] Minimum Turnaround Time : 0000 Reviewed-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello Tested-by: Dhananjay Ugwekar Signed-off-by: Perry Yuan Acked-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 6708c436e1a2..ec049b62b366 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -756,6 +756,36 @@ static void amd_pstate_update_limits(unsigned int cpu) mutex_unlock(&amd_pstate_driver_lock); } +/** + * Get pstate transition delay time from ACPI tables that firmware set + * instead of using hardcode value directly. + */ +static u32 amd_pstate_get_transition_delay_us(unsigned int cpu) +{ + u32 transition_delay_ns; + + transition_delay_ns = cppc_get_transition_latency(cpu); + if (transition_delay_ns == CPUFREQ_ETERNAL) + return AMD_PSTATE_TRANSITION_DELAY; + + return transition_delay_ns / NSEC_PER_USEC; +} + +/** + * Get pstate transition latency value from ACPI tables that firmware + * set instead of using hardcode value directly. + */ +static u32 amd_pstate_get_transition_latency(unsigned int cpu) +{ + u32 transition_latency; + + transition_latency = cppc_get_transition_latency(cpu); + if (transition_latency == CPUFREQ_ETERNAL) + return AMD_PSTATE_TRANSITION_LATENCY; + + return transition_latency; +} + /** * amd_pstate_init_freq: Initialize the max_freq, min_freq, * nominal_freq and lowest_nonlinear_freq for @@ -848,8 +878,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; } - policy->cpuinfo.transition_latency = AMD_PSTATE_TRANSITION_LATENCY; - policy->transition_delay_us = AMD_PSTATE_TRANSITION_DELAY; + policy->cpuinfo.transition_latency = amd_pstate_get_transition_latency(policy->cpu); + policy->transition_delay_us = amd_pstate_get_transition_delay_us(policy->cpu); policy->min = min_freq; policy->max = max_freq; From patchwork Mon Mar 25 03:03:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601224 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2083.outbound.protection.outlook.com [40.107.94.83]) (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 A256222AB83; Mon, 25 Mar 2024 03:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335874; cv=fail; b=HZBU/ruhaPEYvPoF7jut6Pv+OtTURMoJjgcv3caktXI2su0MovRinL/aevneLAJK9jCxS/EwL7vgXTdoaA/rhK55bJxZfjGZg1qiKwlkr1ll+8fL0wZCjCVy7rFn8nam2ENeWzfandxSvm7YsyK3PTGlyFGvX21Jb2ekKdUHrgo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335874; c=relaxed/simple; bh=Um0+J0yaMX/a9vnllsb5rMCBX3DIXBTPnJJjMnw/pIg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z8G9x3CiRwVNxcTPhIPjxadXiKQpXg+c9KOTBcGRSrniwHhRkuRIp+xYaiWPiN3dpB/aF99sMT9KQzy1KyeBILlmbqkYGzj9a1UUuC6af/TWip9Ha2D1a3XTSeaU2ohRylmCW3Xwhlliqe2pv5ztL9exzlrnhhnTOCddgVX8IPg= 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=aGobPE2d; arc=fail smtp.client-ip=40.107.94.83 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="aGobPE2d" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D20dMr1QzRbf+DFE54ou3qnDBbNnme3LG9IfspIlkyoiRI5aL0vBmQNeC7BzyKVzaxz7D77X0aOxIii+bK0eazFSI2m8LfUGPl8xMHeRUG3iWdpEXrTr3y6TElcl+WS5KFDmy440eE3XBFkp8oyZLq6cG2OxNczqVnOl2zHuireaPs+ZnZHF0dTtxTtoQzqqPOH1/Urpy58p4fY4IlYuLWSA+XbwSRiTE24RzSWq3FsgaQmjPX2cd9ap+kJogTFKUaANR1YtyRkCd/87G9tCieYMKtJsZyZhosWspLcjYh9SpBWn/3W6CmhbKKsZWFmULszDkLVtKPTkAESIYTOgMQ== 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=RdGCKabVOMgWeX9gozE3KU+RrIAHicqm0uU9ff238Uo=; b=JvO2M9RH7ZyLKImCAIYE+c0AgsLSKNRyIyWUfQgjYkgZbYE33pBwcaAL9CvMebjmd1PYJKq2a2kvXWvi1+7eveRt8edR4lW6vXvW+Jf0KvQByVqFdzeTVEZLjO2zVgD3fLFe8ORsBxZLXjD0Lv1SYRD3rqUskzW7PTw8m3rhC8kkGvYzxtCLxe5atl5moC3YCcoYT7hNBIA2Pd1Tn6MF+rQBrOjUnMiLB68R/Li2e5GozP+ZE/FaVw7dAkEsDNu7J5uvJMtOtUH6Tdd4rdoeMs43vq2ZHQR1+kKd1eYNB6i/eea45RxvDvTWI6HzcR7NhPkrFvaPV/1coRILqmE2Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=RdGCKabVOMgWeX9gozE3KU+RrIAHicqm0uU9ff238Uo=; b=aGobPE2d8p7D+0VOVDtJEOIeU1AIzVe2Asv6CfT5Cs1tErPb+75IMwHncpG8YBMK1xhaVrbvUkbYL3mqAKxxgThj8UyZvXJCoj6bgs2yj3DsuHOq9Wvo4Ux+EVP90LNQnqPbTIj9opb3LQRN/RDRKi5iqyFaERFNwDPpD4z8hLc= Received: from CYXPR02CA0091.namprd02.prod.outlook.com (2603:10b6:930:ce::6) by CH3PR12MB7522.namprd12.prod.outlook.com (2603:10b6:610:142::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:28 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:ce:cafe::98) by CYXPR02CA0091.outlook.office365.com (2603:10b6:930:ce::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:28 +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 CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:28 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:24 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 7/8] cppc_acpi: print error message if CPPC is unsupported Date: Mon, 25 Mar 2024 11:03:27 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD5:EE_|CH3PR12MB7522:EE_ X-MS-Office365-Filtering-Correlation-Id: dbc67aae-c4d8-45ea-d4b5-08dc4c7848fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4v47AhT8o4IciJxaWLAc0B8LWrL2ur3f4VWgM4GGHyZwHMYDAO/Mi27OqUPZy2UGYAM9z0q2h0cOKxQB8KYJ48j0rTTgifKqC5UEreZ6r8eCSBBAjPqIcuUfq37cmWKIMlyOun30Q1SJLRZhZ3+ROCA8P4m/nbqxFudcHuKjYejrA/bfR2LSi1zo/Igysb6m22oZhOEmV7d43rQm3zyGRu20k1LgYX6fFtOOf/coXkyGUmlxeUmag35y/UPtpuZfbMVGrWEeyxFUcfa/GN8oVfKX8cVXrJ7Wih+8/1VAkCvhqfkPNFTPp87jGZO0LaLwX6AU2AIpyzjxJMLa93zKmFev7nkzNFv0lBJose+oaXUBAB1Z0iaqtbL/oFZHpRK9s1f2qSqCCmMAPMj1BLlAZW6NvoKtkzu+sA8jkPa3CVCvXUIyhWyk/4F1IiYz1k930YhfbnoLenJY1P1DdLtNPrRwDlH92TZu3IT44SNDmHoVb/qjVBMcAhDs0lw80k3Lqj5WFQEjOx/xzoQ7ta9DBXZ6JONtLjDZvbXDXij2SJfkdmpp2BLgS+m/Sd/MSNC+331QSzPK3Krq6HJVJh8p4sI7pIxRxF4DHK5tWUhz8jo1xZU9BzjCY1cX0OVY60XrrXgbM5cqbp2mg/M74JbhGZ8yJDXU510R115e+yEfG74hgGVNt02/h/dodOX/7bC7Ajf0HT+zVWkMZ4dX+ctlutGU/ZLU+LJ0TdF08r7ezfh4hgA+JkoHfTmF2tTC24vR 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:(13230031)(1800799015)(82310400014)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:28.3055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbc67aae-c4d8-45ea-d4b5-08dc4c7848fd 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: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7522 The amd-pstate driver can fail when _CPC objects are not supported by the CPU. However, the current error message is ambiguous (see below) and there is no clear way for attributing the failure of the amd-pstate driver to the lack of CPPC support. [ 0.477523] amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled Fix this by adding an debug message to notify the user if the amd-pstate driver failed to load due to CPPC not be supported by the CPU Reviewed-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy Tested-by: Dhananjay Ugwekar Signed-off-by: Perry Yuan Acked-by: Huang Rui --- drivers/acpi/cppc_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 4bfbe55553f4..3134101f31b6 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -686,8 +686,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) if (!osc_sb_cppc2_support_acked) { pr_debug("CPPC v2 _OSC not acked\n"); - if (!cpc_supported_by_cpu()) + if (!cpc_supported_by_cpu()) { + pr_debug("CPPC is not supported by the CPU\n"); return -ENODEV; + } } /* Parse the ACPI _CPC table for this CPU. */ From patchwork Mon Mar 25 03:03:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13601526 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) (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 C1ED9268034; Mon, 25 Mar 2024 03:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335878; cv=fail; b=Y3KuHERX0LfOkTbCmVW8sH7X5gAbc0bGtkY+o6KJsaTgMJhgrSfNlbUKZKqVg1zbK775KUWKoe9m5H0o2gmzV6dxWRkZNYnm6Sgzs13MWOFQSJ9DUs2U7CaR3j6LryL7hQHkTXli1rcxy/y2O5iCDMqJf3FeBg/0LG8dwtOJ2co= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711335878; c=relaxed/simple; bh=/ORMEDvJlElLdwB05bjjkZ49ZILNK/sXF+PMdCPic2U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q2EY49tdg587gOFpDK60YAnGVppEUqSBbss7cGRQ4HAtsLd1MWv2Gs36oEoX9jFIZ1KsLF57iMb3xmDc8NwjYIr1rNczSkdMw8jOw3p+lXVXPh41bI3TgU/6B7CiL6KTSEu+wu5O6a37CYpJL0/dpKOZVUkmsY947bTUoOSgpUs= 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=ossEOfsx; arc=fail smtp.client-ip=40.107.93.67 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="ossEOfsx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AxN0QtOEEVcAAHG4Dtgaa8B6vFfZOpM0RsrcZnOK3hAbaR4ZefwowPtxg4wNhKttHVu3Db5621gavaFntj9zHV8kmMNIdrBTgZf2fvqtmp4a0W5vFHCd1OdgOdUkTpffSGgijUEkyWBvU1nJ2utWDjT7BLg5DFX3X2YJli4ISy2PdWVqq0vOS47hOp7nTRY3VwbqSk2BUr2ZjGwoDjvTFDzTiSfaX7lTPhxfLvcRcJZjvV+DI8l+tkh56RKSsgHbyzfCvX2pg6Ndsjty5jVE5r2aYga180VSHubpSnsRW52gNLzv2eL8y99/4aCGMwBlFsbiwseeH8YhWBoIC0dBBA== 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=PJa5bG1XvdZh5o3Op4pc5qeNVIcfvEHxqfawH8yvlgk=; b=NYNGr4UWvWuRzfx0EZO57FANYA1PltM2ulikWkpwKs7GGUgjr/Znn+YaWeXO1asECqvqCr3fru4u4++WVOS0GrsdxVpyq+uGUBIV+IIXQnWNS5znlu/96ZUy+AIq1sQO/2+b94QCOcx8AF9hMgFkTg1AOI0A5LZlKhlCcR7jNQ2IYE+o4GIuNZINTmEn+v1fWFfeltg7SP36f8AML/Zrb1HrkJn/Th9wfMoF51yHMAD5VtthA/lyXcmmWFoSR1GowxlKbPlzrepb+ow7XTQ1FmXbTOazTpEjvLzUltbKospLyiN7YfXw3xAXn58LPy8c2X61D5B3WlmYMzAr+sudLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=PJa5bG1XvdZh5o3Op4pc5qeNVIcfvEHxqfawH8yvlgk=; b=ossEOfsxROwf6o+0iMhp8lvzC3+db0CNBY53ggRlGgbSL4GKLEjwHA3PSsDPfvRXtZg4zmBYuqxRVrwpIrfftm1yrzdW9ou4s5/AnZnIfw+Jy1q1Zefe66U0QVH/0mQYzcPvypKGG17N8t5EjvvSujPNn1gBrPC7W1Qzt6E/uyc= Received: from DM6PR08CA0062.namprd08.prod.outlook.com (2603:10b6:5:1e0::36) by PH7PR12MB6585.namprd12.prod.outlook.com (2603:10b6:510:213::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 03:04:32 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:5:1e0:cafe::99) by DM6PR08CA0062.outlook.office365.com (2603:10b6:5:1e0::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 03:04:31 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 03:04:31 +0000 Received: from pyuan-Chachani-VN.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.35; Sun, 24 Mar 2024 22:04:28 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v10 8/8] cpufreq: amd-pstate: Add quirk for the pstate CPPC capabilities missing Date: Mon, 25 Mar 2024 11:03:28 +0800 Message-ID: <31afd5ae23f8b1d7c6a2f0efe593a368dee61224.1711335714.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: CY4PEPF0000EDD6:EE_|PH7PR12MB6585:EE_ X-MS-Office365-Filtering-Correlation-Id: c72a93e9-aa4b-4e48-f57e-08dc4c784b0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fyviQYKepQ+Q/w5GRI4RABCs11GBVLLOl8hwKptTG/Ve6NSpY4+f3Fx29I5GX3AOaL0PYNUtjKC5oF7xA1+Z5mDFA/suP6dhHADmovUsTHnq4DqwzK8uGxB7VbZsFjmxp529MsQbYc5Moc7cw+MFRmekMrnGYMYkZr4kKiq1kkkfjX2ZdCPVp3AEvpB+tnrKt2NBUHkww2ELTV58lOtDzlUbQo/LaUN3lCLyyTURJT50YK/4MWp58uLLvybhADBseZx4mNQVrBp7enkbvrqAtFPqzarBz54WkDN1yN0HPxfeBopalE8bVijFbv1iFsYBPEtIPtfhyDhgGhNkN2SwOzXtrBhQPEoGR66oW7bjqUPe0rWSh6kzetbZgt9Wu4p84/FSAdjHnPe1xSryr9TOBr99lYSS/D3hBMn4S10I1jgdPVT8Vur5P/MVeQvj6SO1mL7psyL8Qe63YHFEQL0o9jDRR2WVvgx/CP4oq/XLBNSBdv8vN6wDqifzVJAxgPlp0+gnHaqSRqdxLJHwJcd0UEi/INgJv/rQLXTnhTZXTNsTHlzvGIcgrAFsuXLiiZf4IoUmr4pqQ4ixHXa7zFu6Op4/RaawMAanMejpa+7evS0b/2GA4TXlQZGum25oVIh0Axutu2jBHhJA149ELpgcJ2CVeNjlIssywQo2slaBH4O9a9JlunDkQnaBWF3v5oGEsfhHQxbyQGTx7s9VZoW5QKL4ajFveCXeJyWr8tkkL/+n5YnKTyLD5ZsSYinDRBUZ 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:(13230031)(36860700004)(376005)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 03:04:31.7444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c72a93e9-aa4b-4e48-f57e-08dc4c784b0c 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6585 Add quirks table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading. If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors. The workaround will match the broken BIOS which lack of CPPC capabilities nominal_freq and lowest_freq definition in the ACPI table. $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_freq 0 $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq 0 Reviewed-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy Tested-by: Dhananjay Ugwekar Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 53 ++++++++++++++++++++++++++++++++++-- include/linux/amd-pstate.h | 6 ++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index ec049b62b366..59a2db225d98 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver; static int cppc_state = AMD_PSTATE_UNDEFINED; static bool cppc_enabled; static bool amd_pstate_prefcore = true; +static struct quirk_entry *quirks; /* * AMD Energy Preference Performance (EPP) @@ -111,6 +112,41 @@ static unsigned int epp_values[] = { typedef int (*cppc_mode_transition_fn)(int); +static struct quirk_entry quirk_amd_7k62 = { + .nominal_freq = 2600, + .lowest_freq = 550, +}; + +static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi) +{ + /** + * match the broken bios for family 17h processor support CPPC V2 + * broken BIOS lack of nominal_freq and lowest_freq capabilities + * definition in ACPI tables + */ + if (boot_cpu_has(X86_FEATURE_ZEN2)) { + quirks = dmi->driver_data; + pr_info("Overriding nominal and lowest frequencies for %s\n", dmi->ident); + return 1; + } + + return 0; +} + +static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = { + { + .callback = dmi_matched_7k62_bios_bug, + .ident = "AMD EPYC 7K62", + .matches = { + DMI_MATCH(DMI_BIOS_VERSION, "5.14"), + DMI_MATCH(DMI_BIOS_RELEASE, "12/12/2019"), + }, + .driver_data = &quirk_amd_7k62, + }, + {} +}; +MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table); + static inline int get_mode_idx_from_str(const char *str, size_t size) { int i; @@ -812,8 +848,16 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) if (ret) return ret; - min_freq = cppc_perf.lowest_freq * 1000; - nominal_freq = cppc_perf.nominal_freq * 1000; + if (quirks && quirks->lowest_freq) + min_freq = quirks->lowest_freq * 1000; + else + min_freq = cppc_perf.lowest_freq * 1000; + + if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq * 1000; + else + nominal_freq = cppc_perf.nominal_freq * 1000; + nominal_perf = READ_ONCE(cpudata->nominal_perf); highest_perf = READ_ONCE(cpudata->highest_perf); @@ -1662,6 +1706,11 @@ static int __init amd_pstate_init(void) if (cpufreq_get_current_driver()) return -EEXIST; + quirks = NULL; + + /* check if this machine need CPPC quirks */ + dmi_check_system(amd_pstate_quirks_table); + switch (cppc_state) { case AMD_PSTATE_UNDEFINED: /* Disable on the following configs by default: diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index ab7e82533718..6b832153a126 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -128,4 +128,10 @@ static const char * const amd_pstate_mode_string[] = { [AMD_PSTATE_GUIDED] = "guided", NULL, }; + +struct quirk_entry { + u32 nominal_freq; + u32 lowest_freq; +}; + #endif /* _LINUX_AMD_PSTATE_H */