linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled
@ 2018-06-21  9:13 Keerthy
  2018-07-03  9:38 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Keerthy @ 2018-06-21  9:13 UTC (permalink / raw)
  To: tony; +Cc: t-kristo, j-keerthy, linux-omap, linux-arm-kernel, d-gerlach

From: Dave Gerlach <d-gerlach@ti.com>

When the RTC lock and unlock functions were introduced it was likely
assumed that they would always be called from irq enabled context, hence
the use of local_irq_disable/enable. This is no longer true as the
RTC+DDR path makes a late call during the suspend path after irqs
have been disabled to enable the RTC hwmod which calls both unlock and
lock, leading to IRQs being reenabled through the local_irq_enable call
in omap_hwmod_rtc_lock call.

To avoid this change the local_irq_disable/enable to
local_irq_save/restore to ensure that from whatever context this is
called the proper IRQ configuration is maintained.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod_reset.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_reset.c b/arch/arm/mach-omap2/omap_hwmod_reset.c
index b68f9c0..d5ddba0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_reset.c
+++ b/arch/arm/mach-omap2/omap_hwmod_reset.c
@@ -92,11 +92,13 @@ static void omap_rtc_wait_not_busy(struct omap_hwmod *oh)
  */
 void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
 {
-	local_irq_disable();
+	unsigned long flags;
+
+	local_irq_save(flags);
 	omap_rtc_wait_not_busy(oh);
 	omap_hwmod_write(OMAP_RTC_KICK0_VALUE, oh, OMAP_RTC_KICK0_REG);
 	omap_hwmod_write(OMAP_RTC_KICK1_VALUE, oh, OMAP_RTC_KICK1_REG);
-	local_irq_enable();
+	local_irq_restore(flags);
 }
 
 /**
@@ -110,9 +112,11 @@ void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
  */
 void omap_hwmod_rtc_lock(struct omap_hwmod *oh)
 {
-	local_irq_disable();
+	unsigned long flags;
+
+	local_irq_save(flags);
 	omap_rtc_wait_not_busy(oh);
 	omap_hwmod_write(0x0, oh, OMAP_RTC_KICK0_REG);
 	omap_hwmod_write(0x0, oh, OMAP_RTC_KICK1_REG);
-	local_irq_enable();
+	local_irq_restore(flags);
 }
-- 
1.9.1

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

* Re: [PATCH] ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled
  2018-06-21  9:13 [PATCH] ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled Keerthy
@ 2018-07-03  9:38 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2018-07-03  9:38 UTC (permalink / raw)
  To: Keerthy; +Cc: t-kristo, linux-omap, linux-arm-kernel, d-gerlach

* Keerthy <j-keerthy@ti.com> [180621 02:16]:
> From: Dave Gerlach <d-gerlach@ti.com>
> 
> When the RTC lock and unlock functions were introduced it was likely
> assumed that they would always be called from irq enabled context, hence
> the use of local_irq_disable/enable. This is no longer true as the
> RTC+DDR path makes a late call during the suspend path after irqs
> have been disabled to enable the RTC hwmod which calls both unlock and
> lock, leading to IRQs being reenabled through the local_irq_enable call
> in omap_hwmod_rtc_lock call.
> 
> To avoid this change the local_irq_disable/enable to
> local_irq_save/restore to ensure that from whatever context this is
> called the proper IRQ configuration is maintained.

Thanks applying into omap-for-v4.19/soc.

Tony

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

end of thread, other threads:[~2018-07-03  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-21  9:13 [PATCH] ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled Keerthy
2018-07-03  9:38 ` 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).