Re: [PATCH v2 2/2] [RFC] CPUFreq: Add support for cpu-perf-dependencies
From: Viresh Kumar
Date: Tue Oct 20 2020 - 06:48:56 EST
On 19-10-20, 14:36, Nicola Mazzucato wrote:
> 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.
Right, you need something like your patch here.
--
viresh