Skip to contentSkip to conversation

clocksource: arm initialize list value

PATCH In review Daniel Walker 3 participants 14 messages Mar 30, 2007 – Mar 31, 2007

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

PATCH 1/9 clocksource: arm initialize list value

Update arch/arm/ with list initialization.

---
 arch/arm/mach-imx/time.c      |    1 +
 arch/arm/mach-ixp4xx/common.c |    1 +
 arch/arm/mach-netx/time.c     |    1 +
 arch/arm/mach-pxa/time.c      |    1 +
 4 files changed, 4 insertions(+)
arch/arm/mach-imx/time.c +1 -0
Index: linux-2.6.19/arch/arm/mach-imx/time.c
===================================================================
@@ -88,6 +88,7 @@ static struct clocksource clocksource_im
 	.mask		= 0xFFFFFFFF,
 	.shift 		= 20,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_imx.list),
 };
 
 static int __init imx_clocksource_init(void)
arch/arm/mach-ixp4xx/common.c +1 -0
Index: linux-2.6.19/arch/arm/mach-ixp4xx/common.c
===================================================================
@@ -396,6 +396,7 @@ static struct clocksource clocksource_ix
 	.mask		= CLOCKSOURCE_MASK(32),
 	.shift 		= 20,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_ixp4xx.list),
 };
 
 unsigned long ixp4xx_timer_freq = FREQ;
arch/arm/mach-netx/time.c +1 -0
Index: linux-2.6.19/arch/arm/mach-netx/time.c
===================================================================
@@ -63,6 +63,7 @@ static struct clocksource clocksource_ne
 	.mask		= CLOCKSOURCE_MASK(32),
 	.shift 		= 20,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_netx.list),
 };
 
 /*
arch/arm/mach-pxa/time.c +1 -0
Index: linux-2.6.19/arch/arm/mach-pxa/time.c
===================================================================
@@ -113,6 +113,7 @@ static struct clocksource clocksource_px
 	.mask           = CLOCKSOURCE_MASK(32),
 	.shift          = 20,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_pxa.list),
 };
 
 static void __init pxa_timer_init(void)
#1 lore raw

PATCH 2/9 clocksource: parisc initialize list value

Update arch/parisc/ with list initialization.

---
 arch/parisc/kernel/time.c |    1 +
 1 file changed, 1 insertion(+)
arch/parisc/kernel/time.c +1 -0
Index: linux-2.6.20/arch/parisc/kernel/time.c
===================================================================
@@ -184,6 +184,7 @@ static struct clocksource clocksource_cr
 	.mult			= 0, /* to be set */
 	.shift			= 22,
 	.flags			= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list			= LIST_HEAD_INIT(clocksource_cr16.list),
 };
 
 #ifdef CONFIG_SMP
#2 lore raw

PATCH 3/9 clocksource: avr32 initialize list value

In reply to Daniel Walker

Update arch/avre32/ with list initialization.

---
 arch/avr32/kernel/time.c         |    1 +
 arch/avr32/mach-at32ap/time-tc.c |    1 +
 2 files changed, 2 insertions(+)
arch/avr32/kernel/time.c +1 -0
Index: linux-2.6.20/arch/avr32/kernel/time.c
===================================================================
@@ -45,6 +45,7 @@ struct clocksource __weak clocksource_av
 	.mask		= CLOCKSOURCE_MASK(32),
 	.shift		= 16,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_avr32.list),
 };
 
 irqreturn_t __weak timer_interrupt(int irq, void *dev_id);
arch/avr32/mach-at32ap/time-tc.c +1 -0
Index: linux-2.6.20/arch/avr32/mach-at32ap/time-tc.c
===================================================================
@@ -50,6 +50,7 @@ struct clocksource clocksource_avr32 = {
 	.mask		= CLOCKSOURCE_MASK(16),
 	.shift		= 16,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_avr32.list),
 };
 
 static void avr32_timer_ack(void)
#3 lore raw

PATCH 4/9 clocksource: mips initialize list value

In reply to Daniel Walker

Update arch/mips/ with list initialization.

---
 arch/mips/kernel/time.c |    1 +
 1 file changed, 1 insertion(+)
arch/mips/kernel/time.c +1 -0
Index: linux-2.6.19/arch/mips/kernel/time.c
===================================================================
@@ -308,6 +308,7 @@ struct clocksource clocksource_mips = {
 	.name		= "MIPS",
 	.mask		= 0xffffffff,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_mips.list),
 };
 
 static void __init init_mips_clocksource(void)
#4 lore raw

PATCH 5/9 clocksource: i386 initialize list value

In reply to Daniel Walker

Update arch/i386/ with list initialization.

---
 arch/i386/kernel/hpet.c    |    1 +
 arch/i386/kernel/i8253.c   |    1 +
 arch/i386/kernel/tsc.c     |    1 +
 arch/i386/kernel/vmitime.c |    1 +
 4 files changed, 4 insertions(+)
arch/i386/kernel/hpet.c +1 -0
Index: linux-2.6.20/arch/i386/kernel/hpet.c
===================================================================
@@ -215,6 +215,7 @@ static struct clocksource clocksource_hp
 	.mask		= HPET_MASK,
 	.shift		= HPET_SHIFT,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_hpet.list),
 };
 
 /*
arch/i386/kernel/i8253.c +1 -0
Index: linux-2.6.20/arch/i386/kernel/i8253.c
===================================================================
@@ -193,6 +193,7 @@ static struct clocksource clocksource_pi
 	.mask	= CLOCKSOURCE_MASK(32),
 	.mult	= 0,
 	.shift	= 20,
+	.list	= LIST_HEAD_INIT(clocksource_pit.list),
 };
 
 static int __init init_pit_clocksource(void)
arch/i386/kernel/tsc.c +1 -0
Index: linux-2.6.20/arch/i386/kernel/tsc.c
===================================================================
@@ -279,6 +279,7 @@ static struct clocksource clocksource_ts
 	.shift			= 22,
 	.flags			= CLOCK_SOURCE_IS_CONTINUOUS |
 				  CLOCK_SOURCE_MUST_VERIFY,
+	.list			= LIST_HEAD_INIT(clocksource_tsc.list),
 };
 
 void mark_tsc_unstable(char *reason)
arch/i386/kernel/vmitime.c +1 -0
Index: linux-2.6.20/arch/i386/kernel/vmitime.c
===================================================================
@@ -116,6 +116,7 @@ static struct clocksource clocksource_vm
 	.mult			= 0, /* to be set */
 	.shift			= 22,
 	.flags			= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list			= LIST_HEAD_INIT(clocksource_vmi.list),
 };
 
 
#5 lore raw

PATCH 6/9 clocksource: x86_64 initialize list value

In reply to Daniel Walker

Update arch/x86_64/ with list initialization.

---
 arch/x86_64/kernel/hpet.c |    1 +
 arch/x86_64/kernel/tsc.c  |    1 +
 2 files changed, 2 insertions(+)
arch/x86_64/kernel/hpet.c +1 -0
Index: linux-2.6.20/arch/x86_64/kernel/hpet.c
===================================================================
@@ -131,6 +131,7 @@ struct clocksource clocksource_hpet = {
 	.shift		= HPET_SHIFT,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 	.vread		= vread_hpet,
+	.list		= LIST_HEAD_INIT(clocksource_hpet.list),
 };
 
 int hpet_arch_init(void)
arch/x86_64/kernel/tsc.c +1 -0
Index: linux-2.6.20/arch/x86_64/kernel/tsc.c
===================================================================
@@ -195,6 +195,7 @@ static struct clocksource clocksource_ts
 	.flags			= CLOCK_SOURCE_IS_CONTINUOUS |
 				  CLOCK_SOURCE_MUST_VERIFY,
 	.vread			= vread_tsc,
+	.list			= LIST_HEAD_INIT(clocksource_tsc.list),
 };
 
 void mark_tsc_unstable(char *reason)
#6 lore raw

PATCH 7/9 clocksource: driver initialize list value

In reply to Daniel Walker

Update drivers/clocksource/ with list initialization.

---
 drivers/clocksource/acpi_pm.c    |    1 +
 drivers/clocksource/cyclone.c    |    1 +
 drivers/clocksource/scx200_hrt.c |    1 +
 3 files changed, 3 insertions(+)
drivers/clocksource/acpi_pm.c +1 -0
Index: linux-2.6.19/drivers/clocksource/acpi_pm.c
===================================================================
@@ -74,6 +74,7 @@ static struct clocksource clocksource_ac
 	.mult		= 0, /*to be caluclated*/
 	.shift		= 22,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_acpi_pm.list),
 
 };
 
drivers/clocksource/cyclone.c +1 -0
Index: linux-2.6.19/drivers/clocksource/cyclone.c
===================================================================
@@ -32,6 +32,7 @@ static struct clocksource clocksource_cy
 	.mult		= 10,
 	.shift		= 0,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_cyclone.list),
 };
 
 static int __init init_cyclone_clocksource(void)
drivers/clocksource/scx200_hrt.c +1 -0
Index: linux-2.6.19/drivers/clocksource/scx200_hrt.c
===================================================================
@@ -58,6 +58,7 @@ static struct clocksource cs_hrt = {
 	.read		= read_hrt,
 	.mask		= CLOCKSOURCE_MASK(32),
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(cs_hrt.list),
 	/* mult, shift are set based on mhz27 flag */
 };
 
#7 lore raw

PATCH 8/9 clocksource: s390 initialize list value

In reply to Daniel Walker

Update arch/s390 with list initialization.

---
 arch/s390/kernel/time.c |    1 +
 1 file changed, 1 insertion(+)
arch/s390/kernel/time.c +1 -0
Index: linux-2.6.20/arch/s390/kernel/time.c
===================================================================
@@ -314,6 +314,7 @@ static struct clocksource clocksource_to
 	.mult		= 1000,
 	.shift		= 12,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_tod.list),
 };
 
 
#8 lore raw

Re: [PATCH 8/9] clocksource: s390 initialize list value

Quoted 13 lines · Daniel Walker

Update arch/s390 with list initialization.

---
 arch/s390/kernel/time.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.20/arch/s390/kernel/time.c
===================================================================

arch/s390/kernel/time.c static struct clocksource clocksource_to · line 318

Quoted 5 lines
arch/s390/kernel/time.c +1 -0
@@ -314,6 +314,7 @@ static struct clocksource clocksource_to
 	.mult		= 1000,
 	.shift		= 12,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_tod.list),
 };

Why? This doesn't fix anything...

#9 lore raw

Re: [PATCH 8/9] clocksource: s390 initialize list value

Quoted 9 lines · Heiko Carstens
Quoted 8 lines · Daniel Walker

Update arch/s390 with list initialization.

---
 arch/s390/kernel/time.c |    1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

arch/s390/kernel/time.c static struct clocksource clocksource_to · line 318

Quoted 10 lines

Index: linux-2.6.20/arch/s390/kernel/time.c
===================================================================

arch/s390/kernel/time.c +1 -0
@@ -314,6 +314,7 @@ static struct clocksource clocksource_to
 	.mult		= 1000,
 	.shift		= 12,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.list		= LIST_HEAD_INIT(clocksource_tod.list),
 };

Why? This doesn't fix anything...

It's needed for patch 9/9 in the series.

Daniel

#10 lore raw

Re: [PATCH 8/9] clocksource: s390 initialize list value

Quoted 5 lines · Daniel Walker
Quoted 4 lines · Heiko Carstens
Quoted 3 lines · Daniel Walker

Update arch/s390 with list initialization.

[...]

Quoted 3 lines
Quoted 1 line

Why? This doesn't fix anything...

It's needed for patch 9/9 in the series.

Then maybe your patch description should reflect that? If this gets merged as a seperate patch and somebody checks the git history of arch/s390 and sees this patch... how could he know what this is good for?
Does it fix a bug? Needed by any feature? Or...?

#11 lore raw

PATCH 9/9 clocksource: refactor duplicate registration checking

In reply to Daniel Walker

Refactors the duplicate registration checking. This makes it based on the clocksource structure list state. I was able to drop some if statements making the registration code path slightly smaller and faster, and remove some looping which was endemic of the first version of this check.

---
 include/linux/clocksource.h |    2 +-
 kernel/time/clocksource.c   |   30 ++++++++++++++++++------------
 kernel/time/jiffies.c       |    1 +
 3 files changed, 20 insertions(+), 13 deletions(-)
include/linux/clocksource.h +1 -1
Index: linux-2.6.20/include/linux/clocksource.h
===================================================================
@@ -26,7 +26,7 @@ struct clocksource;
  *	Provides mostly state-free accessors to the underlying hardware.
  *
  * @name:		ptr to clocksource name
- * @list:		list head for registration
+ * @list:		list head for registration, must be initialized.
  * @rating:		rating value for selection (higher is better)
  *			To avoid rating inflation the following
  *			list should give you a guide as to how
kernel/time/clocksource.c +18 -12
Index: linux-2.6.20/kernel/time/clocksource.c
===================================================================
@@ -232,7 +232,7 @@ static struct clocksource *select_clocks
 /*
  * Enqueue the clocksource sorted by rating
  */
-static int clocksource_enqueue(struct clocksource *c)
+static void clocksource_enqueue(struct clocksource *c)
 {
 	struct list_head *tmp, *entry = &clocksource_list;
 
@@ -240,8 +240,7 @@ static int clocksource_enqueue(struct cl
 		struct clocksource *cs;
 
 		cs = list_entry(tmp, struct clocksource, list);
-		if (cs == c)
-			return -EBUSY;
+
 		/* Keep track of the place, where to insert */
 		if (cs->rating >= c->rating)
 			entry = tmp;
@@ -252,28 +251,35 @@ static int clocksource_enqueue(struct cl
 	    !strcmp(c->name, override_name))
 		clocksource_override = c;
 
-	return 0;
 }
 
 /**
  * clocksource_register - Used to install new clocksources
  * @t:		clocksource to be registered
  *
- * Returns -EBUSY if registration fails, zero otherwise.
+ * Always returns zero.
  */
 int clocksource_register(struct clocksource *c)
 {
 	unsigned long flags;
-	int ret;
+
+	/*
+	 * This BUGON indicates that either the clocksource has been
+	 * registered already, or the list element hasn't been properly
+	 * initialized.
+	 */
+	BUG_ON(!list_empty(&c->list));
 
 	spin_lock_irqsave(&clocksource_lock, flags);
-	ret = clocksource_enqueue(c);
-	if (!ret)
-		next_clocksource = select_clocksource();
+
+	clocksource_enqueue(c);
+	next_clocksource = select_clocksource();
+
 	spin_unlock_irqrestore(&clocksource_lock, flags);
-	if (!ret)
-		clocksource_check_watchdog(c);
-	return ret;
+
+	clocksource_check_watchdog(c);
+
+	return 0;
 }
 EXPORT_SYMBOL(clocksource_register);
 
kernel/time/jiffies.c +1 -0
Index: linux-2.6.20/kernel/time/jiffies.c
===================================================================
@@ -62,6 +62,7 @@ struct clocksource clocksource_jiffies =
 	.mask		= 0xffffffff, /*32bits*/
 	.mult		= NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
 	.shift		= JIFFIES_SHIFT,
+	.list		= LIST_HEAD_INIT(clocksource_jiffies.list),
 };
 
 static int __init init_jiffies_clocksource(void)
#12 lore raw

Re: [PATCH 9/9] clocksource: refactor duplicate registration checking

Quoted 8 lines · Daniel Walker

/**
* clocksource_register - Used to install new clocksources
* @t: clocksource to be registered
*
- * Returns -EBUSY if registration fails, zero otherwise.
+ * Always returns zero.
*/
int clocksource_register(struct clocksource *c)

Return should be void, then.

- James

Signature · 2 lines
James Morris
<[email protected]>
#13 lore raw

Re: [PATCH 9/9] clocksource: refactor duplicate registration checking

Quoted 11 lines · James Morris
Quoted 8 lines · Daniel Walker

/**
* clocksource_register - Used to install new clocksources
* @t: clocksource to be registered
*
- * Returns -EBUSY if registration fails, zero otherwise.
+ * Always returns zero.
*/
int clocksource_register(struct clocksource *c)

Quoted 1 line

Return should be void, then.

Yeah, that's another patch tho ..

Daniel