* [PATCH V2 0/2] rtc-cmos: Workaround unwanted interrupt generation
@ 2016-08-02 7:26 Pratyush Anand
2016-08-02 7:26 ` [PATCH V2 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Pratyush Anand
2016-08-02 7:27 ` [PATCH V2 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered Pratyush Anand
0 siblings, 2 replies; 3+ messages in thread
From: Pratyush Anand @ 2016-08-02 7:26 UTC (permalink / raw)
To: mingo, alexandre.belloni, tglx, hpa, x86
Cc: rtc-linux, linux-kernel, prarit, dyoung, a.zummo, Pratyush Anand
We have observed on few machines with rtc-cmos device that
hpet_rtc_interrupt() is called before cmos_do_probe() could call
hpet_rtc_timer_init(). It has not been observed during normal boot/reboot
of machines. It *sometime* happens when system is booted with kdump
secondary kernel. So, neither hpet_default_delta nor hpet_t1_cmp is
initialized by the time interrupt is raised in the given situation.
Therefore while loop of hpet_cnt_ahead() in hpet_rtc_timer_reinit() never
completes. This leads to "NMI watchdog: Watchdog detected hard LOCKUP on
cpu 0".
These patch set initializes hpet_default_delta and hpet_t1_cmp before
interrupt can be raised.
Changes since RFC:
- Commit log of patches has been improved.
- RFCs were here: https://lkml.org/lkml/2016/6/21/35
Pratyush Anand (2):
rtc/hpet: Factorize hpet_rtc_timer_init()
rtc/rtc-cmos: Initialize software counters before irq is registered
arch/x86/include/asm/hpet.h | 2 ++
arch/x86/kernel/hpet.c | 41 +++++++++++++++++++++++++++++++++++------
drivers/rtc/rtc-cmos.c | 13 ++++++++++++-
3 files changed, 49 insertions(+), 7 deletions(-)
--
2.5.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH V2 1/2] rtc/hpet: Factorize hpet_rtc_timer_init()
2016-08-02 7:26 [PATCH V2 0/2] rtc-cmos: Workaround unwanted interrupt generation Pratyush Anand
@ 2016-08-02 7:26 ` Pratyush Anand
2016-08-02 7:27 ` [PATCH V2 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered Pratyush Anand
1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Anand @ 2016-08-02 7:26 UTC (permalink / raw)
To: mingo, alexandre.belloni, tglx, hpa, x86
Cc: rtc-linux, linux-kernel, prarit, dyoung, a.zummo, Pratyush Anand,
Borislav Petkov, Denys Vlasenko, Ingo Molnar, Jan Beulich,
Sebastian Andrzej Siewior
We have observed on few machines with rtc-cmos device that
hpet_rtc_interrupt() is called before cmos_do_probe() could call
hpet_rtc_timer_init(). It has not been observed during normal boot/reboot
of machines. It *sometime* happens when system is booted with kdump
secondary kernel. So, neither hpet_default_delta nor hpet_t1_cmp is
initialized by the time interrupt is raised in the given situation.
Therefore while loop of hpet_cnt_ahead() in hpet_rtc_timer_reinit() never
completes. This leads to "NMI watchdog: Watchdog detected hard LOCKUP on
cpu 0".
This patch factorize hpet_rtc_timer_init(), so that counter can be
initialized before irq is registered.
No functional change in this patch.
Signed-off-by: Pratyush Anand <panand@redhat.com>
---
arch/x86/include/asm/hpet.h | 2 ++
arch/x86/kernel/hpet.c | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index cc285ec4b2c1..8eecb31bebcb 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -96,6 +96,8 @@ extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
unsigned char sec);
extern int hpet_set_periodic_freq(unsigned long freq);
extern int hpet_rtc_dropped_irq(void);
+extern int hpet_rtc_timer_counter_init(void);
+extern int hpet_rtc_timer_enable(void);
extern int hpet_rtc_timer_init(void);
extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
extern int hpet_register_irq_handler(rtc_irq_handler handler);
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 3d747070fe67..c9da694ff236 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -1075,14 +1075,12 @@ void hpet_unregister_irq_handler(rtc_irq_handler handler)
EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler);
/*
- * Timer 1 for RTC emulation. We use one shot mode, as periodic mode
- * is not supported by all HPET implementations for timer 1.
- *
- * hpet_rtc_timer_init() is called when the rtc is initialized.
+ * hpet_rtc_timer_counter_init() is called before interrupt can be
+ * registered
*/
-int hpet_rtc_timer_init(void)
+int hpet_rtc_timer_counter_init(void)
{
- unsigned int cfg, cnt, delta;
+ unsigned int cnt, delta;
unsigned long flags;
if (!is_hpet_enabled())
@@ -1107,6 +1105,22 @@ int hpet_rtc_timer_init(void)
hpet_writel(cnt, HPET_T1_CMP);
hpet_t1_cmp = cnt;
+ local_irq_restore(flags);
+
+ return 1;
+}
+EXPORT_SYMBOL_GPL(hpet_rtc_timer_counter_init);
+
+/*
+ * hpet_rtc_timer_enable() is called during RTC initialization
+ */
+int hpet_rtc_timer_enable(void)
+{
+ unsigned int cfg;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
cfg = hpet_readl(HPET_T1_CFG);
cfg &= ~HPET_TN_PERIODIC;
cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
@@ -1116,6 +1130,21 @@ int hpet_rtc_timer_init(void)
return 1;
}
+EXPORT_SYMBOL_GPL(hpet_rtc_timer_enable);
+
+/*
+ * Timer 1 for RTC emulation. We use one shot mode, as periodic mode
+ * is not supported by all HPET implementations for timer 1.
+ *
+ * hpet_rtc_timer_init() is called when the rtc is initialized.
+ */
+int hpet_rtc_timer_init(void)
+{
+ if (!hpet_rtc_timer_counter_init())
+ return 0;
+
+ return hpet_rtc_timer_enable();
+}
EXPORT_SYMBOL_GPL(hpet_rtc_timer_init);
static void hpet_disable_rtc_channel(void)
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH V2 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered
2016-08-02 7:26 [PATCH V2 0/2] rtc-cmos: Workaround unwanted interrupt generation Pratyush Anand
2016-08-02 7:26 ` [PATCH V2 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Pratyush Anand
@ 2016-08-02 7:27 ` Pratyush Anand
1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Anand @ 2016-08-02 7:27 UTC (permalink / raw)
To: mingo, alexandre.belloni, tglx, hpa, x86
Cc: rtc-linux, linux-kernel, prarit, dyoung, a.zummo, Pratyush Anand
We have observed on few machines with rtc-cmos device that
hpet_rtc_interrupt() is called before cmos_do_probe() could call
hpet_rtc_timer_init(). It has not been observed during normal boot/reboot
of machines. It *sometime* happens when system is booted with kdump
secondary kernel. So, neither hpet_default_delta nor hpet_t1_cmp is
initialized by the time interrupt is raised in the given situation.
Therefore while loop of hpet_cnt_ahead() in hpet_rtc_timer_reinit() never
completes. This leads to "NMI watchdog: Watchdog detected hard LOCKUP on
cpu 0".
Software counters are being initialized in this patch so that LOCKUP could
be avoided.
Signed-off-by: Pratyush Anand <panand@redhat.com>
---
drivers/rtc/rtc-cmos.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index fbe9c72438e1..101dc948295f 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -129,6 +129,16 @@ static inline int hpet_rtc_dropped_irq(void)
return 0;
}
+static inline int hpet_rtc_timer_counter_init(void)
+{
+ return 0;
+}
+
+static inline int hpet_rtc_timer_enable(void)
+{
+ return 0;
+}
+
static inline int hpet_rtc_timer_init(void)
{
return 0;
@@ -710,6 +720,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
goto cleanup1;
}
+ hpet_rtc_timer_counter_init();
if (is_valid_irq(rtc_irq)) {
irq_handler_t rtc_cmos_int_handler;
@@ -732,7 +743,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
goto cleanup1;
}
}
- hpet_rtc_timer_init();
+ hpet_rtc_timer_enable();
/* export at least the first block of NVRAM */
nvram.size = address_space - NVRAM_OFFSET;
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-02 7:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 7:26 [PATCH V2 0/2] rtc-cmos: Workaround unwanted interrupt generation Pratyush Anand
2016-08-02 7:26 ` [PATCH V2 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Pratyush Anand
2016-08-02 7:27 ` [PATCH V2 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered Pratyush Anand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox