From: Rodrigo Ventura <yoda@isr.ist.utl.pt>
To: linux-kernel@vger.kernel.org
Subject: patch to put IDE drives in sleep-mode after an halt
Date: 24 May 2001 12:03:49 +0100 [thread overview]
Message-ID: <lx4rubc8kq.fsf@pixie.isr.ist.utl.pt> (raw)
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
I am submitting a patch to kernel/sys.c that walks through all
IDE drives (#ifdef CONFIG_BLK_DEV_IDE, of course), and issues a
"sleep" command (as code in hdparam) to each one of them right before
the kernel halts. Here goes the diff:
[-- Attachment #2: sys.diff --]
[-- Type: text/plain, Size: 2113 bytes --]
--- sys.c.ORIG Thu May 24 00:56:50 2001
+++ sys.c Thu May 24 01:40:31 2001
@@ -15,6 +15,11 @@
#include <asm/uaccess.h>
#include <asm/io.h>
+#ifdef CONFIG_BLK_DEV_IDE
+#include "../drivers/block/ide.h"
+#endif
+
+
/*
* this indicates whether you can reboot with ctrl-alt-del: the default is yes
*/
@@ -146,6 +151,45 @@
/*
+ * Puts IDE disks in sleep mode
+ */
+void disks_sleep(void) {
+#ifdef CONFIG_BLK_DEV_IDE
+#define WIN_SLEEPNOW1 0xE6
+#define WIN_SLEEPNOW2 0x99
+ int i, d, ret;
+ unsigned char args[4];
+ ide_drive_t *drv;
+
+ for ( i=0 ; i<MAX_HWIFS ; i++ ) {
+ if ( !ide_hwifs[i].present )
+ continue;
+ /*printk(KERN_DEBUG "HD iface %s\n", ide_hwifs[i].name);*/
+ for ( d=0 ; d<MAX_DRIVES ; d++ ) {
+ if ( !ide_hwifs[i].drives[d].present )
+ continue;
+ /*printk(KERN_DEBUG " - drive %s\n", ide_hwifs[i].drives[d].name);*/
+ drv = &ide_hwifs[i].drives[d];
+ args[0] = WIN_SLEEPNOW1;
+ args[1] = args[2] = args[3] = 0;
+ ret = ide_wait_cmd(drv, args[0], args[1], args[2], args[3], args);
+ if (ret) {
+ args[0] = WIN_SLEEPNOW2;
+ args[1] = args[2] = args[3] = 0;
+ ret = ide_wait_cmd(drv, args[0], args[1], args[2], args[3], args);
+ if (ret)
+ printk(KERN_NOTICE "Putting %s to sleep failed.\n", drv->name);
+ else
+ printk(KERN_NOTICE "Putting %s to sleep at second attempt.\n", drv->name);
+ } else
+ printk(KERN_NOTICE "Putting %s to sleep.\n", drv->name);
+ }
+ }
+#endif
+}
+
+
+/*
* Reboot system call: for obvious reasons only root may call it,
* and even root needs to set up some magic numbers in the registers
* so that some mistake won't make this reboot the whole machine.
@@ -186,6 +230,7 @@
case LINUX_REBOOT_CMD_HALT:
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
printk(KERN_EMERG "System halted.\n");
+ disks_sleep();
machine_halt();
do_exit(0);
break;
@@ -193,6 +238,7 @@
case LINUX_REBOOT_CMD_POWER_OFF:
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
printk(KERN_EMERG "Power down.\n");
+ disks_sleep();
machine_power_off();
do_exit(0);
break;
[-- Attachment #3: Type: text/plain, Size: 386 bytes --]
Please comment!
Cheers,
--
*** Rodrigo Martins de Matos Ventura <yoda@isr.ist.utl.pt>
*** Web page: http://www.isr.ist.utl.pt/~yoda
*** Teaching Assistant and PhD Student at ISR:
*** Instituto de Sistemas e Robotica, Polo de Lisboa
*** Instituto Superior Tecnico, Lisboa, PORTUGAL
*** PGP fingerprint = 0119 AD13 9EEE 264A 3F10 31D3 89B3 C6C4 60C6 4585
next reply other threads:[~2001-05-24 11:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-24 11:03 Rodrigo Ventura [this message]
2001-05-24 11:11 ` patch to put IDE drives in sleep-mode after an halt Russell King
2001-05-24 13:20 ` Erik Mouw
2001-05-24 13:52 ` Rodrigo Ventura
-- strict thread matches above, loose matches on Subject: below --
2001-05-24 12:29 peter k.
2001-05-24 12:46 ` Adrian V. Bono
2001-05-24 12:59 ` peter k.
2001-05-24 13:18 ` Erik Mouw
2001-05-24 15:16 Petr Vandrovec
2001-05-24 17:38 ` idalton
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=lx4rubc8kq.fsf@pixie.isr.ist.utl.pt \
--to=yoda@isr.ist.utl.pt \
--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.