From: "Andi Kleen" <ak@suse.de>

Update uptime after suspend

Derived from i386

Adjust jiffies after suspend to keep uptime. 

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/x86_64/kernel/time.c |    8 ++++++--
 25-akpm/arch/x86_64/mm/srat.c     |    8 ++++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff -puN arch/x86_64/kernel/time.c~x86_64-update-uptime-after-suspend arch/x86_64/kernel/time.c
--- 25/arch/x86_64/kernel/time.c~x86_64-update-uptime-after-suspend	2004-11-28 01:54:35.118258320 -0800
+++ 25-akpm/arch/x86_64/kernel/time.c	2004-11-28 01:54:35.123257560 -0800
@@ -955,7 +955,7 @@ void __init time_init_smp(void)
 
 __setup("report_lost_ticks", time_setup);
 
-static long clock_cmos_diff;
+static long clock_cmos_diff, sleep_start;
 
 static int timer_suspend(struct sys_device *dev, u32 state)
 {
@@ -964,6 +964,7 @@ static int timer_suspend(struct sys_devi
 	 */
 	clock_cmos_diff = -get_cmos_time();
 	clock_cmos_diff += get_seconds();
+	sleep_start = jiffies;
 	return 0;
 }
 
@@ -971,15 +972,18 @@ static int timer_resume(struct sys_devic
 {
 	unsigned long flags;
 	unsigned long sec;
+	unsigned long ctime = get_cmos_time();
+	unsigned long sleep_length = ctime - sleep_start;
 
 	if (vxtime.hpet_address)
 		hpet_reenable();
 
-	sec = get_cmos_time() + clock_cmos_diff;
+	sec = ctime + clock_cmos_diff;
 	write_seqlock_irqsave(&xtime_lock,flags);
 	xtime.tv_sec = sec;
 	xtime.tv_nsec = 0;
 	write_sequnlock_irqrestore(&xtime_lock,flags);
+	jiffies += sleep_length * HZ;
 	return 0;
 }
 
diff -puN arch/x86_64/mm/srat.c~x86_64-update-uptime-after-suspend arch/x86_64/mm/srat.c
--- 25/arch/x86_64/mm/srat.c~x86_64-update-uptime-after-suspend	2004-11-28 01:54:35.119258168 -0800
+++ 25-akpm/arch/x86_64/mm/srat.c	2004-11-28 01:54:35.124257408 -0800
@@ -16,14 +16,14 @@
 #include <asm/proto.h>
 #include <asm/numa.h>
 
-static DECLARE_BITMAP(nodes_parsed, MAXNODE) __initdata;
-static struct node nodes[MAXNODE] __initdata;
+static DECLARE_BITMAP(nodes_parsed, MAX_NUMNODES) __initdata;
+static struct node nodes[MAX_NUMNODES] __initdata;
 static __u8  pxm2node[256] __initdata = { [0 ... 255] = 0xff };
 
 static __init int setup_node(int pxm)
 {
 	if (pxm2node[pxm] == 0xff) {
-		if (numnodes > MAXNODE)
+		if (numnodes > MAX_NUMNODES)
 			return -1;
 		pxm2node[pxm] = numnodes - 1;
 		numnodes++;
@@ -169,7 +169,7 @@ int __init acpi_scan_nodes(unsigned long
 		bad_srat();
 		return -1;
 	}
-	for (i = 0; i < MAXNODE; i++) {
+	for (i = 0; i < MAX_NUMNODES; i++) {
 		if (!test_bit(i, &nodes_parsed))
 			continue;
 		cutoff_node(i, start, end);
_