From patchwork Fri Oct 25 17:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 838631 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2065.outbound.protection.outlook.com [40.107.92.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 77F7F20D4E1; Fri, 25 Oct 2024 17:15:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876535; cv=fail; b=MOlg46M2LkjxBRmCbmS5Lp6pEYxb25XI7SdNKWFz/vJyiZ2XUDfMpRV4ids3y0sa6fbd1XykKyY7HiKU1CsQDJTUY7ut07Y86FfdlQ5dkoZLb0bsWKrspCi5vUIWWs+Q1QcyR1WxRod6An1bYuJfMacdRvtSePG4U2vVmQxpKsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876535; c=relaxed/simple; bh=REB58hOKyh7fDFvVeANX71MO9NXKoJuFtGfohz8Voug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YnqWtahZnvNHs+2hbmuuXAI4XvyGR2mCKB48wXFgXAgcVnObL2V8cZ/aT5H5/z5i60XljvFXGG8+hTy0QqLALm2A4RXmXDelghiLVAlQOy/vJIx6MuFTYKi2qTjKq5Bg3AF2r8Mj7bAMKMbIT2a7IlDuurvCF3gnJcXhZuFR+mI= 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=IsEgB728; arc=fail smtp.client-ip=40.107.92.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="IsEgB728" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vn4K28E1OIXuXalmA66AFf9eCvLc5hxbp48CEf3UyMW570W8Y/7fUfrqHwFOaPRWcCCq4TdhwpgkMIoZMV5/Y9HKMK+z2AATLSKSwTQWkyQldaLPWWzeBpvrXMq7Mzqwx0vM87TW1XtrogoqhA5oRvityhus/2/CWBCwQW5ZjXoHhgU7PTvnZ2Er3sA127Pk+cSW0Ocf1qek+Lw5fKlHhpv+g6hge0sAdIBV9yD53LK8svoxlhg4jbl1Rf8OUr557zuy6NWXoLNWGsXl87H74E1fsKB9fX55ek3m7drN7zS9fNyzpVpxgsz2RYswIFTzhSTwVbn1VZ7L1dv2OGrgXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/52ZQsp8XV9x/pV4X0hD1rqA9RC0NtMeG4YHn071exQ=; b=eh3SiXwH+HFjTYuNOCtm9SS08KEcym4RMfQ6Qy/mt4k5zt2iKrSbAMLXgVh4kRb7BKOLmUcLuC3V3lOYx8k6yXRYSXJNss5G+ubjBNq2OOOs9i4NeKfAII4JUKn9dyS4a8aorixrUADPyoXJLeKEp3kqrqVUvtT16TewZ5PzF02HnmFFtbqO4QPoBtX1sEZQ4ziA6+E5xSqJgLLsgYUes4QY+rWH1V7RfQ1fhkyEyrNwEUM12F7QIMlepkm3Vv4XTqsQW/ZdJqDOg3gdsvCN9PK6aMkgThiiERblsBzW9iQ0L83OGOrzev3NeplunRItMIT7hcDdzEBCN/2sn51yYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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=/52ZQsp8XV9x/pV4X0hD1rqA9RC0NtMeG4YHn071exQ=; b=IsEgB728JW/CXCLexEFFT+tcZyVTJqzpe9yEWDEt2pUkI/Vm6Dv69qD1EhQ8FKRneC0I4V9+iRxvUjJWnjG0KjDZz3HN27Lor+L9LaEN44lPhUB5ZlK5LpsCAHRr3RvaQs1HuGq6z9qocC7eEts6zGr6NfCr4iv6QgLRaN1S3t0= Received: from BN8PR04CA0059.namprd04.prod.outlook.com (2603:10b6:408:d4::33) by BY5PR12MB4274.namprd12.prod.outlook.com (2603:10b6:a03:206::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.22; Fri, 25 Oct 2024 17:15:29 +0000 Received: from BL02EPF0001A107.namprd05.prod.outlook.com (2603:10b6:408:d4:cafe::99) by BN8PR04CA0059.outlook.office365.com (2603:10b6:408:d4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Fri, 25 Oct 2024 17:15:29 +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 BL02EPF0001A107.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:15:29 +0000 Received: from AUS-P9-MLIMONCI.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 12:15:27 -0500 From: Mario Limonciello To: Borislav Petkov CC: Thomas Gleixner , Ingo Molnar , "Dave Hansen" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H . Peter Anvin" , "Rafael J . Wysocki" , "Gautham R . Shenoy" , Mario Limonciello , Perry Yuan , Brijesh Singh , Peter Zijlstra , Li RongQing , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:ACPI" , "open list:AMD PSTATE DRIVER" , Pawan Gupta Subject: [PATCH v4 1/5] x86/cpufeatures: Rename X86_FEATURE_FAST_CPPC to have AMD prefix Date: Fri, 25 Oct 2024 12:14:55 -0500 Message-ID: <20241025171459.1093-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025171459.1093-1-mario.limonciello@amd.com> References: <20241025171459.1093-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A107:EE_|BY5PR12MB4274:EE_ X-MS-Office365-Filtering-Correlation-Id: 60108424-24b2-49a4-1160-08dcf518a019 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: xkAKak146xPTLQYYdN8+eJ89NCJy+43aiafisIEpjQV94GxV6scuWRfwMDK8eL3HlVUNlChUknjQF21pVgcP4MTQb3hnGjGAaUGGPkZfJQOG1zoTzbZ1UNoye73OkdZ8VSHKS/8FbimU1hke8qQPt14SkV7qBUx6sh+VqHYcl8GYO7o2CZwuQB7Vz3uQJ4KvLUpF2fUmxCHi2xBEQHeG2AqQpsaR4YgoRras9JD/w+OC/v0yFF65mpce7l1yxNUEIULObA0d9oDPwGRjk5COgbxkoLbg4P+8afK95u/yJLeZjLdl6ticpyo4rAXvDjkI+ccK91G4H9pQ4aEi96bnzxyHBiVONRkS7Z6RpUXvh7VKqxOm4U6k/pbCyDaQ7WdvhkLEkq0QoLFuQc89oOlIjAaaTocG278LiQatot29s3cs9wuDdLb82aRBe0RvMrIALnQeHYyxUqQEDNS1U7Qd1fqgWJYG49fidZRZFy0hTdlaSi84/C2Ms/XxF84FnUC89HPXU2Qf/dYG8iAhZ3MKeqJWc0YrtQo8g3wn1XtVR4psAmD0313i0If9Ysj4VF+7E5QRQ4cmHckN+cbQp621dKe8EVRikQZBFRC6Qrdz366Kx+AVjVsa6VYAqamfEbticDdyhlODz04gNmtHGBH0eT6FipVSzKKTsMN5uGCulTc5tJCtmsGrvNf0WwWu8pY5xZHVEqSTS9Mj9tSw6Rw1gN+u6TfkpZd+E6MFG/PdtVi5hoYZ8qdV3HdJgNgcNDa89KopD6FCuotkJNaLVVcAobZzmAe7Yn35NbkuOHA8vbDP1R3QQ7A8IKkEECDQAOZ484chMIVtxtrI/6uLlyr6hRZ6eeeHiCPh46ZTmYYka5jk3zJp0gCxgkloEUvOx0L3ZX5S5YC1vdYFZ4DDJwe/Zt0UoASYSTsWNIMb+GW2h/86VmlE6PPbVuDUPHH1gvKsS0e5hG9AS1QM+foGAkRlcOuZyxKgvP6NtIufuGm08vMslLjccLGVsibVNuRh2nuDzXuX/J7JdBagLF6wuuIhfzq5qUb/bW5TUTMvwuDKmW1dafgUAO9yVSIO9TqV+dhji8QCPjPk+jd8l8fS7egwSzAbtcBo9P5t0v56cWbRYLD4xdVlcm/S2sDzUMrCIJw6+Ofunc/K84hNX1Qoh0CdE/ViEpcpBslYgFcZ4nbUv+NFEr0HMZY7nPxntsfvupGybpyVDZiQQ9frVdeK1IXKvKoLgUGBO/NJMVicuJk+uVUkDOXlWvxYzGYIvATWQCsAJvc1fAxpXfvIV0BUSt0M9dw3BjUiM3yXwVkcmggI07VMwfh4EzsYnECpMXlY/u6SfBKCFol+qe29E1ddMXnp2gzRoE10Ac3E6z+yEWQkC2zbELtc1rRGHcotakpniNaU021k9FWcFxo190PZZ0jObw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(7416014)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:15:29.3160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60108424-24b2-49a4-1160-08dcf518a019 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: BL02EPF0001A107.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4274 This feature is an AMD unique feature of some processors, so put AMD into the name. Signed-off-by: Mario Limonciello --- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/kernel/cpu/scattered.c | 2 +- drivers/cpufreq/amd-pstate.c | 2 +- tools/arch/x86/include/asm/cpufeatures.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 913fd3a7bac65..aa63437a677c0 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -473,7 +473,7 @@ #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */ #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ -#define X86_FEATURE_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ +#define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index c84c30188fdf2..1db2bb81a3847 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -45,7 +45,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 }, { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, - { X86_FEATURE_FAST_CPPC, CPUID_EDX, 15, 0x80000007, 0 }, + { X86_FEATURE_AMD_FAST_CPPC, CPUID_EDX, 15, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b63863f77c677..717b4cf4d9c4c 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -847,7 +847,7 @@ static u32 amd_pstate_get_transition_delay_us(unsigned int cpu) transition_delay_ns = cppc_get_transition_latency(cpu); if (transition_delay_ns == CPUFREQ_ETERNAL) { - if (cpu_feature_enabled(X86_FEATURE_FAST_CPPC)) + if (cpu_feature_enabled(X86_FEATURE_AMD_FAST_CPPC)) return AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY; else return AMD_PSTATE_TRANSITION_DELAY; diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index dd4682857c120..23698d0f4bb47 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h @@ -472,7 +472,7 @@ #define X86_FEATURE_BHI_CTRL (21*32+ 2) /* BHI_DIS_S HW control available */ #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enabled */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch history at vmexit using SW loop */ -#define X86_FEATURE_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ +#define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ /* * BUG word(s) From patchwork Fri Oct 25 17:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 838629 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) (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 8DD1720D519; Fri, 25 Oct 2024 17:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876547; cv=fail; b=VRtXw/AN4XFoWscZmNORxin06dtmt/aghDPpSRHVczXpHzolhBUemm5neByID2WzM2VNqpnjgJA7pGd8Cnbfue3/MdX/cCDRmhi6XQuuIEQZYEJoLqcwYaQweLwy+e6/r5vp4HVgh/7MTzdTdlGCtmuZ7dx8UjsHi5lwZwNhrHg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876547; c=relaxed/simple; bh=xLXhOXFwiZdODODdFucl+qVR53ccCY0OTthGpRJkTeo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aDhs8jglAzy1WnyheFrjtdEUz85msH7jkDJSWF7piq7oQOVq41Y1OZCIxuVLxPAF8ZLihUj4YYG93SC+py829nyE6frczw3fNh/b6bqytzmKKDWVbz+NYKr3BMKCihoPSjkQXX3BDYXey7SXSVTVSEmESLsR0AwQ+Mt9mnV0/BQ= 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=PCHJVmzb; arc=fail smtp.client-ip=40.107.93.71 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="PCHJVmzb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IhHqhPf1M0OHNvMT75fULJZG7QT6MjPv43infl9Iu7AHwHN5zrYqM2jgCcnUa/mHiQAeodm5PSeNLMmLUe5tmBs/A3FWnzHT+F9qK81vAodr7PWx5hCx9OI7K5tXJUy2cat2lYb+dmdnnSpCjjrMiiBBexmogQv1TFp+Wmo+obBV8gQR5pDgu07yH6kJthYhj/AhMcRWVXrQH2yG0ovIVGHJEjdnSV0yyOOBw0GvyTUH4LRe/+zRmHNXbDmjESDB4TsVB9y0kHM/+8cRQwljj3PbWvnYDd33s4wI50crx68tGDZcom2nX+kSfdkDg4RiIFrunD537qch9+l2GBuL4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mHRltCZ5SLQ2seKqbyRXFY4YE0LQjCoHDlAIxLK5uP0=; b=U1NFW5bUOkbXEikYbxKfygeSG6wlRmpDKPO+hz8hV+t6O7lfW6+SmE5S5shFfF6dmkrFKUiJN3nceNZ0lqTZriDUJBjn0Zwiam6F6K10JoufqxzRIDk2l96d8vsgYUWxWy86mU/eEXTyhIPeJw987lBh0imDhFDJoSwwI2tb1lA9Oub/FkZmyniDxd5QLRuv076v2QvNbmYniLAfus5s5SmFPARS4r1f6blls/OzvK5rFK5A6JiK3MQD5Zv/9qoxRY3XNpU1NWCSljIDM8w85Agr6eOoCIHZZTqcAMPupdQFDl4rAGTxErF3dqVGjm3wKHFf0xfaalDpPH3qINVFuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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=mHRltCZ5SLQ2seKqbyRXFY4YE0LQjCoHDlAIxLK5uP0=; b=PCHJVmzbAyrdE9y/gnQOw0TuIJckOBeR5JY2eoHxH5Zyx0GAlmSPuFkWMO8bROb4HYbG3l8dBKjA6+IY9kILeEE/a8ZZZgbCEIkozPeO6PLDLuuSNFNJSLJJC1xpbUz/nfYT4VaKz3tMsMp3xWq3Ku2zLUorRwxlBZRUp4mlxV0= Received: from BN8PR03CA0016.namprd03.prod.outlook.com (2603:10b6:408:94::29) by PH0PR12MB7981.namprd12.prod.outlook.com (2603:10b6:510:26c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Fri, 25 Oct 2024 17:15:36 +0000 Received: from BN2PEPF00004FBE.namprd04.prod.outlook.com (2603:10b6:408:94:cafe::7d) by BN8PR03CA0016.outlook.office365.com (2603:10b6:408:94::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.22 via Frontend Transport; Fri, 25 Oct 2024 17:15:36 +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 BN2PEPF00004FBE.mail.protection.outlook.com (10.167.243.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:15:35 +0000 Received: from AUS-P9-MLIMONCI.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 12:15:33 -0500 From: Mario Limonciello To: Borislav Petkov CC: Thomas Gleixner , Ingo Molnar , "Dave Hansen" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H . Peter Anvin" , "Rafael J . Wysocki" , "Gautham R . Shenoy" , Mario Limonciello , Perry Yuan , Brijesh Singh , Peter Zijlstra , Li RongQing , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:ACPI" , "open list:AMD PSTATE DRIVER" , Pawan Gupta Subject: [PATCH v4 4/5] x86/cpu: Add CPU type to struct cpuinfo_topology Date: Fri, 25 Oct 2024 12:14:58 -0500 Message-ID: <20241025171459.1093-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025171459.1093-1-mario.limonciello@amd.com> References: <20241025171459.1093-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBE:EE_|PH0PR12MB7981:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f9d2cd3-ed5c-4fbc-205f-08dcf518a3ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: j1LI5AMMUrSVMvlLi0iYwGX+CPJbTZWJyfqSZXjLlz8M3dFpfxdD0s3bhwt4jzEr+9XSREs+Nf8Yx5tHdCkqeFfKzmetDnJi70os5yn3v+MB17ckarLanDEzRJK+tZTn4wKGCu16ouQilyzgTqsC07tU/jN36hAbGKb+seTgK+TrOzkEN+h+tF3tiEGzpibRssN6SzKCY+EoyAJDP9NZtk9Rx9vqv9BRY1sII6skHV1//SNs6JYbmFUGVhrEJ7MQ0IMWh/sVzlJbf4FKoD0KshCscO+VPdGGKk6TGg/6l+e+bBOTc8+iLfYnXVQImb40t0rYfP+3ZzyJR08PX7i8FkpOF7SeZQkoZUs8BZVAcIYlA8SEBzx0B4GogpkutAnygvJs3UYJxxl3mtzaSt/MrC9g8Q3GJB+nWelRSTLMSuxydRywFPBK9RI2lMxSoy74doW9Ua0PDQaLuEpR2xsve3hBzBKoK6QEgFlhw7/n/tu22Wbvusy6n3r+1yN/RdKljUjwDpMuMKGhWPC1/h8V60kzTx66xb4NC0iDnFYDkqUhMWGXjpkdb6wDPuGfurDnw2l7SLqrmvRAuVIXPvYkTfCvInS74GGbQ3RwqDAZ8dhUpUWE4D1fnf8Pgn0EZ+MJO3bf5d7j9tJ6EAatAR5NWForfT9lLijrWHKrgq3v5GqtnTlHal38wYTzi2IvsbYe4f3Au0IgyuAhANCsI9hjP0tTR2Cc/qJczRlnOQ0UF1AYCRsc6ldv4FevLtkY8/hTUilw9VlluvSdN+iXqL41dextk97rUV3G175cL/+ZgeulZp2BcF33bPMKNY9r8AcQ/ioGcpcXmO3dYTDvCgDjGs46uReGuMW3zvqMkdLa12k1hAvKpxvFE1NQuOO3jkwIS+rtg1wOc8isiYtpqPLgWDkRwW7dTmAoKusaHR6Djlhmfpcag9Z9ZKJNVdBxe0NZsYVJx8lXrQTmoTnOLDAOPEUyQWX7U8XYRoi/Gwfe8aj8STT0qSuTnQY73tPALF+hqwTpi0F6HlgS5c3a+5o+bJOJ4XLG3k2gRUqoa+YSLbGT+xiW1XpMEyn4syx46f+n4VjjbM4/AKk/lscmJLIDOrD3Cigmv6mmGJA0Ldclj0KffAYozKn3fyLtJ8k1/+UDLN5yyUM8lwYtQjkwS5WasGuROSPJ4z5kPDUL1jYR4774Yw9EpPCBNle3BZmjPWifOjyzogpQdAdtLANhIDEEXBc3w/Fmsv3w6YG02JfacnxsTemGxkk5EUkggspUvRZ6S+3st0KiHudLExFT/ap2xp8AojyudpBZNcf7wJTpW5iZ404q5txzD0Bbb9gqTf41OCPAThvE4glFRc/a9whe5epoEY2IlD3fS3UOsvIAN0xzubfCwmd+0PzfSz0m2gPDKMPMGko68BPW3hOXgKAZxw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:15:35.7037 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f9d2cd3-ed5c-4fbc-205f-08dcf518a3ea 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: BN2PEPF00004FBE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7981 From: Pawan Gupta Sometimes it is required to take actions based on if a CPU is a performance or efficiency core. As an example, intel_pstate driver uses the Intel core-type to determine CPU scaling. Also, some CPU vulnerabilities only affect a specific CPU type, like RFDS only affects Intel Atom. Hybrid systems that have variants P+E, P-only(Core) and E-only(Atom), it is not straightforward to identify which variant is affected by a type specific vulnerability. Such processors do have CPUID field that can uniquely identify them. Like, P+E, P-only and E-only enumerates CPUID.1A.CORE_TYPE identification, while P+E additionally enumerates CPUID.7.HYBRID. Based on this information, it is possible for boot CPU to identify if a system has mixed CPU types. Add a new field hw_cpu_type to struct cpuinfo_topology that stores the hardware specific CPU type. This saves the overhead of IPIs to get the CPU type of a different CPU. CPU type is populated early in the boot process, before vulnerabilities are enumerated. Acked-by: Dave Hansen Signed-off-by: Pawan Gupta Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- v3->v4: * Drop generic from function name (Boris) * Pick up tag v2->v3: * Remove a bunch of boilerplate code * Convert to showing string in debugfs * Rename to get_topology_generic_cpu_type/get_topology_cpu_type_name * Add Intel definitions to intel-family.h --- arch/x86/include/asm/intel-family.h | 6 +++++ arch/x86/include/asm/processor.h | 18 ++++++++++++++ arch/x86/include/asm/topology.h | 9 +++++++ arch/x86/kernel/cpu/debugfs.c | 1 + arch/x86/kernel/cpu/topology_amd.c | 3 +++ arch/x86/kernel/cpu/topology_common.c | 34 +++++++++++++++++++++++++++ 6 files changed, 71 insertions(+) diff --git a/arch/x86/include/asm/intel-family.h b/arch/x86/include/asm/intel-family.h index 1a42f829667a3..7367644720484 100644 --- a/arch/x86/include/asm/intel-family.h +++ b/arch/x86/include/asm/intel-family.h @@ -183,4 +183,10 @@ /* Family 19 */ #define INTEL_PANTHERCOVE_X IFM(19, 0x01) /* Diamond Rapids */ +/* CPU core types */ +enum intel_cpu_type { + INTEL_CPU_TYPE_ATOM = 0x20, + INTEL_CPU_TYPE_CORE = 0x40, +}; + #endif /* _ASM_X86_INTEL_FAMILY_H */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 4a686f0e5dbf6..c0975815980c8 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -105,6 +105,24 @@ struct cpuinfo_topology { // Cache level topology IDs u32 llc_id; u32 l2c_id; + + // Hardware defined CPU-type + union { + u32 cpu_type; + struct { + // CPUID.1A.EAX[23-0] + u32 intel_native_model_id :24; + // CPUID.1A.EAX[31-24] + u32 intel_type :8; + }; + struct { + // CPUID 0x80000026.EBX + u32 amd_num_processors :16, + amd_power_eff_ranking :8, + amd_native_model_id :4, + amd_type :4; + }; + }; }; struct cpuinfo_x86 { diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index aef70336d6247..9f9376db64e32 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -114,6 +114,12 @@ enum x86_topology_domains { TOPO_MAX_DOMAIN, }; +enum x86_topology_cpu_type { + TOPO_CPU_TYPE_PERFORMANCE, + TOPO_CPU_TYPE_EFFICIENCY, + TOPO_CPU_TYPE_UNKNOWN, +}; + struct x86_topology_system { unsigned int dom_shifts[TOPO_MAX_DOMAIN]; unsigned int dom_size[TOPO_MAX_DOMAIN]; @@ -149,6 +155,9 @@ extern unsigned int __max_threads_per_core; extern unsigned int __num_threads_per_package; extern unsigned int __num_cores_per_package; +const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c); +enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c); + static inline unsigned int topology_max_packages(void) { return __max_logical_packages; diff --git a/arch/x86/kernel/cpu/debugfs.c b/arch/x86/kernel/cpu/debugfs.c index 3baf3e4358347..10719aba62768 100644 --- a/arch/x86/kernel/cpu/debugfs.c +++ b/arch/x86/kernel/cpu/debugfs.c @@ -22,6 +22,7 @@ static int cpu_debug_show(struct seq_file *m, void *p) seq_printf(m, "die_id: %u\n", c->topo.die_id); seq_printf(m, "cu_id: %u\n", c->topo.cu_id); seq_printf(m, "core_id: %u\n", c->topo.core_id); + seq_printf(m, "cpu_type: %s\n", get_topology_cpu_type_name(c)); seq_printf(m, "logical_pkg_id: %u\n", c->topo.logical_pkg_id); seq_printf(m, "logical_die_id: %u\n", c->topo.logical_die_id); seq_printf(m, "llc_id: %u\n", c->topo.llc_id); diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topology_amd.c index 7d476fa697ca5..03b3c9c3a45e2 100644 --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -182,6 +182,9 @@ static void parse_topology_amd(struct topo_scan *tscan) if (cpu_feature_enabled(X86_FEATURE_TOPOEXT)) has_topoext = cpu_parse_topology_ext(tscan); + if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) + tscan->c->topo.cpu_type = cpuid_ebx(0x80000026); + if (!has_topoext && !parse_8000_0008(tscan)) return; diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c index 9a6069e7133c9..8277c64f88dbf 100644 --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -27,6 +28,36 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom, } } +enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c) +{ + if (c->x86_vendor == X86_VENDOR_INTEL) { + switch (c->topo.intel_type) { + case INTEL_CPU_TYPE_ATOM: return TOPO_CPU_TYPE_EFFICIENCY; + case INTEL_CPU_TYPE_CORE: return TOPO_CPU_TYPE_PERFORMANCE; + } + } + if (c->x86_vendor == X86_VENDOR_AMD) { + switch (c->topo.amd_type) { + case 0: return TOPO_CPU_TYPE_PERFORMANCE; + case 1: return TOPO_CPU_TYPE_EFFICIENCY; + } + } + + return TOPO_CPU_TYPE_UNKNOWN; +} + +const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c) +{ + switch (get_topology_cpu_type(c)) { + case TOPO_CPU_TYPE_PERFORMANCE: + return "performance"; + case TOPO_CPU_TYPE_EFFICIENCY: + return "efficiency"; + default: + return "unknown"; + } +} + static unsigned int __maybe_unused parse_num_cores_legacy(struct cpuinfo_x86 *c) { struct { @@ -87,6 +118,7 @@ static void parse_topology(struct topo_scan *tscan, bool early) .cu_id = 0xff, .llc_id = BAD_APICID, .l2c_id = BAD_APICID, + .cpu_type = TOPO_CPU_TYPE_UNKNOWN, }; struct cpuinfo_x86 *c = tscan->c; struct { @@ -132,6 +164,8 @@ static void parse_topology(struct topo_scan *tscan, bool early) case X86_VENDOR_INTEL: if (!IS_ENABLED(CONFIG_CPU_SUP_INTEL) || !cpu_parse_topology_ext(tscan)) parse_legacy(tscan); + if (c->cpuid_level >= 0x1a) + c->topo.cpu_type = cpuid_eax(0x1a); break; case X86_VENDOR_HYGON: if (IS_ENABLED(CONFIG_CPU_SUP_HYGON)) From patchwork Fri Oct 25 17:14:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 838630 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9D1C21F4B7; Fri, 25 Oct 2024 17:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876545; cv=fail; b=U8g8Kbz2a7wT/uVk+e15hh3uMqJfriTZcu7dqWN/wdAifXd1PJiDnlOUEWsfUTj6Brnq6H9nJcNCjGMdNweu1AVKmlipBLYHDfZnQFfrVO4hrJr4Rav1kygB/wdNpymKyq4Lg4imAw6bxuXeNNLRKCV17fnTKU0ZCtpVPfb1GaM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729876545; c=relaxed/simple; bh=HqOMIGxdcmnUObKEcq0BqU6f3N++DdZHQfiedXOeP9o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ipg5hVMyFw1mnwQpA8XaXa2Gc8PWCINN4AtaqPjbpNTf9txXKLeZWPORBpa99hdgJdtujQDlV6gbIHKLU6a8JWL9hqf6O03T1zou7f2ffruQGmUd37Imumxdgg/LY2BHeT6E4Z6kycjSeZtJPFpFFWBf7Qaiqy+z/yMcMNdk+Og= 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=l8/gmoc1; arc=fail smtp.client-ip=40.107.236.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="l8/gmoc1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CNIyBN9F1B/qSZ7tKOmNsWhVwxMEXqjXQt+0/0q1Bh5dUSrUu1gRplwVl2R91Sih6zca1KiGfZEnKdTMT2cKO3qfy+oq1d0hFba3rOHmORkhM8pYHwhekdWYBJ+NWJgyT9/M3D88za9LsO3F4NaSlt+NKqHw6I/c2Tlskt54wsTTG5iMvt/B2AckH/xxo08O+Mfo5+CvlPQyfBbwXGhavqvGKCP67+SWU1E5Ss1k2mWAT/KxEfd0TBQymy5XQWQEZrFFQkOz1PsXLGaOO97+Z6PzcCB0QSnuwXwkbUl+JWiry4jWfDsZIZTXr9XQ3p770jJI2KO0DOa8cqTd927bug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7oPT1wDjaPCzp3IXZUhsV8ghi6JTITj/MUyI6FqVPt4=; b=vC5Cy9MpU69W1IATEl9JKVG/5Vww3qLENfjxZm4FvvqN+6FaEVWhKx0KQ5vzDz44NszglhTQwcIMQN/5ajwfG6x1l5V+En1pnIVBjpnpMvR0y5mN8/9nceTAUcHOoawisxgZqm1v8ZQuiLtQRxKu8JlRO5xQUkfu7h6f1fKz0I6C9OAuuuNg9JMT7HhoD7did7RNuZRr/UH7OC4wOshOA0Bh/CSRenCbLnwHIOETd4fxduXYPVNPtWZAizZlDxaTxp3MFVIIqVoGpeCmypMqxQgckmAVIUFoYBmGPabS7u6/EmybVpMcAmsPHGP++4exsvI3WWVMsozzFd2bJISQcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de 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=7oPT1wDjaPCzp3IXZUhsV8ghi6JTITj/MUyI6FqVPt4=; b=l8/gmoc1sX1EvI866bXhX9DHcxVLjgSBl4Tgs5OeOFvkfq7BXyG1E9Y71JJEtItzgRPNilz+fSee/iNS4PQs6Rv5rgCvVyhaq3rcr1vRl4c8Ac2hUA5FXY3rcWpAIna+D3alSy3dgEU02UgQLfPfYRCfeNoiZF6aCgNYI+dOGiU= Received: from BN8PR03CA0020.namprd03.prod.outlook.com (2603:10b6:408:94::33) by PH0PR12MB8029.namprd12.prod.outlook.com (2603:10b6:510:26c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Fri, 25 Oct 2024 17:15:38 +0000 Received: from BN2PEPF00004FBE.namprd04.prod.outlook.com (2603:10b6:408:94:cafe::81) by BN8PR03CA0020.outlook.office365.com (2603:10b6:408:94::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21 via Frontend Transport; Fri, 25 Oct 2024 17:15:38 +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 BN2PEPF00004FBE.mail.protection.outlook.com (10.167.243.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:15:38 +0000 Received: from AUS-P9-MLIMONCI.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 12:15:35 -0500 From: Mario Limonciello To: Borislav Petkov CC: Thomas Gleixner , Ingo Molnar , "Dave Hansen" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H . Peter Anvin" , "Rafael J . Wysocki" , "Gautham R . Shenoy" , Mario Limonciello , Perry Yuan , Brijesh Singh , Peter Zijlstra , Li RongQing , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:ACPI" , "open list:AMD PSTATE DRIVER" , Pawan Gupta , Eric Naim , Peter Jung Subject: [PATCH v4 5/5] x86/amd: Use heterogeneous core topology for identifying boost numerator Date: Fri, 25 Oct 2024 12:14:59 -0500 Message-ID: <20241025171459.1093-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025171459.1093-1-mario.limonciello@amd.com> References: <20241025171459.1093-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBE:EE_|PH0PR12MB8029:EE_ X-MS-Office365-Filtering-Correlation-Id: d29b2044-9045-4a65-245f-08dcf518a552 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: S4nEfaduS0sc1bPMPbK4IZt4E53ogdkkttYGDgohzVc60jBvhBv2SLTcYkd34QFJpPyCYSWDr2JDsros/WCNO7a/Fm0ZEDlQwebbkrq93BQbsHnME0ZCJQsxMB0VhFihIxwZtpQuL6r4jIm7+Z3e4bBw1XbyBrE3jyaadar141WA6wRRfzC081m+LP3NE/DQzm7NZQXpfPFFEKtkTAP2pDMLm1fnaRWaMQsRldM+Dg7GZ3Db7eVEexp68HSVq7YjBBu+o2dkFtc3grxFxdWG8EU1bDnr2Ygdo4wdp3nbmueseYuYqrhdBIoxuwMtFjJ4BavvCJU+AxP1pCLOvf6FutvoMh0wLHawq/NxK7Vp80OVw4MpCsrRsGNSuaV7tH0SMoTaYAj9A2NDsBJlknFQLdq1NEeBq7YjmuLp2UUVO7hX+bgpLGfrm5vGDCDSQutozlS0u9W7tTOzUTuaLMEfbuWm45326VGDTRq/X2FiSd8PwOzWfSZyHehpZ/7WbHTh8uI9h9gufZSmN44fTphI6JMvjfX5QSynkINPWOZrt4AVjXBHaOHIEdzSMWq4+P8lZawx2VbB/X+2Z1iliKUVj/L2aFg+QCg5f+2BrQYKLPkuYxJe5H+PEEaFYQ+tAs6LJzZkDs3n7faq2Ma0uk7teYjBLERuiW3Ao5bN1/REpq+rUipPQ6gOsStHPAKlN11umKCNJ+IaJRQn6huyj6OizDC9G6J63SkFs7/QBg/ioWA4mDJmfh9C8Bif+GFSuZ6mzJmH9m6+w3Fg4wdnEggEQpjFPuuUATMV226IeLwYbJjvUkFlFsZJNpTBytpb4xPkxgZWwANB5pNYvdhbiOyX4pBHgg4tc70OyNqdf7Ncyn55X5fNAjptdCzCq5229ahVBvJk36lV+u8PbtXou2t+K+SsN9dhKzubMHj6rodjl+UFE3R4T34byme0jtIoVrTsx4BIgaAoFpAwugKgB9jwZnmookXSRcX5zIWpQyGQh7+vFuNz/64GNDogS6vKvfS/Uza6MN2s7llvJMafioL8vQ1S7Xo2KxOhGwYqKMS//XSDXDdBDR9S0qoqLzEAzzv7S3aYxmJUl90JhTsOgpy6cIhkidiO/LZTrOamKXjaLZ0Ugq6ls2KNSw/a5YQRI1th70ZT8PaGB6P+lI3zufaO0crxg/m9aZ6ftIIowkiCITZdAAP1VWwQeBdQ4k0zJQg1KzbANL6ZLmKVfP6oqOzNoqKO2nwsWXfrNxu5775RuSrHTzagifZcFgUqz5FWsgHwP2nkbvsjtZwKvy5GeBT8F3i2yIvH5rcdPFf/OF0iToi/tw6qfME0HCScKNaZdD/z21VDxd3nnb5bHAkUbKlZthHJo8JvjO2bvNKoKrtxwNFXch8i+Xo3a972y8ahFip8K/Xe+Ys21S99g0HH9U2qMQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:15:38.0630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d29b2044-9045-4a65-245f-08dcf518a552 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: BN2PEPF00004FBE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8029 AMD heterogeneous designs include two types of cores: * Performance * Efficiency Each core type has different highest performance values configured by the platform. Drivers such as `amd_pstate` need to identify the type of core to correctly set an appropriate boost numerator to calculate the maximum frequency. X86_FEATURE_AMD_HETEROGENEOUS_CORES is used to identify whether the SoC supports heterogeneous core type by reading CPUID leaf Fn_0x80000026. On performance cores the scaling factor of 196 is used. On efficiency cores the scaling factor is the value reported as the highest perf. Efficiency cores have the same preferred core rankings. Tested-by: Eric Naim Tested-by: Peter Jung Suggested-by: Perry Yuan Signed-off-by: Mario Limonciello --- v3->v4: * Drop default case and show warning in unknown case if hetero cores were detected (Boris) * Change get_topology_generic_cpu_type to get_topology_cpu_type (Mario) * Only performance boost numerator to hetero designs. This fixes an issue on Zen5 9950X which supports the CPUID for identifying core types but only has performance cores (Peter Jung) --- arch/x86/kernel/acpi/cppc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index 956984054bf30..59edf64ad9edc 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -234,8 +234,10 @@ EXPORT_SYMBOL_GPL(amd_detect_prefcore); */ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator) { + enum x86_topology_cpu_type core_type = get_topology_cpu_type(&cpu_data(cpu)); bool prefcore; int ret; + u32 tmp; ret = amd_detect_prefcore(&prefcore); if (ret) @@ -261,6 +263,27 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator) break; } } + + /* detect if running on heterogeneous design */ + if (cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES)) { + switch (core_type) { + case TOPO_CPU_TYPE_UNKNOWN: + pr_warn("Undefined core type found for cpu %d\n", cpu); + break; + case TOPO_CPU_TYPE_PERFORMANCE: + /* use the max scale for performance cores */ + *numerator = CPPC_HIGHEST_PERF_PERFORMANCE; + return 0; + case TOPO_CPU_TYPE_EFFICIENCY: + /* use the highest perf value for efficiency cores */ + ret = amd_get_highest_perf(cpu, &tmp); + if (ret) + return ret; + *numerator = tmp; + return 0; + } + } + *numerator = CPPC_HIGHEST_PERF_PREFCORE; return 0;