From patchwork Mon Jan 13 11:17:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Ni X-Patchwork-Id: 3474611 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A7B81C02DC for ; Mon, 13 Jan 2014 11:17:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E9C220107 for ; Mon, 13 Jan 2014 11:17:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6796E200E8 for ; Mon, 13 Jan 2014 11:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865AbaAMLQ6 (ORCPT ); Mon, 13 Jan 2014 06:16:58 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:17170 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbaAMLQy (ORCPT ); Mon, 13 Jan 2014 06:16:54 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Mon, 13 Jan 2014 03:17:02 -0800 Received: from hqemhub02.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 13 Jan 2014 03:16:53 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 13 Jan 2014 03:16:53 -0800 Received: from hkemhub01.nvidia.com (10.18.67.12) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.327.1; Mon, 13 Jan 2014 03:16:54 -0800 Received: from niwei-MCP7A.nvidia.com (10.18.67.6) by hkemhub01.nvidia.com (10.18.67.12) with Microsoft SMTP Server id 8.3.327.1; Mon, 13 Jan 2014 19:16:52 +0800 From: Wei Ni To: , , , CC: , , , , Wei Ni Subject: [PATCH v2 1/2] thermal: add available policies attribut Date: Mon, 13 Jan 2014 19:17:42 +0800 Message-ID: <1389611863-7812-2-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389611863-7812-1-git-send-email-wni@nvidia.com> References: <1389611863-7812-1-git-send-email-wni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Linux thermal framework support to change governor policy in run time, but it can't show what available policies supported. This patch adds available_policies attribut to the thermal framework, it can list the thermal governors which can be used for a particular zone. This attribut is read only. Signed-off-by: Wei Ni --- Documentation/thermal/sysfs-api.txt | 6 ++++++ drivers/thermal/thermal_core.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index 87519cb..6a70b55c 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -172,6 +172,7 @@ Thermal zone device sys I/F, created once it's registered: |---temp: Current temperature |---mode: Working mode of the thermal zone |---policy: Thermal governor used for this zone + |---available_policies Available governors for this zone |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point @@ -238,6 +239,10 @@ policy One of the various thermal governors used for a particular zone. RW, Required +available_policies + Availabe thermal governors which can be used for a particular zone. + RO, Required + trip_point_[0-*]_temp The temperature above which trip point will be fired. Unit: millidegree Celsius @@ -330,6 +335,7 @@ method, the sys I/F structure will be built like this: |---temp: 37000 |---mode: enabled |---policy: step_wise + |---available_policies: step_wise fair_share |---trip_point_0_temp: 100000 |---trip_point_0_type: critical |---trip_point_1_temp: 80000 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 338a88b..aab1df8 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -761,6 +761,24 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf) return sprintf(buf, "%s\n", tz->governor->name); } +static ssize_t +available_policies_show(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct thermal_governor *pos; + ssize_t count = 0; + + mutex_lock(&thermal_governor_lock); + + list_for_each_entry(pos, &thermal_governor_list, governor_list) + count += sprintf(buf + count, "%s ", pos->name); + count += sprintf(buf + count, "\n"); + + mutex_unlock(&thermal_governor_lock); + + return count; +} + #ifdef CONFIG_THERMAL_EMULATION static ssize_t emul_temp_store(struct device *dev, struct device_attribute *attr, @@ -794,6 +812,7 @@ static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(available_policies, S_IRUGO, available_policies_show, NULL); /* sys I/F for cooling device */ #define to_cooling_device(_dev) \ @@ -1527,6 +1546,11 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, if (result) goto unregister; + /* Create available_policies attribute */ + result = device_create_file(&tz->device, &dev_attr_available_policies); + if (result) + goto unregister; + /* Update 'this' zone's governor information */ mutex_lock(&thermal_governor_lock); @@ -1622,6 +1646,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) if (tz->ops->get_mode) device_remove_file(&tz->device, &dev_attr_mode); device_remove_file(&tz->device, &dev_attr_policy); + device_remove_file(&tz->device, &dev_attr_available_policies); remove_trip_attrs(tz); tz->governor = NULL;