From: Ralf Baechle <ralf@linux-mips.org>
To: Al Cooper <alcooperx@gmail.com>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Kernel hangs occasionally during boot.
Date: Tue, 8 Nov 2011 17:55:32 +0000 [thread overview]
Message-ID: <20111108175532.GA15493@linux-mips.org> (raw)
In-Reply-To: <1320764341-4275-1-git-send-email-alcooperx@gmail.com>
On Tue, Nov 08, 2011 at 09:59:01AM -0500, Al Cooper wrote:
> arch/mips/kernel/cevt-r4k.c | 38 +++++++++++++++++++-------------------
> 1 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
> index 98c5a97..e2d8e19 100644
> --- a/arch/mips/kernel/cevt-r4k.c
> +++ b/arch/mips/kernel/cevt-r4k.c
> @@ -103,19 +103,10 @@ static int c0_compare_int_pending(void)
>
> /*
> * Compare interrupt can be routed and latched outside the core,
> - * so a single execution hazard barrier may not be enough to give
> - * it time to clear as seen in the Cause register. 4 time the
> - * pipeline depth seems reasonably conservative, and empirically
> - * works better in configurations with high CPU/bus clock ratios.
> + * so wait up to worst case number of cycle counter ticks for timer interrupt
> + * changes to propagate to the cause register.
> */
> -
> -#define compare_change_hazard() \
> - do { \
> - irq_disable_hazard(); \
> - irq_disable_hazard(); \
> - irq_disable_hazard(); \
> - irq_disable_hazard(); \
> - } while (0)
> +#define COMPARE_INT_SEEN_TICKS 50
>
> int c0_compare_int_usable(void)
> {
> @@ -126,8 +117,12 @@ int c0_compare_int_usable(void)
> * IP7 already pending? Try to clear it by acking the timer.
> */
> if (c0_compare_int_pending()) {
> - write_c0_compare(read_c0_count());
> - compare_change_hazard();
> + cnt = read_c0_count();
> + write_c0_compare(cnt);
> + back_to_back_c0_hazard();
back_to_back_c0_hazard is to separate cp0 writes from subsequent reads from
the same cp0 register. So I think no back_to_back_c0_hazard() is needed
here.
> + while (read_c0_count() < (cnt + COMPARE_INT_SEEN_TICKS))
> + if (!c0_compare_int_pending())
> + break;
> if (c0_compare_int_pending())
> return 0;
> }
> @@ -136,7 +131,7 @@ int c0_compare_int_usable(void)
> cnt = read_c0_count();
> cnt += delta;
> write_c0_compare(cnt);
> - compare_change_hazard();
> + back_to_back_c0_hazard();
Same comment as above.
> if ((int)(read_c0_count() - cnt) < 0)
> break;
> /* increase delta if the timer was already expired */
> @@ -145,12 +140,17 @@ int c0_compare_int_usable(void)
> while ((int)(read_c0_count() - cnt) <= 0)
> ; /* Wait for expiry */
>
> - compare_change_hazard();
> + while (read_c0_count() < (cnt + COMPARE_INT_SEEN_TICKS))
> + if (c0_compare_int_pending())
> + break;
> if (!c0_compare_int_pending())
> return 0;
> -
> - write_c0_compare(read_c0_count());
> - compare_change_hazard();
> + cnt = read_c0_count();
> + write_c0_compare(cnt);
> + back_to_back_c0_hazard();
> + while (read_c0_count() < (cnt + COMPARE_INT_SEEN_TICKS))
> + if (!c0_compare_int_pending())
> + break;
> if (c0_compare_int_pending())
> return 0;
I've applied your patch but we may need another hazard barrier to
replace back_to_back_c0_hazard().
Ralf
next prev parent reply other threads:[~2011-11-08 17:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 14:59 [PATCH] MIPS: Kernel hangs occasionally during boot Al Cooper
2011-11-08 17:55 ` Ralf Baechle [this message]
2011-11-09 7:40 ` Gleb O. Raiko
2011-11-09 9:13 ` Ralf Baechle
2011-11-09 10:34 ` Ralf Baechle
2011-11-09 11:26 ` Gleb O. Raiko
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=20111108175532.GA15493@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=alcooperx@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@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