mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: samg <samg@seven4sky.com>, kernel list <linux-kernel@vger.kernel.org>
Subject: Re: Smp swsusp testing wanted
Date: Sun, 23 May 2004 19:35:59 +0200	[thread overview]
Message-ID: <20040523173559.GA1558@elf.ucw.cz> (raw)
In-Reply-To: <20040523173457.GB804@elf.ucw.cz>

Hi!

> > >Hi! If you have smp machine where swsusp works with only one procesor and 
> > >can test patches, please let me know. --p
> 
> > I have  (1) smp machine (dual proc), running 2.4.18/2.6.5/2.6.6,  If you 
> > have a patch I can test it for you.
> 
> Please verify that swsusp works in "UP" mode, first. Then apply this
> and go to "SMP" mode, and see if it still works.
> 
> I have SMP machine here but swsusp will not work there even in "UP"
> mode; I'll need to debug it. 

Sorry, here it is.
								Pavel

--- clean/include/linux/suspend.h	2004-05-20 23:11:46.000000000 +0200
+++ linux/include/linux/suspend.h	2004-05-21 15:02:33.000000000 +0200
@@ -81,6 +81,14 @@
 }
 #endif	/* CONFIG_PM */
 
+#ifdef CONFIG_SMP
+extern void smp_freeze(void);
+extern void smp_restart(void);
+#else
+static inline void smp_freeze(void) {}
+static inline void smp_restart(void) {}
+#endif
+
 asmlinkage void do_magic(int is_resume);
 asmlinkage void do_magic_resume_1(void);
 asmlinkage void do_magic_resume_2(void);
--- clean/kernel/power/Makefile	2003-09-28 22:06:44.000000000 +0200
+++ linux/kernel/power/Makefile	2004-05-21 14:22:50.000000000 +0200
@@ -1,4 +1,5 @@
 obj-y				:= main.o process.o console.o pm.o
+obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
 obj-$(CONFIG_PM_DISK)		+= disk.o pmdisk.o
 
--- clean/kernel/power/smp.c	2004-05-21 14:08:45.000000000 +0200
+++ linux/kernel/power/smp.c	2004-05-21 14:46:40.000000000 +0200
@@ -0,0 +1,62 @@
+/*
+ * drivers/power/smp.c - Functions for stopping other CPUs.
+ *
+ * Copyright 2004 Pavel Machek <pavel@suse.cz>
+ * Copyright (C) 2002-2003 Nigel Cunningham <ncunningham@clear.net.nz>
+ *
+ * This file is released under the GPLv2.
+ */
+
+#undef DEBUG
+
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
+#include <linux/suspend.h>
+#include <linux/module.h>
+#include <asm/atomic.h>
+
+static atomic_t cpu_counter, freeze;
+
+static void smp_pause(void * data)
+{
+	atomic_inc(&cpu_counter);
+	while (atomic_read(&freeze)) {
+		cpu_relax();
+		barrier();
+		{
+			int i;
+			for (i=0; i<10000; i++)
+				barrier();
+		}
+	}
+	atomic_dec(&cpu_counter);
+}
+
+void smp_freeze(void)
+{
+	/* FIXME: for this to work, all the CPUs must be running
+	 * "idle" thread (or we deadlock). Is that guaranteed? */
+	printk("Freezing CPUs...");
+	atomic_set(&cpu_counter, 0);
+	atomic_set(&freeze, 1);
+	smp_call_function(smp_pause, NULL, 0, 0);
+	if (num_online_cpus() != 2)
+		printk("not HT machine?");
+	while (atomic_read(&cpu_counter) < (num_online_cpus() - 1)) {
+		cpu_relax();
+		barrier();
+	}
+	printk("ok\n");
+}
+
+void smp_restart(void)
+{
+	printk("Restarting CPUs...");
+	atomic_set(&freeze, 0);
+	while (atomic_read(&cpu_counter)) {
+		cpu_relax();
+		barrier();
+	}
+	printk("ok\n");
+}
+
--- clean/kernel/power/swsusp.c	2004-05-21 09:49:11.000000000 +0200
+++ linux/kernel/power/swsusp.c	2004-05-21 14:39:38.000000000 +0200
@@ -859,6 +859,8 @@
 
 		free_some_memory();
 		
+		mdelay(1000);
+		smp_freeze();
 		/* Save state of all device drivers, and stop them. */		   
 		if ((res = device_suspend(4))==0)
 			/* If stopping device drivers worked, we proceed basically into
@@ -872,6 +874,7 @@
 			 */
 			do_magic(0);
 		thaw_processes();
+		smp_restart();
 	} else
 		res = -EBUSY;
 	software_suspend_enabled = 1;
@@ -1195,8 +1198,7 @@
 static int __init software_resume(void)
 {
 	if (num_online_cpus() > 1) {
-		printk(KERN_WARNING "Software Suspend has malfunctioning SMP support. Disabled :(\n");	
-		return -EINVAL;
+		printk(KERN_WARNING "SMP support is very experimental.\n");	
 	}
 	/* We enable the possibility of machine suspend */
 	software_suspend_enabled = 1;
@@ -1223,6 +1225,8 @@
 	printk( "resuming from %s\n", resume_file);
 	if (read_suspend_image(resume_file, 0))
 		goto read_failure;
+	mdelay(1000);
+	smp_freeze();
 	device_suspend(4);
 	do_magic(1);
 	panic("This never returns");


-- 
934a471f20d6580d5aad759bf0d97ddc

      reply	other threads:[~2004-05-23 17:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-22 16:36 pavel
     [not found] ` <40B0014B.1030002@seven4sky.com>
2004-05-23 17:34   ` Pavel Machek
2004-05-23 17:35     ` Pavel Machek [this message]

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=20040523173559.GA1558@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samg@seven4sky.com \
    /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

all inboxes | Powered by JetHome®