From: Alan Stern <stern@rowland.harvard.edu> Add support for autosuspend/autoresume of the SCSI devices. Lowlevel driver can use it to spin the disk down... and it is neccessary step for powering down the controllers. Spinning down the disk is useful - saves ~0.5W here, and it is last major thing we can do to save power on some small machines like Kohjinsha subnotebooks. Signed-off-by: Pavel Machek <pavel@suse.cz> -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html --
-ENOPATCH --
> -ENOPATCH I was wondering about too little mails in my inbox... Thanks, Rafael! Pavel From: Alan Stern <stern@rowland.harvard.edu> Add support for autosuspend/autoresume of the SCSI devices. Lowlevel driver can use it to spin the disk down... and it is neccessary step for powering down the controllers. Spinning down the disk is useful - saves ~0.5W here, and it is last major thing we can do to save power on some small machines like Kohjinsha subnotebooks. Signed-off-by: Pavel Machek <pavel@suse.cz> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index c7f0629..eba766d 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -57,6 +57,18 @@ config SCSI_PROC_FS If unsure say Y. +config SCSI_DYNAMIC_PM + bool "SCSI dynamic Power Management support (EXPERIMENTAL)" + depends on SCSI && PM && EXPERIMENTAL + ---help--- + This option enables support for dynamic (or runtime) + power management of SCSI devices and host adapters. + If you say Y here, you can use the sysfs "power/level" + and "power/autosuspend" files to control manual or + automatic suspend/resume of individual SCSI devices. + + If unsure say N. + comment "SCSI support type (disk, tape, CD-ROM)" depends on SCSI diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 72fd504..9ab631c 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -143,7 +143,8 @@ obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wai scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ scsicam.o scsi_error.o scsi_lib.o scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o -scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o +scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o \ + scsi_pm.o scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index fed0b02..827259f 100644 --- ...
Hi, firstly, it doesn't consider error handling before suspending. Secondly, it is simply not true that in SCSI suspending the disks is always necessary before suspending the controller. Regards Oliver --
What problems do you see with error handling? This patch does not Ok, will fix the changelog... but it is still true at least for USB controllers. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html --
You'd make scsi driver writers' life easier if you made sure no autosuspends happen while they recover from errors. After all, you have no idea which commands will get through while the bus is in disarray. Regards Oliver --
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html --
I am afraid this is not true. Regards Oliver /** * scsi_block_when_processing_errors - Prevent cmds from being queued. * @sdev: Device on which we are performing recovery. * * Description: * We block until the host is out of error recovery, and then check to * see whether the host or the device is offline. * * Return value: * 0 when dev was taken offline by error recovery. 1 OK to proceed. */ int scsi_block_when_processing_errors(struct scsi_device *sdev) /** * scsi_restart_operations - restart io operations to the specified host. * @shost: Host we are restarting. * * Notes: * When we entered the error handler, we blocked all further i/o to * this device. we need to 'reverse' this process. */ static void scsi_restart_operations(struct Scsi_Host *shost) --
Hmm, scsi_block_when_ function, which does not _block_, and returns inverted values from what would people expect. ...but this should fix it, no? [incremental to previous] Pavel diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index 3c184fe..7e5ea0d 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -10,6 +10,7 @@ #define DEBUG #include <scsi/scsi.h> #include <scsi/scsi_device.h> #include <scsi/scsi_host.h> +#include <scsi/scsi_eh.h> #include <linux/delay.h> @@ -128,8 +129,11 @@ static int autosuspend_check(struct scsi if (!(sdev->sdev_state == SDEV_RUNNING || sdev->sdev_state == SDEV_QUIESCE)) return -ENODEV; + if (!scsi_block_when_processing_errors(sdev)) + return -EBUSY; suspend_time = sdev->last_busy + sdev->autosuspend_delay; + /* FIXME: what if suspend_time - jiffies == -EPERM by some strange chance */ if (time_before(jiffies, suspend_time)) return suspend_time - jiffies; return 0; -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html --
Am Dienstag 02 September 2008 11:08:00 schrieb Pavel Machek:
/**
* scsi_block_when_processing_errors - Prevent cmds from being queued.
* @sdev: Device on which we are performing recovery.
*
* Description:
* We block until the host is out of error recovery, and then check to
* see whether the host or the device is offline.
*
* Return value:
* 0 when dev was taken offline by error recovery. 1 OK to proceed.
*/
int scsi_block_when_processing_errors(struct scsi_device *sdev)
{
int online;
wait_event(sdev->host->host_wait, !scsi_host_in_recovery(sdev->host));
This I would expect to block. But it may be unwise to block this long.
online = scsi_device_online(sdev);
SCSI_LOG_ERROR_RECOVERY(5, printk("%s: rtn: %d\n", __func__,
online));
return online;
Why this? It seems to me for purpose of autosuspend an offlined device
should be totally ignored.
Regards
Oliver
--
If I'm not mistaken, while error hanlding is in progress we always have shost->shost_state equal to either SHOST_RECOVERY or SHOST_CANCEL_RECOVERY. This is a better test to use. Alan Stern --
Is there a difference regarding power saving to the already existing ways to spin down a disk, like noflushd? In a previous patch you mentioned that this can be used to disable the SATA port so save even more power. However, this part seems to be missing in this patch, right? Regards, Tino --
Correct. That is the plan for the next patch, when I get this one into reasonable form for acceptance. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html --
