All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: update cached phase to respect the fact when setting phase
@ 2018-03-08  6:49 Shawn Lin
  2018-03-08  9:41 ` Jerome Brunet
  2018-03-12  1:28   ` Michael Turquette
  0 siblings, 2 replies; 4+ messages in thread
From: Shawn Lin @ 2018-03-08  6:49 UTC (permalink / raw)
  To: Heiko Stuebner, Michael Turquette, Stephen Boyd
  Cc: linux-clk, Shawn Lin, Stable, Jerome Brunet

It's found that the final phase set by driver doesn't match that of
the output from clk_summary:

dwmmc_rockchip fe310000.dwmmc: Successfully tuned phase to 346
mmc0: new ultra high speed SDR104 SDIO card at address 0001

cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
sdio_sample	0        1        0    50000000 0 0

It seems the cached core->phase isn't updated after the clk was
registered. So fix this issue by updating the core->phase if setting
phase successfully.

Fixes: 9e4d04adeb1a ("clk: add clk_core_set_phase_nolock function")
Cc: Stable <stable@vger.kernel.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/clk/clk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 0f686a9..617e562 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2309,8 +2309,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
 
 	trace_clk_set_phase(core, degrees);
 
-	if (core->ops->set_phase)
+	if (core->ops->set_phase) {
 		ret = core->ops->set_phase(core->hw, degrees);
+		if (!ret)
+			core->phase = degrees;
+	}
 
 	trace_clk_set_phase_complete(core, degrees);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: update cached phase to respect the fact when setting phase
  2018-03-08  6:49 [PATCH] clk: update cached phase to respect the fact when setting phase Shawn Lin
@ 2018-03-08  9:41 ` Jerome Brunet
  2018-03-12  1:28   ` Michael Turquette
  1 sibling, 0 replies; 4+ messages in thread
From: Jerome Brunet @ 2018-03-08  9:41 UTC (permalink / raw)
  To: Shawn Lin, Heiko Stuebner, Michael Turquette, Stephen Boyd
  Cc: linux-clk, Stable

On Thu, 2018-03-08 at 14:49 +0800, Shawn Lin wrote:
> It's found that the final phase set by driver doesn't match that of
> the output from clk_summary:
> 
> dwmmc_rockchip fe310000.dwmmc: Successfully tuned phase to 346
> mmc0: new ultra high speed SDR104 SDIO card at address 0001
> 
> cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
> sdio_sample	0        1        0    50000000 0 0
> 
> It seems the cached core->phase isn't updated after the clk was
> registered. So fix this issue by updating the core->phase if setting
> phase successfully.
> 
> Fixes: 9e4d04adeb1a ("clk: add clk_core_set_phase_nolock function")
> Cc: Stable <stable@vger.kernel.org>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Good catch Shawn.
Actually, I have had already sent a fix for this issue

https://patchwork.kernel.org/patch/10220811/

But I think yours is better as it updates the phase only if the phase has
actually been set

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Tested-by: Jerome Brunet <jbrunet@baylibre.com>

> ---
> 
>  drivers/clk/clk.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 0f686a9..617e562 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2309,8 +2309,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
>  
>  	trace_clk_set_phase(core, degrees);
>  
> -	if (core->ops->set_phase)
> +	if (core->ops->set_phase) {
>  		ret = core->ops->set_phase(core->hw, degrees);
> +		if (!ret)
> +			core->phase = degrees;
> +	}
>  
>  	trace_clk_set_phase_complete(core, degrees);
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: update cached phase to respect the fact when setting phase
  2018-03-08  6:49 [PATCH] clk: update cached phase to respect the fact when setting phase Shawn Lin
@ 2018-03-12  1:28   ` Michael Turquette
  2018-03-12  1:28   ` Michael Turquette
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Turquette @ 2018-03-12  1:28 UTC (permalink / raw)
  To: Heiko Stuebner, Stephen Boyd, Shawn Lin; +Cc: Jerome Brunet, linux-clk, Stable

Excerpts from Shawn Lin's message of March 7, 2018 10:49 pm:
> It's found that the final phase set by driver doesn't match that of
> the output from clk_summary:
> 
> dwmmc_rockchip fe310000.dwmmc: Successfully tuned phase to 346
> mmc0: new ultra high speed SDR104 SDIO card at address 0001
> 
> cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
> sdio_sample	0        1        0    50000000 0 0
> 
> It seems the cached core->phase isn't updated after the clk was
> registered. So fix this issue by updating the core->phase if setting
> phase successfully.
> 
> Fixes: 9e4d04adeb1a ("clk: add clk_core_set_phase_nolock function")
> Cc: Stable <stable@vger.kernel.org>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Applied to clk-phase towards v4.17.

Regards,
Mike

> ---
> 
>  drivers/clk/clk.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 0f686a9..617e562 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2309,8 +2309,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
>  
>  	trace_clk_set_phase(core, degrees);
>  
> -	if (core->ops->set_phase)
> +	if (core->ops->set_phase) {
>  		ret = core->ops->set_phase(core->hw, degrees);
> +		if (!ret)
> +			core->phase = degrees;
> +	}
>  
>  	trace_clk_set_phase_complete(core, degrees);
>  
> -- 
> 1.9.1
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: update cached phase to respect the fact when setting phase
@ 2018-03-12  1:28   ` Michael Turquette
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Turquette @ 2018-03-12  1:28 UTC (permalink / raw)
  To: Heiko Stuebner, Stephen Boyd, Shawn Lin; +Cc: Jerome Brunet, linux-clk, Stable

Excerpts from Shawn Lin's message of March 7, 2018 10:49 pm:
> It's found that the final phase set by driver doesn't match that of
> the output from clk_summary:
>=20
> dwmmc_rockchip fe310000.dwmmc: Successfully tuned phase to 346
> mmc0: new ultra high speed SDR104 SDIO card at address 0001
>=20
> cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
> sdio_sample	0        1        0    50000000 0 0
>=20
> It seems the cached core->phase isn't updated after the clk was
> registered. So fix this issue by updating the core->phase if setting
> phase successfully.
>=20
> Fixes: 9e4d04adeb1a ("clk: add clk_core_set_phase_nolock function")
> Cc: Stable <stable@vger.kernel.org>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Applied to clk-phase towards v4.17.

Regards,
Mike

> ---
>=20
>  drivers/clk/clk.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>=20
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 0f686a9..617e562 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2309,8 +2309,11 @@ static int clk_core_set_phase_nolock(struct clk_co=
re *core, int degrees)
> =20
>  	trace_clk_set_phase(core, degrees);
> =20
> -	if (core->ops->set_phase)
> +	if (core->ops->set_phase) {
>  		ret =3D core->ops->set_phase(core->hw, degrees);
> +		if (!ret)
> +			core->phase =3D degrees;
> +	}
> =20
>  	trace_clk_set_phase_complete(core, degrees);
> =20
> --=20
> 1.9.1
>=20
>=20
>=20
=

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-12 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08  6:49 [PATCH] clk: update cached phase to respect the fact when setting phase Shawn Lin
2018-03-08  9:41 ` Jerome Brunet
2018-03-12  1:28 ` Michael Turquette
2018-03-12  1:28   ` Michael Turquette

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.