All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface
@ 2015-07-16 10:58 Viresh Kumar
  2015-07-16 10:58 ` [PATCH 1/5] x86/apic: Migrate to new " Viresh Kumar
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar

Hi Thomas/Ingo,

This series migrates x86 architecture clockevent drivers to the new
set-state interface. This would enable these drivers to use new states
(like: ONESHOT_STOPPED, etc.) of a clockevent device (if required), as
the set-mode interface is marked obsolete now and wouldn't be expanded
to handle new states.

Rebased over: v4.2-rc2
Target kernel: v4.3

This has been build/boot tested by two bots for few days now.

- kernelci, http://kernelci.org/
- 0-DAY kernel test infrastructure, kbuild test robot

Viresh Kumar (5):
  x86/apic: Migrate to new 'set-state' interface
  x86/hpet: Migrate to new 'set-state' interface
  x86/lguest/timer: Migrate to new 'set-state' interface
  x86/uv/time: Migrate to new 'set-state' interface
  x86/xen/time: Migrate to new 'set-state' interface

 arch/x86/kernel/apic/apic.c    |  86 ++++++++++--------
 arch/x86/kernel/hpet.c         | 198 ++++++++++++++++++++++++++---------------
 arch/x86/lguest/boot.c         |  24 ++---
 arch/x86/platform/uv/uv_time.c |  37 +++-----
 arch/x86/xen/time.c            |  63 +++++--------
 5 files changed, 217 insertions(+), 191 deletions(-)

-- 
2.4.0


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

* [PATCH 1/5] x86/apic: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  2015-07-30 19:27   ` [tip:x86/apic] x86/apic: Migrate apic timer to new set_state interface tip-bot for Viresh Kumar
  2015-07-16 10:58 ` [PATCH 2/5] x86/hpet: Migrate to new 'set-state' interface Viresh Kumar
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar, Jiang Liu,
	Borislav Petkov, David Rientjes, Bandan Das

Migrate apic driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching to resume mode and so that
callback isn't implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/kernel/apic/apic.c | 86 +++++++++++++++++++++++++++------------------
 1 file changed, 51 insertions(+), 35 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index dcb52850a28f..ecd6705c9f4b 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -462,40 +462,53 @@ static int lapic_next_deadline(unsigned long delta,
 	return 0;
 }
 
-/*
- * Setup the lapic timer in periodic or oneshot mode
- */
-static void lapic_timer_setup(enum clock_event_mode mode,
-			      struct clock_event_device *evt)
+static int lapic_timer_shutdown(struct clock_event_device *evt)
 {
 	unsigned long flags;
 	unsigned int v;
 
 	/* Lapic used as dummy for broadcast ? */
 	if (evt->features & CLOCK_EVT_FEAT_DUMMY)
-		return;
+		return 0;
 
 	local_irq_save(flags);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-	case CLOCK_EVT_MODE_ONESHOT:
-		__setup_APIC_LVTT(lapic_timer_frequency,
-				  mode != CLOCK_EVT_MODE_PERIODIC, 1);
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		v = apic_read(APIC_LVTT);
-		v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
-		apic_write(APIC_LVTT, v);
-		apic_write(APIC_TMICT, 0);
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		/* Nothing to do here */
-		break;
-	}
+	v = apic_read(APIC_LVTT);
+	v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
+	apic_write(APIC_LVTT, v);
+	apic_write(APIC_TMICT, 0);
+
+	local_irq_restore(flags);
+
+	return 0;
+}
+
+static inline int
+lapic_timer_set_periodic_oneshot(struct clock_event_device *evt, bool oneshot)
+{
+	unsigned long flags;
+
+	/* Lapic used as dummy for broadcast ? */
+	if (evt->features & CLOCK_EVT_FEAT_DUMMY)
+		return 0;
+
+	local_irq_save(flags);
+
+	__setup_APIC_LVTT(lapic_timer_frequency, oneshot, 1);
 
 	local_irq_restore(flags);
+
+	return 0;
+}
+
+static int lapic_timer_set_periodic(struct clock_event_device *evt)
+{
+	return lapic_timer_set_periodic_oneshot(evt, false);
+}
+
+static int lapic_timer_set_oneshot(struct clock_event_device *evt)
+{
+	return lapic_timer_set_periodic_oneshot(evt, true);
 }
 
 /*
@@ -513,15 +526,18 @@ static void lapic_timer_broadcast(const struct cpumask *mask)
  * The local apic timer can be used for any function which is CPU local.
  */
 static struct clock_event_device lapic_clockevent = {
-	.name		= "lapic",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
-			| CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY,
-	.shift		= 32,
-	.set_mode	= lapic_timer_setup,
-	.set_next_event	= lapic_next_event,
-	.broadcast	= lapic_timer_broadcast,
-	.rating		= 100,
-	.irq		= -1,
+	.name			= "lapic",
+	.features		= CLOCK_EVT_FEAT_PERIODIC |
+				  CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
+				  | CLOCK_EVT_FEAT_DUMMY,
+	.shift			= 32,
+	.set_state_shutdown	= lapic_timer_shutdown,
+	.set_state_periodic	= lapic_timer_set_periodic,
+	.set_state_oneshot	= lapic_timer_set_oneshot,
+	.set_next_event		= lapic_next_event,
+	.broadcast		= lapic_timer_broadcast,
+	.rating			= 100,
+	.irq			= -1,
 };
 static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
 
@@ -778,7 +794,7 @@ static int __init calibrate_APIC_clock(void)
 		 * Setup the apic timer manually
 		 */
 		levt->event_handler = lapic_cal_handler;
-		lapic_timer_setup(CLOCK_EVT_MODE_PERIODIC, levt);
+		lapic_timer_set_periodic(levt);
 		lapic_cal_loops = -1;
 
 		/* Let the interrupts run */
@@ -788,7 +804,7 @@ static int __init calibrate_APIC_clock(void)
 			cpu_relax();
 
 		/* Stop the lapic timer */
-		lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, levt);
+		lapic_timer_shutdown(levt);
 
 		/* Jiffies delta */
 		deltaj = lapic_cal_j2 - lapic_cal_j1;
@@ -878,7 +894,7 @@ static void local_apic_timer_interrupt(void)
 	if (!evt->event_handler) {
 		pr_warning("Spurious LAPIC timer interrupt on cpu %d\n", cpu);
 		/* Switch it off */
-		lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
+		lapic_timer_shutdown(evt);
 		return;
 	}
 
-- 
2.4.0


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

* [PATCH 2/5] x86/hpet: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
  2015-07-16 10:58 ` [PATCH 1/5] x86/apic: Migrate to new " Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  2015-07-30 19:30   ` [tip:x86/core] x86/hpet: Migrate to new set_state interface tip-bot for Viresh Kumar
  2015-07-16 10:58 ` [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface Viresh Kumar
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar, Jiang Liu,
	Andrew Morton, Rasmus Villemoes

Migrate hpet driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Forward definition of 'hpet_clockevent' wasn't required and so it is
placed after all the callback are defined, to avoid forward declaring
all the callbacks.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/kernel/hpet.c | 198 +++++++++++++++++++++++++++++++------------------
 1 file changed, 124 insertions(+), 74 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 10757d0a3fcf..437297ac96d0 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -226,22 +226,7 @@ static void hpet_reserve_platform_timers(unsigned int id) { }
  */
 static unsigned long hpet_freq;
 
-static void hpet_legacy_set_mode(enum clock_event_mode mode,
-			  struct clock_event_device *evt);
-static int hpet_legacy_next_event(unsigned long delta,
-			   struct clock_event_device *evt);
-
-/*
- * The hpet clock event device
- */
-static struct clock_event_device hpet_clockevent = {
-	.name		= "hpet",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.set_mode	= hpet_legacy_set_mode,
-	.set_next_event = hpet_legacy_next_event,
-	.irq		= 0,
-	.rating		= 50,
-};
+static struct clock_event_device hpet_clockevent;
 
 static void hpet_stop_counter(void)
 {
@@ -306,64 +291,74 @@ static void hpet_legacy_clockevent_register(void)
 	printk(KERN_DEBUG "hpet clockevent registered\n");
 }
 
-static void hpet_set_mode(enum clock_event_mode mode,
-			  struct clock_event_device *evt, int timer)
+static int hpet_set_periodic(struct clock_event_device *evt, int timer)
 {
 	unsigned int cfg, cmp, now;
 	uint64_t delta;
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		hpet_stop_counter();
-		delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
-		delta >>= evt->shift;
-		now = hpet_readl(HPET_COUNTER);
-		cmp = now + (unsigned int) delta;
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
-		       HPET_TN_SETVAL | HPET_TN_32BIT;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		hpet_writel(cmp, HPET_Tn_CMP(timer));
-		udelay(1);
-		/*
-		 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
-		 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
-		 * bit is automatically cleared after the first write.
-		 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
-		 * Publication # 24674)
-		 */
-		hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer));
-		hpet_start_counter();
-		hpet_print_config();
-		break;
+	hpet_stop_counter();
+	delta = ((uint64_t)(NSEC_PER_SEC / HZ)) * evt->mult;
+	delta >>= evt->shift;
+	now = hpet_readl(HPET_COUNTER);
+	cmp = now + (unsigned int)delta;
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
+	       HPET_TN_32BIT;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+	hpet_writel(cmp, HPET_Tn_CMP(timer));
+	udelay(1);
+	/*
+	 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
+	 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
+	 * bit is automatically cleared after the first write.
+	 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
+	 * Publication # 24674)
+	 */
+	hpet_writel((unsigned int)delta, HPET_Tn_CMP(timer));
+	hpet_start_counter();
+	hpet_print_config();
 
-	case CLOCK_EVT_MODE_ONESHOT:
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg &= ~HPET_TN_PERIODIC;
-		cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		break;
+	return 0;
+}
 
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg &= ~HPET_TN_ENABLE;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		break;
+static int hpet_set_oneshot(struct clock_event_device *evt, int timer)
+{
+	unsigned int cfg;
 
-	case CLOCK_EVT_MODE_RESUME:
-		if (timer == 0) {
-			hpet_enable_legacy_int();
-		} else {
-			struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
-			irq_domain_activate_irq(irq_get_irq_data(hdev->irq));
-			disable_irq(hdev->irq);
-			irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu));
-			enable_irq(hdev->irq);
-		}
-		hpet_print_config();
-		break;
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg &= ~HPET_TN_PERIODIC;
+	cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+
+	return 0;
+}
+
+static int hpet_shutdown(struct clock_event_device *evt, int timer)
+{
+	unsigned int cfg;
+
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg &= ~HPET_TN_ENABLE;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+
+	return 0;
+}
+
+static int hpet_resume(struct clock_event_device *evt, int timer)
+{
+	if (!timer) {
+		hpet_enable_legacy_int();
+	} else {
+		struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+		irq_domain_activate_irq(irq_get_irq_data(hdev->irq));
+		disable_irq(hdev->irq);
+		irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu));
+		enable_irq(hdev->irq);
 	}
+	hpet_print_config();
+
+	return 0;
 }
 
 static int hpet_next_event(unsigned long delta,
@@ -403,10 +398,24 @@ static int hpet_next_event(unsigned long delta,
 	return res < HPET_MIN_CYCLES ? -ETIME : 0;
 }
 
-static void hpet_legacy_set_mode(enum clock_event_mode mode,
-			struct clock_event_device *evt)
+static int hpet_legacy_shutdown(struct clock_event_device *evt)
+{
+	return hpet_shutdown(evt, 0);
+}
+
+static int hpet_legacy_set_oneshot(struct clock_event_device *evt)
+{
+	return hpet_set_oneshot(evt, 0);
+}
+
+static int hpet_legacy_set_periodic(struct clock_event_device *evt)
 {
-	hpet_set_mode(mode, evt, 0);
+	return hpet_set_periodic(evt, 0);
+}
+
+static int hpet_legacy_resume(struct clock_event_device *evt)
+{
+	return hpet_resume(evt, 0);
 }
 
 static int hpet_legacy_next_event(unsigned long delta,
@@ -416,6 +425,22 @@ static int hpet_legacy_next_event(unsigned long delta,
 }
 
 /*
+ * The hpet clock event device
+ */
+static struct clock_event_device hpet_clockevent = {
+	.name			= "hpet",
+	.features		= CLOCK_EVT_FEAT_PERIODIC |
+				  CLOCK_EVT_FEAT_ONESHOT,
+	.set_state_periodic	= hpet_legacy_set_periodic,
+	.set_state_oneshot	= hpet_legacy_set_oneshot,
+	.set_state_shutdown	= hpet_legacy_shutdown,
+	.tick_resume		= hpet_legacy_resume,
+	.set_next_event		= hpet_legacy_next_event,
+	.irq			= 0,
+	.rating			= 50,
+};
+
+/*
  * HPET MSI Support
  */
 #ifdef CONFIG_PCI_MSI
@@ -459,11 +484,32 @@ void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg)
 	msg->address_hi = 0;
 }
 
-static void hpet_msi_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int hpet_msi_shutdown(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_shutdown(evt, hdev->num);
+}
+
+static int hpet_msi_set_oneshot(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_set_oneshot(evt, hdev->num);
+}
+
+static int hpet_msi_set_periodic(struct clock_event_device *evt)
 {
 	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
-	hpet_set_mode(mode, evt, hdev->num);
+
+	return hpet_set_periodic(evt, hdev->num);
+}
+
+static int hpet_msi_resume(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_resume(evt, hdev->num);
 }
 
 static int hpet_msi_next_event(unsigned long delta,
@@ -523,10 +569,14 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu)
 
 	evt->rating = 110;
 	evt->features = CLOCK_EVT_FEAT_ONESHOT;
-	if (hdev->flags & HPET_DEV_PERI_CAP)
+	if (hdev->flags & HPET_DEV_PERI_CAP) {
 		evt->features |= CLOCK_EVT_FEAT_PERIODIC;
+		evt->set_state_periodic = hpet_msi_set_periodic;
+	}
 
-	evt->set_mode = hpet_msi_set_mode;
+	evt->set_state_shutdown = hpet_msi_shutdown;
+	evt->set_state_oneshot = hpet_msi_set_oneshot;
+	evt->tick_resume = hpet_msi_resume;
 	evt->set_next_event = hpet_msi_next_event;
 	evt->cpumask = cpumask_of(hdev->cpu);
 
-- 
2.4.0


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

* [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
  2015-07-16 10:58 ` [PATCH 1/5] x86/apic: Migrate to new " Viresh Kumar
  2015-07-16 10:58 ` [PATCH 2/5] x86/hpet: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  2015-07-16 11:59   ` Rusty Russell
  2015-07-30 19:28   ` [tip:x86/platform] x86/lguest/timer: Migrate to new set-state interface tip-bot for Viresh Kumar
  2015-07-16 10:58 ` [PATCH 4/5] x86/uv/time: Migrate to new 'set-state' interface Viresh Kumar
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar,
	Rusty Russell, Alexander Kuleshov, Brian Gerst, Denys Vlasenko,
	Jan Beulich, Andy Lutomirski, open list:LGUEST

Migrate lguest driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/lguest/boot.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index f2dc08c003eb..433e5a7dd37f 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -985,23 +985,11 @@ static int lguest_clockevent_set_next_event(unsigned long delta,
 	return 0;
 }
 
-static void lguest_clockevent_set_mode(enum clock_event_mode mode,
-                                      struct clock_event_device *evt)
-{
-	switch (mode) {
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		/* A 0 argument shuts the clock down. */
-		hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* This is what we expect. */
-		break;
-	case CLOCK_EVT_MODE_PERIODIC:
-		BUG();
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+static int lguest_clockevent_shutdown(struct clock_event_device *evt)
+{
+	/* A 0 argument shuts the clock down. */
+	hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
+	return 0;
 }
 
 /* This describes our primitive timer chip. */
@@ -1009,7 +997,7 @@ static struct clock_event_device lguest_clockevent = {
 	.name                   = "lguest",
 	.features               = CLOCK_EVT_FEAT_ONESHOT,
 	.set_next_event         = lguest_clockevent_set_next_event,
-	.set_mode               = lguest_clockevent_set_mode,
+	.set_state_shutdown	= lguest_clockevent_shutdown,
 	.rating                 = INT_MAX,
 	.mult                   = 1,
 	.shift                  = 0,
-- 
2.4.0


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

* [PATCH 4/5] x86/uv/time: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
                   ` (2 preceding siblings ...)
  2015-07-16 10:58 ` [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  2015-07-30 19:28   ` [tip:x86/platform] x86/uv/time: Migrate to new set-state interface tip-bot for Viresh Kumar
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
  5 siblings, 1 reply; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar,
	Christoph Lameter, Tejun Heo

Migrate uv driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/platform/uv/uv_time.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index a244237f3cfa..2b158a9fa1d7 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -32,8 +32,7 @@
 
 static cycle_t uv_read_rtc(struct clocksource *cs);
 static int uv_rtc_next_event(unsigned long, struct clock_event_device *);
-static void uv_rtc_timer_setup(enum clock_event_mode,
-				struct clock_event_device *);
+static int uv_rtc_shutdown(struct clock_event_device *evt);
 
 static struct clocksource clocksource_uv = {
 	.name		= RTC_NAME,
@@ -44,14 +43,14 @@ static struct clocksource clocksource_uv = {
 };
 
 static struct clock_event_device clock_event_device_uv = {
-	.name		= RTC_NAME,
-	.features	= CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 20,
-	.rating		= 400,
-	.irq		= -1,
-	.set_next_event	= uv_rtc_next_event,
-	.set_mode	= uv_rtc_timer_setup,
-	.event_handler	= NULL,
+	.name			= RTC_NAME,
+	.features		= CLOCK_EVT_FEAT_ONESHOT,
+	.shift			= 20,
+	.rating			= 400,
+	.irq			= -1,
+	.set_next_event		= uv_rtc_next_event,
+	.set_state_shutdown	= uv_rtc_shutdown,
+	.event_handler		= NULL,
 };
 
 static DEFINE_PER_CPU(struct clock_event_device, cpu_ced);
@@ -321,24 +320,14 @@ static int uv_rtc_next_event(unsigned long delta,
 }
 
 /*
- * Setup the RTC timer in oneshot mode
+ * Shutdown the RTC timer
  */
-static void uv_rtc_timer_setup(enum clock_event_mode mode,
-			       struct clock_event_device *evt)
+static int uv_rtc_shutdown(struct clock_event_device *evt)
 {
 	int ced_cpu = cpumask_first(evt->cpumask);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_RESUME:
-		/* Nothing to do here yet */
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		uv_rtc_unset_timer(ced_cpu, 1);
-		break;
-	}
+	uv_rtc_unset_timer(ced_cpu, 1);
+	return 0;
 }
 
 static void uv_rtc_interrupt(void)
-- 
2.4.0


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

* [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
                   ` (3 preceding siblings ...)
  2015-07-16 10:58 ` [PATCH 4/5] x86/uv/time: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  2015-07-16 14:28   ` Boris Ostrovsky
  2015-07-30 19:28   ` [tip:x86/platform] x86/xen/time: Migrate to new set-state interface tip-bot for Viresh Kumar
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
  5 siblings, 2 replies; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar,
	Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	moderated list:XEN HYPERVISOR INTERFACE

Migrate xen driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Callbacks aren't implemented for modes where we weren't doing anything.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/xen/time.c | 63 +++++++++++++++++++----------------------------------
 1 file changed, 23 insertions(+), 40 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 55da33b1d51c..4b5ed547daa3 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -274,30 +274,17 @@ static s64 get_abs_timeout(unsigned long delta)
 	return xen_clocksource_read() + delta;
 }
 
-static void xen_timerop_set_mode(enum clock_event_mode mode,
-				 struct clock_event_device *evt)
+static int xen_timerop_shutdown(struct clock_event_device *evt)
 {
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		/* unsupported */
-		WARN_ON(1);
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		HYPERVISOR_set_timer_op(0);  /* cancel timeout */
-		break;
-	}
+	HYPERVISOR_set_timer_op(0);  /* cancel timeout */
+
+	return 0;
 }
 
 static int xen_timerop_set_next_event(unsigned long delta,
 				      struct clock_event_device *evt)
 {
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
 		BUG();
@@ -320,36 +307,31 @@ static const struct clock_event_device xen_timerop_clockevent = {
 	.shift = 0,
 	.rating = 500,
 
-	.set_mode = xen_timerop_set_mode,
+	.set_state_shutdown = xen_timerop_shutdown,
 	.set_next_event = xen_timerop_set_next_event,
 };
 
 
 
-static void xen_vcpuop_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int xen_vcpuop_shutdown(struct clock_event_device *evt)
 {
 	int cpu = smp_processor_id();
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		WARN_ON(1);	/* unsupported */
-		break;
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
+	    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
 
-	case CLOCK_EVT_MODE_ONESHOT:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
+	return 0;
+}
 
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
-		    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
+{
+	int cpu = smp_processor_id();
+
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
+
+	return 0;
 }
 
 static int xen_vcpuop_set_next_event(unsigned long delta,
@@ -359,7 +341,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
 	struct vcpu_set_singleshot_timer single;
 	int ret;
 
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	single.timeout_abs_ns = get_abs_timeout(delta);
 	single.flags = VCPU_SSHOTTMR_future;
@@ -382,7 +364,8 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
 	.shift = 0,
 	.rating = 500,
 
-	.set_mode = xen_vcpuop_set_mode,
+	.set_state_shutdown = xen_vcpuop_shutdown,
+	.set_state_oneshot = xen_vcpuop_set_oneshot,
 	.set_next_event = xen_vcpuop_set_next_event,
 };
 
-- 
2.4.0


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

* [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface
  2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
                   ` (4 preceding siblings ...)
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 10:58 ` Viresh Kumar
  5 siblings, 0 replies; 21+ messages in thread
From: Viresh Kumar @ 2015-07-16 10:58 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, Viresh Kumar, x86, linux-kernel, David Vrabel,
	hpa, moderated list:XEN HYPERVISOR INTERFACE, Boris Ostrovsky

Migrate xen driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Callbacks aren't implemented for modes where we weren't doing anything.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 arch/x86/xen/time.c | 63 +++++++++++++++++++----------------------------------
 1 file changed, 23 insertions(+), 40 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 55da33b1d51c..4b5ed547daa3 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -274,30 +274,17 @@ static s64 get_abs_timeout(unsigned long delta)
 	return xen_clocksource_read() + delta;
 }
 
-static void xen_timerop_set_mode(enum clock_event_mode mode,
-				 struct clock_event_device *evt)
+static int xen_timerop_shutdown(struct clock_event_device *evt)
 {
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		/* unsupported */
-		WARN_ON(1);
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		HYPERVISOR_set_timer_op(0);  /* cancel timeout */
-		break;
-	}
+	HYPERVISOR_set_timer_op(0);  /* cancel timeout */
+
+	return 0;
 }
 
 static int xen_timerop_set_next_event(unsigned long delta,
 				      struct clock_event_device *evt)
 {
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
 		BUG();
@@ -320,36 +307,31 @@ static const struct clock_event_device xen_timerop_clockevent = {
 	.shift = 0,
 	.rating = 500,
 
-	.set_mode = xen_timerop_set_mode,
+	.set_state_shutdown = xen_timerop_shutdown,
 	.set_next_event = xen_timerop_set_next_event,
 };
 
 
 
-static void xen_vcpuop_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int xen_vcpuop_shutdown(struct clock_event_device *evt)
 {
 	int cpu = smp_processor_id();
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		WARN_ON(1);	/* unsupported */
-		break;
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
+	    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
 
-	case CLOCK_EVT_MODE_ONESHOT:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
+	return 0;
+}
 
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
-		    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
+{
+	int cpu = smp_processor_id();
+
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
+
+	return 0;
 }
 
 static int xen_vcpuop_set_next_event(unsigned long delta,
@@ -359,7 +341,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
 	struct vcpu_set_singleshot_timer single;
 	int ret;
 
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	single.timeout_abs_ns = get_abs_timeout(delta);
 	single.flags = VCPU_SSHOTTMR_future;
@@ -382,7 +364,8 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
 	.shift = 0,
 	.rating = 500,
 
-	.set_mode = xen_vcpuop_set_mode,
+	.set_state_shutdown = xen_vcpuop_shutdown,
+	.set_state_oneshot = xen_vcpuop_set_oneshot,
 	.set_next_event = xen_vcpuop_set_next_event,
 };
 
-- 
2.4.0

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

* Re: [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface
  2015-07-16 10:58 ` [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 11:59   ` Rusty Russell
  2015-07-30 19:28   ` [tip:x86/platform] x86/lguest/timer: Migrate to new set-state interface tip-bot for Viresh Kumar
  1 sibling, 0 replies; 21+ messages in thread
From: Rusty Russell @ 2015-07-16 11:59 UTC (permalink / raw)
  To: Viresh Kumar, Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, linux-kernel, x86, hpa, Viresh Kumar,
	Alexander Kuleshov, Brian Gerst, Denys Vlasenko, Jan Beulich,
	Andy Lutomirski, open list:LGUEST

Viresh Kumar <viresh.kumar@linaro.org> writes:
> Migrate lguest driver to the new 'set-state' interface provided by
> clockevents core, the earlier 'set-mode' interface is marked obsolete
> now.
>
> This also enables us to implement callbacks for new states of clockevent
> devices, for example: ONESHOT_STOPPED.
>
> We weren't doing anything while switching modes other than in shutdown
> mode and so those are not implemented.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Tested-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>

Thanks!
Rusty.

> ---
>  arch/x86/lguest/boot.c | 24 ++++++------------------
>  1 file changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
> index f2dc08c003eb..433e5a7dd37f 100644
> --- a/arch/x86/lguest/boot.c
> +++ b/arch/x86/lguest/boot.c
> @@ -985,23 +985,11 @@ static int lguest_clockevent_set_next_event(unsigned long delta,
>  	return 0;
>  }
>  
> -static void lguest_clockevent_set_mode(enum clock_event_mode mode,
> -                                      struct clock_event_device *evt)
> -{
> -	switch (mode) {
> -	case CLOCK_EVT_MODE_UNUSED:
> -	case CLOCK_EVT_MODE_SHUTDOWN:
> -		/* A 0 argument shuts the clock down. */
> -		hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
> -		break;
> -	case CLOCK_EVT_MODE_ONESHOT:
> -		/* This is what we expect. */
> -		break;
> -	case CLOCK_EVT_MODE_PERIODIC:
> -		BUG();
> -	case CLOCK_EVT_MODE_RESUME:
> -		break;
> -	}
> +static int lguest_clockevent_shutdown(struct clock_event_device *evt)
> +{
> +	/* A 0 argument shuts the clock down. */
> +	hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
> +	return 0;
>  }
>  
>  /* This describes our primitive timer chip. */
> @@ -1009,7 +997,7 @@ static struct clock_event_device lguest_clockevent = {
>  	.name                   = "lguest",
>  	.features               = CLOCK_EVT_FEAT_ONESHOT,
>  	.set_next_event         = lguest_clockevent_set_next_event,
> -	.set_mode               = lguest_clockevent_set_mode,
> +	.set_state_shutdown	= lguest_clockevent_shutdown,
>  	.rating                 = INT_MAX,
>  	.mult                   = 1,
>  	.shift                  = 0,
> -- 
> 2.4.0

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

* Re: [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-16 14:28   ` Boris Ostrovsky
  2015-07-30 19:28   ` [tip:x86/platform] x86/xen/time: Migrate to new set-state interface tip-bot for Viresh Kumar
  1 sibling, 0 replies; 21+ messages in thread
From: Boris Ostrovsky @ 2015-07-16 14:28 UTC (permalink / raw)
  To: Viresh Kumar, Thomas Gleixner, Ingo Molnar
  Cc: linaro-kernel, x86, linux-kernel, David Vrabel, hpa,
	XEN HYPERVISOR INTERFACE

On 07/16/2015 06:58 AM, Viresh Kumar wrote:
> Migrate xen driver to the new 'set-state' interface provided by
> clockevents core, the earlier 'set-mode' interface is marked obsolete
> now.
>
> This also enables us to implement callbacks for new states of clockevent
> devices, for example: ONESHOT_STOPPED.
>
> Callbacks aren't implemented for modes where we weren't doing anything.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

* [tip:x86/apic] x86/apic: Migrate apic timer to new set_state interface
  2015-07-16 10:58 ` [PATCH 1/5] x86/apic: Migrate to new " Viresh Kumar
@ 2015-07-30 19:27   ` tip-bot for Viresh Kumar
  0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Viresh Kumar @ 2015-07-30 19:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, linux-kernel, jiang.liu, rientjes, hpa, mingo, bp,
	viresh.kumar, bsd

Commit-ID:  b23d8e527815954768861bb20d2b224009fff7cd
Gitweb:     http://git.kernel.org/tip/b23d8e527815954768861bb20d2b224009fff7cd
Author:     Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Thu, 16 Jul 2015 16:28:44 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Jul 2015 00:51:47 +0200

x86/apic: Migrate apic timer to new set_state interface

Migrate apic driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching to resume mode and so that
callback isn't implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Rientjes <rientjes@google.com>
Cc: Bandan Das <bsd@redhat.com>
Link: http://lkml.kernel.org/r/1896ac5989d27f2ac37f4786af9bd537e1921b83.1437042675.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/apic/apic.c | 86 +++++++++++++++++++++++++++------------------
 1 file changed, 51 insertions(+), 35 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index dcb5285..ecd6705 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -462,40 +462,53 @@ static int lapic_next_deadline(unsigned long delta,
 	return 0;
 }
 
-/*
- * Setup the lapic timer in periodic or oneshot mode
- */
-static void lapic_timer_setup(enum clock_event_mode mode,
-			      struct clock_event_device *evt)
+static int lapic_timer_shutdown(struct clock_event_device *evt)
 {
 	unsigned long flags;
 	unsigned int v;
 
 	/* Lapic used as dummy for broadcast ? */
 	if (evt->features & CLOCK_EVT_FEAT_DUMMY)
-		return;
+		return 0;
 
 	local_irq_save(flags);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-	case CLOCK_EVT_MODE_ONESHOT:
-		__setup_APIC_LVTT(lapic_timer_frequency,
-				  mode != CLOCK_EVT_MODE_PERIODIC, 1);
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		v = apic_read(APIC_LVTT);
-		v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
-		apic_write(APIC_LVTT, v);
-		apic_write(APIC_TMICT, 0);
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		/* Nothing to do here */
-		break;
-	}
+	v = apic_read(APIC_LVTT);
+	v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
+	apic_write(APIC_LVTT, v);
+	apic_write(APIC_TMICT, 0);
+
+	local_irq_restore(flags);
+
+	return 0;
+}
+
+static inline int
+lapic_timer_set_periodic_oneshot(struct clock_event_device *evt, bool oneshot)
+{
+	unsigned long flags;
+
+	/* Lapic used as dummy for broadcast ? */
+	if (evt->features & CLOCK_EVT_FEAT_DUMMY)
+		return 0;
+
+	local_irq_save(flags);
+
+	__setup_APIC_LVTT(lapic_timer_frequency, oneshot, 1);
 
 	local_irq_restore(flags);
+
+	return 0;
+}
+
+static int lapic_timer_set_periodic(struct clock_event_device *evt)
+{
+	return lapic_timer_set_periodic_oneshot(evt, false);
+}
+
+static int lapic_timer_set_oneshot(struct clock_event_device *evt)
+{
+	return lapic_timer_set_periodic_oneshot(evt, true);
 }
 
 /*
@@ -513,15 +526,18 @@ static void lapic_timer_broadcast(const struct cpumask *mask)
  * The local apic timer can be used for any function which is CPU local.
  */
 static struct clock_event_device lapic_clockevent = {
-	.name		= "lapic",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
-			| CLOCK_EVT_FEAT_C3STOP | CLOCK_EVT_FEAT_DUMMY,
-	.shift		= 32,
-	.set_mode	= lapic_timer_setup,
-	.set_next_event	= lapic_next_event,
-	.broadcast	= lapic_timer_broadcast,
-	.rating		= 100,
-	.irq		= -1,
+	.name			= "lapic",
+	.features		= CLOCK_EVT_FEAT_PERIODIC |
+				  CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
+				  | CLOCK_EVT_FEAT_DUMMY,
+	.shift			= 32,
+	.set_state_shutdown	= lapic_timer_shutdown,
+	.set_state_periodic	= lapic_timer_set_periodic,
+	.set_state_oneshot	= lapic_timer_set_oneshot,
+	.set_next_event		= lapic_next_event,
+	.broadcast		= lapic_timer_broadcast,
+	.rating			= 100,
+	.irq			= -1,
 };
 static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
 
@@ -778,7 +794,7 @@ static int __init calibrate_APIC_clock(void)
 		 * Setup the apic timer manually
 		 */
 		levt->event_handler = lapic_cal_handler;
-		lapic_timer_setup(CLOCK_EVT_MODE_PERIODIC, levt);
+		lapic_timer_set_periodic(levt);
 		lapic_cal_loops = -1;
 
 		/* Let the interrupts run */
@@ -788,7 +804,7 @@ static int __init calibrate_APIC_clock(void)
 			cpu_relax();
 
 		/* Stop the lapic timer */
-		lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, levt);
+		lapic_timer_shutdown(levt);
 
 		/* Jiffies delta */
 		deltaj = lapic_cal_j2 - lapic_cal_j1;
@@ -878,7 +894,7 @@ static void local_apic_timer_interrupt(void)
 	if (!evt->event_handler) {
 		pr_warning("Spurious LAPIC timer interrupt on cpu %d\n", cpu);
 		/* Switch it off */
-		lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
+		lapic_timer_shutdown(evt);
 		return;
 	}
 

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

* [tip:x86/platform] x86/lguest/timer: Migrate to new set-state interface
  2015-07-16 10:58 ` [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface Viresh Kumar
  2015-07-16 11:59   ` Rusty Russell
@ 2015-07-30 19:28   ` tip-bot for Viresh Kumar
  1 sibling, 0 replies; 21+ messages in thread
From: tip-bot for Viresh Kumar @ 2015-07-30 19:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, luto, mingo, viresh.kumar, kuleshovmail, tglx, hpa,
	rusty, JBeulich, dvlasenk, brgerst

Commit-ID:  c2e13cc2cea64385043fa9afaaf91a74ec438467
Gitweb:     http://git.kernel.org/tip/c2e13cc2cea64385043fa9afaaf91a74ec438467
Author:     Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Thu, 16 Jul 2015 16:28:46 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/lguest/timer: Migrate to new set-state interface

Migrate lguest driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-and-tested-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: linaro-kernel@lists.linaro.org
Cc: Alexander Kuleshov <kuleshovmail@gmail.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: lguest@lists.ozlabs.org (open list:LGUEST)
Link: http://lkml.kernel.org/r/b96f1c308f4523255c5394a4e6e13f2b67685402.1437042675.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/lguest/boot.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index f2dc08c..433e5a7 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -985,23 +985,11 @@ static int lguest_clockevent_set_next_event(unsigned long delta,
 	return 0;
 }
 
-static void lguest_clockevent_set_mode(enum clock_event_mode mode,
-                                      struct clock_event_device *evt)
-{
-	switch (mode) {
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		/* A 0 argument shuts the clock down. */
-		hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* This is what we expect. */
-		break;
-	case CLOCK_EVT_MODE_PERIODIC:
-		BUG();
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+static int lguest_clockevent_shutdown(struct clock_event_device *evt)
+{
+	/* A 0 argument shuts the clock down. */
+	hcall(LHCALL_SET_CLOCKEVENT, 0, 0, 0, 0);
+	return 0;
 }
 
 /* This describes our primitive timer chip. */
@@ -1009,7 +997,7 @@ static struct clock_event_device lguest_clockevent = {
 	.name                   = "lguest",
 	.features               = CLOCK_EVT_FEAT_ONESHOT,
 	.set_next_event         = lguest_clockevent_set_next_event,
-	.set_mode               = lguest_clockevent_set_mode,
+	.set_state_shutdown	= lguest_clockevent_shutdown,
 	.rating                 = INT_MAX,
 	.mult                   = 1,
 	.shift                  = 0,

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

* [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-16 10:58 ` [PATCH 4/5] x86/uv/time: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-30 19:28   ` tip-bot for Viresh Kumar
  2015-07-30 20:04     ` Christoph Lameter
  0 siblings, 1 reply; 21+ messages in thread
From: tip-bot for Viresh Kumar @ 2015-07-30 19:28 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: cl, linux-kernel, tglx, hpa, viresh.kumar, tj, mingo

Commit-ID:  ca53d434f7e63352c9edd1ad8cde4dfe11da44aa
Gitweb:     http://git.kernel.org/tip/ca53d434f7e63352c9edd1ad8cde4dfe11da44aa
Author:     Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Thu, 16 Jul 2015 16:28:47 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/uv/time: Migrate to new set-state interface

Migrate uv driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

We weren't doing anything while switching modes other than in shutdown
mode and so those are not implemented.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: Christoph Lameter <cl@linux.com>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/52e04139746222a2e82a96d13953cbc306cfb59b.1437042675.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/uv_time.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index a244237..2b158a9 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -32,8 +32,7 @@
 
 static cycle_t uv_read_rtc(struct clocksource *cs);
 static int uv_rtc_next_event(unsigned long, struct clock_event_device *);
-static void uv_rtc_timer_setup(enum clock_event_mode,
-				struct clock_event_device *);
+static int uv_rtc_shutdown(struct clock_event_device *evt);
 
 static struct clocksource clocksource_uv = {
 	.name		= RTC_NAME,
@@ -44,14 +43,14 @@ static struct clocksource clocksource_uv = {
 };
 
 static struct clock_event_device clock_event_device_uv = {
-	.name		= RTC_NAME,
-	.features	= CLOCK_EVT_FEAT_ONESHOT,
-	.shift		= 20,
-	.rating		= 400,
-	.irq		= -1,
-	.set_next_event	= uv_rtc_next_event,
-	.set_mode	= uv_rtc_timer_setup,
-	.event_handler	= NULL,
+	.name			= RTC_NAME,
+	.features		= CLOCK_EVT_FEAT_ONESHOT,
+	.shift			= 20,
+	.rating			= 400,
+	.irq			= -1,
+	.set_next_event		= uv_rtc_next_event,
+	.set_state_shutdown	= uv_rtc_shutdown,
+	.event_handler		= NULL,
 };
 
 static DEFINE_PER_CPU(struct clock_event_device, cpu_ced);
@@ -321,24 +320,14 @@ static int uv_rtc_next_event(unsigned long delta,
 }
 
 /*
- * Setup the RTC timer in oneshot mode
+ * Shutdown the RTC timer
  */
-static void uv_rtc_timer_setup(enum clock_event_mode mode,
-			       struct clock_event_device *evt)
+static int uv_rtc_shutdown(struct clock_event_device *evt)
 {
 	int ced_cpu = cpumask_first(evt->cpumask);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_RESUME:
-		/* Nothing to do here yet */
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		uv_rtc_unset_timer(ced_cpu, 1);
-		break;
-	}
+	uv_rtc_unset_timer(ced_cpu, 1);
+	return 0;
 }
 
 static void uv_rtc_interrupt(void)

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

* [tip:x86/platform] x86/xen/time: Migrate to new set-state interface
  2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
  2015-07-16 14:28   ` Boris Ostrovsky
@ 2015-07-30 19:28   ` tip-bot for Viresh Kumar
  1 sibling, 0 replies; 21+ messages in thread
From: tip-bot for Viresh Kumar @ 2015-07-30 19:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, david.vrabel, boris.ostrovsky, hpa,
	konrad.wilk, tglx, viresh.kumar

Commit-ID:  955381dd65654bd6f066408823691db8fa7d05bb
Gitweb:     http://git.kernel.org/tip/955381dd65654bd6f066408823691db8fa7d05bb
Author:     Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Thu, 16 Jul 2015 16:28:48 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Jul 2015 21:25:38 +0200

x86/xen/time: Migrate to new set-state interface

Migrate xen driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Callbacks aren't implemented for modes where we weren't doing anything.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: xen-devel@lists.xenproject.org (moderated list:XEN HYPERVISOR INTERFACE)
Link: http://lkml.kernel.org/r/881eea6e1a3d483cd33e044cd34827cce26a57fd.1437042675.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/xen/time.c | 80 +++++++++++++++++++++--------------------------------
 1 file changed, 31 insertions(+), 49 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 55da33b..f1ba6a0 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -274,30 +274,18 @@ static s64 get_abs_timeout(unsigned long delta)
 	return xen_clocksource_read() + delta;
 }
 
-static void xen_timerop_set_mode(enum clock_event_mode mode,
-				 struct clock_event_device *evt)
+static int xen_timerop_shutdown(struct clock_event_device *evt)
 {
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		/* unsupported */
-		WARN_ON(1);
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		HYPERVISOR_set_timer_op(0);  /* cancel timeout */
-		break;
-	}
+	/* cancel timeout */
+	HYPERVISOR_set_timer_op(0);
+
+	return 0;
 }
 
 static int xen_timerop_set_next_event(unsigned long delta,
 				      struct clock_event_device *evt)
 {
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	if (HYPERVISOR_set_timer_op(get_abs_timeout(delta)) < 0)
 		BUG();
@@ -310,46 +298,39 @@ static int xen_timerop_set_next_event(unsigned long delta,
 }
 
 static const struct clock_event_device xen_timerop_clockevent = {
-	.name = "xen",
-	.features = CLOCK_EVT_FEAT_ONESHOT,
+	.name			= "xen",
+	.features		= CLOCK_EVT_FEAT_ONESHOT,
 
-	.max_delta_ns = 0xffffffff,
-	.min_delta_ns = TIMER_SLOP,
+	.max_delta_ns		= 0xffffffff,
+	.min_delta_ns		= TIMER_SLOP,
 
-	.mult = 1,
-	.shift = 0,
-	.rating = 500,
+	.mult			= 1,
+	.shift			= 0,
+	.rating			= 500,
 
-	.set_mode = xen_timerop_set_mode,
-	.set_next_event = xen_timerop_set_next_event,
+	.set_state_shutdown	= xen_timerop_shutdown,
+	.set_next_event		= xen_timerop_set_next_event,
 };
 
+static int xen_vcpuop_shutdown(struct clock_event_device *evt)
+{
+	int cpu = smp_processor_id();
 
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
+	    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
+
+	return 0;
+}
 
-static void xen_vcpuop_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int xen_vcpuop_set_oneshot(struct clock_event_device *evt)
 {
 	int cpu = smp_processor_id();
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		WARN_ON(1);	/* unsupported */
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
+	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+		BUG();
 
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
-		    HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
-			BUG();
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+	return 0;
 }
 
 static int xen_vcpuop_set_next_event(unsigned long delta,
@@ -359,7 +340,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
 	struct vcpu_set_singleshot_timer single;
 	int ret;
 
-	WARN_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
+	WARN_ON(!clockevent_state_oneshot(evt));
 
 	single.timeout_abs_ns = get_abs_timeout(delta);
 	single.flags = VCPU_SSHOTTMR_future;
@@ -382,7 +363,8 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
 	.shift = 0,
 	.rating = 500,
 
-	.set_mode = xen_vcpuop_set_mode,
+	.set_state_shutdown = xen_vcpuop_shutdown,
+	.set_state_oneshot = xen_vcpuop_set_oneshot,
 	.set_next_event = xen_vcpuop_set_next_event,
 };
 

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

* [tip:x86/core] x86/hpet: Migrate to new set_state interface
  2015-07-16 10:58 ` [PATCH 2/5] x86/hpet: Migrate to new 'set-state' interface Viresh Kumar
@ 2015-07-30 19:30   ` tip-bot for Viresh Kumar
  0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Viresh Kumar @ 2015-07-30 19:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: viresh.kumar, mingo, jiang.liu, linux-kernel, hpa, tglx, linux

Commit-ID:  c8b5db7de66b75330a96f9f1ad7376b89646c953
Gitweb:     http://git.kernel.org/tip/c8b5db7de66b75330a96f9f1ad7376b89646c953
Author:     Viresh Kumar <viresh.kumar@linaro.org>
AuthorDate: Thu, 16 Jul 2015 16:28:45 +0530
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 30 Jul 2015 21:28:25 +0200

x86/hpet: Migrate to new set_state interface

Migrate hpet driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Forward definition of 'hpet_clockevent' wasn't required and so it is
placed after all the callback are defined, to avoid forward declaring
all the callbacks.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: http://lkml.kernel.org/r/8cc9864b6d6342dfac28f270cf69f4cba46fffae.1437042675.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/hpet.c | 198 +++++++++++++++++++++++++++++++------------------
 1 file changed, 124 insertions(+), 74 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 10757d0..437297a 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -226,22 +226,7 @@ static void hpet_reserve_platform_timers(unsigned int id) { }
  */
 static unsigned long hpet_freq;
 
-static void hpet_legacy_set_mode(enum clock_event_mode mode,
-			  struct clock_event_device *evt);
-static int hpet_legacy_next_event(unsigned long delta,
-			   struct clock_event_device *evt);
-
-/*
- * The hpet clock event device
- */
-static struct clock_event_device hpet_clockevent = {
-	.name		= "hpet",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.set_mode	= hpet_legacy_set_mode,
-	.set_next_event = hpet_legacy_next_event,
-	.irq		= 0,
-	.rating		= 50,
-};
+static struct clock_event_device hpet_clockevent;
 
 static void hpet_stop_counter(void)
 {
@@ -306,64 +291,74 @@ static void hpet_legacy_clockevent_register(void)
 	printk(KERN_DEBUG "hpet clockevent registered\n");
 }
 
-static void hpet_set_mode(enum clock_event_mode mode,
-			  struct clock_event_device *evt, int timer)
+static int hpet_set_periodic(struct clock_event_device *evt, int timer)
 {
 	unsigned int cfg, cmp, now;
 	uint64_t delta;
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		hpet_stop_counter();
-		delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
-		delta >>= evt->shift;
-		now = hpet_readl(HPET_COUNTER);
-		cmp = now + (unsigned int) delta;
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
-		       HPET_TN_SETVAL | HPET_TN_32BIT;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		hpet_writel(cmp, HPET_Tn_CMP(timer));
-		udelay(1);
-		/*
-		 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
-		 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
-		 * bit is automatically cleared after the first write.
-		 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
-		 * Publication # 24674)
-		 */
-		hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer));
-		hpet_start_counter();
-		hpet_print_config();
-		break;
+	hpet_stop_counter();
+	delta = ((uint64_t)(NSEC_PER_SEC / HZ)) * evt->mult;
+	delta >>= evt->shift;
+	now = hpet_readl(HPET_COUNTER);
+	cmp = now + (unsigned int)delta;
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
+	       HPET_TN_32BIT;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+	hpet_writel(cmp, HPET_Tn_CMP(timer));
+	udelay(1);
+	/*
+	 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
+	 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
+	 * bit is automatically cleared after the first write.
+	 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
+	 * Publication # 24674)
+	 */
+	hpet_writel((unsigned int)delta, HPET_Tn_CMP(timer));
+	hpet_start_counter();
+	hpet_print_config();
 
-	case CLOCK_EVT_MODE_ONESHOT:
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg &= ~HPET_TN_PERIODIC;
-		cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		break;
+	return 0;
+}
 
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		cfg = hpet_readl(HPET_Tn_CFG(timer));
-		cfg &= ~HPET_TN_ENABLE;
-		hpet_writel(cfg, HPET_Tn_CFG(timer));
-		break;
+static int hpet_set_oneshot(struct clock_event_device *evt, int timer)
+{
+	unsigned int cfg;
 
-	case CLOCK_EVT_MODE_RESUME:
-		if (timer == 0) {
-			hpet_enable_legacy_int();
-		} else {
-			struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
-			irq_domain_activate_irq(irq_get_irq_data(hdev->irq));
-			disable_irq(hdev->irq);
-			irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu));
-			enable_irq(hdev->irq);
-		}
-		hpet_print_config();
-		break;
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg &= ~HPET_TN_PERIODIC;
+	cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+
+	return 0;
+}
+
+static int hpet_shutdown(struct clock_event_device *evt, int timer)
+{
+	unsigned int cfg;
+
+	cfg = hpet_readl(HPET_Tn_CFG(timer));
+	cfg &= ~HPET_TN_ENABLE;
+	hpet_writel(cfg, HPET_Tn_CFG(timer));
+
+	return 0;
+}
+
+static int hpet_resume(struct clock_event_device *evt, int timer)
+{
+	if (!timer) {
+		hpet_enable_legacy_int();
+	} else {
+		struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+		irq_domain_activate_irq(irq_get_irq_data(hdev->irq));
+		disable_irq(hdev->irq);
+		irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu));
+		enable_irq(hdev->irq);
 	}
+	hpet_print_config();
+
+	return 0;
 }
 
 static int hpet_next_event(unsigned long delta,
@@ -403,10 +398,24 @@ static int hpet_next_event(unsigned long delta,
 	return res < HPET_MIN_CYCLES ? -ETIME : 0;
 }
 
-static void hpet_legacy_set_mode(enum clock_event_mode mode,
-			struct clock_event_device *evt)
+static int hpet_legacy_shutdown(struct clock_event_device *evt)
+{
+	return hpet_shutdown(evt, 0);
+}
+
+static int hpet_legacy_set_oneshot(struct clock_event_device *evt)
+{
+	return hpet_set_oneshot(evt, 0);
+}
+
+static int hpet_legacy_set_periodic(struct clock_event_device *evt)
 {
-	hpet_set_mode(mode, evt, 0);
+	return hpet_set_periodic(evt, 0);
+}
+
+static int hpet_legacy_resume(struct clock_event_device *evt)
+{
+	return hpet_resume(evt, 0);
 }
 
 static int hpet_legacy_next_event(unsigned long delta,
@@ -416,6 +425,22 @@ static int hpet_legacy_next_event(unsigned long delta,
 }
 
 /*
+ * The hpet clock event device
+ */
+static struct clock_event_device hpet_clockevent = {
+	.name			= "hpet",
+	.features		= CLOCK_EVT_FEAT_PERIODIC |
+				  CLOCK_EVT_FEAT_ONESHOT,
+	.set_state_periodic	= hpet_legacy_set_periodic,
+	.set_state_oneshot	= hpet_legacy_set_oneshot,
+	.set_state_shutdown	= hpet_legacy_shutdown,
+	.tick_resume		= hpet_legacy_resume,
+	.set_next_event		= hpet_legacy_next_event,
+	.irq			= 0,
+	.rating			= 50,
+};
+
+/*
  * HPET MSI Support
  */
 #ifdef CONFIG_PCI_MSI
@@ -459,11 +484,32 @@ void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg)
 	msg->address_hi = 0;
 }
 
-static void hpet_msi_set_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int hpet_msi_shutdown(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_shutdown(evt, hdev->num);
+}
+
+static int hpet_msi_set_oneshot(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_set_oneshot(evt, hdev->num);
+}
+
+static int hpet_msi_set_periodic(struct clock_event_device *evt)
 {
 	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
-	hpet_set_mode(mode, evt, hdev->num);
+
+	return hpet_set_periodic(evt, hdev->num);
+}
+
+static int hpet_msi_resume(struct clock_event_device *evt)
+{
+	struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
+
+	return hpet_resume(evt, hdev->num);
 }
 
 static int hpet_msi_next_event(unsigned long delta,
@@ -523,10 +569,14 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu)
 
 	evt->rating = 110;
 	evt->features = CLOCK_EVT_FEAT_ONESHOT;
-	if (hdev->flags & HPET_DEV_PERI_CAP)
+	if (hdev->flags & HPET_DEV_PERI_CAP) {
 		evt->features |= CLOCK_EVT_FEAT_PERIODIC;
+		evt->set_state_periodic = hpet_msi_set_periodic;
+	}
 
-	evt->set_mode = hpet_msi_set_mode;
+	evt->set_state_shutdown = hpet_msi_shutdown;
+	evt->set_state_oneshot = hpet_msi_set_oneshot;
+	evt->tick_resume = hpet_msi_resume;
 	evt->set_next_event = hpet_msi_next_event;
 	evt->cpumask = cpumask_of(hdev->cpu);
 

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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-30 19:28   ` [tip:x86/platform] x86/uv/time: Migrate to new set-state interface tip-bot for Viresh Kumar
@ 2015-07-30 20:04     ` Christoph Lameter
  2015-07-30 22:25       ` Thomas Gleixner
  2015-07-31  5:21       ` Viresh Kumar
  0 siblings, 2 replies; 21+ messages in thread
From: Christoph Lameter @ 2015-07-30 20:04 UTC (permalink / raw)
  To: linux-kernel, Thomas Gleixner, hpa, tj, mingo, viresh.kumar,
	robinmholt, nzimmer, sivanich
  Cc: linux-tip-commits

You need to CC someone at SGI for this I guess. Robin? Nate? Dimitri?

I am definitely not the right guy to be on the CC list.


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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-30 20:04     ` Christoph Lameter
@ 2015-07-30 22:25       ` Thomas Gleixner
  2015-07-31  5:21       ` Viresh Kumar
  1 sibling, 0 replies; 21+ messages in thread
From: Thomas Gleixner @ 2015-07-30 22:25 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, hpa, tj, mingo, viresh.kumar, robinmholt, nzimmer,
	sivanich, linux-tip-commits

On Thu, 30 Jul 2015, Christoph Lameter wrote:

> You need to CC someone at SGI for this I guess. Robin? Nate? Dimitri?
> 
> I am definitely not the right guy to be on the CC list.

Sorry, forgot to edit the CC list.


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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-30 20:04     ` Christoph Lameter
  2015-07-30 22:25       ` Thomas Gleixner
@ 2015-07-31  5:21       ` Viresh Kumar
  2015-07-31 12:20         ` Dimitri Sivanich
  1 sibling, 1 reply; 21+ messages in thread
From: Viresh Kumar @ 2015-07-31  5:21 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, Thomas Gleixner, hpa, tj, mingo, robinmholt,
	nzimmer, sivanich, linux-tip-commits

On 30-07-15, 15:04, Christoph Lameter wrote:
> You need to CC someone at SGI for this I guess. Robin? Nate? Dimitri?
> 
> I am definitely not the right guy to be on the CC list.

Sorry about that. It happened because get_maintainers failed to
identify those people. Probably MAINTAINERS need some update ?

-- 
viresh

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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-31  5:21       ` Viresh Kumar
@ 2015-07-31 12:20         ` Dimitri Sivanich
  2015-08-04 15:25           ` Nathan Zimmer
  0 siblings, 1 reply; 21+ messages in thread
From: Dimitri Sivanich @ 2015-07-31 12:20 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Christoph Lameter, linux-kernel, Thomas Gleixner, hpa, tj, mingo,
	nzimmer, linux-tip-commits, Alex Thorlton

On Fri, Jul 31, 2015 at 10:51:08AM +0530, Viresh Kumar wrote:
> On 30-07-15, 15:04, Christoph Lameter wrote:
> > You need to CC someone at SGI for this I guess. Robin? Nate? Dimitri?
> > 
> > I am definitely not the right guy to be on the CC list.
> 
> Sorry about that. It happened because get_maintainers failed to
> identify those people. Probably MAINTAINERS need some update ?
>
Yes, it probably does.  Regardless, you've got two of the right people now
(myself and nzimmer@sgi.com).  Maybe add athorlton@sgi.com.  Robin Holt does
not need to be on it.

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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-07-31 12:20         ` Dimitri Sivanich
@ 2015-08-04 15:25           ` Nathan Zimmer
  2015-08-05  5:15             ` Viresh Kumar
  0 siblings, 1 reply; 21+ messages in thread
From: Nathan Zimmer @ 2015-08-04 15:25 UTC (permalink / raw)
  To: Dimitri Sivanich
  Cc: Viresh Kumar, Christoph Lameter, linux-kernel, Thomas Gleixner,
	hpa, tj, mingo, nzimmer, linux-tip-commits, Alex Thorlton,
	travis

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

On Fri, Jul 31, 2015 at 07:20:44AM -0500, Dimitri Sivanich wrote:
> On Fri, Jul 31, 2015 at 10:51:08AM +0530, Viresh Kumar wrote:
> > On 30-07-15, 15:04, Christoph Lameter wrote:
> > > You need to CC someone at SGI for this I guess. Robin? Nate? Dimitri?
> > > 
> > > I am definitely not the right guy to be on the CC list.
> > 
> > Sorry about that. It happened because get_maintainers failed to
> > identify those people. Probably MAINTAINERS need some update ?
> >
> Yes, it probably does.  Regardless, you've got two of the right people now
> (myself and nzimmer@sgi.com).  Maybe add athorlton@sgi.com.  Robin Holt does
> not need to be on it.

Sorry I was out on vacation last week, but I whipped this up to help.

Mike Travis usually handles the arch sections and the mailing list should
provide a nice catch all given a few people are subscribed to it.


[-- Attachment #2: 0001-MAINTAINERS-Add-some-maintainers-for-the-UV-architec.patch --]
[-- Type: text/x-patch, Size: 1170 bytes --]

>From f5ef7784e0fe609a1d56cbaa20aea93e27cce274 Mon Sep 17 00:00:00 2001
From: Nathan Zimmer <nzimmer@sgi.com>
Date: Tue, 4 Aug 2015 09:56:05 -0500
Subject: [PATCH] MAINTAINERS: Add some maintainers for the UV architecture.

Currently there is a lack of maintainers for the UV architecture.
We at SGI really should be stepping up here, if for no other reason
then we have the hardware to test the occasional change.

Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 907ce01..9c2beb3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10885,6 +10885,15 @@ W:	http://en.wikipedia.org/wiki/Util-linux
 T:	git git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
 S:	Maintained
 
+UV PLATFORM
+M:     Mike Travis <travis@sgi.com>
+M:     uv_kernel@sgi.com
+S:     Supported
+F:     arch/x86/kernel/apic/x2apic_uv_x.c
+F:     arch/x86/platform/uv/
+F:     arch/x86/include/asm/uv/
+F:     drivers/char/uv_mmtimer.c
+
 UVESAFB DRIVER
 M:	Michal Januszewski <spock@gentoo.org>
 L:	linux-fbdev@vger.kernel.org
-- 
1.8.2.1


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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-08-04 15:25           ` Nathan Zimmer
@ 2015-08-05  5:15             ` Viresh Kumar
  2015-08-05 14:29               ` Nathan Zimmer
  0 siblings, 1 reply; 21+ messages in thread
From: Viresh Kumar @ 2015-08-05  5:15 UTC (permalink / raw)
  To: Nathan Zimmer
  Cc: Dimitri Sivanich, Christoph Lameter, linux-kernel,
	Thomas Gleixner, hpa, tj, mingo, linux-tip-commits,
	Alex Thorlton, travis

On 04-08-15, 10:25, Nathan Zimmer wrote:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 907ce01..9c2beb3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10885,6 +10885,15 @@ W:	http://en.wikipedia.org/wiki/Util-linux
>  T:	git git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
>  S:	Maintained
>  
> +UV PLATFORM
> +M:     Mike Travis <travis@sgi.com>
> +M:     uv_kernel@sgi.com

Should that be L:, as it looks to be a list?

> +S:     Supported
> +F:     arch/x86/kernel/apic/x2apic_uv_x.c
> +F:     arch/x86/platform/uv/
> +F:     arch/x86/include/asm/uv/
> +F:     drivers/char/uv_mmtimer.c
> +
>  UVESAFB DRIVER
>  M:	Michal Januszewski <spock@gentoo.org>
>  L:	linux-fbdev@vger.kernel.org
> -- 
> 1.8.2.1
> 


-- 
viresh

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

* Re: [tip:x86/platform] x86/uv/time: Migrate to new set-state interface
  2015-08-05  5:15             ` Viresh Kumar
@ 2015-08-05 14:29               ` Nathan Zimmer
  0 siblings, 0 replies; 21+ messages in thread
From: Nathan Zimmer @ 2015-08-05 14:29 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Dimitri Sivanich, Christoph Lameter, linux-kernel,
	Thomas Gleixner, hpa, tj, mingo, linux-tip-commits,
	Alex Thorlton, travis

Yes, thank you for the correction.

On 08/05/2015 12:15 AM, Viresh Kumar wrote:
> On 04-08-15, 10:25, Nathan Zimmer wrote:
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 907ce01..9c2beb3 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -10885,6 +10885,15 @@ W:	http://en.wikipedia.org/wiki/Util-linux
>>   T:	git git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
>>   S:	Maintained
>>   
>> +UV PLATFORM
>> +M:     Mike Travis <travis@sgi.com>
>> +M:     uv_kernel@sgi.com
> Should that be L:, as it looks to be a list?
>
>> +S:     Supported
>> +F:     arch/x86/kernel/apic/x2apic_uv_x.c
>> +F:     arch/x86/platform/uv/
>> +F:     arch/x86/include/asm/uv/
>> +F:     drivers/char/uv_mmtimer.c
>> +
>>   UVESAFB DRIVER
>>   M:	Michal Januszewski <spock@gentoo.org>
>>   L:	linux-fbdev@vger.kernel.org
>> -- 
>> 1.8.2.1
>>
>


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

end of thread, other threads:[~2015-08-05 14:29 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 10:58 [PATCH 0/5] X86: Migrate clockevent drivers to 'set-state' interface Viresh Kumar
2015-07-16 10:58 ` [PATCH 1/5] x86/apic: Migrate to new " Viresh Kumar
2015-07-30 19:27   ` [tip:x86/apic] x86/apic: Migrate apic timer to new set_state interface tip-bot for Viresh Kumar
2015-07-16 10:58 ` [PATCH 2/5] x86/hpet: Migrate to new 'set-state' interface Viresh Kumar
2015-07-30 19:30   ` [tip:x86/core] x86/hpet: Migrate to new set_state interface tip-bot for Viresh Kumar
2015-07-16 10:58 ` [PATCH 3/5] x86/lguest/timer: Migrate to new 'set-state' interface Viresh Kumar
2015-07-16 11:59   ` Rusty Russell
2015-07-30 19:28   ` [tip:x86/platform] x86/lguest/timer: Migrate to new set-state interface tip-bot for Viresh Kumar
2015-07-16 10:58 ` [PATCH 4/5] x86/uv/time: Migrate to new 'set-state' interface Viresh Kumar
2015-07-30 19:28   ` [tip:x86/platform] x86/uv/time: Migrate to new set-state interface tip-bot for Viresh Kumar
2015-07-30 20:04     ` Christoph Lameter
2015-07-30 22:25       ` Thomas Gleixner
2015-07-31  5:21       ` Viresh Kumar
2015-07-31 12:20         ` Dimitri Sivanich
2015-08-04 15:25           ` Nathan Zimmer
2015-08-05  5:15             ` Viresh Kumar
2015-08-05 14:29               ` Nathan Zimmer
2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar
2015-07-16 14:28   ` Boris Ostrovsky
2015-07-30 19:28   ` [tip:x86/platform] x86/xen/time: Migrate to new set-state interface tip-bot for Viresh Kumar
2015-07-16 10:58 ` [PATCH 5/5] x86/xen/time: Migrate to new 'set-state' interface Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.