Skip to contentSkip to conversation

MIPS: Migrate clockevent drivers to 'set-state'

PATCH In review Viresh Kumar 4 participants 26 messages Jul 6, 2015 – Jul 27, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover MIPS: Migrate clockevent drivers to 'set-state'

Hi Guys,

This series migrates MIPS clockevent drivers (present in arch/mips/ directory), 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-rc1

Following patches:
MIPS/alchemy/time: Migrate to new 'set-state' interface MIPS/jazz/timer: Migrate to new 'set-state' interface MIPS/cevt-r4k: Migrate to new 'set-state' interface MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface MIPS/sni/time: Migrate to new 'set-state' interface

must be integrated to mainline kernel via clockevents tree, because of dependency on:
352370adb058 ("clockevents: Allow set-state callbacks to be optional")

Other patches don't have this dependency and can be pushed via platform specific trees, if Maintainers want it that way.

This has been build/boot tested by two bots on various platforms for few days now, not sure if we had a good coverage for MIPS though:

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

Cc Andrew Bresticker <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>
Cc Hongliang Tao <[email protected]>
Cc Huacai Chen <[email protected]>
Cc James Hogan <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Kelvin Cheung <[email protected]>
Cc Leonid Yegoshin <[email protected]>
Cc Manuel Lauss <[email protected]>
Cc Michael Opdenacker <[email protected]>
Cc Paul Burton <[email protected]>
Cc Qais Yousef <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Valentin Rothberg <[email protected]>

Viresh Kumar (14):
MIPS/alchemy/time: Migrate to new 'set-state' interface MIPS/jazz/timer: Migrate to new 'set-state' interface MIPS/jz4740/time: Migrate to new 'set-state' interface MIPS/cevt-bcm1480: Migrate to new 'set-state' interface MIPS/cevt-ds1287: Migrate to new 'set-state' interface MIPS/cevt-gt641xx: Migrate to new 'set-state' interface MIPS/cevt-r4k: Migrate to new 'set-state' interface MIPS/cevt-sb1250: Migrate to new 'set-state' interface MIPS/cevt-txx9: Migrate to new 'set-state' interface MIPS/loongson64/timer: Migrate to new 'set-state' interface MIPS/loongsoon32/time: Migrate to new 'set-state' interface MIPS/ralink/rt3352: Migrate to new 'set-state' interface MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface MIPS/sni/time: Migrate to new 'set-state' interface

 arch/mips/alchemy/common/time.c                   |   6 --
 arch/mips/include/asm/cevt-r4k.h                  |   1 -
 arch/mips/jazz/irq.c                              |   7 --
 arch/mips/jz4740/time.c                           |  46 +++++----
 arch/mips/kernel/cevt-bcm1480.c                   |  44 ++++----
 arch/mips/kernel/cevt-ds1287.c                    |  37 ++++---
 arch/mips/kernel/cevt-gt641xx.c                   |  57 +++++++----
 arch/mips/kernel/cevt-r4k.c                       |   7 --
 arch/mips/kernel/cevt-sb1250.c                    |  45 +++++----
 arch/mips/kernel/cevt-txx9.c                      |  81 +++++++++------
 arch/mips/loongson32/common/time.c                |  57 ++++++-----
 arch/mips/loongson64/common/cs5536/cs5536_mfgpt.c |  46 ++++-----
 arch/mips/loongson64/loongson-3/hpet.c            | 116 +++++++++++++---------
 arch/mips/ralink/cevt-rt3352.c                    |  59 +++++------
 arch/mips/sgi-ip27/ip27-timer.c                   |   7 --
 arch/mips/sni/time.c                              |  49 ++++-----
 16 files changed, 359 insertions(+), 306 deletions(-)
Signature · 1 line
2.4.0
#1 lore raw

PATCH 1/14 MIPS/alchemy/time: Migrate to new 'set-state' interface

Migrate alchemy 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Cc Ralf Baechle <[email protected]>
Cc Manuel Lauss <[email protected]>
---
 arch/mips/alchemy/common/time.c | 6 ------
 1 file changed, 6 deletions(-)
arch/mips/alchemy/common/time.c +0 -6
index 50e17e13c18b..f99d3ec17a45 100644
@@ -69,11 +69,6 @@ static int au1x_rtcmatch2_set_next_event(unsigned long delta,
 	return 0;
 }
 
-static void au1x_rtcmatch2_set_mode(enum clock_event_mode mode,
-				    struct clock_event_device *cd)
-{
-}
-
 static irqreturn_t au1x_rtcmatch2_irq(int irq, void *dev_id)
 {
 	struct clock_event_device *cd = dev_id;
@@ -86,7 +81,6 @@ static struct clock_event_device au1x_rtcmatch2_clockdev = {
 	.features	= CLOCK_EVT_FEAT_ONESHOT,
 	.rating		= 1500,
 	.set_next_event = au1x_rtcmatch2_set_next_event,
-	.set_mode	= au1x_rtcmatch2_set_mode,
 	.cpumask	= cpu_all_mask,
 };
 
Signature · 1 line
2.4.0
#2 lore raw

Re: [PATCH 01/14] MIPS/alchemy/time: Migrate to new 'set-state' interface

Hello.

Quoted 9 lines · Viresh Kumar

Migrate alchemy 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

This is broken as well, for the same reason as cevt-r4k.c.

WBR, Sergei

#3 lore raw

Re: [PATCH 01/14] MIPS/alchemy/time: Migrate to new 'set-state' interface

In reply to Viresh Kumar
Quoted 34 lines · Viresh Kumar

Migrate alchemy 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Cc Ralf Baechle <[email protected]>
Cc Manuel Lauss <[email protected]>
---
 arch/mips/alchemy/common/time.c | 6 ------
 1 file changed, 6 deletions(-)
arch/mips/alchemy/common/time.c +0 -5
index 50e17e13c18b..f99d3ec17a45 100644
@@ -69,11 +69,6 @@ static int au1x_rtcmatch2_set_next_event(unsigned long delta,
        return 0;
 }
 
-static void au1x_rtcmatch2_set_mode(enum clock_event_mode mode,
-                                   struct clock_event_device *cd)
-{
-}
-
 static irqreturn_t au1x_rtcmatch2_irq(int irq, void *dev_id)
 {
        struct clock_event_device *cd = dev_id;

arch/mips/alchemy/common/time.c static struct clock_event_device au1x_rtcmatch2_clockdev = { · line 85

Quoted 6 lines
arch/mips/alchemy/common/time.c +0 -1
@@ -86,7 +81,6 @@ static struct clock_event_device au1x_rtcmatch2_clockdev = {
        .features       = CLOCK_EVT_FEAT_ONESHOT,
        .rating         = 1500,
        .set_next_event = au1x_rtcmatch2_set_next_event,
-       .set_mode       = au1x_rtcmatch2_set_mode,
        .cpumask        = cpu_all_mask,
 };

That's broken. You need at least something like this (tested):
the cevt-r4k.c is broken the same way.

arch/mips/alchemy/common/time.c +4 -3
index 50e17e1..ef1ca39 100644
@@ -69,9 +69,9 @@ static int au1x_rtcmatch2_set_next_event(unsigned long delta,
        return 0;
 }
 
-static void au1x_rtcmatch2_set_mode(enum clock_event_mode mode,
-                                   struct clock_event_device *cd)
+static int au1x_rtcmatch2_set_nop(struct clock_event_device *cd)
 {
+       return 0;
 }
 
 static irqreturn_t au1x_rtcmatch2_irq(int irq, void *dev_id)
@@ -86,7 +86,8 @@ static struct clock_event_device au1x_rtcmatch2_clockdev = {
        .features       = CLOCK_EVT_FEAT_ONESHOT,
        .rating         = 1500,
        .set_next_event = au1x_rtcmatch2_set_next_event,
-       .set_mode       = au1x_rtcmatch2_set_mode,
+       .set_state_oneshot      = au1x_rtcmatch2_set_nop,
+       .set_state_shutdown     = au1x_rtcmatch2_set_nop,
        .cpumask        = cpu_all_mask,
 };
 

Manuel

#4 lore raw

PATCH 2/14 MIPS/jazz/timer: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate jazz 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

---
 arch/mips/jazz/irq.c | 7 -------
 1 file changed, 7 deletions(-)
arch/mips/jazz/irq.c +0 -7
index e1ea4f625f7a..5d6828b2a750 100644
@@ -110,18 +110,11 @@ asmlinkage void plat_irq_dispatch(void)
 	}
 }
 
-static void r4030_set_mode(enum clock_event_mode mode,
-			   struct clock_event_device *evt)
-{
-	/* Nothing to do ...  */
-}
-
 struct clock_event_device r4030_clockevent = {
 	.name		= "r4030",
 	.features	= CLOCK_EVT_FEAT_PERIODIC,
 	.rating		= 300,
 	.irq		= JAZZ_TIMER_IRQ,
-	.set_mode	= r4030_set_mode,
 };
 
 static irqreturn_t r4030_timer_interrupt(int irq, void *dev_id)
Signature · 1 line
2.4.0
#5 lore raw

Re: [PATCH 02/14] MIPS/jazz/timer: Migrate to new 'set-state' interface

Quoted 4 lines · Viresh Kumar

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

Quoted 8 lines

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

We weren't doing anything in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Broken too.

WBR, Sergei

#6 lore raw

PATCH 3/14 MIPS/jz4740/time: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate jz4740 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.

Cc Ralf Baechle <[email protected]>
Cc Paul Burton <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>
---
 arch/mips/jz4740/time.c | 46 +++++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 19 deletions(-)
arch/mips/jz4740/time.c +27 -19
index 7ab47fee1be8..1f7ca2c9f262 100644
@@ -58,7 +58,7 @@ static irqreturn_t jz4740_clockevent_irq(int irq, void *devid)
 
 	jz4740_timer_ack_full(TIMER_CLOCKEVENT);
 
-	if (cd->mode != CLOCK_EVT_MODE_PERIODIC)
+	if (!clockevent_state_periodic(cd))
 		jz4740_timer_disable(TIMER_CLOCKEVENT);
 
 	cd->event_handler(cd);
@@ -66,24 +66,29 @@ static irqreturn_t jz4740_clockevent_irq(int irq, void *devid)
 	return IRQ_HANDLED;
 }
 
-static void jz4740_clockevent_set_mode(enum clock_event_mode mode,
-	struct clock_event_device *cd)
+static int jz4740_clockevent_set_periodic(struct clock_event_device *evt)
 {
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		jz4740_timer_set_count(TIMER_CLOCKEVENT, 0);
-		jz4740_timer_set_period(TIMER_CLOCKEVENT, jz4740_jiffies_per_tick);
-	case CLOCK_EVT_MODE_RESUME:
-		jz4740_timer_irq_full_enable(TIMER_CLOCKEVENT);
-		jz4740_timer_enable(TIMER_CLOCKEVENT);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		jz4740_timer_disable(TIMER_CLOCKEVENT);
-		break;
-	default:
-		break;
-	}
+	jz4740_timer_set_count(TIMER_CLOCKEVENT, 0);
+	jz4740_timer_set_period(TIMER_CLOCKEVENT, jz4740_jiffies_per_tick);
+	jz4740_timer_irq_full_enable(TIMER_CLOCKEVENT);
+	jz4740_timer_enable(TIMER_CLOCKEVENT);
+
+	return 0;
+}
+
+static int jz4740_clockevent_resume(struct clock_event_device *evt)
+{
+	jz4740_timer_irq_full_enable(TIMER_CLOCKEVENT);
+	jz4740_timer_enable(TIMER_CLOCKEVENT);
+
+	return 0;
+}
+
+static int jz4740_clockevent_shutdown(struct clock_event_device *evt)
+{
+	jz4740_timer_disable(TIMER_CLOCKEVENT);
+
+	return 0;
 }
 
 static int jz4740_clockevent_set_next(unsigned long evt,
@@ -100,7 +105,10 @@ static struct clock_event_device jz4740_clockevent = {
 	.name = "jz4740-timer",
 	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.set_next_event = jz4740_clockevent_set_next,
-	.set_mode = jz4740_clockevent_set_mode,
+	.set_state_shutdown = jz4740_clockevent_shutdown,
+	.set_state_periodic = jz4740_clockevent_set_periodic,
+	.set_state_oneshot = jz4740_clockevent_shutdown,
+	.tick_resume = jz4740_clockevent_resume,
 	.rating = 200,
 #ifdef CONFIG_MACH_JZ4740
 	.irq = JZ4740_IRQ_TCU0,
Signature · 1 line
2.4.0
#7 lore raw

PATCH 4/14 MIPS/cevt-bcm1480: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-bcm1480 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.

Read operation on R_SCD_TIMER_CFG and R_SCD_TIMER_INIT registers isn't performed now for many modes as there returned values aren't used.

---
 arch/mips/kernel/cevt-bcm1480.c | 44 ++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
arch/mips/kernel/cevt-bcm1480.c +22 -22
index 7976457184b1..940ac00e9129 100644
@@ -40,8 +40,8 @@
  * The general purpose timer ticks at 1MHz independent if
  * the rest of the system
  */
-static void sibyte_set_mode(enum clock_event_mode mode,
-			   struct clock_event_device *evt)
+
+static int sibyte_set_periodic(struct clock_event_device *evt)
 {
 	unsigned int cpu = smp_processor_id();
 	void __iomem *cfg, *init;
@@ -49,24 +49,22 @@ static void sibyte_set_mode(enum clock_event_mode mode,
 	cfg = IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG));
 	init = IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT));
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		__raw_writeq(0, cfg);
-		__raw_writeq((V_SCD_TIMER_FREQ / HZ) - 1, init);
-		__raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS,
-			     cfg);
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* Stop the timer until we actually program a shot */
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		__raw_writeq(0, cfg);
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:	/* shuddup gcc */
-	case CLOCK_EVT_MODE_RESUME:
-		;
-	}
+	__raw_writeq(0, cfg);
+	__raw_writeq((V_SCD_TIMER_FREQ / HZ) - 1, init);
+	__raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, cfg);
+	return 0;
+}
+
+static int sibyte_shutdown(struct clock_event_device *evt)
+{
+	unsigned int cpu = smp_processor_id();
+	void __iomem *cfg;
+
+	cfg = IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG));
+
+	/* Stop the timer until we actually program a shot */
+	__raw_writeq(0, cfg);
+	return 0;
 }
 
 static int sibyte_next_event(unsigned long delta, struct clock_event_device *cd)
@@ -91,7 +89,7 @@ static irqreturn_t sibyte_counter_handler(int irq, void *dev_id)
 	void __iomem *cfg;
 	unsigned long tmode;
 
-	if (cd->mode == CLOCK_EVT_MODE_PERIODIC)
+	if (clockevent_state_periodic(cd))
 		tmode = M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS;
 	else
 		tmode = 0;
@@ -130,7 +128,9 @@ void sb1480_clockevent_init(void)
 	cd->irq			= irq;
 	cd->cpumask		= cpumask_of(cpu);
 	cd->set_next_event	= sibyte_next_event;
-	cd->set_mode		= sibyte_set_mode;
+	cd->set_state_shutdown	= sibyte_shutdown;
+	cd->set_state_periodic	= sibyte_set_periodic;
+	cd->set_state_oneshot	= sibyte_shutdown;
 	clockevents_register_device(cd);
 
 	bcm1480_mask_irq(cpu, irq);
Signature · 1 line
2.4.0
#8 lore raw

PATCH 5/14 MIPS/cevt-ds1287: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-ds1287 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.

---
 arch/mips/kernel/cevt-ds1287.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)
arch/mips/kernel/cevt-ds1287.c +22 -15
index ff1f01b72270..77a5ddf53f57 100644
@@ -59,27 +59,32 @@ static int ds1287_set_next_event(unsigned long delta,
 	return -EINVAL;
 }
 
-static void ds1287_set_mode(enum clock_event_mode mode,
-			    struct clock_event_device *evt)
+static int ds1287_shutdown(struct clock_event_device *evt)
 {
 	u8 val;
 
 	spin_lock(&rtc_lock);
 
 	val = CMOS_READ(RTC_REG_B);
+	val &= ~RTC_PIE;
+	CMOS_WRITE(val, RTC_REG_B);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		val |= RTC_PIE;
-		break;
-	default:
-		val &= ~RTC_PIE;
-		break;
-	}
+	spin_unlock(&rtc_lock);
+	return 0;
+}
 
+static int ds1287_set_periodic(struct clock_event_device *evt)
+{
+	u8 val;
+
+	spin_lock(&rtc_lock);
+
+	val = CMOS_READ(RTC_REG_B);
+	val |= RTC_PIE;
 	CMOS_WRITE(val, RTC_REG_B);
 
 	spin_unlock(&rtc_lock);
+	return 0;
 }
 
 static void ds1287_event_handler(struct clock_event_device *dev)
@@ -87,11 +92,13 @@ static void ds1287_event_handler(struct clock_event_device *dev)
 }
 
 static struct clock_event_device ds1287_clockevent = {
-	.name		= "ds1287",
-	.features	= CLOCK_EVT_FEAT_PERIODIC,
-	.set_next_event = ds1287_set_next_event,
-	.set_mode	= ds1287_set_mode,
-	.event_handler	= ds1287_event_handler,
+	.name			= "ds1287",
+	.features		= CLOCK_EVT_FEAT_PERIODIC,
+	.set_next_event		= ds1287_set_next_event,
+	.set_state_shutdown	= ds1287_shutdown,
+	.set_state_periodic	= ds1287_set_periodic,
+	.tick_resume		= ds1287_shutdown,
+	.event_handler		= ds1287_event_handler,
 };
 
 static irqreturn_t ds1287_interrupt(int irq, void *dev_id)
Signature · 1 line
2.4.0
#9 lore raw

PATCH 6/14 MIPS/cevt-gt641xx: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-gt641xx 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.

---
 arch/mips/kernel/cevt-gt641xx.c | 57 ++++++++++++++++++++++++++++-------------
 1 file changed, 39 insertions(+), 18 deletions(-)
arch/mips/kernel/cevt-gt641xx.c +39 -18
index f069460751ab..66040051151d 100644
@@ -64,8 +64,7 @@ static int gt641xx_timer0_set_next_event(unsigned long delta,
 	return 0;
 }
 
-static void gt641xx_timer0_set_mode(enum clock_event_mode mode,
-				    struct clock_event_device *evt)
+static int gt641xx_timer0_shutdown(struct clock_event_device *evt)
 {
 	u32 ctrl;
 
@@ -73,21 +72,39 @@ static void gt641xx_timer0_set_mode(enum clock_event_mode mode,
 
 	ctrl = GT_READ(GT_TC_CONTROL_OFS);
 	ctrl &= ~(GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
+	GT_WRITE(GT_TC_CONTROL_OFS, ctrl);
+
+	raw_spin_unlock(&gt641xx_timer_lock);
+	return 0;
+}
+
+static int gt641xx_timer0_set_oneshot(struct clock_event_device *evt)
+{
+	u32 ctrl;
+
+	raw_spin_lock(&gt641xx_timer_lock);
+
+	ctrl = GT_READ(GT_TC_CONTROL_OFS);
+	ctrl &= ~GT_TC_CONTROL_SELTC0_MSK;
+	ctrl |= GT_TC_CONTROL_ENTC0_MSK;
+	GT_WRITE(GT_TC_CONTROL_OFS, ctrl);
+
+	raw_spin_unlock(&gt641xx_timer_lock);
+	return 0;
+}
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		ctrl |= GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK;
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		ctrl |= GT_TC_CONTROL_ENTC0_MSK;
-		break;
-	default:
-		break;
-	}
+static int gt641xx_timer0_set_periodic(struct clock_event_device *evt)
+{
+	u32 ctrl;
+
+	raw_spin_lock(&gt641xx_timer_lock);
 
+	ctrl = GT_READ(GT_TC_CONTROL_OFS);
+	ctrl |= GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK;
 	GT_WRITE(GT_TC_CONTROL_OFS, ctrl);
 
 	raw_spin_unlock(&gt641xx_timer_lock);
+	return 0;
 }
 
 static void gt641xx_timer0_event_handler(struct clock_event_device *dev)
@@ -95,12 +112,16 @@ static void gt641xx_timer0_event_handler(struct clock_event_device *dev)
 }
 
 static struct clock_event_device gt641xx_timer0_clockevent = {
-	.name		= "gt641xx-timer0",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.irq		= GT641XX_TIMER0_IRQ,
-	.set_next_event = gt641xx_timer0_set_next_event,
-	.set_mode	= gt641xx_timer0_set_mode,
-	.event_handler	= gt641xx_timer0_event_handler,
+	.name			= "gt641xx-timer0",
+	.features		= CLOCK_EVT_FEAT_PERIODIC |
+				  CLOCK_EVT_FEAT_ONESHOT,
+	.irq			= GT641XX_TIMER0_IRQ,
+	.set_next_event		= gt641xx_timer0_set_next_event,
+	.set_state_shutdown	= gt641xx_timer0_shutdown,
+	.set_state_periodic	= gt641xx_timer0_set_periodic,
+	.set_state_oneshot	= gt641xx_timer0_set_oneshot,
+	.tick_resume		= gt641xx_timer0_shutdown,
+	.event_handler		= gt641xx_timer0_event_handler,
 };
 
 static irqreturn_t gt641xx_timer0_interrupt(int irq, void *dev_id)
Signature · 1 line
2.4.0
#10 lore raw

PATCH 7/14 MIPS/cevt-r4k: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-4k 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Cc Ralf Baechle <[email protected]>
Cc James Hogan <[email protected]>
Cc Andrew Bresticker <[email protected]>
Cc Qais Yousef <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Leonid Yegoshin <[email protected]>
---
 arch/mips/include/asm/cevt-r4k.h | 1 -
 arch/mips/kernel/cevt-r4k.c      | 7 -------
 2 files changed, 8 deletions(-)
arch/mips/include/asm/cevt-r4k.h +0 -1
index f0edf6fcd002..2e13a038d260 100644
@@ -21,7 +21,6 @@ DECLARE_PER_CPU(struct clock_event_device, mips_clockevent_device);
 
 void mips_event_handler(struct clock_event_device *dev);
 int c0_compare_int_usable(void);
-void mips_set_clock_mode(enum clock_event_mode, struct clock_event_device *);
 irqreturn_t c0_compare_interrupt(int, void *);
 
 extern struct irqaction c0_compare_irqaction;
arch/mips/kernel/cevt-r4k.c +0 -7
index d70c4d893219..dd41d797e39f 100644
@@ -28,12 +28,6 @@ static int mips_next_event(unsigned long delta,
 	return res;
 }
 
-void mips_set_clock_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
-{
-	/* Nothing to do ...  */
-}
-
 DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device);
 int cp0_timer_irq_installed;
 
@@ -212,7 +206,6 @@ int r4k_clockevent_init(void)
 	cd->irq			= irq;
 	cd->cpumask		= cpumask_of(cpu);
 	cd->set_next_event	= mips_next_event;
-	cd->set_mode		= mips_set_clock_mode;
 	cd->event_handler	= mips_event_handler;
 
 	clockevents_register_device(cd);
Signature · 1 line
2.4.0
#11 lore raw

Re: [PATCH 07/14] MIPS/cevt-r4k: Migrate to new 'set-state' interface

Hello.

Quoted 9 lines · Viresh Kumar

Migrate cevt-4k 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

The code in __clockevents_switch_state() looks like it's going to oops as
you're not implementing set_state_oneshot()...

WBR, Sergei

#12 lore raw

Re: [PATCH 07/14] MIPS/cevt-r4k: Migrate to new 'set-state' interface

Hello.

Quoted 4 lines · Sergei Shtylyov
Quoted 3 lines

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

Quoted 8 lines
Quoted 5 lines

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

We weren't doing anything in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

The code in __clockevents_switch_state() looks like it's going to oops as
you're not implementing set_state_oneshot()...

In fact, clockevents_sanity_check() should return -EINVAL in this case,
and so the kernel crash even earlier, duyr to BUG_ON() in clockevents_register_device().

WBR, Sergei

#13 lore raw

Re: [PATCH 07/14] MIPS/cevt-r4k: Migrate to new 'set-state' interface

Quoted 10 lines · Sergei Shtylyov
Quoted 9 lines
Quoted 9 lines

Migrate cevt-4k 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Quoted 6 lines
Quoted 2 lines

The code in __clockevents_switch_state() looks like it's going to oops as
you're not implementing set_state_oneshot()...

In fact, clockevents_sanity_check() should return -EINVAL in this case,
and so the kernel crash even earlier, duyr to BUG_ON() in clockevents_register_device().

tglx has turned my attention the pre-requisite patch, and I have finally
found it in the archives. I'm now OK with the patches I considered broken.

WBR, Sergei

#14 lore raw

PATCH 8/14 MIPS/cevt-sb1250: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-rsb1250 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.

---
 arch/mips/kernel/cevt-sb1250.c | 45 +++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 22 deletions(-)
arch/mips/kernel/cevt-sb1250.c +23 -22
index 5ea6d6b1de15..3d860efd63b9 100644
@@ -38,8 +38,20 @@
  * The general purpose timer ticks at 1MHz independent if
  * the rest of the system
  */
-static void sibyte_set_mode(enum clock_event_mode mode,
-			   struct clock_event_device *evt)
+
+static int sibyte_shutdown(struct clock_event_device *evt)
+{
+	void __iomem *cfg;
+
+	cfg = IOADDR(A_SCD_TIMER_REGISTER(smp_processor_id(), R_SCD_TIMER_CFG));
+
+	/* Stop the timer until we actually program a shot */
+	__raw_writeq(0, cfg);
+
+	return 0;
+}
+
+static int sibyte_set_periodic(struct clock_event_device *evt)
 {
 	unsigned int cpu = smp_processor_id();
 	void __iomem *cfg, *init;
@@ -47,24 +59,11 @@ static void sibyte_set_mode(enum clock_event_mode mode,
 	cfg = IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG));
 	init = IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT));
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		__raw_writeq(0, cfg);
-		__raw_writeq((V_SCD_TIMER_FREQ / HZ) - 1, init);
-		__raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS,
-			     cfg);
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* Stop the timer until we actually program a shot */
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		__raw_writeq(0, cfg);
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:	/* shuddup gcc */
-	case CLOCK_EVT_MODE_RESUME:
-		;
-	}
+	__raw_writeq(0, cfg);
+	__raw_writeq((V_SCD_TIMER_FREQ / HZ) - 1, init);
+	__raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, cfg);
+
+	return 0;
 }
 
 static int sibyte_next_event(unsigned long delta, struct clock_event_device *cd)
@@ -89,7 +88,7 @@ static irqreturn_t sibyte_counter_handler(int irq, void *dev_id)
 	void __iomem *cfg;
 	unsigned long tmode;
 
-	if (cd->mode == CLOCK_EVT_MODE_PERIODIC)
+	if (clockevent_state_periodic(cd))
 		tmode = M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS;
 	else
 		tmode = 0;
@@ -129,7 +128,9 @@ void sb1250_clockevent_init(void)
 	cd->irq			= irq;
 	cd->cpumask		= cpumask_of(cpu);
 	cd->set_next_event	= sibyte_next_event;
-	cd->set_mode		= sibyte_set_mode;
+	cd->set_state_shutdown	= sibyte_shutdown;
+	cd->set_state_periodic	= sibyte_set_periodic;
+	cd->set_state_oneshot	= sibyte_shutdown;
 	clockevents_register_device(cd);
 
 	sb1250_mask_irq(cpu, irq);
Signature · 1 line
2.4.0
#15 lore raw

PATCH 9/14 MIPS/cevt-txx9: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate cevt-txx9 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.

Cc Ralf Baechle <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>
---
 arch/mips/kernel/cevt-txx9.c | 81 ++++++++++++++++++++++++++++----------------
 1 file changed, 51 insertions(+), 30 deletions(-)
arch/mips/kernel/cevt-txx9.c +51 -30
index 723932441ecc..537eefdf838f 100644
@@ -85,36 +85,54 @@ static void txx9tmr_stop_and_clear(struct txx9_tmr_reg __iomem *tmrptr)
 	__raw_writel(0, &tmrptr->tisr);
 }
 
-static void txx9tmr_set_mode(enum clock_event_mode mode,
-			     struct clock_event_device *evt)
+static int txx9tmr_set_state_periodic(struct clock_event_device *evt)
 {
 	struct txx9_clock_event_device *txx9_cd =
 		container_of(evt, struct txx9_clock_event_device, cd);
 	struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
 
 	txx9tmr_stop_and_clear(tmrptr);
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE,
-			     &tmrptr->itmr);
-		/* start timer */
-		__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >>
-			     evt->shift,
-			     &tmrptr->cpra);
-		__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
-		break;
-	case CLOCK_EVT_MODE_SHUTDOWN:
-	case CLOCK_EVT_MODE_UNUSED:
-		__raw_writel(0, &tmrptr->itmr);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		__raw_writel(TIMER_CCD, &tmrptr->ccdr);
-		__raw_writel(0, &tmrptr->itmr);
-		break;
-	}
+
+	__raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE, &tmrptr->itmr);
+	/* start timer */
+	__raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >> evt->shift,
+		     &tmrptr->cpra);
+	__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
+	return 0;
+}
+
+static int txx9tmr_set_state_oneshot(struct clock_event_device *evt)
+{
+	struct txx9_clock_event_device *txx9_cd =
+		container_of(evt, struct txx9_clock_event_device, cd);
+	struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
+
+	txx9tmr_stop_and_clear(tmrptr);
+	__raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr);
+	return 0;
+}
+
+static int txx9tmr_set_state_shutdown(struct clock_event_device *evt)
+{
+	struct txx9_clock_event_device *txx9_cd =
+		container_of(evt, struct txx9_clock_event_device, cd);
+	struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
+
+	txx9tmr_stop_and_clear(tmrptr);
+	__raw_writel(0, &tmrptr->itmr);
+	return 0;
+}
+
+static int txx9tmr_tick_resume(struct clock_event_device *evt)
+{
+	struct txx9_clock_event_device *txx9_cd =
+		container_of(evt, struct txx9_clock_event_device, cd);
+	struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
+
+	txx9tmr_stop_and_clear(tmrptr);
+	__raw_writel(TIMER_CCD, &tmrptr->ccdr);
+	__raw_writel(0, &tmrptr->itmr);
+	return 0;
 }
 
 static int txx9tmr_set_next_event(unsigned long delta,
@@ -133,12 +151,15 @@ static int txx9tmr_set_next_event(unsigned long delta,
 
 static struct txx9_clock_event_device txx9_clock_event_device = {
 	.cd = {
-		.name		= "TXx9",
-		.features	= CLOCK_EVT_FEAT_PERIODIC |
-				  CLOCK_EVT_FEAT_ONESHOT,
-		.rating		= 200,
-		.set_mode	= txx9tmr_set_mode,
-		.set_next_event = txx9tmr_set_next_event,
+		.name			= "TXx9",
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,
+		.rating			= 200,
+		.set_state_shutdown	= txx9tmr_set_state_shutdown,
+		.set_state_periodic	= txx9tmr_set_state_periodic,
+		.set_state_oneshot	= txx9tmr_set_state_oneshot,
+		.tick_resume		= txx9tmr_tick_resume,
+		.set_next_event		= txx9tmr_set_next_event,
 	},
 };
 
Signature · 1 line
2.4.0
#16 lore raw

PATCH 10/14 MIPS/loongson64/timer: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate loongson 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.

Cc Ralf Baechle <[email protected]>
Cc Huacai Chen <[email protected]>
Cc Michael Opdenacker <[email protected]>
Cc Hongliang Tao <[email protected]>
Cc Valentin Rothberg <[email protected]>
---
 arch/mips/loongson64/common/cs5536/cs5536_mfgpt.c |  46 ++++-----
 arch/mips/loongson64/loongson-3/hpet.c            | 116 +++++++++++++---------
 2 files changed, 92 insertions(+), 70 deletions(-)
arch/mips/loongson64/common/cs5536/cs5536_mfgpt.c +21 -25
index 12c75db23420..2f4b30f06b19 100644
@@ -51,40 +51,36 @@ void enable_mfgpt0_counter(void)
 }
 EXPORT_SYMBOL(enable_mfgpt0_counter);
 
-static void init_mfgpt_timer(enum clock_event_mode mode,
-			     struct clock_event_device *evt)
+static int mfgpt_timer_set_periodic(struct clock_event_device *evt)
 {
 	raw_spin_lock(&mfgpt_lock);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		outw(COMPARE, MFGPT0_CMP2);	/* set comparator2 */
-		outw(0, MFGPT0_CNT);	/* set counter to 0 */
-		enable_mfgpt0_counter();
-		break;
-
-	case CLOCK_EVT_MODE_SHUTDOWN:
-	case CLOCK_EVT_MODE_UNUSED:
-		if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
-		    evt->mode == CLOCK_EVT_MODE_ONESHOT)
-			disable_mfgpt0_counter();
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* The oneshot mode have very high deviation, Not use it! */
-		break;
-
-	case CLOCK_EVT_MODE_RESUME:
-		/* Nothing to do here */
-		break;
-	}
+	outw(COMPARE, MFGPT0_CMP2);	/* set comparator2 */
+	outw(0, MFGPT0_CNT);		/* set counter to 0 */
+	enable_mfgpt0_counter();
+
 	raw_spin_unlock(&mfgpt_lock);
+	return 0;
+}
+
+static int mfgpt_timer_shutdown(struct clock_event_device *evt)
+{
+	if (clockevent_state_periodic(evt) || clockevent_state_oneshot(evt)) {
+		raw_spin_lock(&mfgpt_lock);
+		disable_mfgpt0_counter();
+		raw_spin_unlock(&mfgpt_lock);
+	}
+
+	return 0;
 }
 
 static struct clock_event_device mfgpt_clockevent = {
 	.name = "mfgpt",
 	.features = CLOCK_EVT_FEAT_PERIODIC,
-	.set_mode = init_mfgpt_timer,
+
+	/* The oneshot mode have very high deviation, don't use it! */
+	.set_state_shutdown = mfgpt_timer_shutdown,
+	.set_state_periodic = mfgpt_timer_set_periodic,
 	.irq = CS5536_MFGPT_INTR,
 };
 
arch/mips/loongson64/loongson-3/hpet.c +71 -45

132 lines not on this page · raw message

Signature · 1 line
2.4.0
#17 lore raw

PATCH 11/14 MIPS/loongsoon32/time: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate loongsoon32 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.

Cc Ralf Baechle <[email protected]>
Cc Kelvin Cheung <[email protected]>
Cc Huacai Chen <[email protected]>
---
 arch/mips/loongson32/common/time.c | 57 +++++++++++++++++++++++---------------
 1 file changed, 34 insertions(+), 23 deletions(-)
arch/mips/loongson32/common/time.c +34 -23
index df0f850d6a5f..0996b025eeef 100644
@@ -126,26 +126,34 @@ static irqreturn_t ls1x_clockevent_isr(int irq, void *devid)
 	return IRQ_HANDLED;
 }
 
-static void ls1x_clockevent_set_mode(enum clock_event_mode mode,
-				     struct clock_event_device *cd)
+static int ls1x_clockevent_set_state_periodic(struct clock_event_device *cd)
 {
 	raw_spin_lock(&ls1x_timer_lock);
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick);
-		ls1x_pwmtimer_restart();
-	case CLOCK_EVT_MODE_RESUME:
-		__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		__raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
-			     timer_base + PWM_CTRL);
-		break;
-	default:
-		break;
-	}
+	ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick);
+	ls1x_pwmtimer_restart();
+	__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
 	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
+}
+
+static int ls1x_clockevent_tick_resume(struct clock_event_device *cd)
+{
+	raw_spin_lock(&ls1x_timer_lock);
+	__raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL);
+	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
+}
+
+static int ls1x_clockevent_set_state_shutdown(struct clock_event_device *cd)
+{
+	raw_spin_lock(&ls1x_timer_lock);
+	__raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN,
+		     timer_base + PWM_CTRL);
+	raw_spin_unlock(&ls1x_timer_lock);
+
+	return 0;
 }
 
 static int ls1x_clockevent_set_next(unsigned long evt,
@@ -160,12 +168,15 @@ static int ls1x_clockevent_set_next(unsigned long evt,
 }
 
 static struct clock_event_device ls1x_clockevent = {
-	.name		= "ls1x-pwmtimer",
-	.features	= CLOCK_EVT_FEAT_PERIODIC,
-	.rating		= 300,
-	.irq		= LS1X_TIMER_IRQ,
-	.set_next_event	= ls1x_clockevent_set_next,
-	.set_mode	= ls1x_clockevent_set_mode,
+	.name			= "ls1x-pwmtimer",
+	.features		= CLOCK_EVT_FEAT_PERIODIC,
+	.rating			= 300,
+	.irq			= LS1X_TIMER_IRQ,
+	.set_next_event		= ls1x_clockevent_set_next,
+	.set_state_shutdown	= ls1x_clockevent_set_state_shutdown,
+	.set_state_periodic	= ls1x_clockevent_set_state_periodic,
+	.set_state_oneshot	= ls1x_clockevent_set_state_shutdown,
+	.tick_resume		= ls1x_clockevent_tick_resume,
 };
 
 static struct irqaction ls1x_pwmtimer_irqaction = {
Signature · 1 line
2.4.0
#18 lore raw

PATCH 12/14 MIPS/ralink/rt3352: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate ralink 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.

---
 arch/mips/ralink/cevt-rt3352.c | 59 +++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 29 deletions(-)
arch/mips/ralink/cevt-rt3352.c +30 -29
index 24bf057a3613..a8e70a9f274b 100644
@@ -36,8 +36,8 @@ struct systick_device {
 	int freq_scale;
 };
 
-static void systick_set_clock_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt);
+static int systick_set_oneshot(struct clock_event_device *evt);
+static int systick_shutdown(struct clock_event_device *evt);
 
 static int systick_next_event(unsigned long delta,
 				struct clock_event_device *evt)
@@ -73,11 +73,12 @@ static struct systick_device systick = {
 		 * cevt-r4k uses 300, make sure systick
 		 * gets used if available
 		 */
-		.rating		= 310,
-		.features	= CLOCK_EVT_FEAT_ONESHOT,
-		.set_next_event	= systick_next_event,
-		.set_mode	= systick_set_clock_mode,
-		.event_handler	= systick_event_handler,
+		.rating			= 310,
+		.features		= CLOCK_EVT_FEAT_ONESHOT,
+		.set_next_event		= systick_next_event,
+		.set_state_shutdown	= systick_shutdown,
+		.set_state_oneshot	= systick_set_oneshot,
+		.event_handler		= systick_event_handler,
 	},
 };
 
@@ -87,33 +88,33 @@ static struct irqaction systick_irqaction = {
 	.dev_id = &systick.dev,
 };
 
-static void systick_set_clock_mode(enum clock_event_mode mode,
-				struct clock_event_device *evt)
+static int systick_shutdown(struct clock_event_device *evt)
 {
 	struct systick_device *sdev;
 
 	sdev = container_of(evt, struct systick_device, dev);
 
-	switch (mode) {
-	case CLOCK_EVT_MODE_ONESHOT:
-		if (!sdev->irq_requested)
-			setup_irq(systick.dev.irq, &systick_irqaction);
-		sdev->irq_requested = 1;
-		iowrite32(CFG_EXT_STK_EN | CFG_CNT_EN,
-				systick.membase + SYSTICK_CONFIG);
-		break;
-
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		if (sdev->irq_requested)
-			free_irq(systick.dev.irq, &systick_irqaction);
-		sdev->irq_requested = 0;
-		iowrite32(0, systick.membase + SYSTICK_CONFIG);
-		break;
-
-	default:
-		pr_err("%s: Unhandeled mips clock_mode\n", systick.dev.name);
-		break;
-	}
+	if (sdev->irq_requested)
+		free_irq(systick.dev.irq, &systick_irqaction);
+	sdev->irq_requested = 0;
+	iowrite32(0, systick.membase + SYSTICK_CONFIG);
+
+	return 0;
+}
+
+static int systick_set_oneshot(struct clock_event_device *evt)
+{
+	struct systick_device *sdev;
+
+	sdev = container_of(evt, struct systick_device, dev);
+
+	if (!sdev->irq_requested)
+		setup_irq(systick.dev.irq, &systick_irqaction);
+	sdev->irq_requested = 1;
+	iowrite32(CFG_EXT_STK_EN | CFG_CNT_EN,
+		  systick.membase + SYSTICK_CONFIG);
+
+	return 0;
 }
 
 static void __init ralink_systick_init(struct device_node *np)
Signature · 1 line
2.4.0
#19 lore raw

PATCH 13/14 MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate sgidriver 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 in the ->set_mode() callback. So, this patch doesn't provide any set-state callbacks.

Cc Ralf Baechle <[email protected]>
Cc Deng-Cheng Zhu <[email protected]>
---
 arch/mips/sgi-ip27/ip27-timer.c | 7 -------
 1 file changed, 7 deletions(-)
arch/mips/sgi-ip27/ip27-timer.c +0 -7
index a6d10f607f34..42d6cb9f956e 100644
@@ -64,12 +64,6 @@ static int rt_next_event(unsigned long delta, struct clock_event_device *evt)
 	return LOCAL_HUB_L(PI_RT_COUNT) >= cnt ? -ETIME : 0;
 }
 
-static void rt_set_mode(enum clock_event_mode mode,
-		struct clock_event_device *evt)
-{
-	/* Nothing to do ...  */
-}
-
 unsigned int rt_timer_irq;
 
 static DEFINE_PER_CPU(struct clock_event_device, hub_rt_clockevent);
@@ -124,7 +118,6 @@ void hub_rt_clock_event_init(void)
 	cd->irq			= irq;
 	cd->cpumask		= cpumask_of(cpu);
 	cd->set_next_event	= rt_next_event;
-	cd->set_mode		= rt_set_mode;
 	clockevents_register_device(cd);
 }
 
Signature · 1 line
2.4.0
#20 lore raw

PATCH 14/14 MIPS/sni/time: Migrate to new 'set-state' interface

In reply to Viresh Kumar

Migrate sni 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.

---
 arch/mips/sni/time.c | 49 +++++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)
arch/mips/sni/time.c +19 -30
index cf8ec568b9df..fb4b3520cdc6 100644
@@ -14,44 +14,33 @@
 #define SNI_COUNTER2_DIV	64
 #define SNI_COUNTER0_DIV	((SNI_CLOCK_TICK_RATE / SNI_COUNTER2_DIV) / HZ)
 
-static void a20r_set_mode(enum clock_event_mode mode,
-			  struct clock_event_device *evt)
+static int a20r_set_periodic(struct clock_event_device *evt)
 {
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34;
-		wmb();
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE +  0) = SNI_COUNTER0_DIV;
-		wmb();
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE +  0) = SNI_COUNTER0_DIV >> 8;
-		wmb();
-
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4;
-		wmb();
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE +  8) = SNI_COUNTER2_DIV;
-		wmb();
-		*(volatile u8 *)(A20R_PT_CLOCK_BASE +  8) = SNI_COUNTER2_DIV >> 8;
-		wmb();
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34;
+	wmb();
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV;
+	wmb();
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV >> 8;
+	wmb();
 
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		break;
-	case CLOCK_EVT_MODE_RESUME:
-		break;
-	}
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4;
+	wmb();
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV;
+	wmb();
+	*(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV >> 8;
+	wmb();
+	return 0;
 }
 
 static struct clock_event_device a20r_clockevent_device = {
-	.name		= "a20r-timer",
-	.features	= CLOCK_EVT_FEAT_PERIODIC,
+	.name			= "a20r-timer",
+	.features		= CLOCK_EVT_FEAT_PERIODIC,
 
 	/* .mult, .shift, .max_delta_ns and .min_delta_ns left uninitialized */
 
-	.rating		= 300,
-	.irq		= SNI_A20R_IRQ_TIMER,
-	.set_mode	= a20r_set_mode,
+	.rating			= 300,
+	.irq			= SNI_A20R_IRQ_TIMER,
+	.set_state_periodic	= a20r_set_periodic,
 };
 
 static irqreturn_t a20r_interrupt(int irq, void *dev_id)
Signature · 1 line
2.4.0
#21 lore raw
In reply to Viresh Kumar
Quoted 15 lines · Viresh Kumar

This series migrates MIPS clockevent drivers (present in arch/mips/ directory), 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-rc1

Following patches:
MIPS/alchemy/time: Migrate to new 'set-state' interface MIPS/jazz/timer: Migrate to new 'set-state' interface MIPS/cevt-r4k: Migrate to new 'set-state' interface MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface MIPS/sni/time: Migrate to new 'set-state' interface

Quoted 3 lines

must be integrated to mainline kernel via clockevents tree, because of dependency on:
352370adb058 ("clockevents: Allow set-state callbacks to be optional")

I had a hard time finding this by ID, since it hasn't landed in any
official trees still.

WBR, Sergei

#22 lore raw
Quoted 17 lines · Sergei Shtylyov
Quoted 14 lines · Viresh Kumar

This series migrates MIPS clockevent drivers (present in arch/mips/ directory), 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-rc1

Following patches:
MIPS/alchemy/time: Migrate to new 'set-state' interface MIPS/jazz/timer: Migrate to new 'set-state' interface MIPS/cevt-r4k: Migrate to new 'set-state' interface MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface MIPS/sni/time: Migrate to new 'set-state' interface

Quoted 6 lines
Quoted 3 lines

must be integrated to mainline kernel via clockevents tree, because of dependency on:
352370adb058 ("clockevents: Allow set-state callbacks to be optional")

I had a hard time finding this by ID, since it hasn't landed in
any official trees still.

For others who might struggle as well:
http://marc.info/?l=linux-kernel&m=143409604825833&w=2

Sorry to waste your time because of this dependency. The best I could have done is to mention the dependency in cover-letter, which I did (though should have included a link as well).

Anyway, thanks :)

Signature · 1 line
viresh
#23 lore raw
In reply to Viresh Kumar
Quoted 17 lines · Viresh Kumar

Hi Guys,

This series migrates MIPS clockevent drivers (present in arch/mips/ directory), 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-rc1

Following patches:
MIPS/alchemy/time: Migrate to new 'set-state' interface MIPS/jazz/timer: Migrate to new 'set-state' interface MIPS/cevt-r4k: Migrate to new 'set-state' interface MIPS/sgi-ip27/timer: Migrate to new 'set-state' interface MIPS/sni/time: Migrate to new 'set-state' interface

Quoted 3 lines

must be integrated to mainline kernel via clockevents tree, because of dependency on:
352370adb058 ("clockevents: Allow set-state callbacks to be optional")

@Ralf: This dependency patch is applied to 4.2-rc2 now and you can pick all the patches from this series.

Signature · 1 line
viresh
#24 lore raw
Quoted 2 lines · Viresh Kumar

@Ralf: This dependency patch is applied to 4.2-rc2 now and you can pick all the patches from this series.

Cool. I've queued the whole series for 4.3.

Ralf

#25 lore raw
Quoted 6 lines · Ralf Baechle
Quoted 2 lines · Viresh Kumar

@Ralf: This dependency patch is applied to 4.2-rc2 now and you can pick all the patches from this series.

Cool. I've queued the whole series for 4.3.

Thanks a lot.

Signature · 1 line
viresh