linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <eduardo.valentin-l0cyMroinI0@public.gmane.org>
To: Wei Ni <wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Eduardo Valentin <eduardo.valentin-l0cyMroinI0@public.gmane.org>,
	"rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
	<rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"mark.rutland-5wv7dgnIgG8@public.gmane.org"
	<mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	"durgadoss.r-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
	<durgadoss.r-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Matthew Longnecker
	<MLongnecker-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	"swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org"
	<swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	"linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2 1/2] thermal: add available policies attribut
Date: Wed, 15 Jan 2014 10:00:55 -0400	[thread overview]
Message-ID: <52D69497.1030903@ti.com> (raw)
In-Reply-To: <52D67066.8010403-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 5666 bytes --]

On 15-01-2014 07:26, Wei Ni wrote:
> On 01/13/2014 11:58 PM, Eduardo Valentin wrote:
>> * PGP Signed by an unknown key
>>
>> On 13-01-2014 07:17, Wei Ni wrote:
>>> 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
>>
>> s/attribut/attribute/g
> 
> oh, thanks, I will fix it.
> 
>>
>>> 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 <wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>>> ---
>>>  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
>>
>> I would prefer:
>> "Available thermal governors for this zone"
> 
> Ok.
> 
>>
>>>      |---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);
>>
>> I would prefer if you'd used scnprintf
>>
>>> +	count += sprintf(buf + count, "\n");
>>
>> ditto.
>>
>>
>> It is unlikely, but What if count if greater than PAGE_SIZE?
> 
> hmm, I checked the sysfs driver, in funciton sysfs_kf_seq_show(), it
> seems it can handle the count greater than PAGE_SIZE.
> Or we can return error here directly.
> What do you think about it?

Just to be aware that it will truncate your buffer:
	/*
	 * The code works fine with PAGE_SIZE return but it's likely to
	 * indicate truncated result or overflow in normal use cases.
	 */
	if (count >= (ssize_t)PAGE_SIZE) {
		print_symbol("fill_read_buffer: %s returned bad count\n",
			(unsigned long)ops->show);
		/* Try to struggle along */
		count = PAGE_SIZE - 1;
	}


So, you either truncate here or leave to sysfs_seq_show(). Leave at
least a comment in case you leave to sysfs layer.

> 
>>
>>> +
>>> +	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;
>>>  
>>>
>>
>>
> 
> 
> 


-- 
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 295 bytes --]

  parent reply	other threads:[~2014-01-15 14:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 11:17 [PATCH v2 0/2] Support to tune governor in run time Wei Ni
2014-01-13 11:17 ` [PATCH v2 1/2] thermal: add available policies attribut Wei Ni
     [not found]   ` <1389611863-7812-2-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-13 15:58     ` Eduardo Valentin
2014-01-15 11:26       ` Wei Ni
     [not found]         ` <52D67066.8010403-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-15 14:00           ` Eduardo Valentin [this message]
     [not found] ` <1389611863-7812-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-13 11:17   ` [PATCH v2 2/2] thermal: add interface to support tune governor in run-time Wei Ni
     [not found]     ` <1389611863-7812-3-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-17  8:22       ` Zhang Rui
2014-01-17  9:32         ` Wei Ni
     [not found]           ` <52D8F8BD.1080700-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-20  1:41             ` Zhang Rui
2014-01-17 16:01         ` Eduardo Valentin
2014-01-13 15:42   ` [PATCH v2 0/2] Support to tune governor in run time Eduardo Valentin
2014-01-13 19:01     ` Matthew Longnecker
2014-01-13 21:33       ` Eduardo Valentin
2014-01-14  4:17         ` Wei Ni
2014-01-14 17:44           ` Eduardo Valentin
     [not found]             ` <52D57762.8070609-l0cyMroinI0@public.gmane.org>
2014-01-15 11:35               ` Wei Ni
     [not found]                 ` <52D67296.7050107-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-15 14:06                   ` Eduardo Valentin
     [not found]           ` <52D4BA76.4040003-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-01-14 17:50             ` Eduardo Valentin
     [not found]               ` <52D57901.5050300-l0cyMroinI0@public.gmane.org>
2014-01-15 11:43                 ` Wei Ni
2014-01-15 14:04                   ` Eduardo Valentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52D69497.1030903@ti.com \
    --to=eduardo.valentin-l0cymroini0@public.gmane.org \
    --cc=MLongnecker-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=durgadoss.r-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).