linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] clocksource: timer-ti-dm: Misc fixes for omap dm timer
@ 2020-02-24  5:07 Lokesh Vutla
  2020-02-24  5:07 ` [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable Lokesh Vutla
  2020-02-24  5:07 ` [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Lokesh Vutla
  0 siblings, 2 replies; 6+ messages in thread
From: Lokesh Vutla @ 2020-02-24  5:07 UTC (permalink / raw)
  To: Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: Linux OMAP Mailing List, linux-kernel, narmstrong, Sekhar Nori,
	Tero Kristo, Lokesh Vutla

This series fixes timer enabling sequence and pwm period updating
sequence.

Lokesh Vutla (2):
  clocksource: timer-ti-dm: Do not restore context on every timer enable
  clocksource: timer-ti-dm: Do not update counter on updating the period

 drivers/clocksource/timer-ti-dm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

-- 
2.23.0


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

* [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable
  2020-02-24  5:07 [PATCH 0/2] clocksource: timer-ti-dm: Misc fixes for omap dm timer Lokesh Vutla
@ 2020-02-24  5:07 ` Lokesh Vutla
  2020-02-26 17:09   ` Tony Lindgren
  2020-02-24  5:07 ` [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Lokesh Vutla
  1 sibling, 1 reply; 6+ messages in thread
From: Lokesh Vutla @ 2020-02-24  5:07 UTC (permalink / raw)
  To: Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: Linux OMAP Mailing List, linux-kernel, narmstrong, Sekhar Nori,
	Tero Kristo, Lokesh Vutla

omap_dm_timer_enable() restores the entire context(including counter)
based on 2 conditions:
- If get_context_loss_count is populated and context is lost.
- If get_context_loss_count is not populated update unconditionally.

Case2 has a side effect of updating the counter register even though
context is not lost. When timer is configured in pwm mode, this is
causing undesired behaviour in the pwm period. So restore context only
if get_context_loss_count is populated and context is actually lost.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/clocksource/timer-ti-dm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 269a994d6a99..40742715ed21 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -229,15 +229,12 @@ static void omap_dm_timer_enable(struct omap_dm_timer *timer)
 
 	pm_runtime_get_sync(&timer->pdev->dev);
 
-	if (!(timer->capability & OMAP_TIMER_ALWON)) {
-		if (timer->get_context_loss_count) {
-			c = timer->get_context_loss_count(&timer->pdev->dev);
-			if (c != timer->ctx_loss_count) {
-				omap_timer_restore_context(timer);
-				timer->ctx_loss_count = c;
-			}
-		} else {
+	if (!(timer->capability & OMAP_TIMER_ALWON) &&
+	    timer->get_context_loss_count) {
+		c = timer->get_context_loss_count(&timer->pdev->dev);
+		if (c != timer->ctx_loss_count) {
 			omap_timer_restore_context(timer);
+			timer->ctx_loss_count = c;
 		}
 	}
 }
-- 
2.23.0


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

* [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period
  2020-02-24  5:07 [PATCH 0/2] clocksource: timer-ti-dm: Misc fixes for omap dm timer Lokesh Vutla
  2020-02-24  5:07 ` [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable Lokesh Vutla
@ 2020-02-24  5:07 ` Lokesh Vutla
  2020-02-26 17:29   ` Tony Lindgren
  2020-03-19  8:47   ` [tip: timers/core] clocksource/drivers/timer-ti-dm: " tip-bot2 for Lokesh Vutla
  1 sibling, 2 replies; 6+ messages in thread
From: Lokesh Vutla @ 2020-02-24  5:07 UTC (permalink / raw)
  To: Tony Lindgren, Daniel Lezcano, Thomas Gleixner
  Cc: Linux OMAP Mailing List, linux-kernel, narmstrong, Sekhar Nori,
	Tero Kristo, Lokesh Vutla

Write to trigger register(OMAP_TIMER_TRIGGER_REG) will load the value
in Load register(OMAP_TIMER_LOAD_REG) into Counter register
(OMAP_TIMER_COUNTER_REG).

omap_dm_timer_set_load() writes into trigger register every time load
register is updated. When timer is configured in pwm mode, this causes
disruption in current pwm cycle, which is not expected especially when
pwm is used as PPS signal for synchronized PTP clocks. So do not write
into trigger register on updating the period.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/clocksource/timer-ti-dm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 40742715ed21..62b145ef3bb8 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -574,7 +574,6 @@ static int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
 
-	omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
 	/* Save the context */
 	timer->context.tclr = l;
 	timer->context.tldr = load;
-- 
2.23.0


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

* Re: [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable
  2020-02-24  5:07 ` [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable Lokesh Vutla
@ 2020-02-26 17:09   ` Tony Lindgren
  0 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2020-02-26 17:09 UTC (permalink / raw)
  To: Lokesh Vutla
  Cc: Daniel Lezcano, Thomas Gleixner, Linux OMAP Mailing List,
	linux-kernel, narmstrong, Sekhar Nori, Tero Kristo

* Lokesh Vutla <lokeshvutla@ti.com> [200224 05:09]:
> omap_dm_timer_enable() restores the entire context(including counter)
> based on 2 conditions:
> - If get_context_loss_count is populated and context is lost.
> - If get_context_loss_count is not populated update unconditionally.
> 
> Case2 has a side effect of updating the counter register even though
> context is not lost. When timer is configured in pwm mode, this is
> causing undesired behaviour in the pwm period. So restore context only
> if get_context_loss_count is populated and context is actually lost.

Sounds like this will break things. We have get_context_loss_count()
only on omap4 and later, and even that was only partially implemented
from what I recall.

To mee it seems the right thing to do here is to save and restore
context on CPU_CLUSTER_PM_ENTER and CPU_CLUSTER_PM_EXIT. And I'd
just get rid of the partially implemented custom calls to
get_context_loss_count().

See for example a recent patch on removing the legacy SDMA code
for CPU_CLUSTER_PM_ENTER in commit d2f924879e19 ("thermal:
ti-soc-thermal:  Enable addition power management").

Then if we really need to add checks for context lost at some point,
that can be implemented via reset_control_status() returning -ENOLINK
or something similar.

Regards,

Tony

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

* Re: [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period
  2020-02-24  5:07 ` [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Lokesh Vutla
@ 2020-02-26 17:29   ` Tony Lindgren
  2020-03-19  8:47   ` [tip: timers/core] clocksource/drivers/timer-ti-dm: " tip-bot2 for Lokesh Vutla
  1 sibling, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2020-02-26 17:29 UTC (permalink / raw)
  To: Lokesh Vutla
  Cc: Daniel Lezcano, Thomas Gleixner, Linux OMAP Mailing List,
	linux-kernel, narmstrong, Sekhar Nori, Tero Kristo

* Lokesh Vutla <lokeshvutla@ti.com> [200224 05:09]:
> Write to trigger register(OMAP_TIMER_TRIGGER_REG) will load the value
> in Load register(OMAP_TIMER_LOAD_REG) into Counter register
> (OMAP_TIMER_COUNTER_REG).
> 
> omap_dm_timer_set_load() writes into trigger register every time load
> register is updated. When timer is configured in pwm mode, this causes
> disruption in current pwm cycle, which is not expected especially when
> pwm is used as PPS signal for synchronized PTP clocks. So do not write
> into trigger register on updating the period.

This patch without patch 1/2 applied still works for me:

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

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

* [tip: timers/core] clocksource/drivers/timer-ti-dm: Do not update counter on updating the period
  2020-02-24  5:07 ` [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Lokesh Vutla
  2020-02-26 17:29   ` Tony Lindgren
@ 2020-03-19  8:47   ` tip-bot2 for Lokesh Vutla
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Lokesh Vutla @ 2020-03-19  8:47 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Lokesh Vutla, Tony Lindgren, Daniel Lezcano, x86, LKML

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     6ce4fcb015a1a1290ffafcf3554901b40f9322df
Gitweb:        https://git.kernel.org/tip/6ce4fcb015a1a1290ffafcf3554901b40f9322df
Author:        Lokesh Vutla <lokeshvutla@ti.com>
AuthorDate:    Mon, 24 Feb 2020 10:37:53 +05:30
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Thu, 27 Feb 2020 10:26:23 +01:00

clocksource/drivers/timer-ti-dm: Do not update counter on updating the period

Write to trigger register(OMAP_TIMER_TRIGGER_REG) will load the value
in Load register(OMAP_TIMER_LOAD_REG) into Counter register
(OMAP_TIMER_COUNTER_REG).

omap_dm_timer_set_load() writes into trigger register every time load
register is updated. When timer is configured in pwm mode, this causes
disruption in current pwm cycle, which is not expected especially when
pwm is used as PPS signal for synchronized PTP clocks. So do not write
into trigger register on updating the period.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200224050753.17784-3-lokeshvutla@ti.com
---
 drivers/clocksource/timer-ti-dm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 269a994..acc9360 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -577,7 +577,6 @@ static int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
 
-	omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0);
 	/* Save the context */
 	timer->context.tclr = l;
 	timer->context.tldr = load;

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

end of thread, other threads:[~2020-03-19  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24  5:07 [PATCH 0/2] clocksource: timer-ti-dm: Misc fixes for omap dm timer Lokesh Vutla
2020-02-24  5:07 ` [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable Lokesh Vutla
2020-02-26 17:09   ` Tony Lindgren
2020-02-24  5:07 ` [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Lokesh Vutla
2020-02-26 17:29   ` Tony Lindgren
2020-03-19  8:47   ` [tip: timers/core] clocksource/drivers/timer-ti-dm: " tip-bot2 for Lokesh Vutla

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