linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
@ 2020-02-13  5:35 Suman Anna
  2020-02-24  5:01 ` Lokesh Vutla
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Suman Anna @ 2020-02-13  5:35 UTC (permalink / raw)
  To: Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: linux-omap, linux-kernel, Suman Anna, Tero Kristo,
	Neil Armstrong, H . Nikolaus Schaller, Bartosz Golaszewski,
	Keerthy, Ladislav Michl, Pavel Machek, Sebastian Reichel

The function omap_dm_timer_of_set_source() was originally added in
commit 31a7448f4fa8a ("ARM: OMAP: dmtimer: Add clock source from DT"),
and is designed to set a clock source from DT using the clocks property
of a timer node. This design choice is okay for clk provider nodes but
otherwise is a bad design as typically the clocks property is used to
specify the functional clocks for a device, and not its parents.

The timer nodes now all define a timer functional clock after the
conversion to ti-sysc and the new clkctrl layout, and this results
in an attempt to set the same functional clock as its parent when a
consumer driver attempts to acquire any of these timers in the
omap_dm_timer_prepare() function. This was masked and worked around
in commit 983a5a43ec25 ("clocksource: timer-ti-dm: Fix pwm dmtimer
usage of fck reparenting"). Fix all of this by simply dropping the
entire function.

Any DT configuration of clock sources should be achieved using
assigned-clocks and assigned-clock-parents properties provided
by the Common Clock Framework.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Ladislav Michl <ladis@linux-mips.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Suman Anna <s-anna@ti.com>
---
Hi Tony,

Do you have the history of why the 32 KHz source is set as parent during
prepare? One of the current side-affects of this patch is that now instead
of bailing out, the 32 KHz source is set, and consumers will still need
to select their appropriate parent. Dropping that call should actually
allow us to select the parents in the consumer nodes in dts files using
the assigned-clocks and assigned-clock-parents properties. I prefer to
drop it if you do not foresee any issues. For now, I do not anticipate
any issues with omap-pwm-dmtimer with this patch.

regards
Suman

 drivers/clocksource/timer-ti-dm.c | 33 +------------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 269a994d6a99..d8637a60a7eb 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -138,35 +138,6 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer)
 	return 0;
 }
 
-static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
-{
-	int ret;
-	struct clk *parent;
-
-	/*
-	 * FIXME: OMAP1 devices do not use the clock framework for dmtimers so
-	 * do not call clk_get() for these devices.
-	 */
-	if (!timer->fclk)
-		return -ENODEV;
-
-	parent = clk_get(&timer->pdev->dev, NULL);
-	if (IS_ERR(parent))
-		return -ENODEV;
-
-	/* Bail out if both clocks point to fck */
-	if (clk_is_match(parent, timer->fclk))
-		return 0;
-
-	ret = clk_set_parent(timer->fclk, parent);
-	if (ret < 0)
-		pr_err("%s: failed to set parent\n", __func__);
-
-	clk_put(parent);
-
-	return ret;
-}
-
 static int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
 {
 	int ret;
@@ -276,9 +247,7 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
 	__omap_dm_timer_enable_posted(timer);
 	omap_dm_timer_disable(timer);
 
-	rc = omap_dm_timer_of_set_source(timer);
-	if (rc == -ENODEV)
-		return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
+	rc = omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
 
 	return rc;
 }
-- 
2.23.0


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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-02-13  5:35 [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Suman Anna
@ 2020-02-24  5:01 ` Lokesh Vutla
  2020-02-26 16:16 ` Tony Lindgren
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Lokesh Vutla @ 2020-02-24  5:01 UTC (permalink / raw)
  To: Suman Anna, Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: linux-omap, linux-kernel, Tero Kristo, Neil Armstrong,
	H . Nikolaus Schaller, Bartosz Golaszewski, Keerthy,
	Ladislav Michl, Pavel Machek, Sebastian Reichel



On 13/02/20 11:05 AM, Suman Anna wrote:
> The function omap_dm_timer_of_set_source() was originally added in
> commit 31a7448f4fa8a ("ARM: OMAP: dmtimer: Add clock source from DT"),
> and is designed to set a clock source from DT using the clocks property
> of a timer node. This design choice is okay for clk provider nodes but
> otherwise is a bad design as typically the clocks property is used to
> specify the functional clocks for a device, and not its parents.
> 
> The timer nodes now all define a timer functional clock after the
> conversion to ti-sysc and the new clkctrl layout, and this results
> in an attempt to set the same functional clock as its parent when a
> consumer driver attempts to acquire any of these timers in the
> omap_dm_timer_prepare() function. This was masked and worked around
> in commit 983a5a43ec25 ("clocksource: timer-ti-dm: Fix pwm dmtimer
> usage of fck reparenting"). Fix all of this by simply dropping the
> entire function.
> 
> Any DT configuration of clock sources should be achieved using
> assigned-clocks and assigned-clock-parents properties provided
> by the Common Clock Framework.
> 
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Tero Kristo <t-kristo@ti.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Cc: Keerthy <j-keerthy@ti.com>
> Cc: Ladislav Michl <ladis@linux-mips.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Suman Anna <s-anna@ti.com>
> ---
> Hi Tony,
> 
> Do you have the history of why the 32 KHz source is set as parent during
> prepare? One of the current side-affects of this patch is that now instead
> of bailing out, the 32 KHz source is set, and consumers will still need
> to select their appropriate parent. Dropping that call should actually
> allow us to select the parents in the consumer nodes in dts files using
> the assigned-clocks and assigned-clock-parents properties. I prefer to
> drop it if you do not foresee any issues. For now, I do not anticipate
> any issues with omap-pwm-dmtimer with this patch.

Without this patch, pwm is not being generated at all on my BBB. After applying
this patch I am able to see pwm being generated on the scope.

FWIW:
Tested-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-02-13  5:35 [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Suman Anna
  2020-02-24  5:01 ` Lokesh Vutla
@ 2020-02-26 16:16 ` Tony Lindgren
  2020-02-26 17:24   ` Daniel Lezcano
  2020-02-27  9:33 ` Daniel Lezcano
  2020-04-25  9:14 ` Lokesh Vutla
  3 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2020-02-26 16:16 UTC (permalink / raw)
  To: Suman Anna
  Cc: Daniel Lezcano, Thomas Gleixner, linux-omap, linux-kernel,
	Tero Kristo, Neil Armstrong, H . Nikolaus Schaller,
	Bartosz Golaszewski, Keerthy, Ladislav Michl, Pavel Machek,
	Sebastian Reichel

* Suman Anna <s-anna@ti.com> [200212 21:36]:
> Hi Tony,
> 
> Do you have the history of why the 32 KHz source is set as parent during
> prepare? One of the current side-affects of this patch is that now instead
> of bailing out, the 32 KHz source is set, and consumers will still need
> to select their appropriate parent. Dropping that call should actually
> allow us to select the parents in the consumer nodes in dts files using
> the assigned-clocks and assigned-clock-parents properties. I prefer to
> drop it if you do not foresee any issues. For now, I do not anticipate
> any issues with omap-pwm-dmtimer with this patch.

Using the 32 KiHz source works better for PM. But yeah the
machine specific source clock should be configured with
assigned-clocks and assigned-clock-parents properites.

Things seem to behave just fine for me with this patch for both
pwm-leds and PM. Good to see this function gone:

Tested-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-02-26 16:16 ` Tony Lindgren
@ 2020-02-26 17:24   ` Daniel Lezcano
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2020-02-26 17:24 UTC (permalink / raw)
  To: Tony Lindgren, Suman Anna
  Cc: Thomas Gleixner, linux-omap, linux-kernel, Tero Kristo,
	Neil Armstrong, H . Nikolaus Schaller, Bartosz Golaszewski,
	Keerthy, Ladislav Michl, Pavel Machek, Sebastian Reichel

On 26/02/2020 17:16, Tony Lindgren wrote:
> * Suman Anna <s-anna@ti.com> [200212 21:36]:
>> Hi Tony,
>>
>> Do you have the history of why the 32 KHz source is set as parent during
>> prepare? One of the current side-affects of this patch is that now instead
>> of bailing out, the 32 KHz source is set, and consumers will still need
>> to select their appropriate parent. Dropping that call should actually
>> allow us to select the parents in the consumer nodes in dts files using
>> the assigned-clocks and assigned-clock-parents properties. I prefer to
>> drop it if you do not foresee any issues. For now, I do not anticipate
>> any issues with omap-pwm-dmtimer with this patch.
> 
> Using the 32 KiHz source works better for PM. But yeah the
> machine specific source clock should be configured with
> assigned-clocks and assigned-clock-parents properites.
> 
> Things seem to behave just fine for me with this patch for both
> pwm-leds and PM. Good to see this function gone:
> 
> Tested-by: Tony Lindgren <tony@atomide.com>

Thanks for testing


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-02-13  5:35 [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Suman Anna
  2020-02-24  5:01 ` Lokesh Vutla
  2020-02-26 16:16 ` Tony Lindgren
@ 2020-02-27  9:33 ` Daniel Lezcano
  2020-04-25  9:14 ` Lokesh Vutla
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2020-02-27  9:33 UTC (permalink / raw)
  To: Suman Anna, Tony Lindgren, Thomas Gleixner
  Cc: linux-omap, linux-kernel, Tero Kristo, Neil Armstrong,
	H . Nikolaus Schaller, Bartosz Golaszewski, Keerthy,
	Ladislav Michl, Pavel Machek, Sebastian Reichel


Hi,

On 13/02/2020 06:35, Suman Anna wrote:
> The function omap_dm_timer_of_set_source() was originally added in
> commit 31a7448f4fa8a ("ARM: OMAP: dmtimer: Add clock source from DT"),
> and is designed to set a clock source from DT using the clocks property
> of a timer node. This design choice is okay for clk provider nodes but
> otherwise is a bad design as typically the clocks property is used to
> specify the functional clocks for a device, and not its parents.
> 
> The timer nodes now all define a timer functional clock after the
> conversion to ti-sysc and the new clkctrl layout, and this results
> in an attempt to set the same functional clock as its parent when a
> consumer driver attempts to acquire any of these timers in the
> omap_dm_timer_prepare() function. This was masked and worked around
> in commit 983a5a43ec25 ("clocksource: timer-ti-dm: Fix pwm dmtimer
> usage of fck reparenting"). Fix all of this by simply dropping the
> entire function.
> 
> Any DT configuration of clock sources should be achieved using
> assigned-clocks and assigned-clock-parents properties provided
> by the Common Clock Framework.

Applied. Thanks

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-02-13  5:35 [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Suman Anna
                   ` (2 preceding siblings ...)
  2020-02-27  9:33 ` Daniel Lezcano
@ 2020-04-25  9:14 ` Lokesh Vutla
  2020-04-25 14:51   ` Tony Lindgren
  3 siblings, 1 reply; 7+ messages in thread
From: Lokesh Vutla @ 2020-04-25  9:14 UTC (permalink / raw)
  To: Suman Anna, Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: linux-omap, linux-kernel, Tero Kristo, Neil Armstrong,
	H . Nikolaus Schaller, Bartosz Golaszewski, Keerthy,
	Ladislav Michl, Pavel Machek, Sebastian Reichel

Hi Tony, Suman,

On 13/02/20 11:05 AM, Suman Anna wrote:
> The function omap_dm_timer_of_set_source() was originally added in
> commit 31a7448f4fa8a ("ARM: OMAP: dmtimer: Add clock source from DT"),
> and is designed to set a clock source from DT using the clocks property
> of a timer node. This design choice is okay for clk provider nodes but
> otherwise is a bad design as typically the clocks property is used to
> specify the functional clocks for a device, and not its parents.
> 
> The timer nodes now all define a timer functional clock after the
> conversion to ti-sysc and the new clkctrl layout, and this results
> in an attempt to set the same functional clock as its parent when a
> consumer driver attempts to acquire any of these timers in the
> omap_dm_timer_prepare() function. This was masked and worked around
> in commit 983a5a43ec25 ("clocksource: timer-ti-dm: Fix pwm dmtimer
> usage of fck reparenting"). Fix all of this by simply dropping the
> entire function.
> 
> Any DT configuration of clock sources should be achieved using
> assigned-clocks and assigned-clock-parents properties provided
> by the Common Clock Framework.
> 
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Tero Kristo <t-kristo@ti.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: H. Nikolaus Schaller <hns@goldelico.com>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Cc: Keerthy <j-keerthy@ti.com>
> Cc: Ladislav Michl <ladis@linux-mips.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Suman Anna <s-anna@ti.com>
> ---
> Hi Tony,
> 
> Do you have the history of why the 32 KHz source is set as parent during
> prepare? One of the current side-affects of this patch is that now instead
> of bailing out, the 32 KHz source is set, and consumers will still need
> to select their appropriate parent. Dropping that call should actually
> allow us to select the parents in the consumer nodes in dts files using
> the assigned-clocks and assigned-clock-parents properties. I prefer to
> drop it if you do not foresee any issues. For now, I do not anticipate
> any issues with omap-pwm-dmtimer with this patch.
> 

Sorry to bring up an old thread. But ping on this question by Suman. prepare()
is over writing any parent set by DT to 32KHz. Is it possible to know why
prepare is doing it? If there is no proper reason can we drop this setting all
together?

Thanks and regards,
Lokesh

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

* Re: [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source()
  2020-04-25  9:14 ` Lokesh Vutla
@ 2020-04-25 14:51   ` Tony Lindgren
  0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2020-04-25 14:51 UTC (permalink / raw)
  To: Lokesh Vutla
  Cc: Suman Anna, Daniel Lezcano, Thomas Gleixner, linux-omap,
	linux-kernel, Tero Kristo, Neil Armstrong, H . Nikolaus Schaller,
	Bartosz Golaszewski, Keerthy, Ladislav Michl, Pavel Machek,
	Sebastian Reichel

* Lokesh Vutla <lokeshvutla@ti.com> [200425 09:15]:
> Hi Tony, Suman,
> 
> On 13/02/20 11:05 AM, Suman Anna wrote:
> > The function omap_dm_timer_of_set_source() was originally added in
> > commit 31a7448f4fa8a ("ARM: OMAP: dmtimer: Add clock source from DT"),
> > and is designed to set a clock source from DT using the clocks property
> > of a timer node. This design choice is okay for clk provider nodes but
> > otherwise is a bad design as typically the clocks property is used to
> > specify the functional clocks for a device, and not its parents.
> > 
> > The timer nodes now all define a timer functional clock after the
> > conversion to ti-sysc and the new clkctrl layout, and this results
> > in an attempt to set the same functional clock as its parent when a
> > consumer driver attempts to acquire any of these timers in the
> > omap_dm_timer_prepare() function. This was masked and worked around
> > in commit 983a5a43ec25 ("clocksource: timer-ti-dm: Fix pwm dmtimer
> > usage of fck reparenting"). Fix all of this by simply dropping the
> > entire function.
> > 
> > Any DT configuration of clock sources should be achieved using
> > assigned-clocks and assigned-clock-parents properties provided
> > by the Common Clock Framework.
> > 
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Tero Kristo <t-kristo@ti.com>
> > Cc: Neil Armstrong <narmstrong@baylibre.com>
> > Cc: H. Nikolaus Schaller <hns@goldelico.com>
> > Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > Cc: Keerthy <j-keerthy@ti.com>
> > Cc: Ladislav Michl <ladis@linux-mips.org>
> > Cc: Pavel Machek <pavel@ucw.cz>
> > Cc: Sebastian Reichel <sre@kernel.org>
> > Signed-off-by: Suman Anna <s-anna@ti.com>
> > ---
> > Hi Tony,
> > 
> > Do you have the history of why the 32 KHz source is set as parent during
> > prepare? One of the current side-affects of this patch is that now instead
> > of bailing out, the 32 KHz source is set, and consumers will still need
> > to select their appropriate parent. Dropping that call should actually
> > allow us to select the parents in the consumer nodes in dts files using
> > the assigned-clocks and assigned-clock-parents properties. I prefer to
> > drop it if you do not foresee any issues. For now, I do not anticipate
> > any issues with omap-pwm-dmtimer with this patch.
> > 
> 
> Sorry to bring up an old thread. But ping on this question by Suman. prepare()
> is over writing any parent set by DT to 32KHz. Is it possible to know why
> prepare is doing it? If there is no proper reason can we drop this setting all
> together?

For devicetree configured machines we should just configure the source
clock with assigned-clock-parents as there may be device specific need
for a specific source. So yeah, I'm all for dropping that code for device
tree booting machines. For the old omap1 devices, the clock code still
needs to configure it probably.

The reason why the 32k source is the default is that it's always on and
works for power management unlike the system clock which may be shut off
during idle.

Regards,

Tony

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

end of thread, other threads:[~2020-04-25 14:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13  5:35 [PATCH] clocksource: timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Suman Anna
2020-02-24  5:01 ` Lokesh Vutla
2020-02-26 16:16 ` Tony Lindgren
2020-02-26 17:24   ` Daniel Lezcano
2020-02-27  9:33 ` Daniel Lezcano
2020-04-25  9:14 ` Lokesh Vutla
2020-04-25 14:51   ` Tony Lindgren

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).