All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Yajun Deng <yajun.deng@linux.dev>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: drivers with target_index() must set freq_table
Date: Mon, 3 Apr 2023 17:28:20 +0200	[thread overview]
Message-ID: <CAJZ5v0h4AUP92Wuprfoy2ErhiktTvRquyc9-iMwzt6d=HaqYMg@mail.gmail.com> (raw)
In-Reply-To: <53d4ed4e5b18a59a48790434f8146fb207e11c49.1680494945.git.viresh.kumar@linaro.org>

On Mon, Apr 3, 2023 at 6:09 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Since the cpufreq core directly uses freq_table, for cpufreq drivers
> that set their target_index() callback, make it mandatory for them to
> set the same.
>
> Since this is set per policy and normally from policy->init(), do this
> from cpufreq_table_validate_and_sort() which gets called right after
> ->init().
>
> Reported-by: Yajun Deng <yajun.deng@linux.dev>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq.c    | 5 +++++
>  drivers/cpufreq/freq_table.c | 9 ++++++++-
>  2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6d8fd3b8dcb5..09131c54703f 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -73,6 +73,11 @@ static inline bool has_target(void)
>         return cpufreq_driver->target_index || cpufreq_driver->target;
>  }
>
> +bool has_target_index(void)
> +{
> +       return !!cpufreq_driver->target_index;
> +}

This needs to go into a header (as a static inline) or the prototype
of it needs to go into a header.

> +
>  /* internal prototypes */
>  static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
>  static int cpufreq_init_governor(struct cpufreq_policy *policy);
> diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
> index 90bfc27ed1ba..c6fc5b0ea91f 100644
> --- a/drivers/cpufreq/freq_table.c
> +++ b/drivers/cpufreq/freq_table.c
> @@ -10,6 +10,8 @@
>  #include <linux/cpufreq.h>
>  #include <linux/module.h>
>
> +bool has_target_index(void);
> +
>  /*********************************************************************
>   *                     FREQUENCY TABLE HELPERS                       *
>   *********************************************************************/
> @@ -355,8 +357,13 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
>  {
>         int ret;
>
> -       if (!policy->freq_table)
> +       if (!policy->freq_table) {
> +               /* Freq table must be passed by drivers with target_index() */
> +               if (has_target_index())
> +                       return -EINVAL;
> +
>                 return 0;
> +       }
>
>         ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table);
>         if (ret)
> --
> 2.31.1.272.g89b43f80a514
>

      parent reply	other threads:[~2023-04-03 15:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03  4:09 [PATCH] cpufreq: drivers with target_index() must set freq_table Viresh Kumar
2023-04-03 11:26 ` kernel test robot
2023-04-03 11:26 ` kernel test robot
2023-04-03 15:28 ` Rafael J. Wysocki [this message]

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='CAJZ5v0h4AUP92Wuprfoy2ErhiktTvRquyc9-iMwzt6d=HaqYMg@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=yajun.deng@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.