From: Kevin Cernekee <cernekee@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: <linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 6/7] MIPS: Fix CP0 COUNTER clockevent race
Date: Tue, 23 Nov 2010 10:26:44 -0800 [thread overview]
Message-ID: <444ef6c4bbb47d55c700452d8cd23229@localhost> (raw)
In-Reply-To: <8a8eee995454c8b271cceb440e31699a@localhost>
Consider the following test case:
write_c0_compare(read_c0_count());
Even if the counter doesn't increment during execution, this might not
generate an interrupt until the counter wraps around. The CPU may
perform the comparison each time CP0 COUNT increments, not when CP0
COMPARE is written.
If mips_next_event() is called with a very small delta, and CP0 COUNT
increments during the calculation of "cnt += delta", it is possible
that CP0 COMPARE will be written with the current value of CP0 COUNT.
If this is detected, the function should return -ETIME, to indicate
that the interrupt might not have actually gotten scheduled.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
arch/mips/kernel/cevt-r4k.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 2f4d7a9..98c5a97 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -32,7 +32,7 @@ static int mips_next_event(unsigned long delta,
cnt = read_c0_count();
cnt += delta;
write_c0_compare(cnt);
- res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0;
+ res = ((int)(read_c0_count() - cnt) >= 0) ? -ETIME : 0;
return res;
}
--
1.7.0.4
next prev parent reply other threads:[~2010-11-23 18:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 18:26 [PATCH RESEND 1/7] MIPS: sync after cacheflush Kevin Cernekee
2010-11-23 18:26 ` [PATCH RESEND 2/7] MIPS: pfn_valid() is broken on low memory HIGHMEM systems Kevin Cernekee
2010-11-23 18:26 ` [PATCH v2 RESEND 3/7] MIPS: Move FIXADDR_TOP into spaces.h Kevin Cernekee
2010-11-23 18:26 ` [PATCH v4 RESEND 4/7] MIPS: HIGHMEM DMA on noncoherent MIPS32 processors Kevin Cernekee
2010-11-23 18:26 ` [PATCH RESEND 5/7] MIPS: Install handlers for BMIPS software IRQs Kevin Cernekee
2010-11-23 18:26 ` Kevin Cernekee [this message]
2010-11-24 11:34 ` [PATCH 6/7] MIPS: Fix CP0 COUNTER clockevent race Ralf Baechle
2010-11-23 18:26 ` [PATCH 7/7] MIPS: Fix regression on BCM4710 processor detection Kevin Cernekee
2010-11-24 11:34 ` Ralf Baechle
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=444ef6c4bbb47d55c700452d8cd23229@localhost \
--to=cernekee@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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