Skip to contentSkip to conversation

clocksource: mips-gic-timer: fix clocksource counter width

PATCH Superseded Felix Fietkau 2 participants 4 messages Feb 21, 2018 – Feb 28, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: mips-gic-timer: fix clocksource counter width

This code needs to use ffs instead of fls on the mask to determine the shift for reading the GIC_CONFIG_COUNTBITS field.

Fixes e07127a077c7 ("clocksource: mips-gic-timer: Use new GIC accessor functions")
Cc Paul Burton <[email protected]>
---
 drivers/clocksource/mips-gic-timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +1 -1
index a04808a21d4e..bf0eee78c6ef 100644
@@ -166,7 +166,7 @@ static int __init __gic_clocksource_init(void)
 
 	/* Set clocksource mask. */
 	count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
-	count_width >>= __fls(GIC_CONFIG_COUNTBITS);
+	count_width >>= __ffs(GIC_CONFIG_COUNTBITS);
 	count_width *= 4;
 	count_width += 32;
 	gic_clocksource.mask = CLOCKSOURCE_MASK(count_width);
Signature · 1 line
2.14.2
#1 lore raw
Quoted 2 lines · Felix Fietkau

This code needs to use ffs instead of fls on the mask to determine the shift for reading the GIC_CONFIG_COUNTBITS field.

Why?

Thanks,

tglx

Quoted 25 lines
Fixes e07127a077c7 ("clocksource: mips-gic-timer: Use new GIC accessor functions")
Cc Paul Burton <[email protected]>
---
 drivers/clocksource/mips-gic-timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +1 -1
index a04808a21d4e..bf0eee78c6ef 100644
@@ -166,7 +166,7 @@ static int __init __gic_clocksource_init(void)
 
 	/* Set clocksource mask. */
 	count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
-	count_width >>= __fls(GIC_CONFIG_COUNTBITS);
+	count_width >>= __ffs(GIC_CONFIG_COUNTBITS);
 	count_width *= 4;
 	count_width += 32;
 	gic_clocksource.mask = CLOCKSOURCE_MASK(count_width);
Signature · 1 line
2.14.2
#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 2 lines · Felix Fietkau

This code needs to use ffs instead of fls on the mask to determine the shift for reading the GIC_CONFIG_COUNTBITS field.

Why?

drivers/clocksource/mips-gic-timer.c static int __init __gic_clocksource_init(void) · line 169

Quoted 3 lines
drivers/clocksource/mips-gic-timer.c +1 -1
 	count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
-	count_width >>= __fls(GIC_CONFIG_COUNTBITS);
+	count_width >>= __ffs(GIC_CONFIG_COUNTBITS);

This code is trying to extract the GIC_CONFIG_COUNTBITS field from read_gic_config(), so it needs to shift count_width right by the index of the least significant bit (__ffs) instead of the most significant bit (__fls) of the field mask.

- Felix

#3 lore raw
Quoted 6 lines · Felix Fietkau
Quoted 5 lines · Thomas Gleixner
Quoted 2 lines · Felix Fietkau

This code needs to use ffs instead of fls on the mask to determine the shift for reading the GIC_CONFIG_COUNTBITS field.

Quoted 8 lines
Quoted 4 lines

Why?

drivers/clocksource/mips-gic-timer.c static int __init __gic_clocksource_init(void) · line 169

Quoted 3 lines
drivers/clocksource/mips-gic-timer.c +1 -1
 	count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
-	count_width >>= __fls(GIC_CONFIG_COUNTBITS);
+	count_width >>= __ffs(GIC_CONFIG_COUNTBITS);

This code is trying to extract the GIC_CONFIG_COUNTBITS field from read_gic_config(), so it needs to shift count_width right by the index of the least significant bit (__ffs) instead of the most significant bit (__fls) of the field mask.

Sure, but that information wants to be in the changelog.

Thanks,

tglx