All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Alchemy: make 32kHz and r4k timer coexist peacefully
@ 2012-12-16 19:41 Manuel Lauss
  2012-12-16 20:17 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: Manuel Lauss @ 2012-12-16 19:41 UTC (permalink / raw)
  To: Ralf Baechle, Linux-MIPS; +Cc: Manuel Lauss

From: Manuel Lauss <manuel.lauss@gmail.com>

Now that the r4k timer is registered no matter what, bump the rating of
the Alchemy 32kHz timer so that it gets used when it is working,
and fall back on the r4k when it isn't.

This fixes a timer-related hang on platform with a working 32kHz timer
(the better rated c0 timer stops while executing 'wait' leading to (almost) 
eternal sleep) and an oops on boot on platforms without a working 32kHz timer
(due to double registration of the r4k timer).

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
For what is to become 3.8.

This is a quick fix; it's far less invasive than my preferred solution:
having each platform register the r4k clocksource explicitly.
It should be enough until Alchemy variants with speeds >= 1.3GHz appear
(which is very unlikely).

 arch/mips/alchemy/common/time.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c
index a7193ae..12589d0 100644
--- a/arch/mips/alchemy/common/time.c
+++ b/arch/mips/alchemy/common/time.c
@@ -53,7 +53,7 @@ static struct clocksource au1x_counter1_clocksource = {
 	.read		= au1x_counter1_read,
 	.mask		= CLOCKSOURCE_MASK(32),
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
-	.rating		= 100,
+	.rating		= 1500,
 };
 
 static int au1x_rtcmatch2_set_next_event(unsigned long delta,
@@ -84,7 +84,7 @@ static irqreturn_t au1x_rtcmatch2_irq(int irq, void *dev_id)
 static struct clock_event_device au1x_rtcmatch2_clockdev = {
 	.name		= "rtcmatch2",
 	.features	= CLOCK_EVT_FEAT_ONESHOT,
-	.rating		= 100,
+	.rating		= 1500,
 	.set_next_event	= au1x_rtcmatch2_set_next_event,
 	.set_mode	= au1x_rtcmatch2_set_mode,
 	.cpumask	= cpu_all_mask,
@@ -158,20 +158,6 @@ cntr_err:
 	return -1;
 }
 
-static void __init alchemy_setup_c0timer(void)
-{
-	/*
-	 * MIPS kernel assigns 'au1k_wait' to 'cpu_wait' before this
-	 * function is called.  Because the Alchemy counters are unusable
-	 * the C0 timekeeping code is installed and use of the 'wait'
-	 * instruction must be prohibited, which is done most easily by
-	 * assigning NULL to cpu_wait.
-	 */
-	cpu_wait = NULL;
-	r4k_clockevent_init();
-	init_r4k_clocksource();
-}
-
 static int alchemy_m2inttab[] __initdata = {
 	AU1000_RTC_MATCH2_INT,
 	AU1500_RTC_MATCH2_INT,
@@ -183,11 +169,8 @@ static int alchemy_m2inttab[] __initdata = {
 
 void __init plat_time_init(void)
 {
-	int t;
-
-	t = alchemy_get_cputype();
-	if (t == ALCHEMY_CPU_UNKNOWN)
-		alchemy_setup_c0timer();
-	else if (alchemy_time_init(alchemy_m2inttab[t]))
-		alchemy_setup_c0timer();
+	int t = alchemy_get_cputype();
+	if ((t == ALCHEMY_CPU_UNKNOWN) ||
+	    (alchemy_time_init(alchemy_m2inttab[t])))
+		cpu_wait = NULL;	/* wait doesn't work with r4k timer */
 }
-- 
1.8.0.2

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

* Re: [PATCH] MIPS: Alchemy: make 32kHz and r4k timer coexist peacefully
  2012-12-16 19:41 [PATCH] MIPS: Alchemy: make 32kHz and r4k timer coexist peacefully Manuel Lauss
@ 2012-12-16 20:17 ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2012-12-16 20:17 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: Ralf Baechle, Linux-MIPS

Hello.

On 16-12-2012 23:41, Manuel Lauss wrote:

> From: Manuel Lauss <manuel.lauss@gmail.com>

> Now that the r4k timer is registered no matter what, bump the rating of
> the Alchemy 32kHz timer so that it gets used when it is working,
> and fall back on the r4k when it isn't.

> This fixes a timer-related hang on platform with a working 32kHz timer
> (the better rated c0 timer stops while executing 'wait' leading to (almost)
> eternal sleep) and an oops on boot on platforms without a working 32kHz timer
> (due to double registration of the r4k timer).

> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
> ---
> For what is to become 3.8.

> This is a quick fix; it's far less invasive than my preferred solution:
> having each platform register the r4k clocksource explicitly.
> It should be enough until Alchemy variants with speeds >= 1.3GHz appear
> (which is very unlikely).

>   arch/mips/alchemy/common/time.c | 29 ++++++-----------------------
>   1 file changed, 6 insertions(+), 23 deletions(-)

> diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c
> index a7193ae..12589d0 100644
> --- a/arch/mips/alchemy/common/time.c
> +++ b/arch/mips/alchemy/common/time.c
[...]
> @@ -183,11 +169,8 @@ static int alchemy_m2inttab[] __initdata = {
>
>   void __init plat_time_init(void)
>   {
> -	int t;
> -
> -	t = alchemy_get_cputype();
> -	if (t == ALCHEMY_CPU_UNKNOWN)
> -		alchemy_setup_c0timer();
> -	else if (alchemy_time_init(alchemy_m2inttab[t]))
> -		alchemy_setup_c0timer();
> +	int t = alchemy_get_cputype();

    Could you please keep the coding style and insert empty line here?

> +	if ((t == ALCHEMY_CPU_UNKNOWN) ||
> +	    (alchemy_time_init(alchemy_m2inttab[t])))

    Useless parens around == and especially around function call.

WBR, Sergei

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

end of thread, other threads:[~2012-12-16 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-16 19:41 [PATCH] MIPS: Alchemy: make 32kHz and r4k timer coexist peacefully Manuel Lauss
2012-12-16 20:17 ` Sergei Shtylyov

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.