All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
@ 2022-12-11 21:58 Prabhakar
  2022-12-23  4:10   ` Lad, Prabhakar
  2022-12-27 23:17   ` Samuel Holland
  0 siblings, 2 replies; 7+ messages in thread
From: Prabhakar @ 2022-12-11 21:58 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Geert Uytterhoeven, Conor Dooley,
	Heiko Stuebner
  Cc: linux-riscv, Anup Patel, linux-renesas-soc, linux-kernel,
	Prabhakar, Biju Das, Lad Prabhakar

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Having a clocksource_arch_init() callback always sets vdso_clock_mode to
VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
required for the riscv-timer.

This works for platforms where just riscv-timer clocksource is present.
On platforms where other clock sources are available we want them to
register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.

On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
move setting of vdso_clock_mode in the riscv-timer driver instead of doing
this in clocksource_arch_init() callback as done similarly for ARM/64
architecture.

[0] drivers/clocksource/renesas-ostm.c

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 arch/riscv/Kconfig                | 1 -
 arch/riscv/kernel/time.c          | 9 ---------
 drivers/clocksource/timer-riscv.c | 7 +++++++
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 7ea12de636bd..b269e062c1b1 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -12,7 +12,6 @@ config 32BIT
 
 config RISCV
 	def_bool y
-	select ARCH_CLOCKSOURCE_INIT
 	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
 	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
 	select ARCH_HAS_BINFMT_FLAT
diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
index 8217b0f67c6c..42bee305e997 100644
--- a/arch/riscv/kernel/time.c
+++ b/arch/riscv/kernel/time.c
@@ -30,12 +30,3 @@ void __init time_init(void)
 	of_clk_init(NULL);
 	timer_probe();
 }
-
-void clocksource_arch_init(struct clocksource *cs)
-{
-#ifdef CONFIG_GENERIC_GETTIMEOFDAY
-	cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
-#else
-	cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
-#endif
-}
diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index 969a552da8d2..7ec9668cd36d 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -29,6 +29,12 @@
 
 static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
 
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
+static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER;
+#else
+static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE;
+#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
+
 static int riscv_clock_next_event(unsigned long delta,
 		struct clock_event_device *ce)
 {
@@ -158,6 +164,7 @@ static int __init riscv_timer_init_dt(struct device_node *n)
 		return -ENODEV;
 	}
 
+	riscv_clocksource.vdso_clock_mode = vdso_default;
 	pr_info("%s: Registering clocksource cpuid [%d] hartid [%lu]\n",
 	       __func__, cpuid, hartid);
 	error = clocksource_register_hz(&riscv_clocksource, riscv_timebase);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
  2022-12-11 21:58 [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback Prabhakar
@ 2022-12-23  4:10   ` Lad, Prabhakar
  2022-12-27 23:17   ` Samuel Holland
  1 sibling, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2022-12-23  4:10 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Geert Uytterhoeven, Conor Dooley,
	Heiko Stuebner
  Cc: linux-riscv, Anup Patel, linux-renesas-soc, linux-kernel,
	Biju Das, Lad Prabhakar

On Sun, Dec 11, 2022 at 9:59 PM Prabhakar <prabhakar.csengg@gmail.com> wrote:
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> required for the riscv-timer.
>
> This works for platforms where just riscv-timer clocksource is present.
> On platforms where other clock sources are available we want them to
> register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
>
> On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> this in clocksource_arch_init() callback as done similarly for ARM/64
> architecture.
>
> [0] drivers/clocksource/renesas-ostm.c
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  arch/riscv/Kconfig                | 1 -
>  arch/riscv/kernel/time.c          | 9 ---------
>  drivers/clocksource/timer-riscv.c | 7 +++++++
>  3 files changed, 7 insertions(+), 10 deletions(-)
>
Gentle ping for review.

Cheers,
Prabhakar

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
@ 2022-12-23  4:10   ` Lad, Prabhakar
  0 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2022-12-23  4:10 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Geert Uytterhoeven, Conor Dooley,
	Heiko Stuebner
  Cc: linux-riscv, Anup Patel, linux-renesas-soc, linux-kernel,
	Biju Das, Lad Prabhakar

On Sun, Dec 11, 2022 at 9:59 PM Prabhakar <prabhakar.csengg@gmail.com> wrote:
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> required for the riscv-timer.
>
> This works for platforms where just riscv-timer clocksource is present.
> On platforms where other clock sources are available we want them to
> register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
>
> On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> this in clocksource_arch_init() callback as done similarly for ARM/64
> architecture.
>
> [0] drivers/clocksource/renesas-ostm.c
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  arch/riscv/Kconfig                | 1 -
>  arch/riscv/kernel/time.c          | 9 ---------
>  drivers/clocksource/timer-riscv.c | 7 +++++++
>  3 files changed, 7 insertions(+), 10 deletions(-)
>
Gentle ping for review.

Cheers,
Prabhakar

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
  2022-12-11 21:58 [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback Prabhakar
@ 2022-12-27 23:17   ` Samuel Holland
  2022-12-27 23:17   ` Samuel Holland
  1 sibling, 0 replies; 7+ messages in thread
From: Samuel Holland @ 2022-12-27 23:17 UTC (permalink / raw)
  To: Prabhakar, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Daniel Lezcano, Thomas Gleixner, Geert Uytterhoeven,
	Conor Dooley, Heiko Stuebner
  Cc: linux-riscv, Anup Patel, linux-renesas-soc, linux-kernel,
	Biju Das, Lad Prabhakar

On 12/11/22 15:58, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> required for the riscv-timer.
> 
> This works for platforms where just riscv-timer clocksource is present.
> On platforms where other clock sources are available we want them to
> register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
> 
> On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> this in clocksource_arch_init() callback as done similarly for ARM/64
> architecture.

This is definitely a good change to make, but shouldn't we still prefer
the architectural CSR-based clocksource over an MMIO-based clocksource?
It has double the number of bits, and reading it should have less
overhead. So I think we also want to increase the rating of
riscv_clocksource.

D1 is in the same situation, as timer-sun4i.c registers a clocksource
with a higher rating than riscv_clocksource. Without this patch,
tools/testing/selftests/vDSO/vdso_test_correctness fails. With this
patch, it passes, so:

Tested-by: Samuel Holland <samuel@sholland.org>

> [0] drivers/clocksource/renesas-ostm.c
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  arch/riscv/Kconfig                | 1 -
>  arch/riscv/kernel/time.c          | 9 ---------
>  drivers/clocksource/timer-riscv.c | 7 +++++++
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 7ea12de636bd..b269e062c1b1 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -12,7 +12,6 @@ config 32BIT
>  
>  config RISCV
>  	def_bool y
> -	select ARCH_CLOCKSOURCE_INIT
>  	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
>  	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
>  	select ARCH_HAS_BINFMT_FLAT
> diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
> index 8217b0f67c6c..42bee305e997 100644
> --- a/arch/riscv/kernel/time.c
> +++ b/arch/riscv/kernel/time.c
> @@ -30,12 +30,3 @@ void __init time_init(void)
>  	of_clk_init(NULL);
>  	timer_probe();
>  }
> -
> -void clocksource_arch_init(struct clocksource *cs)
> -{
> -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> -	cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
> -#else
> -	cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
> -#endif
> -}
> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> index 969a552da8d2..7ec9668cd36d 100644
> --- a/drivers/clocksource/timer-riscv.c
> +++ b/drivers/clocksource/timer-riscv.c
> @@ -29,6 +29,12 @@
>  
>  static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
>  
> +#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER;
> +#else
> +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE;
> +#endif /* CONFIG_GENERIC_GETTIMEOFDAY */

We don't have any workarounds like arm_arch_timer, so we do not need
this indirection through vdso_default. You can set .vdso_clock_mode
directly in the declaration of riscv_clocksource.

Regards,
Samuel

> +
>  static int riscv_clock_next_event(unsigned long delta,
>  		struct clock_event_device *ce)
>  {
> @@ -158,6 +164,7 @@ static int __init riscv_timer_init_dt(struct device_node *n)
>  		return -ENODEV;
>  	}
>  
> +	riscv_clocksource.vdso_clock_mode = vdso_default;
>  	pr_info("%s: Registering clocksource cpuid [%d] hartid [%lu]\n",
>  	       __func__, cpuid, hartid);
>  	error = clocksource_register_hz(&riscv_clocksource, riscv_timebase);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
@ 2022-12-27 23:17   ` Samuel Holland
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Holland @ 2022-12-27 23:17 UTC (permalink / raw)
  To: Prabhakar, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Daniel Lezcano, Thomas Gleixner, Geert Uytterhoeven,
	Conor Dooley, Heiko Stuebner
  Cc: linux-riscv, Anup Patel, linux-renesas-soc, linux-kernel,
	Biju Das, Lad Prabhakar

On 12/11/22 15:58, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> required for the riscv-timer.
> 
> This works for platforms where just riscv-timer clocksource is present.
> On platforms where other clock sources are available we want them to
> register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
> 
> On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> this in clocksource_arch_init() callback as done similarly for ARM/64
> architecture.

This is definitely a good change to make, but shouldn't we still prefer
the architectural CSR-based clocksource over an MMIO-based clocksource?
It has double the number of bits, and reading it should have less
overhead. So I think we also want to increase the rating of
riscv_clocksource.

D1 is in the same situation, as timer-sun4i.c registers a clocksource
with a higher rating than riscv_clocksource. Without this patch,
tools/testing/selftests/vDSO/vdso_test_correctness fails. With this
patch, it passes, so:

Tested-by: Samuel Holland <samuel@sholland.org>

> [0] drivers/clocksource/renesas-ostm.c
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  arch/riscv/Kconfig                | 1 -
>  arch/riscv/kernel/time.c          | 9 ---------
>  drivers/clocksource/timer-riscv.c | 7 +++++++
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 7ea12de636bd..b269e062c1b1 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -12,7 +12,6 @@ config 32BIT
>  
>  config RISCV
>  	def_bool y
> -	select ARCH_CLOCKSOURCE_INIT
>  	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
>  	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
>  	select ARCH_HAS_BINFMT_FLAT
> diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
> index 8217b0f67c6c..42bee305e997 100644
> --- a/arch/riscv/kernel/time.c
> +++ b/arch/riscv/kernel/time.c
> @@ -30,12 +30,3 @@ void __init time_init(void)
>  	of_clk_init(NULL);
>  	timer_probe();
>  }
> -
> -void clocksource_arch_init(struct clocksource *cs)
> -{
> -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> -	cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
> -#else
> -	cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
> -#endif
> -}
> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> index 969a552da8d2..7ec9668cd36d 100644
> --- a/drivers/clocksource/timer-riscv.c
> +++ b/drivers/clocksource/timer-riscv.c
> @@ -29,6 +29,12 @@
>  
>  static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
>  
> +#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER;
> +#else
> +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE;
> +#endif /* CONFIG_GENERIC_GETTIMEOFDAY */

We don't have any workarounds like arm_arch_timer, so we do not need
this indirection through vdso_default. You can set .vdso_clock_mode
directly in the declaration of riscv_clocksource.

Regards,
Samuel

> +
>  static int riscv_clock_next_event(unsigned long delta,
>  		struct clock_event_device *ce)
>  {
> @@ -158,6 +164,7 @@ static int __init riscv_timer_init_dt(struct device_node *n)
>  		return -ENODEV;
>  	}
>  
> +	riscv_clocksource.vdso_clock_mode = vdso_default;
>  	pr_info("%s: Registering clocksource cpuid [%d] hartid [%lu]\n",
>  	       __func__, cpuid, hartid);
>  	error = clocksource_register_hz(&riscv_clocksource, riscv_timebase);


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
  2022-12-27 23:17   ` Samuel Holland
@ 2022-12-28 23:44     ` Lad, Prabhakar
  -1 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2022-12-28 23:44 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Geert Uytterhoeven, Conor Dooley,
	Heiko Stuebner, linux-riscv, Anup Patel, linux-renesas-soc,
	linux-kernel, Biju Das, Lad Prabhakar

Hi Samuel,

Thank you for the review.

On Tue, Dec 27, 2022 at 11:17 PM Samuel Holland <samuel@sholland.org> wrote:
>
> On 12/11/22 15:58, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> > VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> > required for the riscv-timer.
> >
> > This works for platforms where just riscv-timer clocksource is present.
> > On platforms where other clock sources are available we want them to
> > register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
> >
> > On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> > avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> > move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> > this in clocksource_arch_init() callback as done similarly for ARM/64
> > architecture.
>
> This is definitely a good change to make, but shouldn't we still prefer
> the architectural CSR-based clocksource over an MMIO-based clocksource?
> It has double the number of bits, and reading it should have less
> overhead. So I think we also want to increase the rating of
> riscv_clocksource.
>
For which now you have already have a patch posted.

> D1 is in the same situation, as timer-sun4i.c registers a clocksource
> with a higher rating than riscv_clocksource. Without this patch,
> tools/testing/selftests/vDSO/vdso_test_correctness fails. With this
> patch, it passes, so:
>
> Tested-by: Samuel Holland <samuel@sholland.org>
>
> > [0] drivers/clocksource/renesas-ostm.c
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >  arch/riscv/Kconfig                | 1 -
> >  arch/riscv/kernel/time.c          | 9 ---------
> >  drivers/clocksource/timer-riscv.c | 7 +++++++
> >  3 files changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 7ea12de636bd..b269e062c1b1 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -12,7 +12,6 @@ config 32BIT
> >
> >  config RISCV
> >       def_bool y
> > -     select ARCH_CLOCKSOURCE_INIT
> >       select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
> >       select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
> >       select ARCH_HAS_BINFMT_FLAT
> > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
> > index 8217b0f67c6c..42bee305e997 100644
> > --- a/arch/riscv/kernel/time.c
> > +++ b/arch/riscv/kernel/time.c
> > @@ -30,12 +30,3 @@ void __init time_init(void)
> >       of_clk_init(NULL);
> >       timer_probe();
> >  }
> > -
> > -void clocksource_arch_init(struct clocksource *cs)
> > -{
> > -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> > -     cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
> > -#else
> > -     cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
> > -#endif
> > -}
> > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> > index 969a552da8d2..7ec9668cd36d 100644
> > --- a/drivers/clocksource/timer-riscv.c
> > +++ b/drivers/clocksource/timer-riscv.c
> > @@ -29,6 +29,12 @@
> >
> >  static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
> >
> > +#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> > +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER;
> > +#else
> > +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE;
> > +#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
>
> We don't have any workarounds like arm_arch_timer, so we do not need
> this indirection through vdso_default. You can set .vdso_clock_mode
> directly in the declaration of riscv_clocksource.
>
Agreed, I'll do that in v2.

Cheers,
Prabhakar

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback
@ 2022-12-28 23:44     ` Lad, Prabhakar
  0 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2022-12-28 23:44 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Daniel Lezcano,
	Thomas Gleixner, Geert Uytterhoeven, Conor Dooley,
	Heiko Stuebner, linux-riscv, Anup Patel, linux-renesas-soc,
	linux-kernel, Biju Das, Lad Prabhakar

Hi Samuel,

Thank you for the review.

On Tue, Dec 27, 2022 at 11:17 PM Samuel Holland <samuel@sholland.org> wrote:
>
> On 12/11/22 15:58, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Having a clocksource_arch_init() callback always sets vdso_clock_mode to
> > VDSO_CLOCKMODE_ARCHTIMER if GENERIC_GETTIMEOFDAY is enabled, this is
> > required for the riscv-timer.
> >
> > This works for platforms where just riscv-timer clocksource is present.
> > On platforms where other clock sources are available we want them to
> > register with vdso_clock_mode set to VDSO_CLOCKMODE_NONE.
> >
> > On the Renesas RZ/Five SoC OSTM block can be used as clocksource [0], to
> > avoid multiple clock sources being registered as VDSO_CLOCKMODE_ARCHTIMER
> > move setting of vdso_clock_mode in the riscv-timer driver instead of doing
> > this in clocksource_arch_init() callback as done similarly for ARM/64
> > architecture.
>
> This is definitely a good change to make, but shouldn't we still prefer
> the architectural CSR-based clocksource over an MMIO-based clocksource?
> It has double the number of bits, and reading it should have less
> overhead. So I think we also want to increase the rating of
> riscv_clocksource.
>
For which now you have already have a patch posted.

> D1 is in the same situation, as timer-sun4i.c registers a clocksource
> with a higher rating than riscv_clocksource. Without this patch,
> tools/testing/selftests/vDSO/vdso_test_correctness fails. With this
> patch, it passes, so:
>
> Tested-by: Samuel Holland <samuel@sholland.org>
>
> > [0] drivers/clocksource/renesas-ostm.c
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >  arch/riscv/Kconfig                | 1 -
> >  arch/riscv/kernel/time.c          | 9 ---------
> >  drivers/clocksource/timer-riscv.c | 7 +++++++
> >  3 files changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 7ea12de636bd..b269e062c1b1 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -12,7 +12,6 @@ config 32BIT
> >
> >  config RISCV
> >       def_bool y
> > -     select ARCH_CLOCKSOURCE_INIT
> >       select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
> >       select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
> >       select ARCH_HAS_BINFMT_FLAT
> > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
> > index 8217b0f67c6c..42bee305e997 100644
> > --- a/arch/riscv/kernel/time.c
> > +++ b/arch/riscv/kernel/time.c
> > @@ -30,12 +30,3 @@ void __init time_init(void)
> >       of_clk_init(NULL);
> >       timer_probe();
> >  }
> > -
> > -void clocksource_arch_init(struct clocksource *cs)
> > -{
> > -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> > -     cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
> > -#else
> > -     cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
> > -#endif
> > -}
> > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> > index 969a552da8d2..7ec9668cd36d 100644
> > --- a/drivers/clocksource/timer-riscv.c
> > +++ b/drivers/clocksource/timer-riscv.c
> > @@ -29,6 +29,12 @@
> >
> >  static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available);
> >
> > +#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> > +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER;
> > +#else
> > +static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_NONE;
> > +#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
>
> We don't have any workarounds like arm_arch_timer, so we do not need
> this indirection through vdso_default. You can set .vdso_clock_mode
> directly in the declaration of riscv_clocksource.
>
Agreed, I'll do that in v2.

Cheers,
Prabhakar

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-28 23:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-11 21:58 [RFC PATCH] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback Prabhakar
2022-12-23  4:10 ` Lad, Prabhakar
2022-12-23  4:10   ` Lad, Prabhakar
2022-12-27 23:17 ` Samuel Holland
2022-12-27 23:17   ` Samuel Holland
2022-12-28 23:44   ` Lad, Prabhakar
2022-12-28 23:44     ` Lad, Prabhakar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.