Message ID | 20221110175847.3098728-9-Perry.Yuan@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp295165wru; Thu, 10 Nov 2022 10:09:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM5IHa35KCUaKyW2c+oiXeO8xFDyfhZzkFU0JSax4mzYUXHQXqzZ8yl4PdgOlRnGxbqbk2v9 X-Received: by 2002:a17:906:ad9:b0:78d:b6ea:174e with SMTP id z25-20020a1709060ad900b0078db6ea174emr3332147ejf.95.1668103745935; Thu, 10 Nov 2022 10:09:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668103745; cv=pass; d=google.com; s=arc-20160816; b=ZZZcCdP6vfUH5337ttutrXwICw0iP4m+4Oov1trrQuavSfht92UaKqinkwvFNQhXIz IiayljK2qQmte0BoU0ffQAOTemqxaRUGTyJZWV1heAqcQxw0kUUrQWdeQbKqBVaYsvHi Gdi+6Ut5oKPsGZ0tENUZCtGaqwm9ayBoYRs+D8JlxCsLbZId0HOU+OeH0AOkh6bYZkqE 9p9FmaaZS8OEZpgEZx78CKlLZr0TFn2v20bHx8tqC8aPcO1p3+bx9msSMBPWOGTZ0H97 ohA77tWPALweAxMnR8ZzAEs/H50hBzbWE1df/ahjHTEVJSbjxNZYm/dQ0qbPF/E/ibEA CPlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=DYMU7wedICZUltMSm744X/ZkFd75E+ZLSRCMDOPSv4owXakwMpXQvenSuRqV0c5iNR keFfy9JS/ciUWFkpBjJvg7Keq9NdcEFSPycepno3O/deCgES0VXm/pqxK6ZNAHY7AWqp OsDvWkmjog4y4Zp6ihuo9g0rt/1BMi8EE/wTnmDhL8+8jyx+aKzE31EwwD6j07QtaPIW xWEnkyuGBwk2/fUOfdB6lsLtB2jt42wukUjmkFDllEU7jxlZ02t8ArqZtV3aG3H2yzWQ oo/R2FvkVJvYF+wxo1CTNMn8YsHIO1ggfAROW4+T5M+hkplq+iZvWmGvSXn6LmA4X+D/ o3pA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cd00ybCK; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb7-20020a170907160700b007ae743c61ccsi12286635ejc.848.2022.11.10.10.08.41; Thu, 10 Nov 2022 10:09:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cd00ybCK; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231702AbiKJSAp (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 13:00:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiKJSAD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 13:00:03 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E674D5F1; Thu, 10 Nov 2022 09:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VFzaPlgkDXgEx+6mUZF3ckPD5YnSoctMAOwy5o5u+CBoj2YJGPmILQ24iAPmPupZzZoOM+bG0IScqTarNtaIo7xe5gSBQAX1nKuy9F2ZvGKV8PBW/sgNLZS/gxT6a6FULwCrZUSoHiIhPdhhq1fP7vKJ/zCEZwMKS0pHqFXwJP9eXP7ZqclcDOfMnXuxM3A55B2RzFjrtgoTkkVbvqfTLXsKF5hBlmMalPrht4eDrUTkOwRah8C5wh7ELF8Rs8b+per1dC8O0vZWfhEZLfAXffCD5Knh8SQ8d0MnR2yz9/oHoE0DCruZfn/Zjcg31KDY8G35CeWbfRJmqAkuNswsEg== 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=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=EtPNEk0yAhszdEzjdKxQU+cjDh9xZDPH8f8ifDorY7CvZDjz1SNmZ5Po80IK7XitwgiOGIjMCJCem//3f+CU316Gy6f8oMYkcVnR++fJ1Pey0Y3e9rbOMqcuQ8hWnTgJbmnkoxgp9/bP7+bLI2gtJGuBdQ8HSAqDngL7RZr9s+xYCKs/R0dntPHqwvQw5JpcV84iFsUqqM2KGJVR8GO5NS3Tab5X3JFLAgWeDP4L9Ob/v4cDtD4kCUgyRl4yYPAmWQMdI+AwlMqESnYlJXctIcOOropq5pheNf008IhdTEWkbgyYesRmwOIysY4JukhZeA6MjTVKkRLCp41u91hOqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none 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=h0Vg++G6NTCpEK3CPxdr1P7oz16Ijhl8gM43pSpJxi0=; b=Cd00ybCKl399H+E/B1wnopehOKsVBMkIS6/EnRp++F/IWYlAtcWOPWXCYwdvH+TsOsJSH4ThRxKEScVUgkXCsZTpGmMlPW3LtHvYIDkpdCFBmrLrsOiMf74ZANdM7uDi4GQt4LSEQ7jFUGlkOIuqT6ZeKi/S53+qYufTRaVIefs= Received: from BN9PR03CA0168.namprd03.prod.outlook.com (2603:10b6:408:f4::23) by DM4PR12MB7575.namprd12.prod.outlook.com (2603:10b6:8:10d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 17:59:42 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::33) by BN9PR03CA0168.outlook.office365.com (2603:10b6:408:f4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Thu, 10 Nov 2022 17:59:41 +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 BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 17:59:41 +0000 Received: from pyuan-Cloudripper.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.31; Thu, 10 Nov 2022 11:59:38 -0600 From: Perry Yuan <Perry.Yuan@amd.com> To: <rafael.j.wysocki@intel.com>, <Mario.Limonciello@amd.com>, <ray.huang@amd.com>, <viresh.kumar@linaro.org> CC: <Deepak.Sharma@amd.com>, <Nathan.Fontenot@amd.com>, <Alexander.Deucher@amd.com>, <Shimmer.Huang@amd.com>, <Xiaojian.Du@amd.com>, <Li.Meng@amd.com>, <wyes.karny@amd.com>, <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Perry Yuan <Perry.Yuan@amd.com> Subject: [PATCH v4 8/9] cpufreq: amd_pstate: add driver working mode status sysfs entry Date: Fri, 11 Nov 2022 01:58:46 +0800 Message-ID: <20221110175847.3098728-9-Perry.Yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221110175847.3098728-1-Perry.Yuan@amd.com> References: <20221110175847.3098728-1-Perry.Yuan@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-TrafficTypeDiagnostic: BN8NAM11FT005:EE_|DM4PR12MB7575:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cb6216d-e96f-418a-d98e-08dac34557ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yjAyGGgTmT1W6RpohkG0NVB5OLBds/gnAV1rJZ9HDljs664kgw1Q+JLBxPrSWXLbhp5rTMYxilUleWLp75EypGJ25fCidRQdKMXNu60MDUesxoYiUtHhF7CoKNlCiauZGcsqIsWbMKKzJQpHFiZW014AJ6ueIK32LU0SiU7GNkr5ZiEsfPeGanc71q1niYEi+ufMMV7btkvDTeQOEEiiPLgye7YAXi6AFSfO+4mjg1TSzbYg3yUTdi6juDaEb6gc1Atx1sIhqItBwmDjEFcLL8ngXibkO5qIm0jXj9oxXWfhmUeBJ9UnQOQsYKIOp9q9F67STrIPs1eb0+Ita+4HhCMppZnZ3dQjUIXJL3e6RvHdIl+M/3FsIiTJbu7nRb6OlGTIWeUXeIiP3s9LQgYSbmvPkbhd9JY6ACe0xibQ5mNbR4LZWgIKjWpOeu/pa8XzeaBMe7kdvduq4NAJTkk4DSY/h8d5EaFfFuHgUEsGO3U5l0hnBgTKEy8RFcqBhZt8QCUBCNV6In19ToGPLaWf4lbNnO7YYgQyDXvjJcE1nTlIrJWu4k2uVpKqLsA+x/TUHybb7aLwU/WEngXzUkbjY7Cia2DrqAahRXwW1m/p3179BlYHLKJWoYExfUYZ9wiGGTvZb45sF4Isgu5SvWrDohysX+HbRIGfaZL8zfjWQr88v3wuhjKUP65vFY/+mMkJMg8tBT4AlUwgYuJTD7mZpwH2/dm9vNEyuqnx4VwCQ04RDGgTgqeKsDPlCA3mygCZuYn2/PKWrv1Grtdd5wRsuy44GzcgpcLacHGz1/oI06A= 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(46966006)(36840700001)(40470700004)(40460700003)(356005)(6666004)(86362001)(426003)(82310400005)(2906002)(1076003)(16526019)(47076005)(70586007)(36756003)(82740400003)(4326008)(81166007)(83380400001)(336012)(41300700001)(36860700001)(70206006)(110136005)(26005)(2616005)(7696005)(186003)(8676002)(54906003)(8936002)(5660300002)(316002)(478600001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 17:59:41.7114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cb6216d-e96f-418a-d98e-08dac34557ae 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: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7575 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749133553163142221?= X-GMAIL-MSGID: =?utf-8?q?1749133553163142221?= |
Series |
Implement AMD Pstate EPP Driver
|
|
Commit Message
Yuan, Perry
Nov. 10, 2022, 5:58 p.m. UTC
While amd-pstate driver was loaded with specific driver mode, it will
need to check which mode is enabled for the pstate driver,add this sysfs
entry to show the current status
$ cat /sys/devices/system/cpu/amd-pstate/status
active
Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
drivers/cpufreq/amd-pstate.c | 44 ++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
Comments
On 11/10/2022 11:58, Perry Yuan wrote: > While amd-pstate driver was loaded with specific driver mode, it will > need to check which mode is enabled for the pstate driver,add this sysfs > entry to show the current status > > $ cat /sys/devices/system/cpu/amd-pstate/status > active > > Signed-off-by: Perry Yuan <Perry.Yuan@amd.com> > --- > drivers/cpufreq/amd-pstate.c | 44 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index b71bfbbb7639..6a3b610cb084 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -65,6 +65,8 @@ static int cppc_load __initdata; > static int epp_off __initdata; > > static struct cpufreq_driver *default_pstate_driver; > +static struct cpufreq_driver amd_pstate_epp_driver; > +static struct cpufreq_driver amd_pstate_driver; > static struct amd_cpudata **all_cpu_data; > > static struct amd_pstate_params global_params; > @@ -798,6 +800,46 @@ static ssize_t store_boost(struct kobject *a, > return count; > } > > +static ssize_t amd_pstate_show_status(char *buf) > +{ > + if (!default_pstate_driver) > + return sprintf(buf, "off\n"); > + > + return sprintf(buf, "%s\n", default_pstate_driver == &amd_pstate_epp_driver ? > + "active" : "passive"); > +} For new code I believe you should use the new helper sysfs_emit() instead. > + > +static int amd_pstate_update_status(const char *buf, size_t size) > +{ > + /* FIXME! */ > + return -EOPNOTSUPP; > +} > + > +static ssize_t show_status(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + ssize_t ret; > + > + mutex_lock(&amd_pstate_driver_lock); > + ret = amd_pstate_show_status(buf); > + mutex_unlock(&amd_pstate_driver_lock); > + > + return ret; > +} > + > +static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, > + const char *buf, size_t count) > +{ > + char *p = memchr(buf, '\n', count); > + int ret; > + > + mutex_lock(&amd_pstate_driver_lock); > + ret = amd_pstate_update_status(buf, p ? p - buf : count); > + mutex_unlock(&amd_pstate_driver_lock); > + > + return ret < 0 ? ret : count; > +} > + > cpufreq_freq_attr_ro(amd_pstate_max_freq); > cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); > > @@ -805,6 +847,7 @@ cpufreq_freq_attr_ro(amd_pstate_highest_perf); > cpufreq_freq_attr_rw(energy_performance_preference); > cpufreq_freq_attr_ro(energy_performance_available_preferences); > define_one_global_rw(boost); > +define_one_global_rw(status); > > static struct freq_attr *amd_pstate_attr[] = { > &amd_pstate_max_freq, > @@ -824,6 +867,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { > > static struct attribute *pstate_global_attributes[] = { > &boost.attr, > + &status.attr, > NULL > }; >
[AMD Official Use Only - General] > -----Original Message----- > From: Limonciello, Mario <Mario.Limonciello@amd.com> > Sent: Tuesday, November 15, 2022 6:30 AM > To: Yuan, Perry <Perry.Yuan@amd.com>; rafael.j.wysocki@intel.com; Huang, > Ray <Ray.Huang@amd.com>; viresh.kumar@linaro.org > Cc: Sharma, Deepak <Deepak.Sharma@amd.com>; Fontenot, Nathan > <Nathan.Fontenot@amd.com>; Deucher, Alexander > <Alexander.Deucher@amd.com>; Huang, Shimmer > <Shimmer.Huang@amd.com>; Du, Xiaojian <Xiaojian.Du@amd.com>; Meng, > Li (Jassmine) <Li.Meng@amd.com>; Karny, Wyes <Wyes.Karny@amd.com>; > linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH v4 8/9] cpufreq: amd_pstate: add driver working mode > status sysfs entry > > On 11/10/2022 11:58, Perry Yuan wrote: > > While amd-pstate driver was loaded with specific driver mode, it will > > need to check which mode is enabled for the pstate driver,add this > > sysfs entry to show the current status > > > > $ cat /sys/devices/system/cpu/amd-pstate/status > > active > > > > Signed-off-by: Perry Yuan <Perry.Yuan@amd.com> > > --- > > drivers/cpufreq/amd-pstate.c | 44 > ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 44 insertions(+) > > > > diff --git a/drivers/cpufreq/amd-pstate.c > > b/drivers/cpufreq/amd-pstate.c index b71bfbbb7639..6a3b610cb084 > 100644 > > --- a/drivers/cpufreq/amd-pstate.c > > +++ b/drivers/cpufreq/amd-pstate.c > > @@ -65,6 +65,8 @@ static int cppc_load __initdata; > > static int epp_off __initdata; > > > > static struct cpufreq_driver *default_pstate_driver; > > +static struct cpufreq_driver amd_pstate_epp_driver; static struct > > +cpufreq_driver amd_pstate_driver; > > static struct amd_cpudata **all_cpu_data; > > > > static struct amd_pstate_params global_params; @@ -798,6 +800,46 @@ > > static ssize_t store_boost(struct kobject *a, > > return count; > > } > > > > +static ssize_t amd_pstate_show_status(char *buf) { > > + if (!default_pstate_driver) > > + return sprintf(buf, "off\n"); > > + > > + return sprintf(buf, "%s\n", default_pstate_driver == > &amd_pstate_epp_driver ? > > + "active" : "passive"); > > +} > > For new code I believe you should use the new helper sysfs_emit() instead. Make sense, changed in v5. Thanks . Perry. > > > + > > +static int amd_pstate_update_status(const char *buf, size_t size) { > > + /* FIXME! */ > > + return -EOPNOTSUPP; > > +} > > + > > +static ssize_t show_status(struct kobject *kobj, > > + struct kobj_attribute *attr, char *buf) { > > + ssize_t ret; > > + > > + mutex_lock(&amd_pstate_driver_lock); > > + ret = amd_pstate_show_status(buf); > > + mutex_unlock(&amd_pstate_driver_lock); > > + > > + return ret; > > +} > > + > > +static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, > > + const char *buf, size_t count) { > > + char *p = memchr(buf, '\n', count); > > + int ret; > > + > > + mutex_lock(&amd_pstate_driver_lock); > > + ret = amd_pstate_update_status(buf, p ? p - buf : count); > > + mutex_unlock(&amd_pstate_driver_lock); > > + > > + return ret < 0 ? ret : count; > > +} > > + > > cpufreq_freq_attr_ro(amd_pstate_max_freq); > > cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); > > > > @@ -805,6 +847,7 @@ cpufreq_freq_attr_ro(amd_pstate_highest_perf); > > cpufreq_freq_attr_rw(energy_performance_preference); > > cpufreq_freq_attr_ro(energy_performance_available_preferences); > > define_one_global_rw(boost); > > +define_one_global_rw(status); > > > > static struct freq_attr *amd_pstate_attr[] = { > > &amd_pstate_max_freq, > > @@ -824,6 +867,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { > > > > static struct attribute *pstate_global_attributes[] = { > > &boost.attr, > > + &status.attr, > > NULL > > }; > >
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b71bfbbb7639..6a3b610cb084 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -65,6 +65,8 @@ static int cppc_load __initdata; static int epp_off __initdata; static struct cpufreq_driver *default_pstate_driver; +static struct cpufreq_driver amd_pstate_epp_driver; +static struct cpufreq_driver amd_pstate_driver; static struct amd_cpudata **all_cpu_data; static struct amd_pstate_params global_params; @@ -798,6 +800,46 @@ static ssize_t store_boost(struct kobject *a, return count; } +static ssize_t amd_pstate_show_status(char *buf) +{ + if (!default_pstate_driver) + return sprintf(buf, "off\n"); + + return sprintf(buf, "%s\n", default_pstate_driver == &amd_pstate_epp_driver ? + "active" : "passive"); +} + +static int amd_pstate_update_status(const char *buf, size_t size) +{ + /* FIXME! */ + return -EOPNOTSUPP; +} + +static ssize_t show_status(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + ssize_t ret; + + mutex_lock(&amd_pstate_driver_lock); + ret = amd_pstate_show_status(buf); + mutex_unlock(&amd_pstate_driver_lock); + + return ret; +} + +static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) +{ + char *p = memchr(buf, '\n', count); + int ret; + + mutex_lock(&amd_pstate_driver_lock); + ret = amd_pstate_update_status(buf, p ? p - buf : count); + mutex_unlock(&amd_pstate_driver_lock); + + return ret < 0 ? ret : count; +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); @@ -805,6 +847,7 @@ cpufreq_freq_attr_ro(amd_pstate_highest_perf); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); define_one_global_rw(boost); +define_one_global_rw(status); static struct freq_attr *amd_pstate_attr[] = { &amd_pstate_max_freq, @@ -824,6 +867,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = { static struct attribute *pstate_global_attributes[] = { &boost.attr, + &status.attr, NULL };