From patchwork Tue Apr 23 07:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13639525 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) (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 49E6954645; Tue, 23 Apr 2024 07:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859130; cv=fail; b=kNa1j/BJ1f/xcZkxH2LKq8YGmnBRS0DiovTPyxhdd603lrxZFKHxTjnVU55+a28+CXw5pLjc2TSrd8VGXXeYgAYHhb6uwLWndsRmSZGDbvrAsK7AuB3ru8oS+OyeebjP1mm17hBNQ4li8J9kgvWRgvgFu8+UVbpVNIftqHZVexc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859130; c=relaxed/simple; bh=7qVpJHN69a+YM7VR5sMzFULPFNuxFuQfsn4vU1YeY4c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iupX7H06aL4D/zvlzMl3E80MuAEeRQ3aXJnGdzMqPAGZL4vQpgrSl2qzrJ9oq/AuMwMeoGkKXMmZ3akXRi5nMHcD05Ny22Qq7BG1hWp8xYREMnOW2XvGO9FDmWnzJ51XvtQpTQS35UOmumoUA+5UN68c7ex3/gkuNZ2/DW+k+YA= 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=SHMubgXB; arc=fail smtp.client-ip=40.107.93.81 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="SHMubgXB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F81n6tzL0IAksGZ8JOrEYUkwa5mJTIfpWIxQHuH2a9J9ey0CX7/S0mlOA5j9otXi4r52PT7ejYKjRbOXmXRJcjr2P08Gmjln5XnqvGSvAYaht8DLBaAhK6o1WsddlFIkEuJSzXEOgpVXPd9lhRLCwpC6vXCzYNnmhYJTwn03dDeV7EKyvd7wuKj4djZoha8P7o7MXWv3Jlm4pArRmbdZB4l+4d2/9WwdyanN7GsfgZJ1HKoUvl60DGNhDxnJQcYCsOcolARMZgPfFnao3G73j3TwJF8MzsZJBjjxYGxxvy+Xqn68bVPbwgsubuvOUe1etJSSfptyqm5p9w1kiFCQAg== 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=7HXeCwDP1hShOrQ2Q2cbuT0Gosp0Fwy3kjqWF577x4k=; b=QGoUCcB6Kw9SCdRybkUgOFK72c96oGDgpk/jyP3DYJllQLXFfCE6oBoOlqJX55ptruoC4xZq5wAIS8jZyIVTER6irUH9YZB5wO3OI8xY8lvPjzmrCkMw07/OaGnSuRmOqT4L7vfO9pcqZ+HLDtNTJwqrPjopd4AVU5e6djZ7s8oMxH1u8Dzy5OU56CBE0sbd6rNn4vORURu8SgUlaWlmwR9n2JrOmU67pOmmysD52RQXSgyq3x4aymRZwvEQUHUfto7E8vcMZC66ZskWN+PeBjQDiME6gc6GCEy8xLt+gOdYjCo/ZOD152NL3WqU4QKKG2gZeNAfVxcuiN4FM7nUxw== 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=7HXeCwDP1hShOrQ2Q2cbuT0Gosp0Fwy3kjqWF577x4k=; b=SHMubgXBFyEpem8R78tbMVBPAQ+839spSuCM4NcrapO66nSysSrXLjRuStXIMIW82UEPmCcY4p+PFI2o5Z5A48UZs5lk2YJD2hqRvtlfZ23VDB1XzoE1q5gYtbtOCgYDH1yZk4Jrr/pt5hPLYNNBYbItDLyqvQvvQE4u/I6gIbc= Received: from CH2PR03CA0020.namprd03.prod.outlook.com (2603:10b6:610:59::30) by SJ2PR12MB8829.namprd12.prod.outlook.com (2603:10b6:a03:4d0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:58:45 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::a0) by CH2PR03CA0020.outlook.office365.com (2603:10b6:610:59::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 07:58:45 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:58:45 +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; Tue, 23 Apr 2024 02:58:41 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 1/8] cpufreq: amd-pstate: Document *_limit_* fields in struct amd_cpudata Date: Tue, 23 Apr 2024 15:58:17 +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: CH2PEPF0000013E:EE_|SJ2PR12MB8829:EE_ X-MS-Office365-Filtering-Correlation-Id: e361bc8b-6b1d-4f79-8f28-08dc636b336b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZlcU6X9+Do5cQ7NGC/t52bmrC22Mup1MbcbaXNdcYFU+RX2MP0y+R7UnmfEqAnEO5S5IthynmEFGTzvmSB5sbbdMFVprysc3NbRXXnTDDDJMikusadZeRrr4zEWmkZz9VInGNq2365KtIn/x3OTDtwsB8YQdxCwNMT3TiMtlNTrzNsjRXqKI0fKdKkOo5kvh8s4WdUzw0XJjr26Lckza9qbnEQ8k7QVoTsWH+0ASsVyruRmStjmaip9QZ/zQPQWdLL4d6QBIYRodMVdeQWs3xsJHbIazsKBvGv8OCA7P9GurEi9AoamWcW0GCdCKfm0X/5x3WNohcR9/RYTKJuZSrT7oeuTceUHilzA6x5ZkDS+F66f/AB/aK1zW7iMcecrjFZAapUwi30ZE0Wnw319a5o/JD1/Cxo7ieKMyLfaR7Bs/i1PtIVzBYg6i01vLODXtlGMdxYzE2EsJidBUs7vBCroKeBVEsKCv/OyOARef/sUWSCViYLaiEYR9gzh/4eCypRVuvI1ZQMfLxcYOL1jZ8BbMGz449NHhrpG18h7qEXHsmgzwwLEzHtgy9JAtKhVdn3I4TCk8zZjBhOuKylQtHe+HJGBoJgqcDVTkIsNq7FQqO9KaF6YnGwtMnUZjbDmVsOdzOKA0y82FcsQWB0i1rd4FZz6IiLZqgoC9y8FCGBVe8jp/MzhfcQuuiaxRi0jRcFgjitHplbI1qprn59mR8ojzGXApkJJ3GqAZsxws0sZoOKMsmTxkuLuETim9iqqgkpWojrWZrSQ/876jKBCiFA3FvkmO4uggbRzHC9N5lBHtaLodhgOOR5jK9TJYfWiRYMG02p5phOJnLIacfSMN37UXqnAXbxIllYm2K8VmfHPBwLZAJFUoSv+J/+7KyUPMkyqlgNJmjxRqXN7bX0zQkWDaSOaigSu7bQFjtndjOcFqUyOItiiX2od4B7rWc4apRvIPCCa8130b11HYZbawlLl/GrRnxuPVVfAC2Mv+6U/CJGc2t+FCN/iKP13ElvZtQFJjlTG8ihg9ms5Hvcbg0c31OTA8z64b/cUQXMvMuPxPG7NENGgJUMXnKLEsLUzpfrMxDenBlKUV7nkR3xB2ecEl/Cl1/U7qXQT46qHjOSRNKqSSne8EI2p8Pjhc/XDM46hd5wmfL18UpT4WGgsJSz4yItFmsHPLuC8miCQ49Vlw9CbjQqkaFIBaMBzlnqSEiHHmCMsSIh+mujFJkf+qfVywLOOB3BNxBTHMfw1VcTg7eVEsGRQi+hzdk7TCcZq0vl2ii7AQQaC+8XV9JpAzOmKbeHJ263rbw1QuzRG//3mAHF5rdl1JFDfDsmzUY6WmrefxqsGXpHvBgJ5tsX1oGqP3EuQnVF2WJiznqtWzDYZb5WpO9MOYmZWlX6giUX3g 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)(376005)(82310400014)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:58:45.4480 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e361bc8b-6b1d-4f79-8f28-08dc636b336b 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8829 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 Acked-by: Huang Rui 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 Tue Apr 23 07:58:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13639526 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2088.outbound.protection.outlook.com [40.107.96.88]) (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 74FA2548E0; Tue, 23 Apr 2024 07:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859133; cv=fail; b=BpYrJmOxjJ8vha7kAgdgCNjjeEE1RXy+hpwbq3UIezp10L8RGIbE++Jpma7XWWq4+IERUmQLsUibeKQhgD3IuO0RGBvSTlN+gJLHtBiLpw7bwaQ2LcEM0sJfYGw8GM0rQn73lZVx1QuhWc/L1aPqfJvyIZ4v7dfJOZTk40OEFdU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859133; c=relaxed/simple; bh=XND/4DrRvnxXSuCo9VLOeYfmAdUCI9xOj/tgHRyLNFg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=doJQHXmDg63cvo0KMJT8vWOgl5MDubBfzz4YpFFWBjfHEBrDWvkhvOuhxP2WEN16O7AGfnwdqlZRauueyq9RsZLMuumVBjuEqPo6zQfNM8Ut80wfI97WToKcTlYY80Vs7nMhrL2phjJoAnNAaxLOah6nrztdiLs5YJxwkdkrKvc= 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=nqE9nwLU; arc=fail smtp.client-ip=40.107.96.88 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="nqE9nwLU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dyYjJiyROw6LFCowhidW6MSmcLWB83s9EgbWJBaUJ7hFk+MjzjVDmjNeMrmOZ8jTReYGjkB6cgPcrG05HUFKiX2mlqBwZsgFz9XJlvln6hYxtO7aCKej0tRPYIqcEO3IRqXqRFCW2Q1yK6GijnYhNWscneWKmQ67k4bU0F+vLIES60NR75rnJ0l9xqzZqYBjENPo8wv1PwfwhLQ/poi8hIR0pswSd0Exklc2BFjyf+9Xk4F9k1CHKYgCAD6oZpk+jD106z2Bme3Ec3EO1MDOevDwZV3XdpGoy1W9w3hAQ9QTuPB27S+Sq74w841uoCZLPjqEZurQJY47nPLxi/xnhg== 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=rACBeBy1UTX6WaxVN1vDPYnPhWdoyKM4IaNY38r6jZg=; b=UFdqYgbGx4LNkgMzT67BHXlyTS5/oJXrcttNktw0D24OjS+OHIriuwO/KW+uNgVXJe1bSJfWx11kNDuwhL+ToT3P9rIVfPObFoYZbZBcHYxorxO2wN4zXLKtmoO1xR2ltyFET2HeFRQbzqagy4p16OoFGU+xLRtOL389YbV8Ptjyt9ULHNyU8EAMg1wOMSfoIcyPe7XlfzjyzbURtzwY6f5atJr0VI0eyqDgtzEefvYJlbhRZy/14t16MBrpwUouUcEuaic4IQod/beJ9uyzcltPmXT/lk8ZVxE3GU9LgKAnv7w1WtGUlSrWK5bxcAFQ1SURKJpq43EHwA4NqS/EKw== 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=rACBeBy1UTX6WaxVN1vDPYnPhWdoyKM4IaNY38r6jZg=; b=nqE9nwLUCKuDvb7Z0079nz9jvl8nkhPC/mQowEftodLtj1Ug9OIff14Tuipks5dycEKKOxevbIAl1z7qShUFgqoGTEJZqnRqI6xs/h4q6zvGARn1FoPKo6oElNev90mXAOAtSIwstiG6deZaPPfgLNi/vQUG+vGHbkoeW2YAd28= Received: from CH2PR03CA0004.namprd03.prod.outlook.com (2603:10b6:610:59::14) by DM4PR12MB5961.namprd12.prod.outlook.com (2603:10b6:8:68::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:58:49 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::d) by CH2PR03CA0004.outlook.office365.com (2603:10b6:610:59::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 07:58:48 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:58:48 +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; Tue, 23 Apr 2024 02:58:45 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 2/8] cpufreq: amd-pstate: Document the units for freq variables in amd_cpudata Date: Tue, 23 Apr 2024 15:58:18 +0800 Message-ID: <72cbda63659fbe05878320c70f09e4a2b4d1b27a.1713858800.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: CH2PEPF0000013E:EE_|DM4PR12MB5961:EE_ X-MS-Office365-Filtering-Correlation-Id: c9ae4301-4f99-4eac-2a1f-08dc636b356c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0+/v1FKMh6wZMovf6R8LkJTaEdXFLfuAJ2Y5fKzG3RYDY2qLy8LpU2qAtyArV+UuLifYHFiwav+mhtjbevE5i1S2iY6kEq7YSmwamPWHTiQYrVDoYXOrQ+bOgBiUnlOBNxUIX8fewGmBuITllsiZY2q87Rj6b3DLHpz/+6+toCxzFmR0QS7JwO5dmxgJGAiy2CVNUmSTEgnuC03cWF7R1tChRYay3IWYzR6LtogJ6TZhK/yAgSsxygi647Ii5uTVubH74jD1k8RnS7aH7vm8jp0PA/vv0kCFRsPqzsBBRqDh1Lw/6UGrcY5bUf7CVA5fi3UDI/Bj8v2FtRydBiPgUWoMBv8f+5zIplW5WgMfWsobnMKEPhCshlUB74nHSmMqH0DHNwzuB5Qwv//hHJPnTg0d7+2wmj3QAFixVMBtrtW6NbjDhCZLaFSy9y0EkVzEC5zbHH6xKJU9OYDyxuqcfo1SXcsfFE16l0BQcp0hH3jFsArOwy8D3dOOmq6z9mUhobfLdgdTJcSiYjUvZF/cRr7lQLuhzyuVaXLdN+1VeST1i5ISiovzJS3eE/7ExZM0mCgBiWvptaw6U/LDrI9OqB2LHC1+08noLChrTWfz0PNsmEYXt2LX0oJ7IUECt3r9pNBmsEy+TxOEhybcdLjoMCoCKwcRabTQTIWpVO4bSv6ynsG5AQWmFxtyzY+pHjORQ00JmHW2n0RrIAErIlNprI6KlD+MDCI8RA+mul7bbN7seYjYASBY1mogNT5lkApK3QPKrEqBcNdyibUSY9rl4mhtpk0zXIEzqU8HA5CMmrXv2TWKnEtMeXY2/a3HYNtB57tc6h9aiyqer8JuJDikZpcTvetnh/99xAIrkH+4VBd44zYCqCOLun+cwQVlTTLyGrBWa0JTfGo7mejeDuXvAaJkwl9SVd1f5aG1k3S7G0nr8f4m081jv7sl1KAEHqMM+oEfX7jupIXKkWl45WsexAdG10dN3mIgAdM3hCBBCPUKtX52/Fx+bdSs5+ZAMNrPzHrcuaNIoNdRqtOl3PdCc8PUrJk391lC/fd7xYhFOzlVmZ2mMfwMZTypct9HTNfyFflh2oRrHjvqSon4T4D6pOixl7V4SsK64ApAB0WOeAWBavzI8gonZLKqvecPT4qchgP5AliHI8zzX17qFtu10JJuBfHerZFyAhG/UEhNalnAvivvM50J97zVzn/xQ1jlPf1RZpzIPbf+R6W5A1ngrZxA49TfO73dALrg/EkzkJ0TpYof3kjksgY11426oqN0yoBaNz/xgLkeGvnx44MbDibjnTUWxKJtk+OVs7jMNMmDZcqjR1lIn+c7vUj75a+qgIxIZxJNBAv98JZVI4qa6f9TFnOg2myL62G9Kqby4z3llVB22a6cYk0+VtIY0nQ5 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: 23 Apr 2024 07:58:48.8074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9ae4301-4f99-4eac-2a1f-08dc636b356c 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5961 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 Tue Apr 23 07:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13639527 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) (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 11E1654BFE; Tue, 23 Apr 2024 07:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859137; cv=fail; b=UZEW+CqShpuys/X5aUyDOxctOxuBa3e+PML48EhDgvFEy1bxwaSfmIF8PMuO1WRos3MwJabgPP0vJuijqFRBKlhBUbb2585nCEvGrDaD7KugYBQ75N3tvq8B/bnouO4QHrBhrji28Tx2zaLdlWrD1swqW4zIAo8frqSgdYcAoRs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859137; c=relaxed/simple; bh=LtDBJFN9mt4Ghp8tKeZFaX6vbLB5XW99XgCcPx3/nXk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U6UUfb3VOXqkUIncJCJhS5e1DaVTwv4Gkcdou1D45rdt75r+zNIXxKNozmyx3k/bRtlk6ILEszCgXHIot+6kCrNecqVj0It0tMF3ALCY7pSffsGEJ80IRelCKsY5nTUx2VtMTbrAa97tSQhKDEOTARq9VBYALSeav3JvSRcL0XM= 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=NHQAuteh; arc=fail smtp.client-ip=40.107.93.80 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="NHQAuteh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JkpkdW7XKabDg6RGSr7R+sshsD7/0J+jbbzNtOQQfaTSI2Vl9CVK19fhPGdobLDA++6sTIN13rawUwOfVOuOVO6zE7Lsw5a3+75PQZt5P2G4hDgGenHbYYMyMQLhhauvSFzJ8lcioqgH9qF8w5gTcdxEWCha/Yjihf8XL/3FUzfEj1bWhnJddsWIH9ZTmto06zxn5vq1sk7a80mUTE/zsXCEhdUpWZzH345qyvjHT65piyQ6lNtIdP7edv4bjlU58gEZR2r1d4v5IOXhnnk95BjC2UmpeIi5pri7ODWqzs3khcmmlEPa0dMM7B6f0p+FG3pzfBzecCdwPPgaWvFtaA== 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=qMBDLDmclriccSsNVlKFKkaYu1FJp1/xBHkw9sBTVmM=; b=jLYoyRFPiOJ8SwGm2j0cqhTSaujjJ8iBOB+CaNOIDVnhmKngaDL0Qfk+k8DcUcxbOUCD3klVKXz+wy0po3qE6gpohocgrbezROeQLgdehSlRJjB+QMx+T8Trr7tvUKw0O6TOVqAdwDD0PnnFUqjSlw/y05HE7uyz2SEPxk646yfbxKU4Sr2lbePsVd/mIqjh5sTniCzIG7OzNuc2mYauK2maKytiZ+amKUCdBouQIDSpGJZbtmWY53Dq6B4igUdgCPJbdvEp2bR+tITzs1bO/IV6o4OsvyYjFEHtvTwEAsdSJz4if2G2OXVCGLZkOSV8QmSu+vTDExX+dB8pZoHSKQ== 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=qMBDLDmclriccSsNVlKFKkaYu1FJp1/xBHkw9sBTVmM=; b=NHQAutehy3mlWr2uJkbTZQtjl3cGjJI1r/S3+i3eahsYHQ9RuSl7eHr84rW3nswc+1yqagamZLtBUYQ/+asBmItMyBQn78UgzUI0Ffk0Ydvr5ObSjKmnef1DpduDoeg0SdZNyFUR74QQuIVfBEGMJojQ+GOyM4Pxe7wLRfjAyuc= Received: from CH0PR03CA0237.namprd03.prod.outlook.com (2603:10b6:610:e7::32) by IA0PR12MB7723.namprd12.prod.outlook.com (2603:10b6:208:431::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:58:52 +0000 Received: from CH2PEPF0000013C.namprd02.prod.outlook.com (2603:10b6:610:e7:cafe::9a) by CH0PR03CA0237.outlook.office365.com (2603:10b6:610:e7::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.31 via Frontend Transport; Tue, 23 Apr 2024 07:58:52 +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 CH2PEPF0000013C.mail.protection.outlook.com (10.167.244.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:58:52 +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; Tue, 23 Apr 2024 02:58:48 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 3/8] cpufreq: amd-pstate: Unify computation of {max,min,nominal,lowest_nonlinear}_freq Date: Tue, 23 Apr 2024 15:58:19 +0800 Message-ID: <0a8c3ba26e0631e47189c22bc9b9596554461360.1713858800.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: CH2PEPF0000013C:EE_|IA0PR12MB7723:EE_ X-MS-Office365-Filtering-Correlation-Id: 0655a21d-57af-4c4f-a866-08dc636b37ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 09tHmLwpWrNjIa/0+vxL+cemZ6TI5i4444zZtAxYOKuLsTda2xvmaBBnJ/qMBbj2/IZOGJTUmlB2Bsumx439GQ3wREuHKeUB5FdB9n/BxORDGTWtzhh+Do1lZHGz+vK5PhrRWSJFSJqHAzJeeiXjtB5jPU87/F7xv1ZFTNyY2oiPtCmxq8bdr3LmDAud3hNawMSwiKiBA92i7//wYFG+F0QwyJ9nvqOBQEIwTJZee1CwJgg1wf6w9vtoXKGK09XVK6FhiC4xGSYsse1L8YqOd5WLK5dHjJRzFB/l+RScBynUR8eVqUiuQOAGHb6XeCIwXGHql/8RuOSap56vjVnh9X/nHoTQFIKwb1xiv/7QGIOITqXbZezruN1T1MHTarPlaB4w6MbpP393wpHywhpjwt2THZgSBW3Ysgv1FxuFO0L05IzlGSpSdJqnPRjXHiWIVZCswoIfAZXPIvtvGEaggp85F10Agd80fdXKMT1z0TWfWrIZQ0x75IV+nVH0YoNySvPUamLKnVCLXanPsXZEUM6Yix1W9CONnW90PMJyC1nyl1z2CsBAkugN95fd9YIL1PBa8nHmVgHTjgAF1MG+CcG35pne2bfd2wR5qjCWMyGzPLAM5TXNquTl6asPqBgk7u53uVelNk9YDnfq7nj780IFRZS76k5ZbzkKiq6syD7+7IzdSR0XKf/zqEmn2DBxRJxaWVhrsLHjBIDTCEut4n5MpImPMsajwix5HEdIjY8jTApWbfBGB9OZmaieAWKdfx/uMQMkfXk3tveFJiR4nBkBsBxGk+Z4YU42nPEDRkCHv3Bt+x3JJJ/06Lm2MpgzlT4wGisgZZz69mMblLIXm/xAgV6Vtkd2w8hTMr0M1+0SedmtS6uTNQxvwaFLw0Oh7WGi2ypJJTOOIgKJ8KQ0Rxyj7YWPy8HZ6G9tCsA/66j0Bt9dMP5SXj9hqTBbyw/+13bCZTDNfKAwGTbVIoweKIU3Rf+bC3Y4bQlXkkOz4XfbOzcqTKJRaDFmf+YmXBShWgcgq6blEhlOoMKKYIRlVP/350JVi/hvTJWzqgYD+utsFeI/e3YpKi+N+tLNiSEx4szdMSHzxAR/pql9C4ZWHAT3ARaL/YVqpvw3PWEp0BNY6jBQyCZ2aRdvtdjh2mphS+F4PC97ds6n0IupqwKNipUlAzqJuxQuFfA3MlwwvlyIscdppA07soOE3xTSvUTBoqV6BctuBo99f5qwku3DbJbmbVj9D6BVqEUsLR9JIz+m5VNtGVTDRihROohDSLjYGCWTUe2wZ6xVM52T0r1nxIcM6H5F1/jJvChxTZJbrgizGeyfDhYpei5g1sa8/gLqr4DFQ+JYZHyZhoVGSp642dWXvrIrLKW8JF9putz5OUyC0T5oDjHeDBsocDImzLdc 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)(376005)(1800799015)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:58:52.6773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0655a21d-57af-4c4f-a866-08dc636b37ba 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: CH2PEPF0000013C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7723 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. Acked-by: Huang Rui 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..891fad6f90e1 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; + 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) * 1000; + + 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) * 1000; + + 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 Tue Apr 23 07:58:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 13639528 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2050.outbound.protection.outlook.com [40.107.212.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 4DD4955C29; Tue, 23 Apr 2024 07:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859141; cv=fail; b=aswbWNizotscGzP6yk6bRuk1KswLqM4aKmsCj6ZqnNl2LcQmShIc8eKheKpAg1zmpO5BDzfGP3r80avhI2kBQRYDtsUVCEmxLZHUH2VCzD2TBlH7Bh7dJzopd/tP3c0x9jPDdkoHIbmQawZDRdNj+Hj/10mT5ZsIKN5M+RVPL+w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859141; c=relaxed/simple; bh=GOEylsnGtnQnASO5apgdHql6QhHuHp5kmw/FAiy/xSc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P1PnmujNtgOy6fWyajnVb/zt+4vFQ8u4n+WXemjrTiPE9/YJeSN6mL49W1OB2EbzSTUYU181mAtFeJY9dzQOielKTq36JEUbCwK0aPERkl4SOBsi44gyCZw1X6ck+wEI3rRbNixA5nVb9Wk8LDAbfCY5Qip302GMiCdoBlSfXS0= 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=fnk/9LoD; arc=fail smtp.client-ip=40.107.212.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="fnk/9LoD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dMt/6t6kqH5tX2JpP58tJUZcOjJBJugvBBihqgJaI/flhxpaRptSMLzBUXfCpNs9liTVRCbvU6FelB1Z5jmIiqwL6C/EBij8ZpXvkAc1t1Gb4HSdcs5isMUQeenJFuHJNZNoj6fXMGC/wwzGlU08vljAZ5+UD4bX/OEgUosd7GVkUrmhMTQGUcILgLnKnbY/nfqAhX2QjpJJJU9utt/krPZWEvMrs07iGd3+/iU3gCZ/oQj6E+ACqmnDqmP99OYcqhyvAa4xa16minspqx1jUPhtDatfj0YRX1HZFV+hePw+HelWQsb/3nnIsnjeo/MWddQhSSJxcCu6BA5ofXXUKA== 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=AWFXVGCIXk3NQuI7JxRsnYQ5oZtrEZj2oetcQrcIfN0=; b=LPTp5xgfdXJs/2lspMUKlt81lWh/xivZZ/35d8EK/HE+CbE3YMI9NpKvpbDT15ISv5/vEA3n/3WeIeXraIlUOtPxcqE/3kNnPa/kezkK05wXq/IBA7aNMc2lRmE0WIRswZkrxFQjP2koNdx7s9Q8S3MGG7h0fjPTg6qd8Uj/6FBLBvW/RfDB1AAVSrZf4hc9E1EOVjF+H86tQBqMLRg/3IVhn6SJlrZbQXaIhtzS/OjE0MmI852d+F0Tdm3mcgbpzWgc6GDhlvKLzo8FgTOAVWM0JsVJiYO3vVZSnx0YuFLC3cfSQFlPdTxMxnhHfMfjJnth3/X9SIIqhDhUjsl5Pw== 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=AWFXVGCIXk3NQuI7JxRsnYQ5oZtrEZj2oetcQrcIfN0=; b=fnk/9LoDzL6JK84n3QZsqwwH89puy3dA4WNJ2lAd/o09S43vgMUTsIDybAIcGTuS2BAJiRmXezrQH+SY7ItOA0a0LmIT8Fznl6xsqsaFATy6bm7hmt6ZO6+dB3cUZjVD8B24BfaxJhZZ/IG42DpwijjJhGo9qUMNLyRpIIFkK5k= Received: from CH2PR03CA0030.namprd03.prod.outlook.com (2603:10b6:610:59::40) by PH0PR12MB7814.namprd12.prod.outlook.com (2603:10b6:510:288::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:58:56 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::fa) by CH2PR03CA0030.outlook.office365.com (2603:10b6:610:59::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.35 via Frontend Transport; Tue, 23 Apr 2024 07:58:56 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:58:55 +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; Tue, 23 Apr 2024 02:58:52 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 4/8] cpufreq: amd-pstate: Remove amd_get_{min,max,nominal,lowest_nonlinear}_freq() Date: Tue, 23 Apr 2024 15:58:20 +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: CH2PEPF0000013E:EE_|PH0PR12MB7814:EE_ X-MS-Office365-Filtering-Correlation-Id: 79aa5896-c356-4ff5-fb64-08dc636b39a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XHCdHpUL4sMjc7tRksZyRjrAXTp4T3FGft91lwyGtxFnTOrWwHCz/iYhAHrjPnP+prNb0kNbM49zR468P9gTxXV2QBrZU0EGEP076ukFkk0uQcRC+ZKMDpr1SPqsPxCCYEuYTYJadAdVHU4nR3s+a7N9KSg/3v2IB1pUMCPFRPXwumrL3H7h/cXaFbmSx4oMtenztsA/xmnvYUWW/h9NVMMEGJ9x3Dmc7CqYbqEMXFQ18R2aiKZWk9ybGUHhpp44E/dljIyQKi8XXJoBVs/a+0g4itMs/A75DOLGtEk6G0192llDl2Vsgvd5b00YClgL1GKo8+Or4GWz6OBl+b7PNbbeFrnqrvoQ7LO2ChP8A1Ui42+4CcCERjfU3NEaJOMlFwQPagBOTwEW8c9ZUCRCFc/RvrKiZqBO95UAp7ZBnUQ1KohQnVbc/UWNIjZQPxT/Lp4PYjrKuknOBQY/V717ZWkK81e+JbfZDWDy9BIqr/HZX1szil2avUXViUUYtlbtMFDpKmZ9xUglcpHDSMEMiCQUk8/IydQyPhz/Mbi37sK4gRAONiYK12grShFTYa3MlJhtkktGAwkqw7Q2LLkwVmj56udPBUqGByU0FNqzS+TLjEyqzMtgXE1+nyv/UoK4S1SRC8WbUzI7MztiTWdPna70ybpb6C2iqw4WkIg82TXHJ4WbbTBFqSh87CdryG/oByHBYMCWCSpo831H2vWbXAanvpqBVPieJ8NuUutz0sbIywStRkmDERXb9B8ruBuFqaVwHxxa0R3Jgu+NR0rZ8YU59Fn/Zv3lq6ssSGIY+BD0w0rEkrb/8piz21lt4GVL97Lr66zxSExkOIFgTcjBwEj9LEVmZALp/uN0C/sDC7McX16RJkiO99CsxM23quzuAilt93rJTNXmBIYlkvia6S6vyRdLM0EoiT6ZpWrCMfOl8jQyPc/4fFGWxo+1pKQVeDtEzKCHOTKpGCN7OUyb9W1MA9GTVz5+aTm/ZQCEA9ebUvHw7rN6ZbHUHMASpHPFuIwd5/GPOg3Iv0zQLq50j5RU5R6U6OGijc0Jqf4G3Fi8IAKg1mijmW2EdFvCGFmrTIaB+YI7azACyqWjZNvyRCmfU2EeiLf6tPDdyvoNH/NOrsX+p8DhPeg47BAh/4cauNkROzwZD7k82wd6sbYxGuq7kpJbiXy6+QhKhZzQGiuMn/2Bi4TSox25zMqP/YnCuhNEwyq5Q4kvcxsLKoKLpo43ZyZWpCl/xzchtvpu4wCrfoWtIcPXNMWhVHEFbNp9ahkugZW4fjxzJUIbpYFCVcgP2zBun6NsdkAAuQbs4pXJaX4CQN2RkjG9wvoBGf7fDJfNpNWE+7MJXm15EzQnEjmnfgafFrQQGNsW36QOvaWLr/Mm7itUPsaL3ysFbnED 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: 23 Apr 2024 07:58:55.9169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79aa5896-c356-4ff5-fb64-08dc636b39a8 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7814 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. Acked-by: Huang Rui 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 891fad6f90e1..3836d62b54ef 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 Tue Apr 23 07:58: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: 13639529 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2065.outbound.protection.outlook.com [40.107.236.65]) (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 4D01C54BFE; Tue, 23 Apr 2024 07:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859144; cv=fail; b=DFjl0saH0HxJwGGikBS4VmcKGlB9hOnM8X6dE6PV6RJPZR5JSPgVajEkfiwNEKScII0mZpzSNBTB6NjHirNtT0IvD7icUT4UEnZcdY156Ku7/J0B5x+Zd7EwE1P0xHpegdmducVVIgmqmCxXPlcU/qfptC1sTkFZWEz6JBaVPpc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859144; c=relaxed/simple; bh=OLudeT+1gijlMUi7TFfWkAzoR9bs8ojKSeLEe4FVrk0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bJst2oNIlrZzwrGwL99lv3q7iIfQsEXdPg/dO+++kopgrue6IeD+eGOPM++mgHBysyR3nH12sxhmHmgxRF7LOs9FM4l6J2PQFiyudA/rxlVKyj3PjJFeETvG+1GfwdxE9rzXhoGfEoWKFCGpt/XxGoZAVH81d25rouq3A0NdtSE= 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=rYxJTddu; arc=fail smtp.client-ip=40.107.236.65 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="rYxJTddu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L3sMrbUobNQnfSVIZJA3Qw6PDYiTXG9iHoSKGu0qJakyQlqR/vyPM9+loVI3SDKoTUBe4XdRRuUiSTu5/+IjuYJXpQmZqnFUYVM5sMi9EDrwgOqNrZr9Yyo2fUcKPYl3ghuHvkep33vNxLDfgbCKOel7jnA8lIKgAAkILil73giPU49WU1PdlLv7pPb68jFDPCWugGz5PzMBF1qD5uOrh4v0zeeG+1njMd+UfCAXnQcoTyHJaWPiW+efOBhl4f4evakB1elpCbL64wF69iFq90YqC0qIfVlRroDPoUMsbNr+EYiiZ3HgwGx2mja3PBDwlqx1V2MtJEeMkKUWYpqG4w== 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=0+TC2KATw7Hqz4WMVGydK+FfXr1FbAtVbdW2gRVy1Mw=; b=Miyoply3gTq5ALkBIHllc5SJeQkPIGPzrcaU9MHBJAdjwXCTKoL/eY1ltDgm0AihJ9UQuQeWRUAO8lnwrYQadMxitdPQRDt8aq07nplqABGu0NpiEgTLX+ShCbBV7qaUoZc/50vVvIpCJS73jhNDLOs8L4hYwT9wz4yCug3AIlx89BXVnPrmfuc4Rdch/RSyWqtknEEb/1xVL+aERRlnC7/cSj3vOWW3fyTfXqewzVzMxWo2yWGG0Z+NuBR9y6piQjY5lyIciUInOp5qKenMcFeS3xYJHY2UkSKZcXrzZIz/dN/rhmAD2zmUxfXq9PkiqtlR0c5mC/lR7RDFONDIKA== 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=0+TC2KATw7Hqz4WMVGydK+FfXr1FbAtVbdW2gRVy1Mw=; b=rYxJTddu4m+CVSq/txKJFKHY3XH51H3wYy/sF+vkjYTxXh+UiZTP5ZEbIsg8Nxf/ZfYQYxG1Vp+Ud00MX9jJ8HwOnxbIyJ1p1vIkVj4h+lOC22fERzxo//B4/EA9ncPwl+r+fMgFFqZ2TJLeBTL8ekEzoEItWN4nHRlLhAkTW2w= Received: from CH0PR04CA0108.namprd04.prod.outlook.com (2603:10b6:610:75::23) by CH3PR12MB8356.namprd12.prod.outlook.com (2603:10b6:610:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:59:00 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::1c) by CH0PR04CA0108.outlook.office365.com (2603:10b6:610:75::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 07:59:00 +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 CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:59:00 +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; Tue, 23 Apr 2024 02:58:55 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 5/8] cpufreq: amd-pstate: Bail out if min/max/nominal_freq is 0 Date: Tue, 23 Apr 2024 15:58:21 +0800 Message-ID: <6f016bc90debb6fb590db105c32ac9456c6ce490.1713858800.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: CH2PEPF00000140:EE_|CH3PR12MB8356:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ede79f-8af4-4dc1-7295-08dc636b3c25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uhzQIVfrcVUNv9A/xIyNA4MAzXg1BYfCFZKGzXnZKQFqtvv017o3nmNR78hTKXKgpTEWgpAFVgC7kNzsfNhlcRfcgENx8rNaQEBFL7TDpZ7WY9oM5ezfWteCneAXl28alEGvEmQYnSPnuJr2zAiM6VMFeAyik45iwljr3dt/0fx4u6djaMIp52ozIxlg8Bo/s69fysYEj1kNHCD9sywWDskRQ6qRHn3DpcfuXYO4zWEu1PY4ZuCaRUgoZ3fDocV4aBw3q1cvwprqbDy1VlX+HkMSgppFjHDsjat+xmDCuf9AzWRFzwnMc+TuNITPyydOcGOmZ3JYdDaRTmXBHm5xybzs+jhWvHopK8HP/mKDn176/pxp5cNwFmYuLrAtHE/PtK1Y/oEGhPh5t74Hxpj8VBSUDAId9k0KgmkhIPBq7kY6SNFSZyzEkmUYWgn15Q8BBYA60fGTPKYdNxqKUkQVOZh6T0rF/NY8jwBXVC40OAKIUjN+6z1cJWmb7P4xned3j5M9+a0VSzANFeXJjHWU60Bt960RODZ/2IUwotQpvNTlw/t5VMnnT8x21IX7P1/+thX/CdHiqf8ar0/7/MGXoqxQNOnP1l7dH6DRoH3dZA468A/KdSZS/RrYPUs64ZDkQlYYhVBqWzt9Pqtw2UKUEohGTAfQ6Ki4dmYRG7OMGy1N2lOrg1kDdsixeoJ6K74bqCgI/CrVtunqzYW/1UfWa+XmTscbZzIzC9CWR++IsQgm4DaadEv3CnHjJdMgyRPQtZm/YjU2P+YZ+N+1+t2govcLAoWMPX3ggCXV15Mv3YYX9XN7O8vkroLM8qRs6HDkB5seoFU9hbV41HnYvNkciFyECrKunwSzaIEWtM3wgfejaGY4AcG2rsWnZ+8/9rOzkXbt6Nad4SiJLSO0iyUHvFJwcVESwSSeWiPGx7IIF4TFKApFz0WVDDXNQWaGfPqt4qGD9OgkKyigGYPbNYmzzHVoEb43WrzTE7cCoIkiusa2jrrqFaz6h0Nb1QVWXsEBDZrvEBIMnj4O6Vw8r1+sLricJA1RIMWqi7PMlK56qpdTovEZzdOW1DoEUd4xzi6T+gh8Pbjo3UQb9twYzYfqWI8fkhp0gp0r36ZgPkh8w7slehPNFxYrgXH6VfkNNzBtmnCRlcbmf72Oq7XHrPi2JasXCf+QAY2ur/uMWB07L+Ya5V9ICk0uM0wXnV9WNFgX49D2e18Jgz9NpCbcbzP0a7wvdmnd1opKcOqjU2gHQ6Zv4+AuvXTW01jDoKf4CEAMbPbCqoEFnIg46XZgTEitF/2gnfH8ycwychkJyt+EfjDT+nrkT2+XePMXibjb1Zivb+zubWQFwx7bw+xL33ZCNuXsOYph2eWAy1gfM+YveF4= 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)(82310400014)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:59:00.0880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02ede79f-8af4-4dc1-7295-08dc636b3c25 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8356 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. Acked-by: Huang Rui 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 3836d62b54ef..960fead0b83e 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, check _CPC in ACPI tables\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, check _CPC in ACPI tables\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } From patchwork Tue Apr 23 07:58: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: 13639530 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.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 84A4854BFE; Tue, 23 Apr 2024 07:59:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859152; cv=fail; b=J9ZR5gaAw439E7e2FruL+YXj615cgm1vPUEytmQR4ay8AGy2M14fFyLYeiDDwg6a5GOeLS6bao5OWzUGQ35pXI1Ufo3iC/4JQ0Hk510EJHO9DZXV89+6uw20XqzCmYofRauaSkOZxd94Gb+bD+4JZc1BVp06GxFX51auyQggndA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859152; c=relaxed/simple; bh=ckwcOBVNDuF40QHvqaELwzXzB6I9pFsprYsdpq4lBWI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l3zv44bcsucsCmEEa4OVvQJsKvpdkRbi/qSYYeJi44z6Vx7FWQBlKNkjFxWbn27qezKCJeQcz6/CHKEYcBznhxSi0PwnDfuzGR1Cx+W/yic3AO/+3TOohGfDyM0AYpmkCf49aY3aIlzeKma2HBULqEn98fZtqwn2a2pkOFL1prQ= 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=Zi7E/0Z+; arc=fail smtp.client-ip=40.107.237.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="Zi7E/0Z+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QrQuXYi4hw+C7o8UdutHPI5jAf1ublzUgkm0tAWm9714oKjZO0Hp5GDRf2L7AGmMuNku5eqLibVLue260K9VyeTAoYq3VvASgPK+MCeLF73vex6qID45O6oi1w3I38eMdQAecmIaXTDWGs4sO1dyIPKdzRjaUYIGLwOlzzo7tdmLZntjbuXw9/pNtnx8kukPvm5A1pU2tkLBi5PusLiuWRU87Rp58FDiJRlWDYqDsRQXxz/jQwo6qdIo754nLLvtYxByv14r/uZcTLiQxI/88XudVx0jiUZ45T9rnNe2JD5h3wM2z+/rUc2L2O/xtr+o8PcZcNx1kKyuwMhjBjvGrQ== 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=m7Nnj+wrL8I671SDCrz9Xga9ZXP4NJdoC+h1QNGeU94=; b=nYKqyKz5s2ilW37RNMKtZIDdertcVP+CscU/TeG4FJ5PZUYoJPFHAy4XnrBRC1RIZz3Vi2xr3ASwGEM1G8zRXx2ca/4F3CIUEaNh/UaiDqeYbk0/qKPolocyBsaCqhecPFK4XMakmkJrXL58dSVVZuKx1qiED38FXdUvhJr8SbwgfofLT9UGDohyzX1rFaUCFotGLrIbIadCbwi9QuScMa/N9aLcRdVou2J0fQZPaJG5/AShplD8BFxVq3+0XGJJ11SR5Vfv0FEqeUob0K6lHOYJj638luftxKv57Fbnt2W55lzq9rgGskRNHXpV5ENbE+WyF54Dyr3cVyyUQKHynw== 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=m7Nnj+wrL8I671SDCrz9Xga9ZXP4NJdoC+h1QNGeU94=; b=Zi7E/0Z+MtFMCr6T+UmhTxvjWpTj6ROURFIWzHu/zz+Rv4grE54n4Payi1QJE4lHxy/j4i4eKaeUGAw9uOgsYVd6R7PC05xP51mkvbMam+KE7Mcruo9cgOQgSZsNnmUb7yAn0D7w5bvj+rOWR4o7B6Dnl7iIa6BXydnkFkBHnyU= Received: from CH2PR03CA0026.namprd03.prod.outlook.com (2603:10b6:610:59::36) by IA0PR12MB8695.namprd12.prod.outlook.com (2603:10b6:208:485::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:59:06 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::5c) by CH2PR03CA0026.outlook.office365.com (2603:10b6:610:59::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.35 via Frontend Transport; Tue, 23 Apr 2024 07:59:06 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:59:05 +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; Tue, 23 Apr 2024 02:58:59 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 6/8] cpufreq: amd-pstate: get transition delay and latency value from ACPI tables Date: Tue, 23 Apr 2024 15:58:22 +0800 Message-ID: <81aafa46533637984cc9c80f90faf5498a7308c9.1713858800.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: CH2PEPF0000013E:EE_|IA0PR12MB8695:EE_ X-MS-Office365-Filtering-Correlation-Id: 39172584-af73-49d4-6adf-08dc636b3fa8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gPrEsdNZkaMZPQOBAcNXOcd23dfEOg0IQXNyHPV28+isDh95eTQsWC3ukCOiBZQzQmtmyaC8SkLZySeQJZ6c5zXeE3Vw84zypv8UzKPwxkbr9xVecD08hOSq9bAamQYJjigPwSok39jQdj5mhsIQjNmwumH4jOWTgQaoN6CKvBJlJVmfcLKBf0a8yReee13evptusfkUSjb+YG8dVP9O1jXF2P0Zmqqn5vbwk55WQULoZMBeLuIMBfUngVQfxwADq3hsvhCWLZH4JFox76Ib1TgRqBM024BZVSTooZtYDCVraWjzpgOhEwhEbx14fwWteLkqDfNJtYbAZP/SXXlj3PV9EIMp/mZR1oa4V4XATJJ+AnIrqHLl7uKmR7625sU80SIGNnkhLTC63eozlauk+10a/0XeWbAURYvML+s5TrawFBc/FUEfC01G9JdxQlktUhgpX5Fc/ui4/e0RoES7O9P19NOR3jFuFj5mcxCslKuu54t0b6N8lmV+4fJE/at7j6iw48iMPC1AmqVzq3ZZCiuF9MFCy8AP2Mg5W6GRjU/We+mR9LfyZWDeCgPvyaOSiNuUW3nIj/ZyvpBiAxaQD1jqF+OQf4WMX832Ic41vV+r7pPwctfYXmxgAHo937050Cmvt/ChwJ4xwtDdY8FAeG+EnrCuLl50XdaLYXNhQTJxMiB0hoNFWL8ZnJ0SxF/YHTPWIEBzvuNyACJwx41TFmG1z0Sh2H6gxog4vy8aWCUOTyWL9zOCCAXE9fnUc2Du1IOaUPWMXrzu0979ZNpu+2qr3RbEYQvLpwlaWD2ctPrKSlvFxohlKsORW9bQ4L9L/FChiLGbqi1TVQduem9Hvu75pabNbLFrn1RmvphDealQiVVf6ad5ApLzcggZ7QUNqW+HTtanEBYBQx45zULhkTnTMEDfcpEUfs9GoT+GkEpPJTUbWYWCczinSMertu+/rXI/mNo4NHV4vLzT4Y+G8IgwD+bM7Q51gfppE41cm7aMjqLQwrxzxFi5oJKKtRm+GFBb4mxlJb/xUklNQbN2IPtrT+X0a8/EwnNPEGIq6Ajv7i2n13kO5vgPoZkSUtDr3Eux+oW42FtZNGV+lsenkL2z6uUaqFi7303QURyB2soYxY0Q2KsPvEIgEkGcggXuzs5sOmp0gg9XGPcz4vSAr7cwgV/WEi7hVtKf5o0G4v0MQDrhypKtfwb0Pg/8+T2Dnfj+Hk1SNVqB8Vi+KS9Py5n7725rPDmOIKSdSZEufktUGZjRvg/YcrWPAqr2tk85wZEJRN1Fnc1qYP6vhtQeznQWODiJ2I8x5DivP1swory0mmT8ro4tZW5m31MYB7SvD5Gi7EARKNh/KSZnbpoxtTWuhGOQrLl4M7CGojBvpF0= 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: 23 Apr 2024 07:59:05.9795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39172584-af73-49d4-6adf-08dc636b3fa8 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8695 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 960fead0b83e..510b5aec42ea 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 Tue Apr 23 07:58: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: 13639531 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) (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 2C09458ACD; Tue, 23 Apr 2024 07:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859157; cv=fail; b=I3uh9utT2xJFh42kmJq4d+oC6xrUmqyRifUFzx2NMIEmXYkCE4Yg0zRd49apVuEQgZk1b2Dyh7bdh2MDqcUiwREKKyWRMRv3ZmS9MIH3hfliWb7gh3wPBW2GI1SbLY5b8J3hktr+xA44RRydzK6wZrPZaSCwak/4VJnDEeCMw0g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859157; c=relaxed/simple; bh=yMZuIbGw42YjORpyBThUbZaZYwLpoIiSd88evb9PS1g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jn1B5gG9fQZUstXTQTiPQT7XM15scqcT3nSQAjU00SVytUQiCFfSomRtHl4g1bAHHrlOru73km7QcBoazEoz+soPsfZI8fSEYFE6kOg/EVxwa003ThDO54udIXwO54doB2n9vlp9LTPbgtBiwZHS3qF0Ku2RIHXCDhDu5Xae2Bg= 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=NA39QfMN; arc=fail smtp.client-ip=40.107.94.74 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="NA39QfMN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TfX+mZayTMfE3E6JfS0ZdZrpONZ+6sA61/9eYc6QD3/dLecXX+Yw07FRQEB2GYnZ+YBr2Pz4aUvSbPuGypVYil6gv2uE3dUZvMBqwdN0q+Ny19Dntq0qXiIuz3Pc4nAkyearJB7VxFCDvwiPm7YLBPk6uz6cz9Xn+5akOAZL/5qlvh+ryKzMhK6FwACvPp2DmoZY7BlU/UExIf7iabXTIdslUD9gOC6XKWj6/ANlV7iWoRpMpuc/NEZlBYTSXh0wyenac+/5M7CAb5OZ4nUraejZw055gJQpyPYanuFGi7EMz0THnv7eL2ihkpH5Ooghhk5nHYCABVc+XMkpbzooEQ== 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=NnIfoUNNUSgZSFxKZmxAZtt+uHq/r8v5ejdRJ9wrWCM=; b=I2dtd/zifhgihCJD+z1w4xpVZ7L3CSY9qgsnlh2tX1QcH1YVRFvVohmkyqzHivDT+mHT/Ylde5nyauG8VMADTgnPaPcd83Qt1gkVEtvuIcmaQbxrjAsGBpnHXL6Dy9M0KEmsxWys7wb7c8Zx1XnvK9IezKgaL4ZKK9NyATMw/24MiO280clR5HZBzed6EnBl6CJg3S8jfe/29HKb0SgQD59YdxEqb8oPVe6LlgCqYprG9O9ci410KgfB/eAd6i/IhO7w4ZKPmJUZ2qs6ATohU62PtXhcw1DfYflhUMqmOJan+NnQ06TQJdh7aZTLVyp11rBGjCYE/oHXTbTX++NrdQ== 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=NnIfoUNNUSgZSFxKZmxAZtt+uHq/r8v5ejdRJ9wrWCM=; b=NA39QfMN+GocqaSkmXI/1KB+eSn9peizNQo7Nz+XhM2yi5+ypdnlxd/UOSv8jN5wn+J3g2Bl07dFTak82BzorAKcXIV3ePrL4lZGPkL8BKvgaY3tDSQT5S9Lb2kUV8wSWBRwK3lICxhXM63wOhur6JQDJAsCCzx3ZTtklXHUIu0= Received: from CH2PR03CA0030.namprd03.prod.outlook.com (2603:10b6:610:59::40) by DS7PR12MB6048.namprd12.prod.outlook.com (2603:10b6:8:9f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:59:08 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::fa) by CH2PR03CA0030.outlook.office365.com (2603:10b6:610:59::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.35 via Frontend Transport; Tue, 23 Apr 2024 07:59:08 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:59:08 +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; Tue, 23 Apr 2024 02:59:02 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 7/8] cppc_acpi: print error message if CPPC is unsupported Date: Tue, 23 Apr 2024 15:58:23 +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: CH2PEPF0000013E:EE_|DS7PR12MB6048:EE_ X-MS-Office365-Filtering-Correlation-Id: bc5a5811-8ef5-4c8c-702e-08dc636b40f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbWHOWmlE4IjcVSRGR/3mb67RedpqyPvFGn2Xc5vwNX9qK6qy1QJxexMD7BlcW64+//VcsGSx3BK15Q65lAUy5YIt4MzAONC7UFWe37AwXy/T6Ube5b+ij4JImyK8l+/rgiTk66kxo+6s5t/TR8KuyZwxfvOZp04/DIlOcV3Hu1pbXARCWTAOSs/0R0qvm5xKjBsKwWZxEic972+c+3p6ciVYE1yx4rFm4WuP/mDbg87C0hhCQAouYLxaPtOOWdlHdq5Mr9iRVICAF8NnopY52jKUB27H70arXwU0dh0b7guyjkiAS4m3eGiiZApzyKN73DGWb4vN6kqZJNh+3lQlgiKLTZy58fwqlHx3WeXfLAViOzgzZew/I8ePolNfLr7C3tzn1PcO4xbLcx7DvacWeBlir+GLDvTpTYTfRzTZghQ9wtCku6cmN1sSwQdBSImS5Vg0JTLAoGPlE7EP63Su69vbWmhe15Swl4w5bTpjXi9L3Rr6VmCBtamzTl5+011A6ddKAo2w5s9UD/XvrA2Dj7z1uC+wrEk02pjGlbajj5e5Ai+n/EcktX+LgpKuyrwgc4wiYSXzqztkyHxYfiFpk2CBsz67dTgJdC0AzuCSQXiKu/OS7jbrvrx5IrWDkOUklzAtHsi6KspLLJtSevY8GEQCVUN5BcWVzN/OqxEJJ0kQZfXAcLlpCGdn5LFDDy6zmydSWMmFnubjtDgo1Rj9EkkRFq8bmxjgpM/aDTIQFu6pJeSvB69JmrMblLvL5x/BbALpZWxcZdCjVPG7BkbUfssg29xLJVmxo3K9NlIfTooHTDAOMqu6UCkhi1MiM1YXNWLDpWwxNF6Bd+RS+wltQC7sM6JMHFGjjtdwmJ5CGrgVKCrcEWsxe+DDURFuGMkZDHPT6Lyh19wMLXGbNNQRPZ/lK4bItxP02frCtPzpsu+rMxG77OTz/hG7rirgFIutUidCptGwFv3lDDCaqvr7yLFtvu7JNdk2k2N7rGOUY2Xo8vz4hHO2fzWuRtFISz3qB2+o5MsZL5QyEVRQ38sJo71zev1lIQH3yzMGfglPpqLy97Gjy5Sjw6l8j+DdpI/JZG4MTKn6XipuBuWAAxn8AIpsrrC6MfsvOx2sKNtMMbYmjb3Udm1W1N0gDoZbTj0LqTlKPh3dxZmG9olAThYfqYApUMCiTME7bL9fu4esPZOKKzFmzXgHjI/QlIYbrNg3WjO7LXWYY/1tQh/Fqj6dP/Iy0uJylynBYYANNa3AgGi2Ml8PAoFIyN+jxbMy4sbqaFPAAjB+AEjmfesxeH7Wwi07WM5Tg96jzzApfS7w1iRbZHd1WUaRHst3kSgxFUtGuzhjyHeTXEhbczcQ4gmUoUwokF4Wy3ml+7O+unhj6cXpRF2ZS+xXYgcXKX5vS57 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)(1800799015)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:59:08.1358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc5a5811-8ef5-4c8c-702e-08dc636b40f1 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6048 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 Tue Apr 23 07:58: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: 13639532 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2070.outbound.protection.outlook.com [40.107.220.70]) (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 AD0EF59147; Tue, 23 Apr 2024 07:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859159; cv=fail; b=BTxjzltA6GuzVhbQXpbvWmwv84JJaMnDKJQPQd9ZFy4d+9LK0lPR+7V/kRrALFUarRIYm50DXh2B4OF1AtxoJgqtIFoJ5I3UQTO8Lx5AuSDK8Gg+Bg0tIc4bzdh8svpY3xn1fDil9Z0MvnZXbGsl6zDhjAi7ubvmLiWktLgb9rg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859159; c=relaxed/simple; bh=S4gsus1AXJRFAgD2JZ2zQyEthUpzhSrTBjm9MkN9kWc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fzP9nDbl6vRQyrmekxFK6cB82//GYXV2Y1er5kYw4/w7MjlRBSoa9jWzt0r2mgn5bN3QXxdHbarsfqAqPVF4dI0SmNXLV+zh699K1r7ln2gYgwDQ8Y39qRTIGiwKnV2JuiUiZEJExPAc1NoBqnjfV1E4ZVSQuWAcfb+++mEiYnI= 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=fkycmskF; arc=fail smtp.client-ip=40.107.220.70 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="fkycmskF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hwxPEGzhZgrWhUYZzMh9x/ZDkCqCoONbl2GGJxEGwvnNqEDO8XUDI72SbXKc16PJ/KOu1+QbAMtcqnxN2drYHojTArAyrgYZVxvtSaALhMkFZNblTxQBk3sxUiSBm5oguts4ftca+Azvx1GSTmZsSI9RgVic3xweTQ/3nwYaYsHw2M8xOWvyjZ5bS4q190Mr/20Pi0hUP46/HZ/a0CYjrrewCcoRBWBeTuW1mmMBqEvohhTqChberoehQkjCfqPpRSmg1IZO9HmxHHuvG+2qHEhNUfjMJTpwKThqQoTEEMBXRB2Tx82RQqTeukPxcHIMW2BLkuzfJNhTtD4Qu2iHlA== 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=X4t0t0fJjgDfNpBvcy1Ndw/c94RTZuz0xnRm36uFwBM=; b=fVTFegscXm6JftW4kMstMVICkI8MHF9vyJqWtoDC3r/tldCmjivr7rNoNRRGVPCkAYzbD7dBsjYCnqGxXZTStEgzTrChgdFc4nGppUCgc3ExetOms8Jkm7D66SzKL//f/kMlt5YbW7J5v/R4HdAvmT4cXVP0Fc1Izlp5RlwBrvJgpKSFfTB2F7ii2RzabRfzzW9ZmCAHmQNtpWEs9x7R7r3oO7874kD4DtUq/pUOuJnzp4vxvjvkqnwMBI5IutXnPc/6m6m+35AhQqK03fdtMYWt+z7VWBYFsIvXtcIxhb/Z++tqRj4M1pzWIb8W7urNup/yW9pkkkKfwILNz8qSmg== 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=X4t0t0fJjgDfNpBvcy1Ndw/c94RTZuz0xnRm36uFwBM=; b=fkycmskFdsSwwn3zBcYtX3By7F8cGxACJRAI8MQlg/q4YGxvp+ydqPEWt/ZS2MGRtSohDIplN7tKWYzrsnhR1mz/XB5e9NyWVBo9OiKw0L/QWcM4x1N1pokceZCNqMlkWBcprAPyiyIDYn2gegNqKHyV/30fJZv7fzac7xh8wc8= Received: from CH2PR03CA0028.namprd03.prod.outlook.com (2603:10b6:610:59::38) by MN2PR12MB4062.namprd12.prod.outlook.com (2603:10b6:208:1d0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Tue, 23 Apr 2024 07:59:12 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::55) by CH2PR03CA0028.outlook.office365.com (2603:10b6:610:59::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.35 via Frontend Transport; Tue, 23 Apr 2024 07:59: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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:59:12 +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; Tue, 23 Apr 2024 02:59:06 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 8/8] cpufreq: amd-pstate: Add quirk for the pstate CPPC capabilities missing Date: Tue, 23 Apr 2024 15:58:24 +0800 Message-ID: <381226526d045eb70a0d7fddbaff06a5e0592bb0.1713858800.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: CH2PEPF0000013E:EE_|MN2PR12MB4062:EE_ X-MS-Office365-Filtering-Correlation-Id: ae941862-a31a-495f-7a38-08dc636b43a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|82310400014|376005; X-Microsoft-Antispam-Message-Info: 3q5XP9ZHq1aSyMojBFWz7WLVqc6UblNf7EqOZPLMP/P1pmxo8auxUDOIQ9SsMwibrm7v9lrXPZpUtl+ZtwwrSJCmu6jeGzFijBgDu6O1rpwSoP25Ir3RzmcwA3cbgrA6F2+hGse2t7fM1cJKx+ZW8A9BQJpCciAlTFSF3r0TRZWoir/tRyO5mxsVc9+XN5n8eUwnb0QB9IyHCR8urv/kb1vXGQb4GcabAPCpYMf09UeqU6CP78zoQ2rr33f0eRuTUpJ9zHe3V82uCXWanXmT+0rsg+xX7JQE0IhKbHQKuV0FmVvnhEQbMvmdZM43ArPAeDWV/4JAOlcePLURMujYkRDRRW9iz6uW1MPjjBG5T3G5yuJv+1ARjjvlkULfWNtfNr2oqIyGC2upwb/tawVH6DfyqG6BEhNER7XWQhTmxbmhX2Qqgv0EabPc9S9brqieJbHabm4rux74g5/ZEkPUJZE/K0Bc2dM3mp8IWag1sfwLDTb2ohg4WY+Agjm8hnlmE0N7jtmoDznokspNiF7NxU00Y12re4uoGSka+Ftlv2sNIlu6DG865SwyUQkfda146ZfhUnGc484dc4LR+clrqQTA/UFNW12coq1RHm1ZjYG+PsukaUMp1ineDxFo6F7z0NWEsMAu81uvAHvNBnIuBrCpkiAQyTbh0yhtUXCNsz0PKPOYnLeQB4gR5MegMIrH1HB5e7ALJFEWKIF5FPReCnYtdkRvrYF34HEeNeT/DQpOJmuoNBWqD+BoXutxlc+0acH+i9IEHYWYrYV40d+6LRYL5hKatuHnLRAepXkY7S5n8h2OfT71qZzntTHZvWoDq8ZcAMLUBaSOaArrmZLzXU3BSI7glTQigRoIaBNmn0RDIJdDCGTZThKkkL3hYqiBXvNBUYAu6c/l/wvU55feJxr0QREQ7Tx0ShJ6gHL6WNU1wUIgH8oDV10SRU+4Sl8EyJzpJrsZhLMCqdNOARjd2OY528BU04uB7b8dT9gou1dSFN1Iy1mzm2BSDcQUHqKRg4E2Pz1Ue4H6jdfL9W9qcfgHoZVjav4LGxXuadC3sVY9lSbBYQQfvQsqtfx1FWWDHHDLqgVQmB7LH5VzWzbOdcy7IXyhXoU1OVdiThI/ANbjLULBfJKH2uVMtrrgZSQaZ+i0rAs2cybMkvqObgqSfVvdyRxXgM/67cVXyrECdGKjUKKtqnnSlggRWUuuie/+90yRfIkDmabPz0h/qLwM030Bzmg0DYo3LUceNinacRYJSWqvAh8rcJvz54TZc3FAa3eY7dHl+semdMnv4HWddH+w3+d/4LpMa0vRAGlqvNDZnfz70ihNisg7SRAfB9KHmYs3ZiDvKiTkVZl5gIIW7nFuz2kbSVyQ3UIxn6Yh7QwcZh+6oRuSEcV/N4JDNnts 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)(1800799015)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:59:12.6514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae941862-a31a-495f-7a38-08dc636b43a2 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4062 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 Acked-by: Huang Rui 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 510b5aec42ea..83a29b257794 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; + 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 ; + else + nominal_freq = cppc_perf.nominal_freq; + 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 */