Skip to contentSkip to conversation

SGI RTC: add clocksource/clockevent driver and generic vector

PATCH Superseded Dimitri Sivanich 4 participants 14 messages Mar 3, 2009

Subsystems (7)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover SGI RTC: add clocksource/clockevent driver and generic vector

The following patches provide a driver for synchronized RTC clocksource and clockevents for SGI systems, as well as a generic system interrupt.

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.

Subject: [PATCH 1/6 v6] SGI RTC: add generic system interrupt
Subject: [PATCH 2/6 v6] SGI RTC: export clocksource_unregister
Subject: [PATCH 3/6 v6] SGI RTC: export clockevents_register_device
Subject: [PATCH 4/6 v6] SGI RTC: export schedule_on_each_cpu
Subject: [PATCH 5/6 v6] SGI RTC: loop through installed UV blades
Subject: [PATCH 6/6 v6] SGI RTC: add clocksource driver

#1 lore raw

PATCH v6 1/6 SGI RTC: add generic system interrupt

This patch allocates a system interrupt vector for various platform specific uses.

---

Made changes suggested by tglx and refreshed for latest -tip.

 arch/x86/include/asm/hardirq.h     |    1 
 arch/x86/include/asm/hw_irq.h      |    3 +
 arch/x86/include/asm/irq.h         |    9 ++++
 arch/x86/include/asm/irq_vectors.h |    5 ++
 arch/x86/kernel/entry_64.S         |    2 
 arch/x86/kernel/irq.c              |   12 +++++
 arch/x86/kernel/irqinit_64.c       |   74 +++++++++++++++++++++++++++++++++
 7 files changed, 106 insertions(+)
arch/x86/kernel/entry_64.S +2 -0
Index: linux/arch/x86/kernel/entry_64.S
===================================================================
@@ -984,6 +984,8 @@ apicinterrupt UV_BAU_MESSAGE \
 #endif
 apicinterrupt LOCAL_TIMER_VECTOR \
 	apic_timer_interrupt smp_apic_timer_interrupt
+apicinterrupt GENERIC_INTERRUPT_VECTOR \
+	generic_interrupt smp_generic_interrupt
 
 #ifdef CONFIG_SMP
 apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \
arch/x86/kernel/irqinit_64.c +74 -0

92 lines not on this page · raw message

arch/x86/include/asm/irq_vectors.h +5 -0
Index: linux/arch/x86/include/asm/irq_vectors.h
===================================================================
@@ -112,6 +112,11 @@
 #define LOCAL_PERF_VECTOR		0xee
 
 /*
+ * Generic system vector for platform specific use
+ */
+#define GENERIC_INTERRUPT_VECTOR	0xed
+
+/*
  * First APIC vector available to drivers: (vectors 0x30-0xee) we
  * start at 0x31(0x41) to spread out vectors evenly between priority
  * levels. (0x80 is the syscall vector)
arch/x86/include/asm/hw_irq.h +3 -0
Index: linux/arch/x86/include/asm/hw_irq.h
===================================================================
@@ -27,6 +27,9 @@
 
 /* Interrupt handlers registered during init_IRQ */
 extern void apic_timer_interrupt(void);
+#ifdef CONFIG_X86_64
+extern void generic_interrupt(void);
+#endif
 extern void error_interrupt(void);
 extern void perf_counter_interrupt(void);
 
arch/x86/include/asm/irq.h +9 -0
Index: linux/arch/x86/include/asm/irq.h
===================================================================
@@ -42,6 +42,15 @@ extern bool handle_irq(unsigned irq, str
 
 extern unsigned int do_IRQ(struct pt_regs *regs);
 
+#ifdef CONFIG_X86_64
+extern int is_generic_interrupt_registered(void);
+extern char *generic_interrupt_string(void);
+extern char *generic_interrupt_prefix(void);
+extern int register_generic_interrupt_extension(void (*fn)(void), const char *,
+							const char *);
+extern void unregister_generic_interrupt_extension(void);
+#endif
+
 /* Interrupt vector management */
 extern DECLARE_BITMAP(used_vectors, NR_VECTORS);
 extern int vector_used_by_percpu_irq(unsigned int vector);
arch/x86/kernel/irq.c +12 -0
Index: linux/arch/x86/kernel/irq.c
===================================================================
@@ -60,6 +60,14 @@ static int show_other_interrupts(struct 
 		seq_printf(p, "%10u ", irq_stats(j)->apic_perf_irqs);
 	seq_printf(p, "  Performance counter interrupts\n");
 #endif
+#ifdef CONFIG_X86_64
+	if (is_generic_interrupt_registered()) {
+		seq_printf(p, "%s", generic_interrupt_prefix());
+		for_each_online_cpu(j)
+			seq_printf(p, "%10u ", irq_stats(j)->generic_irqs);
+		seq_printf(p, "%s\n", generic_interrupt_string());
+	}
+#endif
 #ifdef CONFIG_SMP
 	seq_printf(p, "RES: ");
 	for_each_online_cpu(j)
@@ -168,6 +176,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 	sum += irq_stats(cpu)->apic_timer_irqs;
 	sum += irq_stats(cpu)->apic_perf_irqs;
 #endif
+#ifdef CONFIG_X86_64
+	if (is_generic_interrupt_registered())
+		sum += irq_stats(cpu)->generic_irqs;
+#endif
 #ifdef CONFIG_SMP
 	sum += irq_stats(cpu)->irq_resched_count;
 	sum += irq_stats(cpu)->irq_call_count;
arch/x86/include/asm/hardirq.h +1 -0
Index: linux/arch/x86/include/asm/hardirq.h
===================================================================
@@ -22,6 +22,7 @@ typedef struct {
 	unsigned int irq_thermal_count;
 # ifdef CONFIG_X86_64
 	unsigned int irq_threshold_count;
+	unsigned int generic_irqs;
 # endif
 #endif
 } ____cacheline_aligned irq_cpustat_t;
#2 lore raw

PATCH v6 2/6 SGI RTC: export clocksource_unregister

Export clocksource_unregister().

---

 kernel/time/clocksource.c |    1 +
 1 file changed, 1 insertion(+)
kernel/time/clocksource.c +1 -0
Index: linux/kernel/time/clocksource.c
===================================================================
@@ -370,6 +370,7 @@ void clocksource_unregister(struct clock
 	next_clocksource = select_clocksource();
 	spin_unlock_irqrestore(&clocksource_lock, flags);
 }
+EXPORT_SYMBOL_GPL(clocksource_unregister);
 
 #ifdef CONFIG_SYSFS
 /**
#3 lore raw

PATCH v6 3/6 SGI RTC: export clockevents_register_device

Export clockevents_register_device().

---

 kernel/time/clockevents.c |    1 +
 1 file changed, 1 insertion(+)
kernel/time/clockevents.c +1 -0
Index: linux/kernel/time/clockevents.c
===================================================================
@@ -187,6 +187,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
#4 lore raw

PATCH v6 4/6 SGI RTC: export schedule_on_each_cpu

Export schedule_on_each_cpu().

---

 kernel/workqueue.c |    1 +
 1 file changed, 1 insertion(+)
kernel/workqueue.c +1 -0
Index: linux/kernel/workqueue.c
===================================================================
@@ -705,6 +705,7 @@ int schedule_on_each_cpu(work_func_t fun
 	free_percpu(works);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(schedule_on_each_cpu);
 
 void flush_scheduled_work(void)
 {
#5 lore raw

PATCH v6 5/6 SGI RTC: loop through installed UV blades

Add macro to loop through each possible blade.

---

 arch/x86/include/asm/uv/uv_hub.h |    4 ++++
 1 file changed, 4 insertions(+)
arch/x86/include/asm/uv/uv_hub.h +4 -0
Index: linux/arch/x86/include/asm/uv/uv_hub.h
===================================================================
@@ -179,6 +179,10 @@ DECLARE_PER_CPU(struct uv_hub_info_s, __
 #define LOCAL_BUS_BASE		0x1c00000
 #define LOCAL_BUS_SIZE		(4 * 1024 * 1024)
 
+/* Loop through all installed blades */
+#define for_each_possible_blade(bid)                    \
+	for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++)
+
 /*
  * System Controller Interface Reg
  *
#6 lore raw

PATCH v6 6/6 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.

---

Implemented suggested changes and refreshed for latest -tip.

 drivers/clocksource/Makefile |    1 
 drivers/clocksource/rtc_uv.c |  381 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig         |    9 
 3 files changed, 391 insertions(+)
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 +9 -0
Index: linux/drivers/misc/Kconfig
===================================================================
@@ -225,6 +225,15 @@ config DELL_LAPTOP
 	This driver adds support for rfkill and backlight control to Dell
 	laptops.
 
+config SGI_RTC_TIMER
+	tristate "SGI RTC driver"
+	depends on GENERIC_CLOCKEVENTS_BUILD
+	depends on X86_UV && SMP
+	default m
+	---help---
+	This option enables RTC event handling and adds the systemwide RTC
+	as a high resolution clock source for SGI systems.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 
drivers/clocksource/rtc_uv.c new file +381 -0

381 lines not on this page · raw message

#11 lore raw

Re: [PATCH 1/6 v6] SGI RTC: add generic system interrupt

In reply to Dimitri Sivanich
Quoted 2 lines · Dimitri Sivanich

This patch allocates a system interrupt vector for various platform specific uses.

this is really ugly.

Also, why are all these symbols exported? There's no need to build the UV RTC driver as a module. It's either built-in or not built-in - it's small enough.

this stuff:

Quoted 12 lines
arch/x86/kernel/irqinit_64.c +12 -0
+/* Function pointer for generic interrupt vector handling */
+static void (*generic_interrupt_extension)(void);
+static char generic_show_string[28];
+static char generic_show_prefix[6];
+
+int is_generic_interrupt_registered()
+{
+	if (generic_interrupt_extension)
+		return 1;
+	else
+		return 0;
+}

arch/x86/kernel/irqinit_64.c static void __init init_ISA_irqs(void) · line 131

Quoted 10 lines
arch/x86/kernel/irqinit_64.c +10 -0
+
+char *generic_interrupt_string(void)
+{
+	return generic_show_string;
+}
+
+char *generic_interrupt_prefix(void)
+{
+	return generic_show_prefix;
+}

is SMP unsafe, etc. etc. - not something we should ever call from a module. We just shouldnt do it in this form. What necessiates it?

All we need is:

arch/x86/kernel/irqinit_64.c static void __init apic_intr_init(void) · line 222

Quoted 2 lines
arch/x86/kernel/irqinit_64.c +2 -0
+	/* generic IPI for platform specific use */
+	alloc_intr_gate(GENERIC_INTERRUPT_VECTOR, generic_interrupt);

plus one trivial callback function - and then the UV platform uses it for its own purpose. It's not like two platforms will be running at once so there's no locking needed, etc.

arch/x86/include/asm/hw_irq.h line 32

Quoted 3 lines
arch/x86/include/asm/hw_irq.h +3 -0
+#ifdef CONFIG_X86_64
+extern void generic_interrupt(void);
+#endif

in any case please make it symmetric across 32-bit and 64-bit - even though UV is 64-bit only.

Ingo

#7 lore raw

Re: [PATCH 6/6 v6] SGI RTC: add clocksource driver

In reply to Dimitri Sivanich
Quoted 3 lines · Dimitri Sivanich
 drivers/clocksource/Makefile |    1 
 drivers/clocksource/rtc_uv.c |  381 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig         |    9 

btw., since this is a platform driver, i'd suggest to move it to arch/x86/kernel/uv_time.c or so.

Ingo

#12 lore raw

Re: [PATCH 1/6 v6] SGI RTC: add generic system interrupt

In reply to Ingo Molnar
Quoted 11 lines · Ingo Molnar
Quoted 2 lines · Dimitri Sivanich

This patch allocates a system interrupt vector for various platform specific uses.

this is really ugly.

Also, why are all these symbols exported? There's no need to build the UV RTC driver as a module. It's either built-in or not built-in - it's small enough.

OK.

Quoted 21 lines

this stuff:

Quoted 18 lines
arch/x86/kernel/irqinit_64.c +18 -0
+/* Function pointer for generic interrupt vector handling */
+static void (*generic_interrupt_extension)(void);
+static char generic_show_string[28];
+static char generic_show_prefix[6];
+
+int is_generic_interrupt_registered()
+{
+	if (generic_interrupt_extension)
+		return 1;
+	else
+		return 0;
+}
+
+char *generic_interrupt_string(void)
+{
+	return generic_show_string;
+}
+
Quoted 8 lines

arch/x86/kernel/irqinit_64.c static void __init init_ISA_irqs(void) · line 131

Quoted 4 lines
arch/x86/kernel/irqinit_64.c +4 -0
+char *generic_interrupt_prefix(void)
+{
+	return generic_show_prefix;
+}

is SMP unsafe, etc. etc. - not something we should ever call from a module. We just shouldnt do it in this form. What necessiates it?

I wanted a way to show specific strings when displaying irq statistics. We could show these in a more generic way I suppose.

Any given platform should just be changing these once, hence the lack of need for locking.

Quoted 9 lines

All we need is:

arch/x86/kernel/irqinit_64.c static void __init apic_intr_init(void) · line 222

Quoted 2 lines
arch/x86/kernel/irqinit_64.c +2 -0
+	/* generic IPI for platform specific use */
+	alloc_intr_gate(GENERIC_INTERRUPT_VECTOR, generic_interrupt);

plus one trivial callback function - and then the UV platform uses it for its own purpose. It's not like two platforms will be running at once so there's no locking needed, etc.

Right. But still register the callback function as I have it now?

Quoted 7 lines

arch/x86/include/asm/hw_irq.h line 32

Quoted 4 lines
arch/x86/include/asm/hw_irq.h +3 -0
+#ifdef CONFIG_X86_64
+extern void generic_interrupt(void);
+#endif

in any case please make it symmetric across 32-bit and 64-bit - even though UV is 64-bit only.

OK.

Quoted 2 lines

Ingo

#13 lore raw

Re: [PATCH 1/6 v6] SGI RTC: add generic system interrupt

Quoted 59 lines · Dimitri Sivanich
Quoted 11 lines · Ingo Molnar
Quoted 2 lines · Dimitri Sivanich

This patch allocates a system interrupt vector for various platform specific uses.

this is really ugly.

Also, why are all these symbols exported? There's no need to build the UV RTC driver as a module. It's either built-in or not built-in - it's small enough.

OK.

Quoted 21 lines

this stuff:

Quoted 18 lines
arch/x86/kernel/irqinit_64.c +18 -0
+/* Function pointer for generic interrupt vector handling */
+static void (*generic_interrupt_extension)(void);
+static char generic_show_string[28];
+static char generic_show_prefix[6];
+
+int is_generic_interrupt_registered()
+{
+	if (generic_interrupt_extension)
+		return 1;
+	else
+		return 0;
+}
+
+char *generic_interrupt_string(void)
+{
+	return generic_show_string;
+}
+
Quoted 8 lines

arch/x86/kernel/irqinit_64.c static void __init init_ISA_irqs(void) · line 131

Quoted 4 lines
arch/x86/kernel/irqinit_64.c +4 -0
+char *generic_interrupt_prefix(void)
+{
+	return generic_show_prefix;
+}

is SMP unsafe, etc. etc. - not something we should ever call from a module. We just shouldnt do it in this form. What necessiates it?

I wanted a way to show specific strings when displaying irq statistics. We could show these in a more generic way I suppose.

Any given platform should just be changing these once, hence the lack of need for locking.

Quoted 9 lines

All we need is:

arch/x86/kernel/irqinit_64.c static void __init apic_intr_init(void) · line 222

Quoted 2 lines
arch/x86/kernel/irqinit_64.c +2 -0
+	/* generic IPI for platform specific use */
+	alloc_intr_gate(GENERIC_INTERRUPT_VECTOR, generic_interrupt);

plus one trivial callback function - and then the UV platform uses it for its own purpose. It's not like two platforms will be running at once so there's no locking needed, etc.

Quoted 2 lines

Right. But still register the callback function as I have it now?

i'd suggest to just override that global function pointer from the UV detection routines.

this way we have it in a minimalistically generic fashion, but with a minimum amount of fuss around it.

Ingo

#9 lore raw

Re: [PATCH 6/6 v6] SGI RTC: add clocksource driver

In reply to Dimitri Sivanich
Quoted 15 lines · Dimitri Sivanich

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.

---

Implemented suggested changes and refreshed for latest -tip.

 drivers/clocksource/Makefile |    1 
 drivers/clocksource/rtc_uv.c |  381 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig         |    9 
 3 files changed, 391 insertions(+)

[snip]

drivers/clocksource/rtc_uv.c line 44

Quoted 7 lines
drivers/clocksource/rtc_uv.c new file +7 -0
+
+static struct clocksource clocksource_uv = {
+	.name		= RTC_NAME,
+	.rating		= 400,
+	.read		= uv_read_rtc,
+	.mask		= (cycle_t)UVH_RTC_REAL_TIME_CLOCK_MASK,
+	.shift		= 10,

What is the expected value for sn_rtc_cycles_per_second ?

I ask because a shift value of 10 seems a bit low. It could very well be appropriate, but I just wanted to check.

thanks
-john

#10 lore raw

Re: [PATCH 6/6 v6] SGI RTC: add clocksource driver

Quoted 12 lines · john stultz

drivers/clocksource/rtc_uv.c line 44

Quoted 7 lines · Dimitri Sivanich
drivers/clocksource/rtc_uv.c new file +7 -0
+
+static struct clocksource clocksource_uv = {
+	.name		= RTC_NAME,
+	.rating		= 400,
+	.read		= uv_read_rtc,
+	.mask		= (cycle_t)UVH_RTC_REAL_TIME_CLOCK_MASK,
+	.shift		= 10,

What is the expected value for sn_rtc_cycles_per_second ?

Quoted 3 lines

I ask because a shift value of 10 seems a bit low. It could very well be appropriate, but I just wanted to check.

Likely in the range of 20,000,000 - 40,000,000.

#8 lore raw

Re: [PATCH 6/6 v6] SGI RTC: add clocksource driver

In reply to Ingo Molnar
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Dimitri Sivanich
 drivers/clocksource/Makefile |    1 
 drivers/clocksource/rtc_uv.c |  381 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig         |    9 

btw., since this is a platform driver, i'd suggest to move it to arch/x86/kernel/uv_time.c or so.

I thought we agreed platforms drivers go in drivers/x86?

-hpa