Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427293 > unrolled thread

[PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init()

Started byPratyush Anand <panand@redhat.com>
First post2016-06-21 07:00 +0200
Last post2016-06-23 16:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Pratyush Anand <panand@redhat.com> - 2016-06-21 07:00 +0200
    Re: [PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Thomas Gleixner <tglx@linutronix.de> - 2016-06-23 10:40 +0200
      Re: [PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init() Pratyush Anand <panand@redhat.com> - 2016-06-23 16:40 +0200

#1427293 — [PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init()

FromPratyush Anand <panand@redhat.com>
Date2016-06-21 07:00 +0200
Subject[PATCH RFC 1/2] rtc/hpet: Factorize hpet_rtc_timer_init()
Message-ID<rMlX4-15G-15@gated-at.bofh.it>
This patch factorize hpet_rtc_timer_init(), so that counter can be
initialized before irq is registered.

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 f112af7aa62e..cd5153126958 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -1076,14 +1076,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())
@@ -1108,6 +1106,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;
@@ -1117,6 +1131,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

[toc] | [next] | [standalone]


#1429582

FromThomas Gleixner <tglx@linutronix.de>
Date2016-06-23 10:40 +0200
Message-ID<rN8l3-7kx-17@gated-at.bofh.it>
In reply to#1427293
On Tue, 21 Jun 2016, Pratyush Anand wrote:

> This patch factorize hpet_rtc_timer_init(), so that counter can be
> initialized before irq is registered.

This changelog is useless. It tells what the patch does, but not WHY this is
required.
 
Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1429908

FromPratyush Anand <panand@redhat.com>
Date2016-06-23 16:40 +0200
Message-ID<rNdXs-2Tn-33@gated-at.bofh.it>
In reply to#1429582
Hi Thomas,

On 23/06/2016:10:33:26 AM, Thomas Gleixner wrote:
> On Tue, 21 Jun 2016, Pratyush Anand wrote:
> 
> > This patch factorize hpet_rtc_timer_init(), so that counter can be
> > initialized before irq is registered.
> 
> This changelog is useless. It tells what the patch does, but not WHY this is
> required.

Sorry, I have described the problem in the cover letter which is here [1].
Please, let me know if any further test/debug result you would need.

Thanks for your help!!

~Pratyush

[1] https://lkml.org/lkml/2016/6/21/35

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web