Skip to contentSkip to conversation

SGI RTC: add clocksource/clockevent driver and timer bios calls

PATCH Superseded Dimitri Sivanich 2 participants 6 messages Oct 21, 2008 – Oct 22, 2008

Subsystems (5)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover SGI RTC: add clocksource/clockevent driver and timer bios calls

The following patchset provides a driver and bios call framework for synchronized RTC clocksource and clockevents for SGI systems.

With these patches, a module can be installed that registers the system-wide synchronized RTC clocksource and timers as both a clocksource and clockevents device running in high resolution mode.

[PATCH 1/3] SGI RTC: add clocksource driver
[PATCH 2/3] SGI RTC: add bios framework for RTC timer operations [PATCH 3/3] SGI RTC: add RTC system interrupt

These patches should be installed on top of the following:

	http://marc.info/?l=linux-kernel&m=122461934110503&w=2
	http://marc.info/?l=linux-kernel&m=122461934110506&w=2
	http://marc.info/?l=linux-kernel&m=122461934210509&w=2
#1 lore raw

PATCH 1/3 SGI RTC: add clocksource driver

This patch provides a driver for SGI RTC clocks and timers.

This provides a high resolution clock and timer source using the SGI system-wide synchronized RTC clock/timer hardware.

drivers/clocksource/Makefile +1 -0
Index: linux/drivers/clocksource/Makefile
===================================================================
@@ -2,3 +2,4 @@ obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_cl
 obj-$(CONFIG_X86_CYCLONE_TIMER)	+= cyclone.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
+obj-$(CONFIG_SGI_RTC_TIMER)	+= rtc_uv.o
drivers/misc/Kconfig +8 -0
Index: linux/drivers/misc/Kconfig
===================================================================
@@ -488,4 +488,12 @@ config SGI_GRU_DEBUG
 	This option enables addition debugging code for the SGI GRU driver. If
 	you are unsure, say N.
 
+config SGI_RTC_TIMER
+	tristate "SGI RTC driver"
+	depends on X86_64 || IA64_SGI_UV
+	default m
+	---help---
+	This option enables RTC event handling and adds the systemwide RTC
+	as a high resolution clock source for SGI systems.
+
 endif # MISC_DEVICES
drivers/clocksource/rtc_uv.c new file +213 -0

213 lines not on this page · raw message

kernel/time/clockevents.c +1 -0
Index: linux/kernel/time/clockevents.c
===================================================================
@@ -183,6 +183,7 @@ void clockevents_register_device(struct 
 
 	spin_unlock(&clockevents_lock);
 }
+EXPORT_SYMBOL_GPL(clockevents_register_device);
 
 /*
  * Noop handler when we shut down an event device
kernel/time/clocksource.c +1 -0
Index: linux/kernel/time/clocksource.c
===================================================================
@@ -369,6 +369,7 @@ void clocksource_unregister(struct clock
 	next_clocksource = select_clocksource();
 	spin_unlock_irqrestore(&clocksource_lock, flags);
 }
+EXPORT_SYMBOL(clocksource_unregister);
 
 #ifdef CONFIG_SYSFS
 /**
#2 lore raw

PATCH 2/3 SGI RTC: add bios framework for RTC timer operations

This patch provides a bios call framework for implementing SGI RTC timer functions.

arch/x86/kernel/bios_uv.c +60 -0
Index: linux/arch/x86/kernel/bios_uv.c
===================================================================
@@ -160,6 +160,66 @@ s64 uv_bios_freq_base(u64 clock_type, u6
 }
 EXPORT_SYMBOL_GPL(uv_bios_freq_base);
 
+int uv_bios_rtct(enum uv_bios_rtct_cmd which, void *a1, void *a2, void *a3,
+			void *a4, void *a5)
+{
+	int rc = 0;
+
+	switch (which) {
+	case UV_RTC_MASK:
+		rc = uv_bios_call(UV_BIOS_RTC_MASK, (u64)a1, 0, 0, 0, 0);
+		break;
+	case UV_RTC_READ:
+		rc = uv_bios_call(UV_BIOS_RTC_READ, (u64)a1, 0, 0, 0, 0);
+		break;
+	case UV_RTC_EVT_INIT:
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_INIT, (u64)a1, (u64)a2,
+				(u64)a3, (u64)a4, (u64)a5);
+		break;
+	case UV_RTC_EVT_SET:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_SET, apicid, (u64)a2, 0, 0,
+				0);
+		}
+		break;
+	case UV_RTC_EVT_UNSET:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_UNSET, apicid, 0, 0, 0, 0);
+		}
+		break;
+	case UV_RTC_EVT_ACK:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_ACK, apicid, 0, 0, 0, 0);
+		}
+		break;
+	case UV_RTC_EVT_START:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_START, apicid, 0, 0, 0, 0);
+		}
+		break;
+	case UV_RTC_EVT_STOP:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_STOP, apicid, 0, 0, 0, 0);
+		}
+		break;
+	case UV_RTC_EVT_RESUME:
+		{
+		u64 apicid = per_cpu(x86_cpu_to_apicid, *(int *)a1);
+		rc = uv_bios_call(UV_BIOS_RTC_EVT_RESUME, apicid, 0, 0, 0, 0);
+		}
+		break;
+	default:
+		rc = -1;
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(uv_bios_rtct);
 
 #ifdef CONFIG_EFI
 void uv_bios_init(void)
include/asm-x86/uv/bios.h +29 -1
Index: linux/include/asm-x86/uv/bios.h
===================================================================
@@ -36,7 +36,16 @@ enum uv_bios_cmd {
 	UV_BIOS_WATCHLIST_ALLOC,
 	UV_BIOS_WATCHLIST_FREE,
 	UV_BIOS_MEMPROTECT,
-	UV_BIOS_GET_PARTITION_ADDR
+	UV_BIOS_GET_PARTITION_ADDR,
+	UV_BIOS_RTC_MASK,
+	UV_BIOS_RTC_READ,
+	UV_BIOS_RTC_EVT_INIT,
+	UV_BIOS_RTC_EVT_SET,
+	UV_BIOS_RTC_EVT_UNSET,
+	UV_BIOS_RTC_EVT_ACK,
+	UV_BIOS_RTC_EVT_START,
+	UV_BIOS_RTC_EVT_STOP,
+	UV_BIOS_RTC_EVT_RESUME
 };
 
 /*
@@ -66,6 +75,22 @@ enum {
 	BIOS_FREQ_BASE_REALTIME_CLOCK = 2
 };
 
+/*
+ * Values for the BIOS rtct calls.  It is passed as the first argument
+ * in the uv_bios_rtct call.
+ */
+enum uv_bios_rtct_cmd {
+	UV_RTC_MASK,
+	UV_RTC_READ,
+	UV_RTC_EVT_INIT,
+	UV_RTC_EVT_SET,
+	UV_RTC_EVT_UNSET,
+	UV_RTC_EVT_ACK,
+	UV_RTC_EVT_START,
+	UV_RTC_EVT_STOP,
+	UV_RTC_EVT_RESUME
+};
+
 union partition_info_u {
 	u64	val;
 	struct {
@@ -106,6 +131,9 @@ extern int uv_bios_mq_watchlist_free(int
 extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
 extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *);
 
+extern int uv_bios_rtct(enum uv_bios_rtct_cmd, void *, void *, void *,
+					void *, void *);
+
 extern void uv_bios_init(void);
 
 extern unsigned long sn_rtc_cycles_per_second;
#3 lore raw

PATCH 3/3 SGI RTC: add RTC system interrupt

This patch allocates a system interrupt vector for architecture specific use in implementing RTC timer interrupts.

arch/x86/kernel/entry_64.S +4 -0
Index: linux/arch/x86/kernel/entry_64.S
===================================================================
@@ -858,6 +858,10 @@ ENTRY(apic_timer_interrupt)
 	apicinterrupt LOCAL_TIMER_VECTOR,smp_apic_timer_interrupt
 END(apic_timer_interrupt)
 
+ENTRY(uv_rtc_timer_intr)
+	apicinterrupt RTC_TIMER_VECTOR,uv_rtc_timer_interrupt
+END(uv_rtc_timer_intr)
+
 ENTRY(uv_bau_message_intr1)
 	apicinterrupt 220,uv_bau_message_interrupt
 END(uv_bau_message_intr1)
arch/x86/kernel/irqinit_64.c +3 -0
Index: linux/arch/x86/kernel/irqinit_64.c
===================================================================
@@ -205,6 +205,9 @@ static void __init apic_intr_init(void)
 	/* self generated IPI for local APIC timer */
 	alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
 
+	/* IPI for RTC timers */
+	alloc_intr_gate(RTC_TIMER_VECTOR, uv_rtc_timer_intr);
+
 	/* IPI vectors for APIC spurious and error interrupts */
 	alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
 	alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
include/asm-x86/irq_vectors.h +1 -0
Index: linux/include/asm-x86/irq_vectors.h
===================================================================
@@ -90,6 +90,7 @@
  * sources per level' errata.
  */
 #define LOCAL_TIMER_VECTOR	0xef
+#define RTC_TIMER_VECTOR	0xee
 
 /*
  * First APIC vector available to drivers: (vectors 0x30-0xee) we
arch/x86/kernel/genx2apic_uv_x.c +41 -0

53 lines not on this page · raw message

include/asm-x86/genapic_64.h +2 -0
Index: linux/include/asm-x86/genapic_64.h
===================================================================
@@ -49,6 +49,8 @@ extern int is_uv_system(void);
 
 extern struct genapic apic_x2apic_uv_x;
 DECLARE_PER_CPU(int, x2apic_extra_bits);
+extern int uv_rtc_reg_extension(void (*fn)(void));
+extern void uv_rtc_unreg_extension(void);
 extern void uv_cpu_init(void);
 extern void uv_system_init(void);
 extern int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip);
include/asm-x86/hw_irq.h +1 -0
Index: linux/include/asm-x86/hw_irq.h
===================================================================
@@ -29,6 +29,7 @@
 
 /* Interrupt handlers registered during init_IRQ */
 extern void apic_timer_interrupt(void);
+extern void uv_rtc_timer_intr(void);
 extern void error_interrupt(void);
 extern void spurious_interrupt(void);
 extern void thermal_interrupt(void);
#4 lore raw
In reply to Dimitri Sivanich
Quoted 11 lines · Dimitri Sivanich

The following patchset provides a driver and bios call framework for synchronized RTC clocksource and clockevents for SGI systems.

With these patches, a module can be installed that registers the system-wide synchronized RTC clocksource and timers as both a clocksource and clockevents device running in high resolution mode.

[PATCH 1/3] SGI RTC: add clocksource driver
[PATCH 2/3] SGI RTC: add bios framework for RTC timer operations [PATCH 3/3] SGI RTC: add RTC system interrupt

hm, i dont really like the direction of this.

Why isnt there a native Linux driver offered for this? This isnt about memory discovery or device discovery, where BIOS interaction might be acceptable (and might be unavoidable). This is about hardware interfaces and drivers, and the last thing we want there is BIOSes.

Ingo

#5 lore raw
Quoted 15 lines · Ingo Molnar
Quoted 11 lines · Dimitri Sivanich

The following patchset provides a driver and bios call framework for synchronized RTC clocksource and clockevents for SGI systems.

With these patches, a module can be installed that registers the system-wide synchronized RTC clocksource and timers as both a clocksource and clockevents device running in high resolution mode.

[PATCH 1/3] SGI RTC: add clocksource driver
[PATCH 2/3] SGI RTC: add bios framework for RTC timer operations [PATCH 3/3] SGI RTC: add RTC system interrupt

Quoted 6 lines

hm, i dont really like the direction of this.

Why isnt there a native Linux driver offered for this? This isnt about memory discovery or device discovery, where BIOS interaction might be acceptable (and might be unavoidable). This is about hardware interfaces and drivers, and the last thing we want there is BIOSes.

Ingo,

I'm perfectly willing to do this with a native Linux driver. My reason for doing it the above way was that as the hardware interfaces change, we wouldn't have to be pulling all of those hardware interface changes into the community kernel.

I'll try to get a new patchset submitted for the native driver tomorrow.