Re: [PATCH 1/2] OPP: pstate is only valid for genpd OPP tables

From: Bjorn Andersson
Date: Thu Jun 15 2023 - 19:36:01 EST


On Wed, Jun 14, 2023 at 04:07:25PM +0530, Viresh Kumar wrote:
> It is not very clear right now that the `pstate` field is only valid for
> genpd OPP tables and not consumer tables. And there is no checking for
> the same at various places.
>
> Add checks in place to verify that and make it clear to the reader.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
> drivers/opp/core.c | 18 ++++++++++++++++--
> drivers/opp/debugfs.c | 4 +++-
> drivers/opp/of.c | 6 ++++++
> 3 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
[..]
> @@ -2686,6 +2694,12 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
> int dest_pstate = -EINVAL;
> int i;
>
> + /* Both OPP tables must belong to genpds */
> + if (unlikely(!src_table->is_genpd || !dst_table->is_genpd)) {

I have a platform_device, with a required-opps and with an associated
genpd which does not implement set_performance_state(), but its parent
genpd does.

This results in me arriving here with src_table of NULL, and boom...


Looking at the very next statement in this function, it seems arriving
here without src_table was valid up until this change.

Regards,
Bjorn