Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2782756lqt; Tue, 23 Apr 2024 01:02:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdbX+YPoAwRlETXLXIWQV+DdEpyAOCu5njLGznPBhB7GkyL709vb4pHuShFYPp24FeD2yeV3fADL35O9weU/SWdZm1RZWevICK3n8C4w== X-Google-Smtp-Source: AGHT+IFSp49uDZ217AQKIGwqV3+zGQuAwRmrF4+YMcI6iHsFIUEjVq7DXHlTYTX/dv8sB0IXD+1w X-Received: by 2002:a50:d542:0:b0:568:cdd8:cf60 with SMTP id f2-20020a50d542000000b00568cdd8cf60mr12223598edj.8.1713859356566; Tue, 23 Apr 2024 01:02:36 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cb1-20020a0564020b6100b0057047412cc3si6725662edb.658.2024.04.23.01.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:02:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Zi7E/0Z+"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-154647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4BCB21F244ED for ; Tue, 23 Apr 2024 08:02:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2473D5822A; Tue, 23 Apr 2024 07:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Zi7E/0Z+" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: =?us-ascii?Q?gPrEsdNZkaMZPQOBAcNXOcd23dfEOg0IQXNyHPV28+isDh95eTQsWC3ukCOi?= =?us-ascii?Q?BZQzQmtmyaC8SkLZySeQJZ6c5zXeE3Vw84zypv8UzKPwxkbr9xVecD08hOSq?= =?us-ascii?Q?9bAamQYJjigPwSok39jQdj5mhsIQjNmwumH4jOWTgQaoN6CKvB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X0a8/EwnNPEGIq6Ajv7i2n13kO5vgP?= =?us-ascii?Q?oZkSUtDr3Eux+oW42FtZNGV+lsenkL2z6uUaqFi7303QURyB2soYxY0Q2KsP?= =?us-ascii?Q?vEIgEkGcggXuzs5sOmp0gg9XGPcz4vSAr7cwgV/WEi7hVtKf5o0G4v0MQDrh?= =?us-ascii?Q?ypKtfwb0Pg/8+T2Dnfj+Hk1SNVqB8Vi+KS9Py5n7725rPDmOIKSdSZEufktU?= =?us-ascii?Q?GZjRvg/YcrWPAqr2tk85wZEJRN1Fnc1qYP6vhtQeznQWODiJ2I8x5DivP1sw?= =?us-ascii?Q?ory0mmT8ro4tZW5m31MYB7SvD5Gi7EARKNh/KSZnbpoxtTWuhGOQrLl4M7CG?= =?us-ascii?Q?ojBvpF0=3D?= 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; -- 2.34.1