Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1604490lql; Wed, 13 Mar 2024 03:01:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVRcForHTzjl6YeMwhpyGzssxvUT2vxxjPpYrzshvmql9jexSxTyd9Ud0JPWiVYhm0uv3tDRxKmPfP5/oftigwOFCHjupCgE2M+e3+iQ== X-Google-Smtp-Source: AGHT+IG98u9Uov4o6x55hjarLmiw0EECjIwe025fpt96YZ1c+U8jC10N5/GNnbkud4P4X8ZZl1O5 X-Received: by 2002:a17:90a:dc0d:b0:29b:acc6:c54f with SMTP id i13-20020a17090adc0d00b0029bacc6c54fmr10109636pjv.35.1710324112136; Wed, 13 Mar 2024 03:01:52 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mz16-20020a17090b379000b0029bc307fb2csi1087342pjb.93.2024.03.13.03.01.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 03:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101313-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=YkRONCAf; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-101313-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101313-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A4FA1282B76 for ; Wed, 13 Mar 2024 10:01:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE85E3D0D9; Wed, 13 Mar 2024 10:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YkRONCAf" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C7DE3B798; Wed, 13 Mar 2024 10:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324060; cv=fail; b=dAIgGUcnuVRAZxaE2cYidN4ZeQq1VKYQYuPf3psAxgmX54myDmsnKKuk2whtEJpzpCPTjdEv9Qg2bsunKMnLaxc0cRQWKwopPXNMtG0F7lXsmUMZbUY8DAK/4pobTyfM8ujoTys8bLWm3EFMx6u+CRpt3Y9Dp2MknDOHFPy1c8A= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324060; c=relaxed/simple; bh=izbf3uRLqrt+JxeDkBVexoYaKMLMqSYJ9ClA7Faj7Lw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H0f63q8MDN1O1i7tdYjgjFUH3wNUxHPAyxZWc66khdZoIbyRT5lAkFzTEJdbguVgSUFiEyXbjo0B5mIrHU2mHKvIO5zLgiArXPplpdc8eI5xtahwWWWu0+FmDztTve8SGfnBZ+LSxMxt8EO7a2dtdGJ27rHfrMpHq/IuRIvMUmA= 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=YkRONCAf; arc=fail smtp.client-ip=40.107.243.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+bwhgyaME8H62WcPDXHwHZAzlfmWA+RJ2XmW8A4IarzSxOG/eN2KocEoOR7JhZTHa2KxQ1zevsbGUCu7Sg5HdFe7BcxlwZ5RfEd6B3SNy9LBwdM1ouwHsOe77jTD7sSEDIuzSdypKdVsCYCW6J2oTEEvGRX+nrB5YOIeh6858r/SfHVwzUmpPCOyO0TaSXjTbl80ZQRbELFenAR07a6b9N6CLmhLm+YMlS/IZq0g8o0g+eTOIoUHcqA53G0GiC+fdHYREG3sjMDNEPquAYha6TeQahsUAiB6C8Mg+Pgb9jNeTvcF60HcoK+OGdydcLG6n4TVuxm1XMY+S9k9MF7LQ== 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=nE90DJd0QcwGZ1W/trga9+yZJ0DKzPHH2uJogpruomY=; b=R6rtkvtudWQJAlnubTvPU4evg2GPoSzQR1QO6NEvleMiGBKShQV2RX51vLBn3cVCoKdQAqjsD9r/xKi0BvGkyreOi2jkzne85v3GFhAOL2ldK1Y5r2JfsiyrnS4OZ8TmYRGJxaZgUFLEp/K/1ZW0s7zuf1ex9LkTd5WM8wed/foNPqDiCY/ODq8I53Xw4+joKaftuU31L9qGP+5nuGZvZ2QraIm0sLbLFmSArxs21gh+AFVkgv6AIoX3OEjHf8XXVNmjCObG/sWe32/oxpCqo5S3bOuCG2A3Zn1h7ebWlovmI5VY0WwUXfeOo2ozNvW/0+gEMh1eGDVjYh8MP/gbGg== 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=nE90DJd0QcwGZ1W/trga9+yZJ0DKzPHH2uJogpruomY=; b=YkRONCAfARapl3O6d1eYgVnk0h9xug1J42Kt+fBa1C/rGjYltWTzu6ajgqVZ/BdQQ5imGmO+gqwS2LxzwnxggtcdYQyjVnSG8q3YoTj0ar+YcaGRfnPEHIEJzB2SggQ81/rNu23YoLpTUXgSuossoVkEAruZkion3/fvlwOSSs8= Received: from MW4PR04CA0089.namprd04.prod.outlook.com (2603:10b6:303:6b::34) by CY8PR12MB7124.namprd12.prod.outlook.com (2603:10b6:930:5f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Wed, 13 Mar 2024 10:00:56 +0000 Received: from CO1PEPF000066ED.namprd05.prod.outlook.com (2603:10b6:303:6b:cafe::26) by MW4PR04CA0089.outlook.office365.com (2603:10b6:303:6b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38 via Frontend Transport; Wed, 13 Mar 2024 10:00: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 CO1PEPF000066ED.mail.protection.outlook.com (10.167.249.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7386.12 via Frontend Transport; Wed, 13 Mar 2024 10:00:56 +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; Wed, 13 Mar 2024 05:00:52 -0500 From: Perry Yuan To: , , , , , CC: , , , , , Subject: [PATCH v7 5/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing Date: Wed, 13 Mar 2024 17:59:17 +0800 Message-ID: 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: CO1PEPF000066ED:EE_|CY8PR12MB7124:EE_ X-MS-Office365-Filtering-Correlation-Id: fdc227f5-4c84-4f38-6c0a-08dc434479f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qKp9HjC795ST3/pVxGX5BIE/CdQxlHtU6/yKxmj50bKqyEfls5BOv5/A2M5Q42id1yHRxYn5mP5XXYueJsRADOMZ5mnQ00VfFPnZaVe7LhX1C2KWfik5quO6W4u84BbivD+E5TCgrRYcxIUWZtWshQ6XrlAAeBIyu2ENnh8Y5vwzlbLdFawMjWlLYNONSH4inpzyyji2kt1Egg0k7Ays4AfI/X08eJvySFdYxwZJ4/FrszbeaHpals5AHXM2+TrSfByL9EQI9RFTHt1TBnvYDd/b1vZJTyN0MBbJRJz/0p+CrWvOQE8WNE0Yecn2B2AbcEXJxcnuOSr5slLsEFfyBLSQho2K9w8YRmilF8XsHm3Y3g0IxzLx+/GIzTUUrNQgab4aLlFcah+4yRGZ96LNgx6pyzc8Fm0kBRoweL7cQWpPs0sA/X1WguB3F6bar0ea/sxuyE8gdHBuLU7h7kd3pnGjohej1cvhgpzuOE+y4wLBEGf7knC9JWeOQuhr6yo7Yk5ThAYMSxJqEbLX/zL3M85e67eJOcjKJPYzqRRCZ+9YPhdZTPvC/U9EZSUbxHJFNH349/GjlEN33XeG4Lwfs7kJpKnzrbeQ/qGy+O+TKroxGx4aJtN9JaHLS9eNCvEgWGpe7GBq7PrTwZdkuSP7p5sd2At1wr0OTcPq85FumERVQ5GZTrsJlzKBMa0unt3TDqb0SsUs4j2rTrd+dd7xCE5g0hm8ciJD+NdJD018wuM1grT6KClN3u/wKQcAxP8C X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2024 10:00:56.0907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdc227f5-4c84-4f38-6c0a-08dc434479f1 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: CO1PEPF000066ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7124 Add quirks table to get CPPC capabilities issue fixed by providing correct perf or frequency values while driver loading. If CPPC capabilities are not defined in the ACPI tables or wrongly defined by platform firmware, it needs to use quick to get those issues fixed with correct workaround values to make pstate driver can be loaded even though there are CPPC capabilities errors. The workaround will match the broken BIOS which lack of CPPC capabilities nominal_freq and lowest_freq definition in the ACPI table. $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_freq 0 $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq 0 Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 57 ++++++++++++++++++++++++++++++++++-- include/linux/amd-pstate.h | 6 ++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index ec6259957d25..59bcdf829c93 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; @@ -607,13 +643,19 @@ 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; + u32 lowest_freq; int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; + if (quirks && quirks->lowest_freq) + lowest_freq = quirks->lowest_freq; + else + lowest_freq = cppc_perf.lowest_freq; + /* Switch to khz */ - return cppc_perf.lowest_freq * 1000; + return lowest_freq * 1000; } static int amd_get_max_freq(struct amd_cpudata *cpudata) @@ -642,12 +684,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) static int amd_get_nominal_freq(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; + u32 nominal_freq; int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; - return cppc_perf.nominal_freq; + if (quirks && quirks->nominal_freq) + nominal_freq = quirks->nominal_freq; + else + nominal_freq = cppc_perf.nominal_freq; + + return nominal_freq; } static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) @@ -1685,6 +1733,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 d21838835abd..7b2cbb892fd9 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -124,4 +124,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 */ -- 2.34.1