/[linux-patches]/genpatches-2.6/tags/2.6.15-6/1027_2_sparc64-ultra-iie-timekeeping.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.15-6/1027_2_sparc64-ultra-iie-timekeeping.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 304 - (show annotations) (download) (as text)
Sat Feb 4 13:25:49 2006 UTC (13 years, 2 months ago) by dsd
File MIME type: text/x-diff
File size: 3243 byte(s)
2.6.15-6 release
1 From stable-bounces@linux.kernel.org Tue Jan 17 15:27:59 2006
2 Date: Tue, 17 Jan 2006 15:23:00 -0800 (PST)
3 Message-Id: <20060117.152300.10006770.davem@davemloft.net>
4 To: stable@kernel.org
5 From: "David S. Miller" <davem@davemloft.net>
6 Subject: [PATCH] Fix timekeeping on sparc64 ultra-IIe machines
7
8 From: Richard Mortimer <richm@oldelvet.org.uk>
9
10 [SPARC64]: Eliminate race condition reading Hummingbird STICK register
11
12 Ensure a consistent value is read from the STICK register by ensuring
13 that both high and low are read without high changing due to a roll
14 over of the low register.
15
16 Various Debian/SPARC users (myself include) have noticed problems with
17 Hummingbird based systems. The symptoms are that the system time is
18 seen to jump forward 3 days, 6 hours, 11 minutes give or take a few
19 seconds. In many cases the system then hangs some time afterwards.
20
21 I've spotted a race condition in the code to read the STICK register.
22 I could not work out why 3d, 6h, 11m is important but guess that it is
23 due to the 2^32 jump of STICK (forwards on one read and then the next
24 read will seem to be backwards) during a timer interrupt. I'm guessing
25 that a change of -2^32 will get converted to a large unsigned
26 increment after the arithmetic manipulation between STICK,
27 nanoseconds, jiffies etc.
28
29 I did a test where I modified __hbird_read_stick to artificially
30 inject rollover faults forcefully every few seconds. With this I saw
31 the clock jump over 6 times in 12 hours compared to once every month
32 or so.
33
34 Signed-off-by: Richard Mortimer <richm@oldelvet.org.uk>
35 Signed-off-by: David S. Miller <davem@davemloft.net>
36 Signed-off-by: Chris Wright <chrisw@sous-sol.org>
37 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
38 ---
39 arch/sparc64/kernel/time.c | 22 +++++++++++-----------
40 1 file changed, 11 insertions(+), 11 deletions(-)
41
42 --- linux-2.6.15.1.orig/arch/sparc64/kernel/time.c
43 +++ linux-2.6.15.1/arch/sparc64/kernel/time.c
44 @@ -280,9 +280,9 @@ static struct sparc64_tick_ops stick_ope
45 * Since STICK is constantly updating, we have to access it carefully.
46 *
47 * The sequence we use to read is:
48 - * 1) read low
49 - * 2) read high
50 - * 3) read low again, if it rolled over increment high by 1
51 + * 1) read high
52 + * 2) read low
53 + * 3) read high again, if it rolled re-read both low and high again.
54 *
55 * Writing STICK safely is also tricky:
56 * 1) write low to zero
57 @@ -295,18 +295,18 @@ static struct sparc64_tick_ops stick_ope
58 static unsigned long __hbird_read_stick(void)
59 {
60 unsigned long ret, tmp1, tmp2, tmp3;
61 - unsigned long addr = HBIRD_STICK_ADDR;
62 + unsigned long addr = HBIRD_STICK_ADDR+8;
63
64 - __asm__ __volatile__("ldxa [%1] %5, %2\n\t"
65 - "add %1, 0x8, %1\n\t"
66 - "ldxa [%1] %5, %3\n\t"
67 + __asm__ __volatile__("ldxa [%1] %5, %2\n"
68 + "1:\n\t"
69 "sub %1, 0x8, %1\n\t"
70 + "ldxa [%1] %5, %3\n\t"
71 + "add %1, 0x8, %1\n\t"
72 "ldxa [%1] %5, %4\n\t"
73 "cmp %4, %2\n\t"
74 - "blu,a,pn %%xcc, 1f\n\t"
75 - " add %3, 1, %3\n"
76 - "1:\n\t"
77 - "sllx %3, 32, %3\n\t"
78 + "bne,a,pn %%xcc, 1b\n\t"
79 + " mov %4, %2\n\t"
80 + "sllx %4, 32, %4\n\t"
81 "or %3, %4, %0\n\t"
82 : "=&r" (ret), "=&r" (addr),
83 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3)

  ViewVC Help
Powered by ViewVC 1.1.20