From patchwork Wed Aug 17 03:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 598404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21DB4C25B08 for ; Wed, 17 Aug 2022 03:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbiHQDtD (ORCPT ); Tue, 16 Aug 2022 23:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiHQDtC (ORCPT ); Tue, 16 Aug 2022 23:49:02 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5CD79608; Tue, 16 Aug 2022 20:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KrPGAyjWMIA08NLFOznWCQhGV0aAvromCRUC/MivrEP0Yk7i9ZVbPbzAUfMX76lp5FVI6W5E8mftH3RzRRQZba3cxbd3SwXRgwo3pAZz34BcJsZHpClDkAUklQx/MnU4ZkjtK6UN40CRjHQbkRghKeY3JTNfNBIjzQK/5l0xxUkWg188cfo/cThEy4vghsoJgW6eAioeXR1LcLU8uZpzZ+QrsSQFteMfaszr19k06ofMO7tOryfQNa+OnkPxEoVRc7egOWyNU3CDY4QiN6RlPyyog82S4V5qnh6I45v67/dZoe8xRbfLTiPXzlj5NZzeURwJd6eV5oKErJe1B002Kw== 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=zTbV5Bqs2MGDamG3ZbiKfiDeggMgoBRYGVPEMhRI0+g=; b=buGIoklXc96Wi/dze0KYNtVDYs0ZNjao02Woj/FNXKrygElf9mrlFOGIbKvUengiLH0ZbrYog5QCw+zYdLmoU5NYTEe9ySqB+8n3mxKnHPFgtJabLQHceiX7JERVb3dMXodQCPpEFZUgieiwpOa1sYU5LWrYYEoa7KhAg1r238SFPztBxJEQENpEIkNHUFHRPFt+dfPWfFdu3nIQBsRauyusr+Fq+/n9643IV8sx0T3lz+jOv/v9OhZJqfEaw2X5cCG+p4Y4Om82ww9lzpwR4z0VthoNTUy7dgvfu6lOLPx+9UOOM+2GDYmg8EkLmtIcBPP4NAzRVGO2NR9deqNnYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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 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=zTbV5Bqs2MGDamG3ZbiKfiDeggMgoBRYGVPEMhRI0+g=; b=ugm7B6WMpVULXx40h0ZebIUZ6tggkpDY+WuwZyFajxgrzH4O0MBd+Vl3L3i9dzLNFWFw+WaRD4ZGdDtapUNvto4IZtytGthrbrtcB36ZSgYUh2tNyQTeRy02OtQkrK3UXLEFUum6lcopE6SHYUPJZ8J2NGEsvFeUmKxBdiZO+jk= Received: from BN9PR03CA0267.namprd03.prod.outlook.com (2603:10b6:408:ff::32) by BL3PR12MB6377.namprd12.prod.outlook.com (2603:10b6:208:3b0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Wed, 17 Aug 2022 03:48:58 +0000 Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::ce) by BN9PR03CA0267.outlook.office365.com (2603:10b6:408:ff::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.19 via Frontend Transport; Wed, 17 Aug 2022 03:48:58 +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 BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5546.15 via Frontend Transport; Wed, 17 Aug 2022 03:48:58 +0000 Received: from jasmine-meng.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.2375.28; Tue, 16 Aug 2022 22:46:57 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Jinzhou Su , Perry Yuan , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [RESEND PATCH 1/4] cpufreq: amd-pstate: Expose struct amd_cpudata Date: Wed, 17 Aug 2022 11:46:27 +0800 Message-ID: <20220817034630.1172065-2-li.meng@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220817034630.1172065-1-li.meng@amd.com> References: <20220817034630.1172065-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ce7eb1e-aecf-470b-4795-08da80036a5a X-MS-TrafficTypeDiagnostic: BL3PR12MB6377:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DBLxiZDXVNQXWSK6BerXjQFsDRovSexejzRXFXlvGp/eMonHTqfWPhlTjpgTcgOPU252huHhHIZEF1ODZ39+UNqSonFn5tcXf3Qm3UyTAda1QBR1+K4gelp+rdpHeOrElcuOb5kpvlAfN5CV6tNI8yQg+/8PdB2tLjuSKG7ncmgzXqQUB9yMzxEJTsvkaS2qCOmUhNy6tmKBxnJQOdfvda5K948SDPssyhZsySGngx8Oynm4epWw8Jsiy86q2DcYMu7m7S7IDitsQm489hkwAR3ovB0XXGiXq9MvChhJQVCE64mbc/to0QVO5EfVny4wm/Rx2rmQxE7uk1djZVRDsfQ2x5AHJs03G+8esRGISiYtxyKxl0VhJEqWcy0LCWM67SzRK+zEwYH/gA+N4XcazYTOUYhmeyNfeS0Q1/AB2J9Tbly9ZBbByg1VgI7I7LvwSXkLW09j6kh3g2Yr3r7tFfCW8CQPhrKm2MiRwjlZ0LgJlWEr/iOf9TJg0idh98QPKR5AfZmsyAfFEL8nHziRiA/OITNHKPyjukeWgDSFBhmMSB2obPJ20vHlaIJzbPPuvu9pQShkgJWbFZWyQPbydXG6f/QVXrW7aSJ7o6ZLaINaKnoqqc5P37FUr6flmX8EbtHQrWt70JS81mkq5QyTalDl+uuarRYDq9AHwP4LC3dMzEddu5nSYvDGjgV3183bx3LtIRe4zXrrwJUQ5X1rVY0rpw4Pb1hWgu2htUqrGkVXYp52Qy1S7p04z84S19ga+yfqJFYZuZPPFKelE+4N2Xql3lGbgCSLRQUqyfhie/KLQniuumSNr+oIlQ67oAjYWNF5SRBVdZs3Nt/hUAXK2w== 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:(13230016)(4636009)(136003)(346002)(376002)(39860400002)(396003)(46966006)(36840700001)(40470700004)(2616005)(41300700001)(336012)(426003)(1076003)(54906003)(47076005)(478600001)(356005)(186003)(110136005)(82310400005)(16526019)(7696005)(86362001)(316002)(26005)(40480700001)(82740400003)(6666004)(81166007)(40460700003)(83380400001)(8936002)(2906002)(4326008)(36860700001)(8676002)(36756003)(5660300002)(70586007)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 03:48:58.3280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ce7eb1e-aecf-470b-4795-08da80036a5a 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: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6377 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Expose struct amd_cpudata to AMD P-State unit test module. This data struct will be used on the following AMD P-State unit test (amd-pstate-ut) module. The amd-pstate-ut module can get some AMD infomations by this data struct. For example: highest perf, nominal perf, boost supported etc. Signed-off-by: Meng Li Acked-by: Huang Rui Acked-by: Shuah Khan --- MAINTAINERS | 1 + drivers/cpufreq/amd-pstate.c | 60 +--------------------------- include/linux/amd-pstate.h | 77 ++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 include/linux/amd-pstate.h diff --git a/MAINTAINERS b/MAINTAINERS index 8a5012ba6ff9..5c404d2686d1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1045,6 +1045,7 @@ L: linux-pm@vger.kernel.org S: Supported F: Documentation/admin-guide/pm/amd-pstate.rst F: drivers/cpufreq/amd-pstate* +F: include/linux/amd-pstate.h F: tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py AMD PTDMA DRIVER diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9ac75c1cde9c..218f777a5915 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -65,65 +66,6 @@ MODULE_PARM_DESC(shared_mem, static struct cpufreq_driver amd_pstate_driver; -/** - * struct amd_aperf_mperf - * @aperf: actual performance frequency clock count - * @mperf: maximum performance frequency clock count - * @tsc: time stamp counter - */ -struct amd_aperf_mperf { - u64 aperf; - u64 mperf; - u64 tsc; -}; - -/** - * struct amd_cpudata - private CPU data for AMD P-State - * @cpu: CPU number - * @req: constraint request to apply - * @cppc_req_cached: cached performance request hints - * @highest_perf: the maximum performance an individual processor may reach, - * assuming ideal conditions - * @nominal_perf: the maximum sustained performance level of the processor, - * assuming ideal operating conditions - * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power - * savings are achieved - * @lowest_perf: the absolute lowest performance level of the processor - * @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 - * @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 - * @boost_supported: check whether the Processor or SBIOS supports boost mode - * - * The amd_cpudata is key private data for each CPU thread in AMD P-State, and - * represents all the attributes and goals that AMD P-State requests at runtime. - */ -struct amd_cpudata { - int cpu; - - struct freq_qos_request req[2]; - u64 cppc_req_cached; - - u32 highest_perf; - u32 nominal_perf; - u32 lowest_nonlinear_perf; - u32 lowest_perf; - - u32 max_freq; - u32 min_freq; - u32 nominal_freq; - u32 lowest_nonlinear_freq; - - struct amd_aperf_mperf cur; - struct amd_aperf_mperf prev; - - u64 freq; - bool boost_supported; -}; - static inline int pstate_enable(bool enable) { return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable); diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h new file mode 100644 index 000000000000..1c4b8659f171 --- /dev/null +++ b/include/linux/amd-pstate.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/include/linux/amd-pstate.h + * + * Copyright (C) 2022 Advanced Micro Devices, Inc. + * + * Author: Meng Li + */ + +#ifndef _LINUX_AMD_PSTATE_H +#define _LINUX_AMD_PSTATE_H + +#include + +/********************************************************************* + * AMD P-state INTERFACE * + *********************************************************************/ +/** + * struct amd_aperf_mperf + * @aperf: actual performance frequency clock count + * @mperf: maximum performance frequency clock count + * @tsc: time stamp counter + */ +struct amd_aperf_mperf { + u64 aperf; + u64 mperf; + u64 tsc; +}; + +/** + * struct amd_cpudata - private CPU data for AMD P-State + * @cpu: CPU number + * @req: constraint request to apply + * @cppc_req_cached: cached performance request hints + * @highest_perf: the maximum performance an individual processor may reach, + * assuming ideal conditions + * @nominal_perf: the maximum sustained performance level of the processor, + * assuming ideal operating conditions + * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power + * savings are achieved + * @lowest_perf: the absolute lowest performance level of the processor + * @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 + * @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 + * @boost_supported: check whether the Processor or SBIOS supports boost mode + * + * The amd_cpudata is key private data for each CPU thread in AMD P-State, and + * represents all the attributes and goals that AMD P-State requests at runtime. + */ +struct amd_cpudata { + int cpu; + + struct freq_qos_request req[2]; + u64 cppc_req_cached; + + u32 highest_perf; + u32 nominal_perf; + u32 lowest_nonlinear_perf; + u32 lowest_perf; + + u32 max_freq; + u32 min_freq; + u32 nominal_freq; + u32 lowest_nonlinear_freq; + + struct amd_aperf_mperf cur; + struct amd_aperf_mperf prev; + + u64 freq; + bool boost_supported; +}; + +#endif /* _LINUX_AMD_PSTATE_H */ From patchwork Wed Aug 17 03:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 598054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66694C25B08 for ; Wed, 17 Aug 2022 03:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbiHQDtf (ORCPT ); Tue, 16 Aug 2022 23:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiHQDte (ORCPT ); Tue, 16 Aug 2022 23:49:34 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0CA47C1E4; Tue, 16 Aug 2022 20:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJZdhvObxdFAd/MImSJdLwbnSyhTOcX9NClzHMmqJotGIWanICb0onBsIqrFhJQp3uCEa22LUEXAuk5ym3/pJp5dBaebLPxe1C36+SVjeY5V/INRUUz3lRoKWzcBn5eshJ2myiVnu3g3FDPQlSgUMg4o0B+uF84DWRQ6S3I1zzfESNm3ALifoZjMqUVgwYSo/Q38I0lDS4c+nmI7Tut5CeQWtro7Vmf58eU/quteyPUhb1795saK046fOCoS4lZmAmUQTS8VioIOTmLMPK5DxL9SFBLz534nE+fAw7nnuaA14UNxpfCSs5LXXZYNFy2ThU7SRiBSk31JWkHRXF9TKQ== 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=uMKPx5SHlHKb67SIczUcoI7YWpllYob01xC80sSRcJ8=; b=YxeUqo+Y/Elouy6jaaolI8bLJwjz6bTkQvLGHM4EnjmZtLLN8McrOMx1IjPGh3F1dF7cFl/3+2utVblBkvFNetkGH85LQpgGGSpoiPfZMwnjW/AcGCl05JN5r6CM30SZEGCs+puPthXvEYgK/rWC/wivJZtRP5gwSY1KIU3t3Nsqytu/X4g4ezl4IEHzbOqJLU3IwJ6FHQPgyjOAXGaVujCxfslOaerGfptdzO7nTN9jwOvTmWK9caf2De8EPHRIwOwoQ2OKc/OiNakr7V8TNQ1hHLPc8YJiMBobACUBJLXRo1+nJi+86Tr7xSJkCcInFcyui59lY7GJgTDz8wnB7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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 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=uMKPx5SHlHKb67SIczUcoI7YWpllYob01xC80sSRcJ8=; b=TZ/K0QAATjmixG+tgtfnC/bFKW5NaKti3pxGqHCPj6tcVipCoGm2laJ9skT33Vhty1cSzw7t3jdSBO/zaxVkTlkc6/9YJ+flxtFqjNTYb6XE+TFuS/6eH4TWbyU576DVx8iF5kschRkzD8MP2Suax9VOoUYN+BcTf1tYzd9ZX0c= Received: from BN9PR03CA0784.namprd03.prod.outlook.com (2603:10b6:408:13f::9) by BN6PR12MB1425.namprd12.prod.outlook.com (2603:10b6:404:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Wed, 17 Aug 2022 03:49:30 +0000 Received: from BN8NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::73) by BN9PR03CA0784.outlook.office365.com (2603:10b6:408:13f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10 via Frontend Transport; Wed, 17 Aug 2022 03:49:30 +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 BN8NAM11FT085.mail.protection.outlook.com (10.13.176.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5546.7 via Frontend Transport; Wed, 17 Aug 2022 03:49:30 +0000 Received: from jasmine-meng.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.2375.28; Tue, 16 Aug 2022 22:48:07 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Jinzhou Su , Perry Yuan , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [RESEND PATCH 2/4] cpufreq: amd-pstate: Add test module for amd-pstate driver Date: Wed, 17 Aug 2022 11:46:28 +0800 Message-ID: <20220817034630.1172065-3-li.meng@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220817034630.1172065-1-li.meng@amd.com> References: <20220817034630.1172065-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54e2eadd-a43e-4f6a-1a17-08da80037d3e X-MS-TrafficTypeDiagnostic: BN6PR12MB1425:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4dLOa2UmTkFwTzSp6MXJauuL9lx9dLCKLoj/jI/Z4jUt4V/yrpB0bwaqEwB1o14FvoCR97TbS0Qlh6NKSgwKin2GR4IRWwgPgtyDUR7F3K3KQ7FvhIXHr2r3v26C+XqvaJEUo2+IqYARnx/ddOUVGKvVPfzzhVgruHdkMvYauv8IAvYjApVTN+iWvWWFixlETZ2XUI1+iC8jTa5D+fzJMxDgTwqe6HIEGEPu1e54+eKa4eopCPMgMQL1L4W3KDpyTPalmjfz5DbEoALcVF7Ts0BZPrS+jqFGoY/1eecUs9Hbc+qCnpTk0xQbRGbosyRqAZ7rEXEu6Rh2UkYBoUZZ7hXjOjluHKRsgYmQar0rEIOI1UwVgbQhG8ypHzxBwvnWV2Y/6GdPyOJPkkT0EVsdCbqm6fFHeekOMEb4Is1zhzUgSOwsQ/O+GCHpD5ZDd4D/qsoa0vDzYIeamDfeawtFPTbHU1gepfZ8e2nphhZTqcOJKbHCWCRsDEgbD80dh6t7R3aSk6iApOfscqQcVfMuJ5BD6gJXvD9XdIMG5TF23GEACRRNoleUvcyZ9OVG4RhWKGL38HI/ryDjcZQVHRtBTKZqT9le4iLrl/75587Wx8a/utAhqghDTfnaj+fnUXFZdnnfhkMfFB5GM5zzIQahkFCKiaUgCgVgTRtGjpBG7TPRvhPnwiN3pEOJAQC1/zqoZFACQgMqsxTqBGRhWLl6If7ojnsnxoUsb9hLdpmUdR9NUTpFpyNrgjZQZkyfNeGfKqkLkNjqT78tNXJQLfEqU4+tLwt3mjqVA/SkJc2OlkipL0RfvXmmTqBUzinE05+D8+ZDMa4Ccz801fvhAr2q5g== 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:(13230016)(4636009)(396003)(346002)(376002)(136003)(39860400002)(36840700001)(46966006)(40470700004)(30864003)(47076005)(83380400001)(336012)(1076003)(426003)(81166007)(82740400003)(16526019)(356005)(70206006)(316002)(70586007)(5660300002)(186003)(8676002)(82310400005)(7696005)(2616005)(4326008)(2906002)(26005)(54906003)(110136005)(478600001)(36756003)(36860700001)(40480700001)(41300700001)(86362001)(8936002)(40460700003)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 03:49:30.0044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54e2eadd-a43e-4f6a-1a17-08da80037d3e 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: BN8NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1425 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add amd-pstate-ut test module, this module is used by kselftest to unit test amd-pstate functionality. This module will be expected by some of selftests to be present and loaded. Signed-off-by: Meng Li Acked-by: Huang Rui Reviewed-by: Shuah Khan --- drivers/cpufreq/Kconfig.x86 | 7 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/amd-pstate-ut.c | 293 ++++++++++++++++++++++++++++++++ 3 files changed, 301 insertions(+) create mode 100644 drivers/cpufreq/amd-pstate-ut.c diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 55516043b656..fdd819069d72 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 @@ -51,6 +51,13 @@ config X86_AMD_PSTATE If in doubt, say N. +config X86_AMD_PSTATE_UT + tristate "selftest for AMD Processor P-State driver" + depends on X86 && ACPI_PROCESSOR + default n + help + This kernel module is used for testing. It's safe to say M here. + config X86_ACPI_CPUFREQ tristate "ACPI Processor P-States driver" depends on ACPI_PROCESSOR diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 285de70af877..49b98c62c5af 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -30,6 +30,7 @@ amd_pstate-y := amd-pstate.o amd-pstate-trace.o obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o obj-$(CONFIG_X86_AMD_PSTATE) += amd_pstate.o +obj-$(CONFIG_X86_AMD_PSTATE_UT) += amd-pstate-ut.o obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c new file mode 100644 index 000000000000..3947b7138184 --- /dev/null +++ b/drivers/cpufreq/amd-pstate-ut.c @@ -0,0 +1,293 @@ +// SPDX-License-Identifier: GPL-1.0-or-later +/* + * AMD Processor P-state Frequency Driver Unit Test + * + * Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Author: Meng Li + * + * The AMD P-State Unit Test is a test module for testing the amd-pstate + * driver. 1) It can help all users to verify their processor support + * (SBIOS/Firmware or Hardware). 2) Kernel can have a basic function + * test to avoid the kernel regression during the update. 3) We can + * introduce more functional or performance tests to align the result + * together, it will benefit power and performance scale optimization. + * + * This driver implements basic framework with plans to enhance it with + * additional test cases to improve the depth and coverage of the test. + * + * See Documentation/admin-guide/pm/amd-pstate.rst Unit Tests for + * amd-pstate to get more detail. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include + +#include + +/* + * Abbreviations: + * amd_pstate_ut: used as a shortform for AMD P-State unit test. + * It helps to keep variable names smaller, simpler + */ +enum amd_pstate_ut_result { + AMD_PSTATE_UT_RESULT_PASS, + AMD_PSTATE_UT_RESULT_FAIL, +}; + +struct amd_pstate_ut_struct { + const char *name; + void (*func)(u32 index); + enum amd_pstate_ut_result result; +}; + +/* + * Kernel module for testing the AMD P-State unit test + */ +static void amd_pstate_ut_acpi_cpc_valid(u32 index); +static void amd_pstate_ut_check_enabled(u32 index); +static void amd_pstate_ut_check_perf(u32 index); +static void amd_pstate_ut_check_freq(u32 index); + +static struct amd_pstate_ut_struct amd_pstate_ut_cases[] = { + {"amd_pstate_ut_acpi_cpc_valid", amd_pstate_ut_acpi_cpc_valid }, + {"amd_pstate_ut_check_enabled", amd_pstate_ut_check_enabled }, + {"amd_pstate_ut_check_perf", amd_pstate_ut_check_perf }, + {"amd_pstate_ut_check_freq", amd_pstate_ut_check_freq } +}; + +static bool get_shared_mem(void) +{ + bool result = false; + char path[] = "/sys/module/amd_pstate/parameters/shared_mem"; + char buf[5] = {0}; + struct file *filp = NULL; + loff_t pos = 0; + ssize_t ret; + + if (!boot_cpu_has(X86_FEATURE_CPPC)) { + filp = filp_open(path, FMODE_PREAD, 0); + if (IS_ERR(filp)) + pr_err("%s unable to open %s file!\n", __func__, path); + else { + ret = kernel_read(filp, &buf, sizeof(buf), &pos); + if (ret < 0) + pr_err("%s read %s file fail ret=%ld!\n", + __func__, path, (long)ret); + filp_close(filp, NULL); + } + + if ('Y' == *buf) + result = true; + } + + return result; +} + +/* + * check the _CPC object is present in SBIOS. + */ +static void amd_pstate_ut_acpi_cpc_valid(u32 index) +{ + if (acpi_cpc_valid()) + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; + else { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s the _CPC object is not present in SBIOS!\n", __func__); + } +} + +static void amd_pstate_ut_pstate_enable(u32 index) +{ + int ret = 0; + u64 cppc_enable = 0; + + ret = rdmsrl_safe(MSR_AMD_CPPC_ENABLE, &cppc_enable); + if (ret) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s rdmsrl_safe MSR_AMD_CPPC_ENABLE ret=%d error!\n", __func__, ret); + return; + } + if (cppc_enable) + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; + else { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s amd pstate must be enabled!\n", __func__); + } +} + +/* + * check if amd pstate is enabled + */ +static void amd_pstate_ut_check_enabled(u32 index) +{ + if (get_shared_mem()) + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; + else + amd_pstate_ut_pstate_enable(index); +} + +/* + * check if performance values are reasonable. + * highest_perf >= nominal_perf > lowest_nonlinear_perf > lowest_perf > 0 + */ +static void amd_pstate_ut_check_perf(u32 index) +{ + int cpu = 0, ret = 0; + u32 highest_perf = 0, nominal_perf = 0, lowest_nonlinear_perf = 0, lowest_perf = 0; + u64 cap1 = 0; + struct cppc_perf_caps cppc_perf; + struct cpufreq_policy *policy = NULL; + struct amd_cpudata *cpudata = NULL; + + highest_perf = amd_get_highest_perf(); + + for_each_possible_cpu(cpu) { + policy = cpufreq_cpu_get(cpu); + if (!policy) + break; + cpudata = policy->driver_data; + + if (get_shared_mem()) { + ret = cppc_get_perf_caps(cpu, &cppc_perf); + if (ret) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cppc_get_perf_caps ret=%d error!\n", __func__, ret); + return; + } + + nominal_perf = cppc_perf.nominal_perf; + lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; + lowest_perf = cppc_perf.lowest_perf; + } else { + ret = rdmsrl_safe_on_cpu(cpu, MSR_AMD_CPPC_CAP1, &cap1); + if (ret) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s read CPPC_CAP1 ret=%d error!\n", __func__, ret); + return; + } + + nominal_perf = AMD_CPPC_NOMINAL_PERF(cap1); + lowest_nonlinear_perf = AMD_CPPC_LOWNONLIN_PERF(cap1); + lowest_perf = AMD_CPPC_LOWEST_PERF(cap1); + } + + if ((highest_perf != READ_ONCE(cpudata->highest_perf)) || + (nominal_perf != READ_ONCE(cpudata->nominal_perf)) || + (lowest_nonlinear_perf != READ_ONCE(cpudata->lowest_nonlinear_perf)) || + (lowest_perf != READ_ONCE(cpudata->lowest_perf))) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d highest=%d %d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n", + __func__, cpu, highest_perf, cpudata->highest_perf, + nominal_perf, cpudata->nominal_perf, + lowest_nonlinear_perf, cpudata->lowest_nonlinear_perf, + lowest_perf, cpudata->lowest_perf); + return; + } + + if (!((highest_perf >= nominal_perf) && + (nominal_perf > lowest_nonlinear_perf) && + (lowest_nonlinear_perf > lowest_perf) && + (lowest_perf > 0))) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d highest=%d >= nominal=%d > lowest_nonlinear=%d > lowest=%d > 0, the formula is incorrect!\n", + __func__, cpu, highest_perf, nominal_perf, + lowest_nonlinear_perf, lowest_perf); + return; + } + } + + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; +} + +/* + * Check if frequency values are reasonable. + * max_freq >= nominal_freq > lowest_nonlinear_freq > min_freq > 0 + * check max freq when set support boost mode. + */ +static void amd_pstate_ut_check_freq(u32 index) +{ + int cpu = 0; + struct cpufreq_policy *policy = NULL; + struct amd_cpudata *cpudata = NULL; + + for_each_possible_cpu(cpu) { + policy = cpufreq_cpu_get(cpu); + if (!policy) + break; + cpudata = policy->driver_data; + + if (!((cpudata->max_freq >= cpudata->nominal_freq) && + (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && + (cpudata->lowest_nonlinear_freq > cpudata->min_freq) && + (cpudata->min_freq > 0))) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", + __func__, cpu, cpudata->max_freq, cpudata->nominal_freq, + cpudata->lowest_nonlinear_freq, cpudata->min_freq); + return; + } + + if (cpudata->min_freq != policy->min) { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d cpudata_min_freq=%d policy_min=%d, they should be equal!\n", + __func__, cpu, cpudata->min_freq, policy->min); + return; + } + + if (cpudata->boost_supported) { + if ((policy->max == cpudata->max_freq) || + (policy->max == cpudata->nominal_freq)) + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; + else { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", + __func__, cpu, policy->max, cpudata->max_freq, + cpudata->nominal_freq); + return; + } + } else { + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; + pr_err("%s cpu%d must support boost!\n", __func__, cpu); + return; + } + } + + amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; +} + +static int __init amd_pstate_ut_init(void) +{ + u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases); + + for (i = 0; i < arr_size; i++) { + amd_pstate_ut_cases[i].func(i); + switch (amd_pstate_ut_cases[i].result) { + case AMD_PSTATE_UT_RESULT_PASS: + pr_info("%-4d %-20s\t success!\n", i+1, amd_pstate_ut_cases[i].name); + break; + case AMD_PSTATE_UT_RESULT_FAIL: + default: + pr_info("%-4d %-20s\t fail!\n", i+1, amd_pstate_ut_cases[i].name); + break; + } + } + + return 0; +} + +static void __exit amd_pstate_ut_exit(void) +{ +} + +module_init(amd_pstate_ut_init); +module_exit(amd_pstate_ut_exit); + +MODULE_AUTHOR("Meng Li "); +MODULE_DESCRIPTION("AMD P-state driver Test module"); +MODULE_LICENSE("GPL"); From patchwork Wed Aug 17 03:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 598403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4103FC32771 for ; Wed, 17 Aug 2022 03:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbiHQDtj (ORCPT ); Tue, 16 Aug 2022 23:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238139AbiHQDtf (ORCPT ); Tue, 16 Aug 2022 23:49:35 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1F57B287; Tue, 16 Aug 2022 20:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cWgNU5dASF2EvQxq7xRGQ8bXApNbPCPVVFhOaS28/saJYmjK2L4W/Irr/48OjUmXdWYk2qfR0NRus7Ncp4hETpRmnjY6rrVttKj3rGBp93UFEdRbCo71nV1EtuIA8ycvC08Szt7k/xl4J3MTLqQ77uaH0c3QBfIksJMWUTjKscOXJ1A1AFLfQhR62asKOm1iurxTLGjNapDRei/EjscdZfRuj6W/Ab3tV2tUqFx0WEob1mDs/abp3CMml0hfw1LNPcDl04yje8g8JPFVJgkwZjk55cQYiUBnyPu7z8dR9dowbhB9WMkgAm+3XDDQDtbsQMnFEzyqTqRdYgy6DuGQbw== 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=0GVszYkIkLFZfnNmhfzhMQaxHfb2cQkoV6KOKw5UxP4=; b=d2quR/YpOwRrdM9erep67IErAzp6vS2AOj7cMPKxqCAkwMaoG5+TWU8Idsl9Lr9yP0oYM4ZApufYISm+pXlVJEscc8SoJc3xvsK0Bvmcuah83TupBTVIMbwIHy5LjJADasriq2ZQMkpCfeWyA/FxZgzXzU636U6hhDFXvggK+Qu6XwAykG+yksM/+6gKlywR0wq6aWvw/CP/XVINSnAb91pNFbjS8ub6Dlt6CZtMZNL8wYnbNAZNNrs5gbc89BkFmFTBN2JYmWJd4XkogZxRHpMU+CVKAX/Oenl/UsqDpm7PSnM3jeuOlQ/01d+1X0yYlBrr8twmjgYyramqK24CtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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 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=0GVszYkIkLFZfnNmhfzhMQaxHfb2cQkoV6KOKw5UxP4=; b=LUFZIdH1MlyZdIL1sXrfiplx0evW39HeyJvB5jYNrxN3QWY2Vqp9zvkJLfGRnUbDGsMv25LAtiwJujSMBABC1jNgeLfTl4Btw5MPf3lm1q4zTNX0UfhMPokzPmyuOZWILt/LYh9hUU8gjy0CYfj6vIGUUtMGmZgaIHRWVHAQhr8= Received: from BN9PR03CA0787.namprd03.prod.outlook.com (2603:10b6:408:13f::12) by BY5PR12MB4131.namprd12.prod.outlook.com (2603:10b6:a03:212::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Wed, 17 Aug 2022 03:49:30 +0000 Received: from BN8NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::56) by BN9PR03CA0787.outlook.office365.com (2603:10b6:408:13f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.18 via Frontend Transport; Wed, 17 Aug 2022 03:49:30 +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 BN8NAM11FT085.mail.protection.outlook.com (10.13.176.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5546.7 via Frontend Transport; Wed, 17 Aug 2022 03:49:30 +0000 Received: from jasmine-meng.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.2375.28; Tue, 16 Aug 2022 22:48:58 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Jinzhou Su , Perry Yuan , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [RESEND PATCH 3/4] selftests: amd-pstate: Add test trigger for amd-pstate driver Date: Wed, 17 Aug 2022 11:46:29 +0800 Message-ID: <20220817034630.1172065-4-li.meng@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220817034630.1172065-1-li.meng@amd.com> References: <20220817034630.1172065-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7bfdd9bf-d0cc-4f7d-165d-08da80037d7c X-MS-TrafficTypeDiagnostic: BY5PR12MB4131:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: spBanXJOLZEu3zm2KEQZHkGA1azhbxMVVBbqFi8z2o3WEtdvOuHXcpYZA3/It13RQsRv1KRzxOKo0HVLfO3PuJLnYoI2/tv89cqGEccwnfEwasEh7TaqGaSz2SDVLFemdZadNRBua1ukC7kvEEnCvn5W9pn7lMENwG6WuXXAIfM2ZCyfOnDS7BQZUQym+QDXDibbls4e4NVZ389L6L1hcPsRLQBSjRclGEpa0y25Rye0I0+iZ/NhQ1aw0Ri1Sunb53MPZeLXzb8QnRudh9qSRKPnN9eIpI492idcDXbgc+gcgEy0VyFIzQncbWCCfWCnZPhXrCwAlisOfnZkC97FPdpGhJoKhLJTCagz51/4ne5q1W7l8d+ZJ2Mp7n0NzRXo986kixtaMedzoUMtWzQWA7lm5uu2W8DEy9eeRGPG+yONnurmP1gF0LpUyueIIfihK7+s1qz13vJK/dlT0v5JE+m2G91PkL28BXllAfc302fLi1MV5/aHChn88m+8VXvOcx6mBlwBNUypmteT1DRoGcpIPgJOuUNERbYNsCYwNQfK+HVGuYSi/stqQ+AfTbQcRZfo6u2f2F1AY+/4KqNSBcymV/W5uB2xLP0wPYQjvfL0uDK32MSm00wIXfCAqriovMMpaHMrMLpHw729YmvPBDtra49ARu9gI3mjS5tdKliYlLAzRsEZr8wmisdEI2yaBQoVMQBp9Xwi5XB1K2T+OCSokbFdZvp+gIktw3aTf/YdsiRwkaJ5ORfX1E42deja5XaFTaGl6hFEKbK3VcuEENWlUE7sS8/dXjSH7IEEjzFq1egn59P0Gy4l5cAxrCfqyD1z2WcB+busf3XUTsvWSg== 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:(13230016)(4636009)(136003)(376002)(39860400002)(396003)(346002)(36840700001)(46966006)(40470700004)(336012)(47076005)(54906003)(2616005)(1076003)(40480700001)(6666004)(186003)(86362001)(7696005)(36860700001)(36756003)(26005)(83380400001)(110136005)(40460700003)(82310400005)(316002)(16526019)(4326008)(426003)(41300700001)(70206006)(2906002)(70586007)(478600001)(5660300002)(81166007)(356005)(82740400003)(8676002)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 03:49:30.4262 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bfdd9bf-d0cc-4f7d-165d-08da80037d7c 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: BN8NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4131 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add amd-pstate test trigger in kselftest, it will load/unload amd-pstate-ut module to test some cases etc. Signed-off-by: Meng Li Acked-by: Huang Rui Reviewed-by: Shuah Khan --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/amd-pstate/Makefile | 9 +++ .../selftests/amd-pstate/amd-pstate-ut.sh | 55 +++++++++++++++++++ tools/testing/selftests/amd-pstate/config | 1 + 4 files changed, 66 insertions(+) create mode 100644 tools/testing/selftests/amd-pstate/Makefile create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh create mode 100644 tools/testing/selftests/amd-pstate/config diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 10b34bb03bc1..02b4f3477eae 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 TARGETS += alsa +TARGETS += amd-pstate TARGETS += arm64 TARGETS += bpf TARGETS += breakpoints diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile new file mode 100644 index 000000000000..199867f44b32 --- /dev/null +++ b/tools/testing/selftests/amd-pstate/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Makefile for amd-pstate/ function selftests + +# No binaries, but make sure arg-less "make" doesn't trigger "run_tests" +all: + +TEST_PROGS := amd-pstate-ut.sh + +include ../lib.mk diff --git a/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh new file mode 100755 index 000000000000..273364650285 --- /dev/null +++ b/tools/testing/selftests/amd-pstate/amd-pstate-ut.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# amd-pstate-ut is a test module for testing the amd-pstate driver. +# It can only run on x86 architectures and current cpufreq driver +# must be amd-pstate. +# (1) It can help all users to verify their processor support +# (SBIOS/Firmware or Hardware). +# (2) Kernel can have a basic function test to avoid the kernel +# regression during the update. +# (3) We can introduce more functional or performance tests to align +# the result together, it will benefit power and performance scale optimization. + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +# amd-pstate-ut only run on x86/x86_64 AMD systems. +ARCH=$(uname -m 2>/dev/null | sed -e 's/i.86/x86/' -e 's/x86_64/x86/') +VENDOR=$(cat /proc/cpuinfo | grep -m 1 'vendor_id' | awk '{print $NF}') + +if ! echo "$ARCH" | grep -q x86; then + echo "$0 # Skipped: Test can only run on x86 architectures." + exit $ksft_skip +fi + +if ! echo "$VENDOR" | grep -iq amd; then + echo "$0 # Skipped: Test can only run on AMD CPU." + echo "$0 # Current cpu vendor is $VENDOR." + exit $ksft_skip +fi + +scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver) +if [ "$scaling_driver" != "amd-pstate" ]; then + echo "$0 # Skipped: Test can only run on amd-pstate driver." + echo "$0 # Current cpufreq scaling drvier is $scaling_driver." + exit $ksft_skip +fi + +msg="Skip all tests:" +if [ ! -w /dev ]; then + echo $msg please run this as root >&2 + exit $ksft_skip +fi + +if ! /sbin/modprobe -q -n amd-pstate-ut; then + echo "amd-pstate-ut: module amd-pstate-ut is not found [SKIP]" + exit $ksft_skip +fi +if /sbin/modprobe -q amd-pstate-ut; then + /sbin/modprobe -q -r amd-pstate-ut + echo "amd-pstate-ut: ok" +else + echo "amd-pstate-ut: [FAIL]" + exit 1 +fi diff --git a/tools/testing/selftests/amd-pstate/config b/tools/testing/selftests/amd-pstate/config new file mode 100644 index 000000000000..f43103c9adc4 --- /dev/null +++ b/tools/testing/selftests/amd-pstate/config @@ -0,0 +1 @@ +CONFIG_X86_AMD_PSTATE_UT=m From patchwork Wed Aug 17 03:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li \(Jassmine\)" X-Patchwork-Id: 598053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39459C25B08 for ; Wed, 17 Aug 2022 03:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238248AbiHQDuB (ORCPT ); Tue, 16 Aug 2022 23:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238167AbiHQDti (ORCPT ); Tue, 16 Aug 2022 23:49:38 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 230B77EFF0; Tue, 16 Aug 2022 20:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MKwmsEQLpYybRAA459Fi6vY09hQi9fw84gPN6swOs8S4gBdD0hd1h1/beYlrnj3KQBG8djgs6+M4PbcYAp/NzzxBf2nAA4u+pFGt6LSynPRjwVSkUl8furs4TakRHH3/sNJA4gS7Hmc5Q2Blsk4zU21t9jopoTI+6Tk6bvgiDMlxJwFpsobpbk3CZ/uSVkAuT8TLIKzm+ZBgVNknA8Shanl3avAaVI7vTnbO16QxHCEf2R6JCn437tzS03iRvBJgMGxg/f/AZiFaBhppMXfRvl3x2CjifE7G5mcmEnDOPx3uJRzrwFe5NyGSHeulmz8fMEzSc7aGc4uYRIAM1+ejnw== 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=OYkbSQC2Wb1E40TC6+os9NHgkzLRNn1CGGGEKK5fN4Q=; b=UgmY/GBB+7YdD/phR5qBFfE95dli99bjrc/+UlNxFc2RWxU1aQKQ2TBylIqvCFY1oxW0XveBAuJhHEDrD4wPtYGbkyRggkEgRRgyciE7i0e+ytOf+GXuC4Mq1MTPDtTSSllZrZnpXfV5PRzQvUqP120ryXpByZfiZwKrDsJmaHNfV+XgvK1qmeNfinBZU7rbV+AsTCkOoixui0TlFB9V5AvZYy1CqzNQYqeZGgm5XrEdMZMB9srJs7D3qwFO0znSqlzMuus+ZpaYhy8iyZJFqUNTN7MTbjZHMHaPLlyEJCnLunhZYv+KjoX2TRwoJvIl6esnBQ0U+M1lYgpKqBxszQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org 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 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=OYkbSQC2Wb1E40TC6+os9NHgkzLRNn1CGGGEKK5fN4Q=; b=Kezp+QCUk9CDqYNrI4Xi1XT1Gc6ooZEAzSWjFuBGIaiTn+xqLZqTiTgoVQy6PBJLCVk+dog1n1FC4huDLupzLyKB0imj6+44fU9WHgBRWAzkhOTgAnsydB8GbFosrsl+hpf2Nk++iiH5D0ID18quLTVdQkgPf4kwjgVAFW0dbYk= Received: from BN9PR03CA0809.namprd03.prod.outlook.com (2603:10b6:408:13f::34) by BYAPR12MB2693.namprd12.prod.outlook.com (2603:10b6:a03:6a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Wed, 17 Aug 2022 03:49:32 +0000 Received: from BN8NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::40) by BN9PR03CA0809.outlook.office365.com (2603:10b6:408:13f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.19 via Frontend Transport; Wed, 17 Aug 2022 03:49:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT085.mail.protection.outlook.com (10.13.176.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5546.7 via Frontend Transport; Wed, 17 Aug 2022 03:49:31 +0000 Received: from jasmine-meng.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.2375.28; Tue, 16 Aug 2022 22:49:02 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Jinzhou Su , Perry Yuan , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [RESEND PATCH 4/4] Documentation: amd-pstate: Add unit test introduction Date: Wed, 17 Aug 2022 11:46:30 +0800 Message-ID: <20220817034630.1172065-5-li.meng@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220817034630.1172065-1-li.meng@amd.com> References: <20220817034630.1172065-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd6ace22-5225-4645-81d6-08da80037e2c X-MS-TrafficTypeDiagnostic: BYAPR12MB2693:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pw4IebPLL/NP4tYcIAmC2ON+4mMlHcrUrypvnHwjhLJlnhlzq21fEwX+MtshLUoOc7yoh5jeDauFSwY/+N9/Rj0FuEHsYuNMxWZmryi3CtQiGgdSonmbs58pGNgdgvX3GGWZ30w8ZGWQI6kTMRn+PStZZ/KT3sqchuSJfILm0YJDcqhV8EYG2O2rgZvMCAc0pM28LBIg/ETE5w2mf88TFm/Ih1O32GLYK5/ZNPeUlqNrvWT78VZ7aJtEb5/nhyZo64d10sjPqRmj4G3Eq/TO/NbWOa+tLcZ+k7XR6GnsKsiIp7TsegMoPYeh5G6TwN7OGTZTo1aKiD/XVwdUX7IVoPw0Z9385EoRKrtuv6KSt3hKdcH37rg1ivfF2ZktFI60S6YgTNcbc2yqkvQ3cwbCmi4J+pDAYvn9mFOG+lm1fsSEAUXpnsCE+tlKRLcoouVzH58ZWWo8DFU9NzFLuJ2WMSinJaRw/DlP9IYcuJLEZUDVXJj7AhXpyH138qWS1riE+Ti6iXLzNRabUerBfkWZyGDFUx1a051Aba83PXtd2U9VHfCMGZhg5QM3MiYmGO+t6EEhMI1VQhO5mF6PDXjjuInT1vW/pdJWhOIv0dTiX1HNuXmOozasRHbaQ7YfXQYWP6gb3QbcjLE5NdiKWoLXLfrh0rjnlLeyuTbdJFUU185gHnNS3QPkZBe+sIyT4XZstNAZiEf02Kw1SUMmJEbFlL92wGE7kZ7ZVB3K2QGqU9+76PXVslJNcuCeZzAKjYKxWQ6f2o46tVvA7z4mBGCdy25BHynu37xggWatkWNT49JP+3njxJ3n1bQJimE95joNmeVmfsAXT8SwQ+KrmZ+c4mQCNnuOMdmDJ6onqHkopKInVycBJikNKyef7T9cPtypd4IrOvqDr/qM/0tiMdz2CODxqcKTyaL0JZG/pUQt4lY= 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:(13230016)(4636009)(376002)(346002)(39860400002)(136003)(396003)(46966006)(40470700004)(36840700001)(2616005)(336012)(356005)(47076005)(82740400003)(8676002)(40480700001)(4326008)(2906002)(36756003)(1076003)(70586007)(81166007)(86362001)(54906003)(186003)(70206006)(110136005)(426003)(36860700001)(316002)(40460700003)(16526019)(5660300002)(83380400001)(966005)(41300700001)(82310400005)(8936002)(6666004)(26005)(478600001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 03:49:31.5668 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd6ace22-5225-4645-81d6-08da80037e2c 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: BN8NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2693 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce the AMD P-State unit test module design and implementation. It also talks about kselftest and how to use. Signed-off-by: Meng Li Acked-by: Huang Rui Reviewed-by: Shuah Khan --- Documentation/admin-guide/pm/amd-pstate.rst | 76 +++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 83b58eb4ab4d..8f3d30c5a0d8 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -182,6 +182,7 @@ to the ``struct sugov_cpu`` that the utilization update belongs to. Then, ``amd-pstate`` updates the desired performance according to the CPU scheduler assigned. +.. _processor_support: Processor Support ======================= @@ -282,6 +283,8 @@ efficiency frequency management method on AMD processors. Kernel Module Options for ``amd-pstate`` ========================================= +.. _shared_mem: + ``shared_mem`` Use a module param (shared_mem) to enable related processors manually with **amd_pstate.shared_mem=1**. @@ -393,6 +396,76 @@ about part of the output. :: CPU_005 712 116384 39 49 166 0.7565 9645075 2214891 38431470 25.1 11.646 469 2.496 kworker/5:0-40 CPU_006 712 116408 39 49 166 0.6769 8950227 1839034 37192089 24.06 11.272 470 2.496 kworker/6:0-1264 +Unit Tests for amd-pstate +------------------------- + +``amd-pstate-ut`` is a test module for testing the ``amd-pstate`` driver. + + * It can help all users to verify their processor support (SBIOS/Firmware or Hardware). + + * Kernel can have a basic function test to avoid the kernel regression during the update. + + * We can introduce more functional or performance tests to align the result together, it will benefit power and performance scale optimization. + +1. Test case decriptions + + +---------+--------------------------------+------------------------------------------------------------------------------------+ + | Index | Functions | Description | + +=========+================================+====================================================================================+ + | 0 | amd_pstate_ut_acpi_cpc_valid || Check whether the _CPC object is present in SBIOS. | + | | || | + | | || The detail refer to `Processor Support `_. | + +---------+--------------------------------+------------------------------------------------------------------------------------+ + | 1 | amd_pstate_ut_check_enabled || Check whether AMD P-State is enabled. | + | | || | + | | || AMD P-States and ACPI hardware P-States always can be supported in one processor. | + | | | But AMD P-States has the higher priority and if it is enabled with | + | | | :c:macro:`MSR_AMD_CPPC_ENABLE` or ``cppc_set_enable``, it will respond to the | + | | | request from AMD P-States. | + +---------+--------------------------------+------------------------------------------------------------------------------------+ + | 2 | amd_pstate_ut_check_perf || Check if the each performance values are reasonable. | + | | || highest_perf >= nominal_perf > lowest_nonlinear_perf > lowest_perf > 0. | + +---------+--------------------------------+------------------------------------------------------------------------------------+ + | 3 | amd_pstate_ut_check_freq || Check if the each frequency values and max freq when set support boost mode | + | | | are reasonable. | + | | || max_freq >= nominal_freq > lowest_nonlinear_freq > min_freq > 0 | + | | || If boost is not active but supported, this maximum frequency will be larger than | + | | | the one in ``cpuinfo``. | + +---------+--------------------------------+------------------------------------------------------------------------------------+ + +#. How to execute the tests + + We use test module in the kselftest frameworks to implement it. + We create amd-pstate-ut module and tie it into kselftest.(for + details refer to Linux Kernel Selftests [4]_). + + 1. Build + + + open the :c:macro:`CONFIG_X86_AMD_PSTATE` configuration option. + + set the :c:macro:`CONFIG_X86_AMD_PSTATE_UT` configuration option to M. + + make project + + make selftest :: + + $ cd linux + $ make -C tools/testing/selftests + + #. Installation & Steps :: + + $ make -C tools/testing/selftests install INSTALL_PATH=~/kselftest + $ sudo ./kselftest/run_kselftest.sh -c amd-pstate + TAP version 13 + 1..1 + # selftests: amd-pstate: amd-pstate-ut.sh + # amd-pstate-ut: ok + ok 1 selftests: amd-pstate: amd-pstate-ut.sh + + #. Results :: + + $ dmesg | grep "amd_pstate_ut" | tee log.txt + [12977.570663] amd_pstate_ut: 1 amd_pstate_ut_acpi_cpc_valid success! + [12977.570673] amd_pstate_ut: 2 amd_pstate_ut_check_enabled success! + [12977.571207] amd_pstate_ut: 3 amd_pstate_ut_check_perf success! + [12977.571212] amd_pstate_ut: 4 amd_pstate_ut_check_freq success! Reference =========== @@ -405,3 +478,6 @@ Reference .. [3] Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip + +.. [4] Linux Kernel Selftests, + https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html