From: Manuel Lauss <manuel.lauss@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Linux-MIPS <linux-mips@linux-mips.org>,
Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH v2] MIPS: Alchemy: fix wait function
Date: Thu, 23 May 2013 15:28:36 +0200 [thread overview]
Message-ID: <1369315716-7408-1-git-send-email-manuel.lauss@gmail.com> (raw)
Only an interrupt can wake the core from 'wait', enable interrupts
locally before executing 'wait'.
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
Ralf made me aware of the race in between enabling interrupts and
entering wait. While this patch does not eliminate it, it shrinks it
to 1 instruction. It's not perfect, but lets Alchemy boot until a
more sophisticated solution (like __r4k_wait) can be implemented
without having to duplicate the interrupt exception handler.
arch/mips/kernel/idle.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/mips/kernel/idle.c b/arch/mips/kernel/idle.c
index 3b09b88..1d37b4b 100644
--- a/arch/mips/kernel/idle.c
+++ b/arch/mips/kernel/idle.c
@@ -93,9 +93,9 @@ static void rm7k_wait_irqoff(void)
}
/*
- * The Au1xxx wait is available only if using 32khz counter or
- * external timer source, but specifically not CP0 Counter.
- * alchemy/common/time.c may override cpu_wait!
+ * Au1 'wait' is only useful when the 32kHz counter is used as timer,
+ * since coreclock (and the cp0 counter) stops upon executing it. Only an
+ * interrupt can wake it, so they must be enabled before entering idle modes.
*/
static void au1k_wait(void)
{
@@ -103,8 +103,10 @@ static void au1k_wait(void)
" .set mips3 \n"
" cache 0x14, 0(%0) \n"
" cache 0x14, 32(%0) \n"
+ " mfc0 $8, $12 \n"
+ " ori $8, $8, 1 \n"
" sync \n"
- " nop \n"
+ " mtc0 $8, $12 \n" /* enable irqs */
" wait \n"
" nop \n"
" nop \n"
@@ -112,7 +114,6 @@ static void au1k_wait(void)
" nop \n"
" .set mips0 \n"
: : "r" (au1k_wait));
- local_irq_enable();
}
static int __initdata nowait;
--
1.8.2.1
next reply other threads:[~2013-05-23 13:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 13:28 Manuel Lauss [this message]
2013-06-08 18:18 ` [PATCH v2] MIPS: Alchemy: fix wait function Maciej W. Rozycki
2013-06-08 20:15 ` Manuel Lauss
2013-06-10 15:49 ` Ralf Baechle
2013-06-10 18:45 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369315716-7408-1-git-send-email-manuel.lauss@gmail.com \
--to=manuel.lauss@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox