All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 10/11] sh: machine_halt()/machine_power_off() cleanups.
Date: Sat, 28 Jan 2006 00:53:57 +0200	[thread overview]
Message-ID: <20060127225357.GK30816@linux-sh.org> (raw)
In-Reply-To: <20060127224919.GA30816@linux-sh.org>

machine_halt() managed to trigger the soft lockup detection
due to not disabling interrupts before going to sleep, so
correct that.

machine_power_off() should be using pm_power_off, which
lets us drop the board-specific hacks from here.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

---

 arch/sh/kernel/process.c |   54 ++++++++++++++++++++++------------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

38550502f429e90b18c2d05cd976593b63d164f0
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index a4dc2b5..9fd1723 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -15,21 +15,18 @@
 #include <linux/unistd.h>
 #include <linux/mm.h>
 #include <linux/elfcore.h>
-#include <linux/slab.h>
 #include <linux/a.out.h>
+#include <linux/slab.h>
+#include <linux/pm.h>
 #include <linux/ptrace.h>
 #include <linux/platform.h>
 #include <linux/kallsyms.h>
+#include <linux/kexec.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 #include <asm/elf.h>
-#if defined(CONFIG_SH_HS7751RVOIP)
-#include <asm/hs7751rvoip/hs7751rvoip.h>
-#elif defined(CONFIG_SH_RTS7751R2D)
-#include <asm/rts7751r2d/rts7751r2d.h>
-#endif
 
 static int hlt_counter=0;
 
@@ -37,6 +34,11 @@ int ubc_usercnt = 0;
 
 #define HARD_IDLE_TIMEOUT (HZ / 3)
 
+void (*pm_idle)(void);
+
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
 void disable_hlt(void)
 {
 	hlt_counter++;
@@ -51,17 +53,25 @@ void enable_hlt(void)
 
 EXPORT_SYMBOL(enable_hlt);
 
+void default_idle(void)
+{
+	if (!hlt_counter)
+		cpu_sleep();
+	else
+		cpu_relax();
+}
+
 void cpu_idle(void)
 {
 	/* endless idle loop with no priority at all */
 	while (1) {
-		if (hlt_counter) {
-			while (!need_resched())
-				cpu_relax();
-		} else {
-			while (!need_resched())
-				cpu_sleep();
-		}
+		void (*idle)(void) = pm_idle;
+
+		if (!idle)
+			idle = default_idle;
+
+		while (!need_resched())
+			idle();
 
 		preempt_enable_no_resched();
 		schedule();
@@ -88,28 +98,16 @@ void machine_restart(char * __unused)
 
 void machine_halt(void)
 {
-#if defined(CONFIG_SH_HS7751RVOIP)
-	unsigned short value;
+	local_irq_disable();
 
-	value = ctrl_inw(PA_OUTPORTR);
-	ctrl_outw((value & 0xffdf), PA_OUTPORTR);
-#elif defined(CONFIG_SH_RTS7751R2D)
-	ctrl_outw(0x0001, PA_POWOFF);
-#endif
 	while (1)
 		cpu_sleep();
 }
 
 void machine_power_off(void)
 {
-#if defined(CONFIG_SH_HS7751RVOIP)
-	unsigned short value;
-
-	value = ctrl_inw(PA_OUTPORTR);
-	ctrl_outw((value & 0xffdf), PA_OUTPORTR);
-#elif defined(CONFIG_SH_RTS7751R2D)
-	ctrl_outw(0x0001, PA_POWOFF);
-#endif
+	if (pm_power_off)
+		pm_power_off();
 }
 
 void show_regs(struct pt_regs * regs)

  parent reply	other threads:[~2006-01-27 22:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-27 22:49 [PATCH 0/11] sh cleanups Paul Mundt
2006-01-27 22:50 ` [PATCH 1/11] sh: SH4-202 microdev updates Paul Mundt
2006-01-27 22:50 ` [PATCH 2/11] sh: Make peripheral clock frequency setting mandatory Paul Mundt
2006-01-28  0:38   ` Andrew Morton
2006-01-27 22:51 ` [PATCH 3/11] sh: Move TRA/EXPEVT/INTEVT definitions for reuse Paul Mundt
2006-01-27 22:51 ` [PATCH 4/11] sh: Cleanup struct sh_cpuinfo for clock framework changes Paul Mundt
2006-01-27 22:51 ` [PATCH 5/11] sh: unknown mach-type updates Paul Mundt
2006-01-27 22:52 ` [PATCH 6/11] sh: drop maskpos from make_ipr_irq(), remove duplicate irq definitions Paul Mundt
2006-01-27 22:52 ` [PATCH 7/11] sh: convert voyagergx to platform device, drop sh-bus Paul Mundt
2006-01-27 22:53 ` [PATCH 8/11] sh: sh-sci clock framework updates Paul Mundt
2006-01-27 22:53 ` [PATCH 9/11] sh: Add missing timers directory rule to build Paul Mundt
2006-01-27 22:53 ` Paul Mundt [this message]
2006-01-27 22:54 ` [PATCH 11/11] sh/sh64: Fix bogus TIOCGICOUNT definitions Paul Mundt

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=20060127225357.GK30816@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.