]> git.baikalelectronics.ru Git - kernel.git/commit
MIPS: Fix CP0 COUNTER clockevent race
authorKevin Cernekee <cernekee@gmail.com>
Tue, 23 Nov 2010 18:26:44 +0000 (10:26 -0800)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 16 Dec 2010 18:10:58 +0000 (18:10 +0000)
commit9bc9c8e9e281e3f77f4dd4c72516f3e96368cffb
treeee9d8cec2235b737cfb2cd931e43ede7d9772a53
parentbcea15343724ec05a8ea341f9763ae6bf4aa759b
MIPS: Fix CP0 COUNTER clockevent race

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>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/1836/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/cevt-r4k.c