mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Quentin Perret <quentin.perret@linaro.org>
Cc: rjw@rjwysocki.net, linux-kernel@vger.kernel.org,
	viresh.kumar@linaro.org, Chris Redpath <chris.redpath@linaro.org>,
	Amit Kucheria <amit.kucheria@linaro.org>,
	Nicolas Dechesne <nicolas.dechesne@linaro.org>,
	Niklas Cassel <niklas.cassel@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH V3 2/2] base/drivers/arch_topology: Default dmips-mhz if they are not set in DT
Date: Mon, 26 Nov 2018 11:08:42 +0100	[thread overview]
Message-ID: <97f85a4b-efb6-b26f-94d0-cd538c83a03e@linaro.org> (raw)
In-Reply-To: <20181126095224.i5se3n5lavww4a2n@queper01-ThinkPad-T460s>

On 26/11/2018 10:52, Quentin Perret wrote:
> On Monday 26 Nov 2018 at 09:44:21 (+0100), Daniel Lezcano wrote:
>> In the case of asymmetric SoC with the same micro-architecture, we
>> have a group of CPUs with smaller OPPs than the other group. One
>> example is the 96boards dragonboard 820c. There is no dmips/MHz
>> difference between both groups, so no need to specify the values in
>> the DT. Unfortunately, without these defined, there is no scaling
>> capacity computation triggered, so we need to write
>> 'capacity-dmips-mhz' for each CPU with the same value in order to
>> force the scaled capacity computation.
>>
>> In order to fix this situation, allocate 'raw_capacity' so the pointer
>> is set and the init_cpu_capacity_callback() function can be called.
>>
>> This was tested on db820c:
>>  - specified values in the DT (correct results)
>>  - partial values defined in the DT (error + fallback to defaults)
>>  - no specified values in the DT (correct results)
>>
>> correct results are:
>>   cat /sys/devices/system/cpu/cpu*/cpu_capacity
>>    758
>>    758
>>   1024
>>   1024
>>
>>   ... respectively for CPU0, CPU1, CPU2 and CPU3.
>>
>> That reflects the capacity for the max frequencies 1593600 and 2150400.
>>
>> Cc: Chris Redpath <chris.redpath@linaro.org>
>> Cc: Quentin Perret <quentin.perret@linaro.org>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> Cc: Amit Kucheria <amit.kucheria@linaro.org>
>> Cc: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>> Cc: Niklas Cassel <niklas.cassel@linaro.org>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
>>  drivers/base/arch_topology.c | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
>> index fd5325b..e0c5b60 100644
>> --- a/drivers/base/arch_topology.c
>> +++ b/drivers/base/arch_topology.c
>> @@ -243,9 +243,20 @@ static int __init register_cpufreq_notifier(void)
>>  	 * until we have the necessary code to parse the cpu capacity, so
>>  	 * skip registering cpufreq notifier.
>>  	 */
>> -	if (!acpi_disabled || !raw_capacity)
>> +	if (!acpi_disabled)
>>  		return -EINVAL;
>>  
>> +	if (!raw_capacity) {
>> +
>> +		pr_info("cpu_capacity: No capacity defined in DT, set default "
>> +		       "values to %ld\n", SCHED_CAPACITY_SCALE);
>> +
>> +		raw_capacity = kmalloc_array(num_possible_cpus(),
>> +					     sizeof(*raw_capacity), GFP_KERNEL);
>> +		if (!raw_capacity)
>> +			return -ENOMEM;
>> +	}
>> +
>>  	if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) {
>>  		pr_err("cpu_capacity: failed to allocate memory for cpus_to_visit\n");
>>  		return -ENOMEM;
>> -- 
>> 2.7.4
> 
> With this, if the DT is partially filled, we will still do the frequency
> scaling thing now right ?

Right, if the DT is partially filled. We end up with the error, the
raw_capacity is free and set to NULL.

register_cpufreq_notifier() will allocate it and the capacity is computed.

> I'm not sure if this is the expected behaviour. If the DT is partially
> filled, we probably want to have 1024 of capacity for all CPUs to match
> the doc.

Yes if they have the same number of OPP which is the case of 99% of the
boards (excluding the big Little). Otherwise setting all CPU with a
capacity of 1024 but having different OPP (like qcom gold-silver arch)
does not make sense and the patch fix this.

> Maybe you want to test 'if (!raw_capacity || cap_parsing_failed)' at the
> top of topology_parse_cpu_capacity() ?

I prefer to update the documentation, it makes more sense than adding
more cumbersome tests in the current code.



-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2018-11-26 10:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26  8:44 [PATCH V3 1/2] base/drivers/arch_topology: Replace mutex with READ_ONCE / WRITE_ONCE Daniel Lezcano
2018-11-26  8:44 ` [PATCH V3 2/2] base/drivers/arch_topology: Default dmips-mhz if they are not set in DT Daniel Lezcano
2018-11-26  8:45   ` Viresh Kumar
2018-11-26  9:52   ` Quentin Perret
2018-11-26 10:08     ` Daniel Lezcano [this message]
2018-11-26 10:19       ` Viresh Kumar
2018-11-26 11:09         ` Quentin Perret
2018-11-26 11:36           ` Daniel Lezcano
2018-11-26 12:15             ` Quentin Perret

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=97f85a4b-efb6-b26f-94d0-cd538c83a03e@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=amit.kucheria@linaro.org \
    --cc=chris.redpath@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.dechesne@linaro.org \
    --cc=niklas.cassel@linaro.org \
    --cc=quentin.perret@linaro.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.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

all inboxes | Powered by JetHome®