Commit 5e4bfd66 authored by Jiaxun Yang's avatar Jiaxun Yang Committed by Daniel Lezcano

clocksource/drivers/mips-gic-timer: Correct sched_clock width

Counter width of GIC is configurable and can be read from a
register.

Use width value from the register for sched_clock.
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Link: https://lore.kernel.org/r/20240612-mips-clks-v2-7-a57e6f49f3db@flygoat.comSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent cc9b2c59
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
static DEFINE_PER_CPU(struct clock_event_device, gic_clockevent_device); static DEFINE_PER_CPU(struct clock_event_device, gic_clockevent_device);
static int gic_timer_irq; static int gic_timer_irq;
static unsigned int gic_frequency; static unsigned int gic_frequency;
static unsigned int gic_count_width;
static bool __read_mostly gic_clock_unstable; static bool __read_mostly gic_clock_unstable;
static void gic_clocksource_unstable(char *reason); static void gic_clocksource_unstable(char *reason);
...@@ -186,15 +187,14 @@ static void gic_clocksource_unstable(char *reason) ...@@ -186,15 +187,14 @@ static void gic_clocksource_unstable(char *reason)
static int __init __gic_clocksource_init(void) static int __init __gic_clocksource_init(void)
{ {
unsigned int count_width;
int ret; int ret;
/* Set clocksource mask. */ /* Set clocksource mask. */
count_width = read_gic_config() & GIC_CONFIG_COUNTBITS; gic_count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
count_width >>= __ffs(GIC_CONFIG_COUNTBITS); gic_count_width >>= __ffs(GIC_CONFIG_COUNTBITS);
count_width *= 4; gic_count_width *= 4;
count_width += 32; gic_count_width += 32;
gic_clocksource.mask = CLOCKSOURCE_MASK(count_width); gic_clocksource.mask = CLOCKSOURCE_MASK(gic_count_width);
/* Calculate a somewhat reasonable rating value. */ /* Calculate a somewhat reasonable rating value. */
if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ))
...@@ -264,7 +264,7 @@ static int __init gic_clocksource_of_init(struct device_node *node) ...@@ -264,7 +264,7 @@ static int __init gic_clocksource_of_init(struct device_node *node)
if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) { if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) {
sched_clock_register(mips_cm_is64 ? sched_clock_register(mips_cm_is64 ?
gic_read_count_64 : gic_read_count_2x32, gic_read_count_64 : gic_read_count_2x32,
64, gic_frequency); gic_count_width, gic_frequency);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment