Linux Power Management development
 help / color / mirror / Atom feed
From: Vladimir Lypak <vladimir.lypak@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Thorsten Leemhuis <regressions@leemhuis.info>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] OPP: Fix required_opp_tables for multiple genpds using same table
Date: Wed, 10 Apr 2024 21:58:02 +0300	[thread overview]
Message-ID: <ZhbhOsNQeFnLHzsp@trashcan> (raw)
In-Reply-To: <c274500b623b83c00c0460383cbe1cdc7490eeac.1712658693.git.viresh.kumar@linaro.org>

On Tue, Apr 09, 2024 at 04:02:19PM +0530, Viresh Kumar wrote:
> The required_opp_tables parsing is not perfect, as the OPP core does the
> parsing solely based on the DT node pointers.
> 
> The core sets the required_opp_tables entry to the first OPP table in
> the "opp_tables" list, that matches with the node pointer.
> 
> If the target DT OPP table is used by multiple devices and they all
> create separate instances of 'struct opp_table' from it, then it is
> possible that the required_opp_tables entry may be set to the incorrect
> sibling device.
> 
> Unfortunately, there is no clear way to initialize the right values
> during the initial parsing and we need to do this at a later point of
> time.
> 
> Cross check the OPP table again while the genpds are attached and fix
> them if required.
> 
> Also add a new API for the genpd core to fetch the device pointer for
> the genpd.
> 
> Cc: Thorsten Leemhuis <regressions@leemhuis.info>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218682
> Reported-by: Vladimir Lypak <vladimir.lypak@gmail.com>
> Co-developed-by: Vladimir Lypak <vladimir.lypak@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Vladimir Lypak,
> 
> Can you please give this a try and confirm that it fixes the issue.
> 
>  drivers/opp/core.c        | 31 ++++++++++++++++++++++++++++++-
>  drivers/pmdomain/core.c   | 10 ++++++++++
>  include/linux/pm_domain.h |  6 ++++++
>  3 files changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index e233734b7220..1f64b703b744 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -2394,7 +2394,8 @@ static void _opp_detach_genpd(struct opp_table *opp_table)
>  static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
>  			const char * const *names, struct device ***virt_devs)
>  {
> -	struct device *virt_dev;
> +	struct device *virt_dev, *gdev;
> +	struct opp_table *genpd_table;
>  	int index = 0, ret = -EINVAL;
>  	const char * const *name = names;
>  
> @@ -2427,6 +2428,34 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
>  			goto err;
>  		}
>  
> +		/*
> +		 * The required_opp_tables parsing is not perfect, as the OPP
> +		 * core does the parsing solely based on the DT node pointers.
> +		 * The core sets the required_opp_tables entry to the first OPP
> +		 * table in the "opp_tables" list, that matches with the node
> +		 * pointer.
> +		 *
> +		 * If the target DT OPP table is used by multiple devices and
> +		 * they all create separate instances of 'struct opp_table' from
> +		 * it, then it is possible that the required_opp_tables entry
> +		 * may be set to the incorrect sibling device.
> +		 *
> +		 * Cross check it again and fix if required.
> +		 */
> +		gdev = dev_to_genpd_dev(virt_dev);
> +		if (!IS_ERR(gdev))
> +			return PTR_ERR(gdev);

This condition shouldn't be inverted. It returns if gdev is valid.
With this bit corrected patch fixes the issue.

  reply	other threads:[~2024-04-10 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 10:32 [PATCH] OPP: Fix required_opp_tables for multiple genpds using same table Viresh Kumar
2024-04-10 18:58 ` Vladimir Lypak [this message]
2024-04-11 10:23 ` Thorsten Leemhuis

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=ZhbhOsNQeFnLHzsp@trashcan \
    --to=vladimir.lypak@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rafael@kernel.org \
    --cc=regressions@leemhuis.info \
    --cc=sboyd@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vireshk@kernel.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