linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] clk: imx: Allow re-parenting by default on set rate
@ 2019-03-07  9:20 Abel Vesa
  2019-03-11 10:28 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Abel Vesa @ 2019-03-07  9:20 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Sascha Hauer, Lucas Stach, Shawn Guo
  Cc: Fabio Estevam, dl-linux-imx, Aisheng Dong, Jacky Bai,
	Anson Huang, linux-clk, linux-arm-kernel,
	Linux Kernel Mailing List, Abel Vesa

By default, the muxes should re-parent on set_rate.
This would allow the drivers to control only the leaf clock node,
leaving the rest to the clock driver, that way simplifying the
clock control.

Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
---
 drivers/clk/imx/clk.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 5748ec8..055b602 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -148,7 +148,7 @@ static inline struct clk *imx_clk_mux_ldb(const char *name, void __iomem *reg,
 			int num_parents)
 {
 	return clk_register_mux(NULL, name, parents, num_parents,
-			CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, reg,
+			CLK_SET_RATE_PARENT, reg,
 			shift, width, CLK_MUX_READ_ONLY, &imx_ccm_lock);
 }
 
@@ -321,7 +321,7 @@ static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
 			int num_parents)
 {
 	return clk_register_mux(NULL, name, parents, num_parents,
-			CLK_SET_RATE_NO_REPARENT, reg, shift,
+			0, reg, shift,
 			width, 0, &imx_ccm_lock);
 }
 
@@ -330,7 +330,7 @@ static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg,
 			int num_parents)
 {
 	return clk_register_mux(NULL, name, parents, num_parents,
-			CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
+			CLK_OPS_PARENT_ENABLE,
 			reg, shift, width, 0, &imx_ccm_lock);
 }
 
@@ -340,7 +340,6 @@ static inline struct clk_hw *imx_clk_hw_mux2(const char *name, void __iomem *reg
 					     int num_parents)
 {
 	return clk_hw_register_mux(NULL, name, parents, num_parents,
-				   CLK_SET_RATE_NO_REPARENT |
 				   CLK_OPS_PARENT_ENABLE,
 				   reg, shift, width, 0, &imx_ccm_lock);
 }
@@ -351,7 +350,7 @@ static inline struct clk *imx_clk_mux_flags(const char *name,
 			unsigned long flags)
 {
 	return clk_register_mux(NULL, name, parents, num_parents,
-			flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
+			flags, reg, shift, width, 0,
 			&imx_ccm_lock);
 }
 
@@ -361,7 +360,7 @@ static inline struct clk *imx_clk_mux2_flags(const char *name,
 		int num_parents, unsigned long flags)
 {
 	return clk_register_mux(NULL, name, parents, num_parents,
-			flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
+			flags | CLK_OPS_PARENT_ENABLE,
 			reg, shift, width, 0, &imx_ccm_lock);
 }
 
@@ -373,7 +372,7 @@ static inline struct clk_hw *imx_clk_hw_mux_flags(const char *name,
 						  unsigned long flags)
 {
 	return clk_hw_register_mux(NULL, name, parents, num_parents,
-				   flags | CLK_SET_RATE_NO_REPARENT,
+				   flags,
 				   reg, shift, width, 0, &imx_ccm_lock);
 }
 
@@ -389,7 +388,7 @@ struct clk *imx8m_clk_composite_flags(const char *name,
 #define __imx8m_clk_composite(name, parent_names, reg, flags) \
 	imx8m_clk_composite_flags(name, parent_names, \
 		ARRAY_SIZE(parent_names), reg, \
-		flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
+		flags | CLK_OPS_PARENT_ENABLE)
 
 #define imx8m_clk_composite(name, parent_names, reg) \
 	__imx8m_clk_composite(name, parent_names, reg, 0)
-- 
2.7.4


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

* Re: [RFC] clk: imx: Allow re-parenting by default on set rate
  2019-03-07  9:20 [RFC] clk: imx: Allow re-parenting by default on set rate Abel Vesa
@ 2019-03-11 10:28 ` Sascha Hauer
  2019-03-11 10:41   ` Abel Vesa
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2019-03-11 10:28 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Michael Turquette, Stephen Boyd, Sascha Hauer, Lucas Stach,
	Shawn Guo, Aisheng Dong, Jacky Bai, Anson Huang,
	Linux Kernel Mailing List, dl-linux-imx, Fabio Estevam,
	linux-clk, linux-arm-kernel

Hi Abel,

On Thu, Mar 07, 2019 at 09:20:37AM +0000, Abel Vesa wrote:
> By default, the muxes should re-parent on set_rate.
> This would allow the drivers to control only the leaf clock node,
> leaving the rest to the clock driver, that way simplifying the
> clock control.

I am afraid of this change. Besides the rate there might be other
reasons to choose one mux input over another, consider for example low
power audio playback where we need one specific mux setting because it
provides a clock which runs at low power mode.
On the IPU on i.MX5/6 there are clocks being used as pixel clocks
derived from different muxes. I don't think you want to pick an input
clock just because it happens to deliver the best clock rate at that
point in time, but really is shared with some other clock that changes
its rate in the next moment.

I have no concrete examples for things that break with this change, but
I would be more confident if we change the behaviour explicitly only for
the muxes that we have reviewed to cope with this change.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [RFC] clk: imx: Allow re-parenting by default on set rate
  2019-03-11 10:28 ` Sascha Hauer
@ 2019-03-11 10:41   ` Abel Vesa
  2019-03-13 10:41     ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Abel Vesa @ 2019-03-11 10:41 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Michael Turquette, Stephen Boyd, Sascha Hauer, Lucas Stach,
	Shawn Guo, Aisheng Dong, Jacky Bai, Anson Huang,
	Linux Kernel Mailing List, dl-linux-imx, Fabio Estevam,
	linux-clk, linux-arm-kernel

On 19-03-11 11:28:25, Sascha Hauer wrote:
> Hi Abel,
> 
> On Thu, Mar 07, 2019 at 09:20:37AM +0000, Abel Vesa wrote:
> > By default, the muxes should re-parent on set_rate.
> > This would allow the drivers to control only the leaf clock node,
> > leaving the rest to the clock driver, that way simplifying the
> > clock control.
> 
> I am afraid of this change. Besides the rate there might be other
> reasons to choose one mux input over another, consider for example low
> power audio playback where we need one specific mux setting because it
> provides a clock which runs at low power mode.
> On the IPU on i.MX5/6 there are clocks being used as pixel clocks
> derived from different muxes. I don't think you want to pick an input
> clock just because it happens to deliver the best clock rate at that
> point in time, but really is shared with some other clock that changes
> its rate in the next moment.
> 

> I have no concrete examples for things that break with this change, but
> I would be more confident if we change the behaviour explicitly only for
> the muxes that we have reviewed to cope with this change.
> 

Fair enough. We could replace all the imx_clk_mux with imx_clk_mux_noreparent
and after that we can independently switch the clocks that are safe (to switch)
to imx_clk_mux (which would not have the noreparent flag set).

The main idea is to simplify the clock control from drivers point of view.

The end goal here would be to only have noreparent flag set for the clocks that
need specific mux control.

> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pengutronix.de%2F&amp;data=02%7C01%7Cabel.vesa%40nxp.com%7Cde43ba7dcd774a3709df08d6a60c4d90%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636878969100157679&amp;sdata=4eU6YmuXDhHJZUKVKJhiRwlzq7b9XIrUfLSl2JFlRd8%3D&amp;reserved=0  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [RFC] clk: imx: Allow re-parenting by default on set rate
  2019-03-11 10:41   ` Abel Vesa
@ 2019-03-13 10:41     ` Sascha Hauer
  2019-03-13 11:29       ` Daniel Baluta
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2019-03-13 10:41 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Michael Turquette, Stephen Boyd, Sascha Hauer, Lucas Stach,
	Shawn Guo, Aisheng Dong, Jacky Bai, Anson Huang,
	Linux Kernel Mailing List, dl-linux-imx, Fabio Estevam,
	linux-clk, linux-arm-kernel

On Mon, Mar 11, 2019 at 10:41:40AM +0000, Abel Vesa wrote:
> On 19-03-11 11:28:25, Sascha Hauer wrote:
> > Hi Abel,
> > 
> > On Thu, Mar 07, 2019 at 09:20:37AM +0000, Abel Vesa wrote:
> > > By default, the muxes should re-parent on set_rate.
> > > This would allow the drivers to control only the leaf clock node,
> > > leaving the rest to the clock driver, that way simplifying the
> > > clock control.
> > 
> > I am afraid of this change. Besides the rate there might be other
> > reasons to choose one mux input over another, consider for example low
> > power audio playback where we need one specific mux setting because it
> > provides a clock which runs at low power mode.
> > On the IPU on i.MX5/6 there are clocks being used as pixel clocks
> > derived from different muxes. I don't think you want to pick an input
> > clock just because it happens to deliver the best clock rate at that
> > point in time, but really is shared with some other clock that changes
> > its rate in the next moment.
> > 
> 
> > I have no concrete examples for things that break with this change, but
> > I would be more confident if we change the behaviour explicitly only for
> > the muxes that we have reviewed to cope with this change.
> > 
> 
> Fair enough. We could replace all the imx_clk_mux with imx_clk_mux_noreparent
> and after that we can independently switch the clocks that are safe (to switch)
> to imx_clk_mux (which would not have the noreparent flag set).

Ok with me.

> 
> The main idea is to simplify the clock control from drivers point of view.

Which drivers do you have in mind? I hardly ever missed reparenting on
rate changes, so where is this feature useful?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [RFC] clk: imx: Allow re-parenting by default on set rate
  2019-03-13 10:41     ` Sascha Hauer
@ 2019-03-13 11:29       ` Daniel Baluta
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Baluta @ 2019-03-13 11:29 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Sascha Hauer,
	Lucas Stach, Shawn Guo, Aisheng Dong, Jacky Bai, Anson Huang,
	Linux Kernel Mailing List, dl-linux-imx, Fabio Estevam,
	linux-clk, linux-arm-kernel, S.j. Wang

On Wed, Mar 13, 2019 at 12:42 PM Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> On Mon, Mar 11, 2019 at 10:41:40AM +0000, Abel Vesa wrote:
> > On 19-03-11 11:28:25, Sascha Hauer wrote:
> > > Hi Abel,
> > >
> > > On Thu, Mar 07, 2019 at 09:20:37AM +0000, Abel Vesa wrote:
> > > > By default, the muxes should re-parent on set_rate.
> > > > This would allow the drivers to control only the leaf clock node,
> > > > leaving the rest to the clock driver, that way simplifying the
> > > > clock control.
> > >
> > > I am afraid of this change. Besides the rate there might be other
> > > reasons to choose one mux input over another, consider for example low
> > > power audio playback where we need one specific mux setting because it
> > > provides a clock which runs at low power mode.
> > > On the IPU on i.MX5/6 there are clocks being used as pixel clocks
> > > derived from different muxes. I don't think you want to pick an input
> > > clock just because it happens to deliver the best clock rate at that
> > > point in time, but really is shared with some other clock that changes
> > > its rate in the next moment.
> > >
> >
> > > I have no concrete examples for things that break with this change, but
> > > I would be more confident if we change the behaviour explicitly only for
> > > the muxes that we have reviewed to cope with this change.
> > >
> >
> > Fair enough. We could replace all the imx_clk_mux with imx_clk_mux_noreparent
> > and after that we can independently switch the clocks that are safe (to switch)
> > to imx_clk_mux (which would not have the noreparent flag set).
>
> Ok with me.
>
> >
> > The main idea is to simplify the clock control from drivers point of view.
>
> Which drivers do you have in mind? I hardly ever missed reparenting on
> rate changes, so where is this feature useful?

Hi Sascha,

Reparenting is very useful for Audio IPs (SAI, SPDIF, PDM, FSL DSP).
We often need clock rates that are multiples of 8000 or 11025
which can be obtain from different PLLs. But in order for this to work
we need to have the correct parent.

In our current tree we do the re parenting manually inside drivers. For example:

https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/fsl/fsl_sai.c?h=imx_4.14.78_1.0.0_ga#n244

This is far from optimal. Abel's patch will be of a great help for Audio.

thanks,
Daniel.

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

end of thread, other threads:[~2019-03-13 11:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07  9:20 [RFC] clk: imx: Allow re-parenting by default on set rate Abel Vesa
2019-03-11 10:28 ` Sascha Hauer
2019-03-11 10:41   ` Abel Vesa
2019-03-13 10:41     ` Sascha Hauer
2019-03-13 11:29       ` Daniel Baluta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).