From patchwork Wed Apr 13 09:05:08 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: 561140
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 98951C433FE
for ; Wed, 13 Apr 2022 09:06:44 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S234209AbiDMJJD (ORCPT );
Wed, 13 Apr 2022 05:09:03 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47012 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S230012AbiDMJI7 (ORCPT
); Wed, 13 Apr 2022 05:08:59 -0400
Received: from NAM11-CO1-obe.outbound.protection.outlook.com
(mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1853945067;
Wed, 13 Apr 2022 02:06:35 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=Z9Bw2IIWHxpEb/KhCdlQ1aVYKl8gP9w+Fn4V0GTjguCpNgLfISdJgbLMqeR3Z0VxoSHHYFAxVhaj6bmhQxK48no2EFV3R4DzByqve6q9v0qqC67I0l8OgqCE3S3MznZAbHgmg2zMgZWtsExps6Gh4yE0Y9N2FNNZ4AdJB3i82IKoawvQEZhB7WiKUEYkDo0eUjIh1APKTw5GkSBVxk1WjfoOSKrLQY4Iq8nv92tGTQxIwAGrStrG1xb66ZncV4AIgDL2Ev3ickLEaWebT9mxb7zl2p3kphZhnwV2UCkiAk0uiJk9bYAZqDp94u0lckhtyNCt61s2qVw+7E1OJdODFA==
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=b1M/gAui03GK7QWanBmlzhDkBO7xvhEjMyYIWDq8v50=;
b=JMHvVcnh+//0OrJmndtvBcvKqDawkMlN3rVT0JTb40zy16gQ0i55Eb2QAYlBOAbVRdYt5PUmHQmGTqC3emvayBOpWY2bJ28CouDXIgWh1nakCoo8AivNTcVlVkvu3KPNO8ZKTqqUqlslb1o5h5xCqjUAj8+uIX+ldyXtE8UBpKjPSNdjlWEKGBhvahA9SZxGTBSt9nmQtkcoYtVsTfbts/xHkuB9GlWXOZABFK7PNZLJzrmWCFSm7RJsu6K6aKJoH+2SEQ2suYCD4SBwu/891aTQJH4QnoYuUyg5qitocBE5+LVxb2/D4aYJiBcuyApoJuEiJVd3JWRB1y3GY3rfgA==
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=b1M/gAui03GK7QWanBmlzhDkBO7xvhEjMyYIWDq8v50=;
b=F+4tKnrUorRFDESYcHIcokfQgGWm80QgFal7IUC0ScJO9caAfYsJsjchzesXnZiHFVsKVf5i2iELu2ASzeyw40FX9c3zQnNbuA3qJGYuXSqb9G8ULdhpNFr0dDpdLEoLDhPqWiUuDSqxfIxlxSiw+z7HurZ1kG0BucNB+hUPh70=
Received: from BN9PR03CA0412.namprd03.prod.outlook.com (2603:10b6:408:111::27)
by MW5PR12MB5598.namprd12.prod.outlook.com (2603:10b6:303:193::11)
with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Wed, 13 Apr
2022 09:06:32 +0000
Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
(2603:10b6:408:111:cafe::c0) by BN9PR03CA0412.outlook.office365.com
(2603:10b6:408:111::27) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20 via Frontend
Transport; Wed, 13 Apr 2022 09:06: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;
Received: from SATLEXMB04.amd.com (165.204.84.17) by
BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.20.5164.19 via Frontend Transport; Wed, 13 Apr 2022 09:06: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.24; Wed, 13 Apr
2022 04:06:26 -0500
From: Meng Li
To: Shuah Khan ,
"Rafael J . Wysocki" ,
Huang Rui ,
CC: Nathan Fontenot ,
Deepak Sharma ,
Alex Deucher ,
"Mario Limonciello" ,
Jinzhou Su , Perry Yuan ,
Xiaojian Du ,
"Viresh Kumar" ,
Borislav Petkov , ,
Meng Li
Subject: [PATCH 1/3] cpufreq: amd-pstate: Expose struct amd_cpudata
Date: Wed, 13 Apr 2022 17:05:08 +0800
Message-ID: <20220413090510.4039589-2-li.meng@amd.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220413090510.4039589-1-li.meng@amd.com>
References: <20220413090510.4039589-1-li.meng@amd.com>
MIME-Version: 1.0
X-Originating-IP: [10.180.168.240]
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-Office365-Filtering-Correlation-Id: d352b309-ae0b-415e-0122-08da1d2ce693
X-MS-TrafficTypeDiagnostic: MW5PR12MB5598:EE_
X-Microsoft-Antispam-PRVS:
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: syYFovIqM3Wp82a04zOyRSXGEKTvkRIp/z1dmB08CAN8V/4D7ES+4BsOKAXaSOKzbaZ0ermNS5UrCE8Z8o0R4/YCyC4S8/prU41W0KS/YS+YjxMROpN4/SsrBTI8tBpzJyzc9L+sMCCvRREzjopI1Np0zl/vY2ijP8gBj7qpEoJngilP6LymdiynJMdunpaOqoX21J9/KASVQdiCwsyM/K7rDBDaMkcafNTqCC049P4iG6z16l9KG/MvKr3sgEiPSzKv+WfH+65+w76qKO+IjOMrW/rC/24JX/ek/Pk68Wy/Eqz5CYr3ZM4+DySO0grHbj2kpUBf9Ahu31rKZpTcDvSKMuaZvav+XKZEIEaVrOyROFKLnMtgQlaH8fEYcsq/IY3xauoprAnioWLoYcy2STGyzNa8rnnC8UCWSv4iAtQdV6fY+aEooVWWMI47jjfXKVYvhVPvX0WdFIvLUPlzjp5GzwuTmS+gcnUz4+5rVVDZUMgAugFTe987NIS70Q+awUuQ3o5fR5bppewlGI9vsyJv0K64q7vnV7NOMux/vTbaVGUU+SafM63rdkmlJT0l69xvRhr5EUbSRPVrFHJ1AL4XlLMszOvcepv7xdIJRK4jU34BXApAQsKt8Qu1PXaaT/Me73koVHUktx1XWxT0R7aOXTwkbogcIwbXoRuX/b5Yl4tatn2ypdug05TU3/1+trr7+KYuWWgbv5AbzkPR4Q==
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:(13230001)(4636009)(46966006)(36840700001)(40470700004)(36756003)(82310400005)(36860700001)(8676002)(4326008)(336012)(426003)(70206006)(83380400001)(81166007)(2906002)(356005)(5660300002)(40460700003)(2616005)(16526019)(8936002)(26005)(47076005)(508600001)(316002)(1076003)(86362001)(6666004)(7696005)(54906003)(70586007)(110136005)(186003)(36900700001);
DIR:OUT; SFP:1101;
X-OriginatorOrg: amd.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 09:06:30.9881 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: d352b309-ae0b-415e-0122-08da1d2ce693
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: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5598
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
---
MAINTAINERS | 1 +
drivers/cpufreq/amd-pstate.c | 60 +----------------------------
include/linux/amd-pstate.h | 74 ++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 59 deletions(-)
create mode 100644 include/linux/amd-pstate.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 9832b607e2e2..f108e83ba851 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1003,6 +1003,7 @@ S: Supported
F: Documentation/admin-guide/pm/amd-pstate.rst
F: drivers/cpufreq/amd-pstate*
F: tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
+F: include/linux/amd-pstate.h
AMD PTDMA DRIVER
M: Sanjay R Mehta
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7be38bc6a673..5f7a00a64f76 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..790b04c9000b
--- /dev/null
+++ b/include/linux/amd-pstate.h
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/include/linux/amd-pstate.h
+ *
+ * Copyright (C) 2007-2010 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 Apr 13 09:05:09 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: 561139
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 44B2CC433EF
for ; Wed, 13 Apr 2022 09:06:45 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S234208AbiDMJJD (ORCPT );
Wed, 13 Apr 2022 05:09:03 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47060 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S234203AbiDMJJB (ORCPT
); Wed, 13 Apr 2022 05:09:01 -0400
Received: from NAM10-DM6-obe.outbound.protection.outlook.com
(mail-dm6nam10on2042.outbound.protection.outlook.com [40.107.93.42])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6210943482;
Wed, 13 Apr 2022 02:06:37 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=EIiXEnp1JUWnArQbg5Q+tqlXUXRA4d0m5yWIMoOJiDz9VBq7ZY8oTsuazodXu4NI3LkIcgwL3MTxaqSJmylF2DBJ6846Z5Trrx84scDbJAhQi6PeHcUZZFHawjlHDZxwYmm293shZ4fB/MFk3W8MUAeB3UIA8gc+tw0MQ/4fgE+Fz4OAvQInYMWnt4qaQvu4Rg+vTu2OLfh7S4wCbRetyvHb0aj+YJD2xsthBYyPEQoWx1zpbx0Mx6bNhPPiQ5VbfRnRxSUWOEoZQW5p/mbaz5GCaKnE/yOkRBk1eBKIMjZA3hCS9NBKVrhx83XKcN3ragJIzihqJjBAge0bQOHNYw==
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=AFhfwWP2JpSIITtzrxjnNCPm9zXDjiVGb/jIh5bbf2k=;
b=DnCo7kZ6TPJXHS1CT6++F5ePld+m17YocoqiqI2uw63vIkT0gTkveCBxb6zngxkdz3eaYKqD80Gscu1DLDoWd/R73HCvloqZX2m1gVP7UE68CFc15sCnXsw+rTckiC0FjQ8uyYM2cVnzngoIiCozljL3hnnlR/QP5IrHj8WQd0RBJnkXzx5e91AhPwan1ewuYqqyET1PBI4G1eDuLeqXtJ8PcmjoXkoYRFXzDVqz61eE8mKuau8qWsZwPBl+OKy6YSBIgKLXtYF0KiX3cbRCrilf0wlBPgo1CAPmRfS+OOQXN3eFnMjv61+T+FBAcjqyy3/zwmhPqAFf7TksxalclA==
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=AFhfwWP2JpSIITtzrxjnNCPm9zXDjiVGb/jIh5bbf2k=;
b=Ia83ydL8cZnSZ2lZFidi0kcN3PIcdr2hTkIoMpiHqneZK9QGxTLrtqQip+9UczxjMz0wRf2JVCUQSLirO+Cw0LDPi0WWzbcftxZqqjvJs5A7bEYToKhvPF82Kn0XHNfPv88prLn9rbBbv2GnywhjKWl9pbxa18gUui/h4zqiw3w=
Received: from BN9PR03CA0404.namprd03.prod.outlook.com (2603:10b6:408:111::19)
by CH0PR12MB5345.namprd12.prod.outlook.com (2603:10b6:610:d4::11)
with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Wed, 13 Apr
2022 09:06:35 +0000
Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
(2603:10b6:408:111:cafe::cd) by BN9PR03CA0404.outlook.office365.com
(2603:10b6:408:111::19) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20 via Frontend
Transport; Wed, 13 Apr 2022 09:06:35 +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;
Received: from SATLEXMB04.amd.com (165.204.84.17) by
BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.20.5164.19 via Frontend Transport; Wed, 13 Apr 2022 09:06:35 +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.24; Wed, 13 Apr
2022 04:06:30 -0500
From: Meng Li
To: Shuah Khan ,
"Rafael J . Wysocki" ,
Huang Rui ,
CC: Nathan Fontenot ,
Deepak Sharma ,
Alex Deucher ,
"Mario Limonciello" ,
Jinzhou Su , Perry Yuan ,
Xiaojian Du ,
"Viresh Kumar" ,
Borislav Petkov , ,
Meng Li
Subject: [PATCH 2/3] selftests: cpufreq: Add wapper script for test AMD P-State
Date: Wed, 13 Apr 2022 17:05:09 +0800
Message-ID: <20220413090510.4039589-3-li.meng@amd.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220413090510.4039589-1-li.meng@amd.com>
References: <20220413090510.4039589-1-li.meng@amd.com>
MIME-Version: 1.0
X-Originating-IP: [10.180.168.240]
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-Office365-Filtering-Correlation-Id: 61a88996-c496-4887-733b-08da1d2ce8fc
X-MS-TrafficTypeDiagnostic: CH0PR12MB5345:EE_
X-Microsoft-Antispam-PRVS:
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 7E+A1+ATbtt7EEdPRc7EHih6H4LWo112+/AZ97Rr7eDeMe+LvxqRaMgBKqkcfpZr9uLkXOSrE+wVDXrBDTJpQCjXXVzmMzRUlf81fJUrdgwjj4EIBGmj9Oiny/zrNoYdvpVxk0o5q/li9rVs4ec2QEVS958aI5MrReImFRwcXGRd4hOxwZ3ubekn2Xzm0M09tGe2M4l5xUM7lRtSBf0J38mVuq2N/EQAavQTh2M1q7kBJ21NcZ7+lMeHPBJsGxVsV/kcw/bQN+ci9imCo6OeOB3PNNC8AsHj9DiyicMhk6kn6NOJpKHLz//Tw+7B3jaM747FcvYj6rJ+gqSJK0Ioor4vZUMmunKX+oyaHGPTI3TqKqTBT6jz1+eDM+PATkP3pi+PQvw0YRjUkEmEShGuWsT0kkJmVa2q+Rk8s0m6dgT8honMTXGDHGuK1nnXdGEG+5cBmfVR/CC8z7ru35nNK9LE3qrSFP9b8ww8v1ZbqCEI9Ynkr0MNqQr6I2C+RX/IOZJRvGT7ESfFg5qKSPRgoG0LJGD1O28Ee49NpHf+kMPwTFW7DcQs7cHmYe8XbVK25K0qY7rnJzcLSK7SetPN8LmrEdiT8fdYfO5n3ogvatH4SeugLOmtN3JnwEdowIvSFxPKjCuqYKhqQLs+J/g1I3PKqVCbQt8HUeqn/5sYY6Fe5CF3Sq2rO6u80dK4yFvw1mjkgPbYceao2aNvkG43aQ==
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:(13230001)(4636009)(46966006)(40470700004)(36840700001)(40460700003)(26005)(7696005)(6666004)(36756003)(81166007)(2906002)(86362001)(508600001)(82310400005)(5660300002)(8936002)(1076003)(110136005)(316002)(186003)(16526019)(356005)(54906003)(70206006)(426003)(70586007)(336012)(83380400001)(47076005)(4326008)(36860700001)(2616005)(8676002)(36900700001);
DIR:OUT; SFP:1101;
X-OriginatorOrg: amd.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 09:06:35.0346 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 61a88996-c496-4887-733b-08da1d2ce8fc
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: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5345
Precedence: bulk
List-ID:
X-Mailing-List: linux-pm@vger.kernel.org
Adds a wrapper shell script for the amd_pstate_testmod module.
Signed-off-by: Meng Li
---
tools/testing/selftests/cpufreq/Makefile | 2 +-
tools/testing/selftests/cpufreq/amd_pstate_testmod.sh | 4 ++++
tools/testing/selftests/cpufreq/config | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/cpufreq/amd_pstate_testmod.sh
diff --git a/tools/testing/selftests/cpufreq/Makefile b/tools/testing/selftests/cpufreq/Makefile
index c86ca8342222..c32adc59a1f4 100644
--- a/tools/testing/selftests/cpufreq/Makefile
+++ b/tools/testing/selftests/cpufreq/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
all:
-TEST_PROGS := main.sh
+TEST_PROGS := main.sh amd_pstate_testmod.sh
TEST_FILES := cpu.sh cpufreq.sh governor.sh module.sh special-tests.sh
include ../lib.mk
diff --git a/tools/testing/selftests/cpufreq/amd_pstate_testmod.sh b/tools/testing/selftests/cpufreq/amd_pstate_testmod.sh
new file mode 100755
index 000000000000..5398ad568885
--- /dev/null
+++ b/tools/testing/selftests/cpufreq/amd_pstate_testmod.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Tests the AMD P-State unit test infrastructure using amd_pstate_testmod kernel module.
+$(dirname $0)/../kselftest/module.sh "amd_pstate_testmod" amd_pstate_testmod
diff --git a/tools/testing/selftests/cpufreq/config b/tools/testing/selftests/cpufreq/config
index 75e900793e8a..374a8adbb34c 100644
--- a/tools/testing/selftests/cpufreq/config
+++ b/tools/testing/selftests/cpufreq/config
@@ -13,3 +13,4 @@ CONFIG_DEBUG_LOCK_ALLOC=y
CONFIG_PROVE_LOCKING=y
CONFIG_LOCKDEP=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
+CONFIG_AMD_PSTATE_TESTMOD=m
From patchwork Wed Apr 13 09:05:10 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: 563838
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 AF821C43219
for ; Wed, 13 Apr 2022 09:06:46 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S230012AbiDMJJF (ORCPT );
Wed, 13 Apr 2022 05:09:05 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S234210AbiDMJJE (ORCPT
); Wed, 13 Apr 2022 05:09:04 -0400
Received: from NAM12-BN8-obe.outbound.protection.outlook.com
(mail-bn8nam12on2042.outbound.protection.outlook.com [40.107.237.42])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3F4245067;
Wed, 13 Apr 2022 02:06:42 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=O8o3FTn28Fm16hpHJCDTxSUzkPC7O3NEWgj7zoCuVDWkVGEzjRLhT8Cu9UDYlfRJAZk/+AJKRzQibZI0NLJ/jgH04BSLm1yUqO5H48xJDAlCaoU67VzlHIHMHprFMe8erqSeWWS1xRv9L+NYgT61MB6MERuJCUMNbkNcK+Ba4Ji9HU42jUSjzlVmKfQ0zxFbB0W9829P3Kc9vFQBoTMMOdf9n6/BI1AV5H07GUKbckBDXa1rxWJad9vn466AbLrxZtXaR1B4r/VrzPP9/CeUE+kC4F7A206sWNN7UPZ04Ha2bZSIYxi6Td6Oq3uaC7jHbjk/Cjnxgp8TAwU2ymUXFg==
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=IMGb2bXdspLmjc8UBhXEQRf05qd3SYNi93eN/C1xdas=;
b=OuQYh0/oAfRinsMB7S4QsbZnp7calozAUzCuCao1sfa+Rhhs2AFU7PrR4FeM1/fdp04vijS2SHk18SW/1x9v5DjpwhXxOFXP36ZzrL42IDvsJZvcbxXUMLZSXFrJ2Fevoc5YWQryGQgyv9n/X06cYeaPlaLUm8G7Q4371+UV/jNv5oHkbmAUu6SDL7Kxwwgj4PddiwpzhTqzvUaxzgDZ88QA5Yanp1v3wFOh1bk9GDffnU1+9GUz73hv6bYtHQJSc5Ng2osVZq4EGcGAQ8t2H/b+D0AKu+k5UtDrjnIQkRbeKxF5JCpg0UCtOQdacyIlFhUSino14czdoH58C7UjQw==
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=IMGb2bXdspLmjc8UBhXEQRf05qd3SYNi93eN/C1xdas=;
b=o1Kk7fQ84mg83pjxKcbWQjYk39bclODVgZGqIVlsBwNqLvQOfDazRAcp5WUt3rM/hGJYK32FfbUVfXrqIp0HHJwk7smemLZLl61DCKY7BM3GlO8/iaV6/Eleqm9tLvZGta6cMqoelAU7qfp2b5mfuVJp/7wqnFCtE/78PMMHqvY=
Received: from BN9PR03CA0404.namprd03.prod.outlook.com (2603:10b6:408:111::19)
by MWHPR12MB1534.namprd12.prod.outlook.com (2603:10b6:301:10::11)
with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Wed, 13 Apr
2022 09:06:40 +0000
Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
(2603:10b6:408:111:cafe::77) by BN9PR03CA0404.outlook.office365.com
(2603:10b6:408:111::19) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20 via Frontend
Transport; Wed, 13 Apr 2022 09:06:39 +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;
Received: from SATLEXMB04.amd.com (165.204.84.17) by
BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.20.5164.19 via Frontend Transport; Wed, 13 Apr 2022 09:06:39 +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.24; Wed, 13 Apr
2022 04:06:34 -0500
From: Meng Li
To: Shuah Khan ,
"Rafael J . Wysocki" ,
Huang Rui ,
CC: Nathan Fontenot ,
Deepak Sharma ,
Alex Deucher ,
"Mario Limonciello" ,
Jinzhou Su , Perry Yuan ,
Xiaojian Du ,
"Viresh Kumar" ,
Borislav Petkov , ,
Meng Li
Subject: [PATCH 3/3] selftests: cpufreq: Add amd_pstate_testmod kernel module
for testing
Date: Wed, 13 Apr 2022 17:05:10 +0800
Message-ID: <20220413090510.4039589-4-li.meng@amd.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220413090510.4039589-1-li.meng@amd.com>
References: <20220413090510.4039589-1-li.meng@amd.com>
MIME-Version: 1.0
X-Originating-IP: [10.180.168.240]
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-Office365-Filtering-Correlation-Id: 356f08bc-4e0c-4c0b-7ec9-08da1d2ceba1
X-MS-TrafficTypeDiagnostic: MWHPR12MB1534:EE_
X-Microsoft-Antispam-PRVS:
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: H7I0V+4dlOggipgZ1saZAggM6TgK0QguSu9iCJBpnubPP1FaL/uEUrzb0d9aKBgQIA45z4kv9VVpNiMoJ8c7goSMScRHxENZm8Q2nZnCVxmPK4mqvaVm9pw+mZGvtSKkfRiLmP4R3uPe8tbxinonQTMTSDZ4AFIjf+qT+LRZAXp70giSfiAR58uD7saY3nD0hQI9NOG6gvUju82808Ugzy6CC4S+JqN6M+3WvmSXKceHNZ2GjIApgDcfHZtD69ofYMPmr1YL6eLSU6rzBMxMKizEy9YYBcUo/7q/6xjoC955J81habBMH9LPToXeGmSzWU/4qrH7YLT0CP7HTLb5l2sL8fkaSgMtBNbe14nJGAm6ntD9BkhBbM2nC94RLm4OPvZaUm1Vz4M9nGPIQTZj3yKNGoy2nzoeAiW8226fp5HXr9LbdMSTDY4LUhwhSStiearJnPmRXkdrHlBcpD4mleNQlZYv1IZzZkeH9nl9ZvnYORvBKIDYVZokFdadvO0ZB8My1l4OKeAURA2W4eA/31xX1zwNRPa2gezufpKv6Z90jcbEdd0cyHIjaoTQEOgAGKGWxJ1pzEzCqMaKtwOYAw5yJu1BhrmN3PHz3x9unfXSzPmp7mgny1F0Jlfa8xXIOf14uLTwQNU0SGv8aNCVUFu0qu4ZBmbasjgwxyGgaILm35WBdwYZUNRLnat9R2topboRRo4T8zQ93aNfol/w9w==
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:(13230001)(4636009)(40470700004)(46966006)(36840700001)(186003)(6666004)(26005)(8676002)(16526019)(40460700003)(70206006)(316002)(82310400005)(54906003)(36756003)(36860700001)(110136005)(81166007)(86362001)(70586007)(4326008)(356005)(83380400001)(47076005)(7696005)(2906002)(426003)(336012)(8936002)(5660300002)(508600001)(1076003)(2616005)(36900700001);
DIR:OUT; SFP:1101;
X-OriginatorOrg: amd.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 09:06:39.4717 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 356f08bc-4e0c-4c0b-7ec9-08da1d2ceba1
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: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1534
Precedence: bulk
List-ID:
X-Mailing-List: linux-pm@vger.kernel.org
Add amd_pstate_testmod module, which is conceptually out-of-tree module and
provides ways for selftests/cpufreq amd pstate driver to test various
kernel module-related functionality. This module will be expected by some
of selftests to be present and loaded.
Signed-off-by: Meng Li
---
.../cpufreq/amd_pstate_testmod/Makefile | 20 ++
.../amd_pstate_testmod/amd_pstate_testmod.c | 302 ++++++++++++++++++
2 files changed, 322 insertions(+)
create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile
create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c
diff --git a/tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile b/tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile
new file mode 100644
index 000000000000..8a5596cb2c18
--- /dev/null
+++ b/tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile
@@ -0,0 +1,20 @@
+AMD_PSTATE_TESTMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
+KDIR ?= $(abspath $(AMD_PSATE_TESTMOD_DIR)/../../../../..)
+
+ifeq ($(V),1)
+Q =
+else
+Q = @
+endif
+
+MODULES = amd_pstate_testmod.ko
+
+obj-m += amd_pstate_testmod.o
+CFLAGS_amd_pstate_testmod.o = -I$(src)
+
+all:
+ +$(Q)make -C $(KDIR) M=$(AMD_PSTATE_TESTMOD_DIR) modules
+
+clean:
+ +$(Q)make -C $(KDIR) M=$(AMD_PSTATE_TESTMOD_DIR) clean
+
diff --git a/tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c b/tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c
new file mode 100644
index 000000000000..a892cecf19da
--- /dev/null
+++ b/tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c
@@ -0,0 +1,302 @@
+// 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
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "../../kselftest_module.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+/*
+ * Abbreviations:
+ * aput: used as a shortform for AMD P-State unit test.
+ * It helps to keep variable names smaller, simpler
+*/
+
+KSTM_MODULE_GLOBALS();
+
+/*
+ * Kernel module for testing the AMD P-State unit test
+ */
+enum aput_result {
+ APUT_RESULT_PASS, //0
+ APUT_RESULT_FAIL, //
+ MAX_APUT_RESULT,
+};
+
+struct aput_struct {
+ const char *name;
+ void (*func)(u32 index);
+ enum aput_result result;
+};
+
+static void aput_x86_vendor(u32 index);
+static void aput_acpi_cpc(u32 index);
+static void aput_modprobed_driver(u32 index);
+static void aput_capability_check(u32 index);
+static void aput_enable(u32 index);
+static void aput_init_perf(u32 index);
+static void aput_support_boost(u32 index);
+
+static struct aput_struct aput_cases[] = {
+ {"x86_vendor", aput_x86_vendor },
+ {"acpi_cpc_valid", aput_acpi_cpc },
+ {"modprobed_driver", aput_modprobed_driver },
+ {"capability_check", aput_capability_check },
+ {"enable", aput_enable },
+ {"init_perf", aput_init_perf },
+ {"support_boost", aput_support_boost }
+};
+
+static bool get_shared_mem(void)
+{
+ bool result = false;
+ char buf[5] = {0};
+ struct file *filp = NULL;
+ loff_t pos = 0;
+ ssize_t ret;
+
+ filp = filp_open("/sys/module/amd_pstate/parameters/shared_mem", FMODE_PREAD, 0);
+ if (IS_ERR(filp))
+ {
+ pr_err("%s Open param file fail! \n", __func__);
+ }
+ else
+ {
+ ret = kernel_read(filp, &buf, sizeof(buf), &pos);
+ if (ret < 0)
+ {
+ pr_err("%s ret=%ld unable to read from param file! \n", __func__, ret);
+ }
+ filp_close(filp, NULL);
+ }
+
+ if ('Y' == *buf)
+ {
+ result = true;
+ }
+
+ return (result);
+}
+
+static void aput_x86_vendor(u32 index)
+{
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ }
+}
+
+static void aput_acpi_cpc(u32 index)
+{
+ if (acpi_cpc_valid())
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ }
+}
+
+static void aput_modprobed_driver(u32 index)
+{
+ if (cpufreq_get_current_driver())
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ }
+}
+
+static void aput_capability_check(u32 index)
+{
+ if (boot_cpu_has(X86_FEATURE_CPPC))
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ //shared memory
+ if (get_shared_mem())
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ }
+ }
+}
+
+static void aput_pstate_enable(u32 index)
+{
+ int ret = 0;
+ u64 cppc_enable = 0;
+
+ ret = rdmsrl_safe(MSR_AMD_CPPC_ENABLE, &cppc_enable);
+ if (ret)
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ pr_err("%s rdmsrl_safe MSR_AMD_CPPC_ENABLE ret=%d is error! \n", __func__, ret);
+ return;
+ }
+ if (cppc_enable)
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ }
+}
+
+static void aput_enable(u32 index)
+{
+ if (get_shared_mem())
+ {
+ //not check
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_pstate_enable(index);
+ }
+}
+
+static void aput_init_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;
+
+ //get perf
+ highest_perf = amd_get_highest_perf();
+
+ for_each_possible_cpu(cpu)
+ {
+ //get amd cpudata
+ 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)
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ pr_err("%s cppc_get_perf_caps ret=%d is 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)
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ pr_err("%s rdmsrl_safe_on_cpu MSR_AMD_CPPC_CAP1 ret=%d is error! \n", __func__, ret);
+ return;
+ }
+
+ //get perf from MSR
+ nominal_perf = AMD_CPPC_NOMINAL_PERF(cap1);
+ lowest_nonlinear_perf = AMD_CPPC_LOWNONLIN_PERF(cap1);
+ lowest_perf = AMD_CPPC_LOWEST_PERF(cap1);
+ }
+
+ //check highest_perf,nominal_perf,lowest_nonlinear_perf
+ 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)))
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ pr_err("%s cpu%d highest_perf=%d %d nominal_perf=%d %d lowest_nonlinear_perf=%d %d lowest_perf=%d %d are not 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;
+ }
+ }
+
+ aput_cases[index].result = APUT_RESULT_PASS;
+}
+
+static void aput_support_boost(u32 index)
+{
+ int cpu = 0;
+ struct cpufreq_policy *policy = NULL;
+ struct amd_cpudata *cpudata = NULL;
+
+ for_each_possible_cpu(cpu)
+ {
+ //get amd cpudata
+ policy = cpufreq_cpu_get(cpu);
+ if (!policy)
+ break;
+ cpudata = policy->driver_data;
+
+ if (READ_ONCE(cpudata->boost_supported))
+ {
+ aput_cases[index].result = APUT_RESULT_PASS;
+ }
+ else
+ {
+ aput_cases[index].result = APUT_RESULT_FAIL;
+ break;
+ }
+ }
+}
+
+static void aput_do_test_case(void)
+{
+ u32 i=0, arr_size = ARRAY_SIZE(aput_cases);
+
+ for (i = 0; i < arr_size; i++)
+ {
+ pr_info("****** Begin %-5d\t %-20s\t ******\n", i+1, aput_cases[i].name);
+ aput_cases[i].func(i);
+ KSTM_CHECK_ZERO(aput_cases[i].result);
+ pr_info("****** End %-5d\t %-20s\t ******\n", i+1, aput_cases[i].name);
+ }
+}
+
+static void __init selftest(void)
+{
+ aput_do_test_case();
+}
+
+KSTM_MODULE_LOADERS(amd_pstate_testmod);
+MODULE_AUTHOR("Meng Li ");
+MODULE_DESCRIPTION("Unit test for AMD P-state driver");
+MODULE_LICENSE("GPL");