Re: [PATCH v2 2/2] [RFC] CPUFreq: Add support for cpu-perf-dependencies

Nicola Mazzucato
2020-10-19T13:35:18Z

Hi Viresh,

On 10/19/20 10:46 AM, Viresh Kumar wrote:
> On 19-10-20, 09:50, Nicola Mazzucato wrote:
>> Hi Viresh,
>>
>> thank you for your suggestion on using 'opp-shared'.
>> I think it could work for most of the cases we explained earlier.
>>
>> Summarising, there are two parts of this entire proposal:
>> 1) where/how to get the information: now we are focusing on taking advantage of
>> 'opp-shared' within an empty opp table
>> 2) and how/where this information will be consumed
>>
>> Further details below:
>>
>> 1) a CPUFreq driver that takes the OPPs from firmware, can call
>> dev_pm_opp_of_get_sharing_cpus like you suggested. When doing so, a provided
>> cpumaksk will be populated with the corresponding cpus that share the same
>> (empty) table opp in DT.
>> All good so far.
>
> Great.
>
>> The current opp core is not expecting an empty table and therefore some errors
>> are thrown when this happens.
>> Since we are now allowing this corner-case, I am presenting below where I think
>> some minor corrections may be needed:
>>
>> --- a/drivers/opp/of.c
>> +++ b/drivers/opp/of.c
>> @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
>> struct device_node *required_np, *np;
>> int count, i;
>>
>> /* Traversing the first OPP node is all we need */
>> np = of_get_next_available_child(opp_np, NULL);
>> if (!np) {
>> - dev_err(dev, "Empty OPP table\n");
>> + dev_warn(dev, "Empty OPP table\n");
>> +
>> + /*
>> + * With empty table we remove shared_opp. This is to leave the
>> + * responsibility to decide which opp are shared to the opp users
>> + */
>> + opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE;
>> +
>> return;
>> }
>>
>> @@ int dev_pm_opp_of_find_icc_paths(struct device *dev,
>> int ret, i, count, num_paths;
>> struct icc_path **paths;
>>
>> ret = _bandwidth_supported(dev, opp_table);
>> - if (ret <= 0)
>> + if (ret == -EINVAL)
>> + return 0; /* Empty OPP table is a valid corner-case, let's not
>> fail */
>> + else if (ret <= 0)
>> return ret;
>>
>> The above are not 'strictly' necessary to achieve the intended goal, but they
>> make clearer that an empty table is now allowed and not an error anymore.
>> What it is your point of view on this?
>
> Why is this stuff getting called in your case ? We shouldn't be trying
> to create an OPP table here and it should still be an error in the
> code if we are asked to parse an empty OPP table.

A driver that gets a set of opp-points from f/w needs to add them to each
device. To do so, it will call dev_pm_opp_add(). If an opp_table struct for this
device is not found, one will be created and the opp-point will be added to it.
When allocation a new opp_table the opp will try to initialise it by parsing the
values in DT. It will also try to find_icc_paths.

Everything happens silently if we don't have a table in DT.

>
>> In addition, I think it would also be appropriate to update the documentation
>> (Documentation/devicetree/bindings/opp/opp.txt) to reflect this new case
>> (required properties etc).
>> Any different thoughts?
>
> Yes, this needs a small update in the required-opps section.

Cool, I'll sketch something in the next version.

>
>> 2) Once the driver gets the 'performance dependencies' by
>> dev_pm_opp_of_get_sharing_cpus(), this information will have to be shared with
>> EAS, thermal, etc.. The natural way to do so would be to add a new cpumask like
>> I proposed in this RFC.
>> I see this as an improvement for the whole subsystem and a scalable choice since
>> we can unambiguously provide the correct information to whoever needs it, given
>> that we don't enforce "hw dependencies" for related_cpus.
>> The changes would be trivial (it's in the original RFC).
>> On the other hand, we can't unload this h/w detail into related_cpus IMO as we
>> are dealing with per-cpu systems in this context.
>> Hope it makes sense?
>
> I will have another look at this stuff, honestly I haven't looked at
> this in detail yet. But I do understand that we can't really use
> related-cpu here without changing its earlier meaning.

Sure. thanks
>

Hope it helps

Best regards
Nicola