public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device
@ 2015-11-23  7:29 MyungJoo Ham
  2015-11-23  8:51 ` Chanwoo Choi
  0 siblings, 1 reply; 4+ messages in thread
From: MyungJoo Ham @ 2015-11-23  7:29 UTC (permalink / raw)
  To: 최찬우, 박경민
  Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org

>   
>  This patch initialize the freq_table array of each devfreq device by using
> the devfreq_set_freq_table(). If freq_table is NULL, the devfreq framework
> is not able to support the frequency transtion information through sysfs.
> 
> The OPP core uses the integer type for the number of opps in the opp list
> and uses the 'unsigned long' type for each frequency. So, this patch modifies
> the type of some variable as following:
> - the type of freq_table : unsigned int -> unsigned long
> - the type of max_state  : unsigned int -> int
> 
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
[]
> +/**
>   * devfreq_update_status() - Update statistics of devfreq behavior
>   * @devfreq:	the devfreq instance
>   * @freq:	the update target frequency
> @@ -477,7 +516,12 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	devfreq->previous_freq = profile->initial_freq;
>  	devfreq->data = data;
>  	devfreq->nb.notifier_call = devfreq_notifier_call;
> +	mutex_unlock(&devfreq->lock);
>  
> +	if (devfreq->profile->max_state <= 0 && !devfreq->profile->freq_table)
> +		devfreq_set_freq_table(devfreq);
> +
> +	mutex_lock(&devfreq->lock);

Anyway, what about modifying the block above as:

+	if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
+		mutex_unlock(&devfreq->lock);
 		devfreq_set_freq_table(devfreq);
+		mutex_lock(&devfreq->lock);
+	}

>  	devfreq->trans_table =	devm_kzalloc(dev, sizeof(unsigned int) *
>  						devfreq->profile->max_state *
>  						devfreq->profile->max_state,
[]

If that's not a problem, I'll squash
https://git.kernel.org/cgit/linux/kernel/git/mzx/devfreq.git/commit/?h=for-rafael&id=55df2b43cdb5ac82d26b64d739f3d758c9b7486c
with the given patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device
@ 2015-11-23  6:44 MyungJoo Ham
  0 siblings, 0 replies; 4+ messages in thread
From: MyungJoo Ham @ 2015-11-23  6:44 UTC (permalink / raw)
  To: 최찬우, 박경민
  Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org

>  This patch initialize the freq_table array of each devfreq device by using
> the devfreq_set_freq_table(). If freq_table is NULL, the devfreq framework
> is not able to support the frequency transtion information through sysfs.
> 
> The OPP core uses the integer type for the number of opps in the opp list
> and uses the 'unsigned long' type for each frequency. So, this patch modifies
> the type of some variable as following:
> - the type of freq_table : unsigned int -> unsigned long
> - the type of max_state  : unsigned int -> int

I have some comments on this patch described below.

I've created an 'updated' patch based on this at:
https://git.kernel.org/cgit/linux/kernel/git/mzx/devfreq.git/commit/?h=for-rafael&id=9e35a6caf143cd77f14d5e62269ed00ea1775854

It will be applied as suggested on the link above unless you
have strong reason to make max_state signed.

[]
> +static void devfreq_set_freq_table(struct devfreq *devfreq)
> +{
> +	struct devfreq_dev_profile *profile = devfreq->profile;
> +	struct dev_pm_opp *opp;
> +	unsigned long freq;
# -	int i;

+	int i, count;

> +
> +	/* Initialize the freq_table from OPP table */
# -	profile->max_state = dev_pm_opp_get_opp_count(devfreq->dev.parent);
# -	if (profile->max_state <= 0)
# -		return;

+	count = dev_pm_opp_get_opp_count(devfreq->dev.parent);
+	if (count < 0)
+		return;

If dev_pm_opp_get_opp_count() gives us an error (probably, this
device does not support OPP and does not give freq_table for the
statistics support), we do not need to store that error in
profile->max_state. We just need to return. (no need to be
signed.)

[]
> -		len += sprintf(buf + len, "%8u",
> +		len += sprintf(buf + len, "%8ld",
>  				devfreq->profile->freq_table[i]);
[]
> -		len += sprintf(buf + len, "%8u:",
> +		len += sprintf(buf + len, "%8ld:",
>  				devfreq->profile->freq_table[i]);

freq_table is unsigned.


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 0/6] PM / devfreq: Clean code and add set the freq_table array
@ 2015-11-19  8:17 Chanwoo Choi
  2015-11-19  8:17 ` [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device Chanwoo Choi
  0 siblings, 1 reply; 4+ messages in thread
From: Chanwoo Choi @ 2015-11-19  8:17 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park; +Cc: linux-kernel, linux-pm, Chanwoo Choi

This patch-set clean the code for both devfreq and devfreq-event framework
and add the 'freq_table' for devfreq device. After initializing the
'freq_table', the 'trans_stat' sysfs provide the appropriate information.

Chanwoo Choi (6):
  PM / devfreq: event: Remove the error log of devfreq_event_get_edev_by_phandle()
  PM / devfreq: event: Fix the error and warning from script/checkpatch.pl
  PM / devfreq: Add show_one macro to delete the duplicate code
  PM / devfreq: Set the freq_table of devfreq device
  PM / devfreq: Modify the indentation of trans_stat sysfs for readability
  PM / devfreq: Set the min_freq and max_freq of devfreq device

 drivers/devfreq/devfreq-event.c | 16 +++-----
 drivers/devfreq/devfreq.c       | 81 ++++++++++++++++++++++++++++++++---------
 include/linux/devfreq.h         |  4 +-
 3 files changed, 71 insertions(+), 30 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-23  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23  7:29 [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device MyungJoo Ham
2015-11-23  8:51 ` Chanwoo Choi
  -- strict thread matches above, loose matches on Subject: below --
2015-11-23  6:44 MyungJoo Ham
2015-11-19  8:17 [PATCH 0/6] PM / devfreq: Clean code and add set the freq_table array Chanwoo Choi
2015-11-19  8:17 ` [PATCH 4/6] PM / devfreq: Set the freq_table of devfreq device Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox