clocksource: mips-gic-timer: fix clocksource counter width
Subsystems (2)
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.
--- drivers/clocksource/mips-gic-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +1 -1
@@ -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
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_COUNTBITSfield.
Why?
Thanks,
tglx
Quoted 25 lines
Fixes e07127a077c7 ("clocksource: mips-gic-timer: Use new GIC accessor functions")Cc Paul Burton <[email protected]>Signed-off-by Felix Fietkau <[email protected]>--- drivers/clocksource/mips-gic-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clocksource/mips-gic-timer.c +1
-1@@ -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
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_COUNTBITSfield.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
-1count_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
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_COUNTBITSfield.
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
-1count_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_COUNTBITSfield fromread_gic_config(), so it needs to shiftcount_widthright 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