lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200824111820.rcaingohxw3wozgd@vireshk-i7>
Date:   Mon, 24 Aug 2020 16:48:20 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Stephan Gerhold <stephan@...hold.net>
Cc:     "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Kevin Hilman <khilman@...nel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Nishanth Menon <nm@...com>, Stephen Boyd <sboyd@...nel.org>,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Niklas Cassel <nks@...wful.org>
Subject: Re: [RFC PATCH 1/3] opp: Reduce code duplication in
 _set_required_opps()

On 30-07-20, 10:01, Stephan Gerhold wrote:
> Move call to dev_pm_genpd_set_performance_state() to a separate
> function so we can avoid duplicating the code for the single and
> multiple genpd case.
> 
> Signed-off-by: Stephan Gerhold <stephan@...hold.net>
> ---
>  drivers/opp/core.c | 40 +++++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 9d7fb45b1786..f7a476b55069 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -781,6 +781,21 @@ static int _set_opp_custom(const struct opp_table *opp_table,
>  	return opp_table->set_opp(data);
>  }
>  
> +static int _set_required_opp(struct device *dev, struct device *pd_dev,
> +			     struct dev_pm_opp *opp, int i)
> +{
> +	unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
> +	int ret;
> +
> +	ret = dev_pm_genpd_set_performance_state(pd_dev, pstate);
> +	if (ret) {
> +		dev_err(dev, "Failed to set performance rate of %s: %d (%d)\n",
> +			dev_name(pd_dev), pstate, ret);
> +	}
> +
> +	return ret;
> +}
> +
>  /* This is only called for PM domain for now */
>  static int _set_required_opps(struct device *dev,
>  			      struct opp_table *opp_table,
> @@ -788,22 +803,15 @@ static int _set_required_opps(struct device *dev,
>  {
>  	struct opp_table **required_opp_tables = opp_table->required_opp_tables;
>  	struct device **genpd_virt_devs = opp_table->genpd_virt_devs;
> -	unsigned int pstate;
> +	struct device *pd_dev;
>  	int i, ret = 0;
>  
>  	if (!required_opp_tables)
>  		return 0;
>  
>  	/* Single genpd case */
> -	if (!genpd_virt_devs) {
> -		pstate = likely(opp) ? opp->required_opps[0]->pstate : 0;
> -		ret = dev_pm_genpd_set_performance_state(dev, pstate);
> -		if (ret) {
> -			dev_err(dev, "Failed to set performance state of %s: %d (%d)\n",
> -				dev_name(dev), pstate, ret);
> -		}
> -		return ret;
> -	}
> +	if (!genpd_virt_devs)
> +		return _set_required_opp(dev, dev, opp, 0);
>  
>  	/* Multiple genpd case */
>  
> @@ -814,17 +822,11 @@ static int _set_required_opps(struct device *dev,
>  	mutex_lock(&opp_table->genpd_virt_dev_lock);
>  
>  	for (i = 0; i < opp_table->required_opp_count; i++) {
> -		pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
> -
> -		if (!genpd_virt_devs[i])
> -			continue;

Don't we need this check anymore ?

> +		pd_dev = genpd_virt_devs[i];
>  
> -		ret = dev_pm_genpd_set_performance_state(genpd_virt_devs[i], pstate);
> -		if (ret) {
> -			dev_err(dev, "Failed to set performance rate of %s: %d (%d)\n",
> -				dev_name(genpd_virt_devs[i]), pstate, ret);
> +		ret = _set_required_opp(dev, pd_dev, opp, i);
> +		if (ret)
>  			break;
> -		}
>  	}
>  	mutex_unlock(&opp_table->genpd_virt_dev_lock);
>  
> -- 
> 2.27.0

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ