diff mbox series

[v10,2/8] opp: Allow dev_pm_opp_set_clkname() to replace released clock

Message ID 20210831135450.26070-3-digetx@gmail.com
State New
Headers show
Series NVIDIA Tegra power management patches for 5.16 | expand

Commit Message

Dmitry Osipenko Aug. 31, 2021, 1:54 p.m. UTC
The opp_table->clk is set to error once clock is released by
dev_pm_opp_put_clkname(). This doesn't allow to set clock again,
until OPP table is re-created from scratch. Check opp_table->clk
for both NULL and ERR_PTR to allow the clock's replacement.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/opp/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Viresh Kumar Sept. 1, 2021, 4:42 a.m. UTC | #1
On 31-08-21, 16:54, Dmitry Osipenko wrote:
> The opp_table->clk is set to error once clock is released by

> dev_pm_opp_put_clkname(). This doesn't allow to set clock again,


I am not sure why are you required to set the clk again here ? I mean,
users aren't expected to put clkname in the middle of using it. The
set-name API also checks that the OPP list should be empty in such a
case.

> until OPP table is re-created from scratch. Check opp_table->clk

> for both NULL and ERR_PTR to allow the clock's replacement.

> 

> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

> ---

>  drivers/opp/core.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/opp/core.c b/drivers/opp/core.c

> index dde8a5cc948c..602e502d092e 100644

> --- a/drivers/opp/core.c

> +++ b/drivers/opp/core.c

> @@ -2146,7 +2146,7 @@ struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name)

>  	}

>  

>  	/* clk shouldn't be initialized at this point */

> -	if (WARN_ON(opp_table->clk)) {

> +	if (WARN_ON(!IS_ERR_OR_NULL(opp_table->clk))) {

>  		ret = -EBUSY;

>  		goto err;

>  	}

> -- 

> 2.32.0


-- 
viresh
Dmitry Osipenko Sept. 1, 2021, 5:46 a.m. UTC | #2
01.09.2021 07:42, Viresh Kumar пишет:
> On 31-08-21, 16:54, Dmitry Osipenko wrote:

>> The opp_table->clk is set to error once clock is released by

>> dev_pm_opp_put_clkname(). This doesn't allow to set clock again,

> 

> I am not sure why are you required to set the clk again here ? I mean,

> users aren't expected to put clkname in the middle of using it. The

> set-name API also checks that the OPP list should be empty in such a

> case.


I added explanatory comment to tegra_pmc_pd_dev_get_performance_state(),
isn't it enough?
Viresh Kumar Sept. 1, 2021, 6:02 a.m. UTC | #3
On 01-09-21, 08:46, Dmitry Osipenko wrote:
> 01.09.2021 07:42, Viresh Kumar пишет:

> > On 31-08-21, 16:54, Dmitry Osipenko wrote:

> >> The opp_table->clk is set to error once clock is released by

> >> dev_pm_opp_put_clkname(). This doesn't allow to set clock again,

> > 

> > I am not sure why are you required to set the clk again here ? I mean,

> > users aren't expected to put clkname in the middle of using it. The

> > set-name API also checks that the OPP list should be empty in such a

> > case.

> 

> I added explanatory comment to tegra_pmc_pd_dev_get_performance_state(),

> isn't it enough?


It confused me even more. Lemme comment there.

-- 
viresh
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index dde8a5cc948c..602e502d092e 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -2146,7 +2146,7 @@  struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name)
 	}
 
 	/* clk shouldn't be initialized at this point */
-	if (WARN_ON(opp_table->clk)) {
+	if (WARN_ON(!IS_ERR_OR_NULL(opp_table->clk))) {
 		ret = -EBUSY;
 		goto err;
 	}