autosuspend for SCSI devices
Subsystems (2)
From: Alan Stern <[email protected]>
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.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
From: Alan Stern <[email protected]>
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 <[email protected]>
-ENOPATCH
Quoted 11 lines · Pavel Machek
From: Alan Stern <[email protected]>
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 <[email protected]>
-ENOPATCH
Quoted 1 line
-ENOPATCH
I was wondering about too little mails in my inbox... Thanks, Rafael!
Pavel
From: Alan Stern <[email protected]>
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.
drivers/scsi/Kconfig +12 -0
@@ -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
drivers/scsi/Makefile +2 -1
@@ -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
drivers/scsi/hosts.c +2 -0
@@ -402,6 +402,8 @@ #endif shost->host_no); shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; +scsi_pm_host_initialize (shost); + shost->ehandler =kthread_run (scsi_error_handler, shost,"scsi_eh_%d" , shost->host_no);if (IS_ERR (shost->ehandler)) {
drivers/scsi/scsi.c +7 -1
@@ -1279,15 +1279,20 @@ static int __init init_scsi(void) error =scsi_init_sysctl ();if (error) goto cleanup_hosts; - error =scsi_sysfs_register (); + error =scsi_init_pm ();if (error) goto cleanup_sysctl; + error =scsi_sysfs_register (); +if (error) + goto cleanup_pm;scsi_netlink_init ();printk (KERN_NOTICE "SCSI subsystem initialized\n" );return 0 ; +cleanup_pm: +scsi_exit_pm (); cleanup_sysctl:scsi_exit_sysctl (); cleanup_hosts:
@@ -1307,6 +1312,7 @@ static void __exit exit_scsi(void) {scsi_netlink_exit ();scsi_sysfs_unregister (); +scsi_exit_pm ();scsi_exit_sysctl ();scsi_exit_hosts ();scsi_exit_devinfo ();
drivers/scsi/scsi_lib.c +4 -3
@@ -67,8 +67,6 @@ #undef SPstruct kmem_cache *scsi_sdb_cache; -static void scsi_run_queue (struct request_queue *q); -/* * Function: scsi_unprep_request() *
@@ -470,6 +468,7 @@ void scsi_device_unbusy(struct scsi_devispin_unlock (shost->host_lock);spin_lock (sdev->request_queue->queue_lock); sdev->device_busy--; +scsi_mark_last_busy (sdev);spin_unlock_irqrestore (sdev->request_queue->queue_lock, flags); }
@@ -531,7 +530,7 @@ static void scsi_single_lun_run(struct s* Notes: The previous command was completely finished, start * a new one if possible. */ -static void scsi_run_queue (struct request_queue *q) +void scsi_run_queue (struct request_queue *q) {struct scsi_device *sdev = q->queuedata;struct Scsi_Host *shost = sdev->host;
@@ -1249,6 +1248,8 @@ int scsi_prep_state_check(struct scsi_de ret =BLKPREP_KILL ;break ;case SDEV_QUIESCE : + ret =scsi_pm_state_check (sdev, req); +break ;case SDEV_BLOCK :/* * If the devices is blocked we defer normal commands.
drivers/scsi/scsi_pm.c new file +742 -0
742 lines not on this page · raw message
drivers/scsi/scsi_priv.h +38 -0
@@ -4,11 +4,13 @@ #define _SCSI_PRIV_H#include <linux/device.h> struct request_queue ; +struct request ;struct scsi_cmnd ;struct scsi_device ;struct scsi_host_template ;struct Scsi_Host ;struct scsi_nl_hdr ; +struct workqueue_struct ;/*
@@ -67,6 +69,7 @@ int scsi_eh_get_sense(struct list_head *extern int scsi_maybe_unblock_host (struct scsi_device *sdev);extern void scsi_device_unbusy (struct scsi_device *sdev);extern int scsi_queue_insert (struct scsi_cmnd *cmd,int reason); +extern void scsi_run_queue (struct request_queue *q);extern void scsi_next_command (struct scsi_cmnd *cmd);extern void scsi_io_completion (struct scsi_cmnd *,unsigned int );extern void scsi_run_host_queues (struct Scsi_Host *shost);
@@ -134,6 +137,41 @@ static inline void scsi_netlink_init(voistatic inline void scsi_netlink_exit (void ) {}#endif +/* scsi_pm.c */ +extern int scsi_bus_suspend (struct device *,pm_message_t ); +extern int scsi_bus_resume (struct device *); +extern int scsi_pm_state_check (struct scsi_device *,struct request *); +extern int scsi_pm_device_stop (struct scsi_device *); +extern int scsi_pm_host_stop (struct Scsi_Host *); +#ifdef CONFIG_SCSI_DYNAMIC_PM +extern void scsi_autosuspend_host (struct Scsi_Host *); +extern int scsi_autoresume_host (struct Scsi_Host *); +extern void scsi_pm_host_initialize (struct Scsi_Host *); +extern void scsi_mark_last_busy (struct scsi_device *); +extern void scsi_use_ULD_pm (struct scsi_device *,int ); +extern void scsi_autosuspend_device (struct scsi_device *); +extern int scsi_autoresume_device (struct scsi_device *); +extern int scsi_pm_create_device_files (struct scsi_device *); +extern void scsi_pm_device_initialize (struct scsi_device *); +extern int scsi_init_pm (void ); +extern void scsi_exit_pm (void ); +#else +static inline void scsi_autosuspend_host (struct Scsi_Host *shost) {} +static inline int scsi_autoresume_host (struct Scsi_Host *shost) + {return 0 ; } +static inline void scsi_pm_host_initialize (struct Scsi_Host *shost) {} +static inline void scsi_mark_last_busy (struct scsi_device *sdev) {} +static inline void scsi_use_ULD_pm (struct scsi_device *sdev,int v) {} +static inline void scsi_autosuspend_device (struct scsi_device *sdev) {} +static inline int scsi_autoresume_device (struct scsi_device *sdev) + {return 0 ; } +static inline int scsi_pm_create_device_files (struct scsi_device *sdev) + {return 0 ; } +static inline void scsi_pm_device_initialize (struct scsi_device *sdev) {} +static inline int scsi_init_pm (void ) {return 0 ; } +static inline void scsi_exit_pm (void ) {} +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +/* * internal scsi timeout functions: for use by mid-layer and transport * classes.
drivers/scsi/scsi_scan.c +2 -0
@@ -297,6 +297,7 @@ static struct scsi_device *scsi_alloc_sdscsi_adjust_queue_depth (sdev,0 , sdev->host->cmd_per_lun);scsi_sysfs_device_initialize (sdev); +scsi_pm_device_initialize (sdev);if (shost->hostt->slave_alloc) { ret = shost->hostt->slave_alloc (sdev);
@@ -1090,6 +1091,7 @@ static int scsi_probe_and_add_lun(struct res =scsi_add_lun (sdev, result, &bflags, shost->async_scan);if (res ==SCSI_SCAN_LUN_PRESENT ) { +scsi_autosuspend_device (sdev);if (bflags &BLIST_KEY ) { sdev->lockable =0 ;scsi_unlock_floptical (sdev, result);
drivers/scsi/scsi_sysfs.c +7 -63
94 lines not on this page · raw message
drivers/scsi/sd.c +10 -0
@@ -61,6 +61,7 @@ #include <scsi/scsicam.h>#include "sd.h" #include "scsi_logging.h" +#include "scsi_priv.h" MODULE_AUTHOR ("Eric Youngdale" );MODULE_DESCRIPTION ("SCSI disk (sd) driver" );
@@ -1815,6 +1816,10 @@ static int sd_probe(struct device *dev)if (error) goto out_put; + error =scsi_autoresume_device (sdp); +if (error) + goto out_put; + error = -EBUSY ;if (index >=SD_MAX_DISKS ) goto out_free_index;
@@ -1880,8 +1885,12 @@ static int sd_probe(struct device *dev)sd_printk (KERN_NOTICE , sdkp,"Attached SCSI %sdisk\n" , sdp->removable ?"removable " :"" ); +scsi_use_ULD_pm (sdp,1 ); +scsi_autosuspend_device (sdp);return 0 ; + out_suspend: +scsi_autosuspend_device (sdp); out_free_index:ida_remove (&sd_index_ida, index); out_put:
@@ -1909,6 +1918,7 @@ static int sd_remove(struct device *dev)device_del (&sdkp->dev);del_gendisk (sdkp->disk); +scsi_use_ULD_pm (sdkp->device,0 );sd_shutdown (dev);mutex_lock (&sd_ref_mutex);
drivers/scsi/sg.c +10 -0
@@ -58,6 +58,7 @@ #include <scsi/scsi_driver.h>#include <scsi/scsi_ioctl.h> #include <scsi/sg.h> +#include "scsi_priv.h" #include "scsi_logging.h" #ifdef CONFIG_SCSI_PROC_FS
@@ -227,6 +228,7 @@ sg_open(struct inode *inode, struct fileSg_fd *sfp;int res;int retval; +int autoresume_rc =1 ;lock_kernel ();nonseekable_open (inode, filp);
@@ -249,6 +251,10 @@ sg_open(struct inode *inode, struct filereturn retval; } + retval = autoresume_rc =scsi_autoresume_device (sdp->device); +if (retval) + goto error_out; +if (!((flags &O_NONBLOCK ) ||scsi_block_when_processing_errors (sdp->device))) { retval = -ENXIO ;
@@ -307,6 +313,8 @@ sg_open(struct inode *inode, struct filereturn 0 ; error_out: +if (autoresume_rc ==0 ) +scsi_autosuspend_device (sdp->device);scsi_device_put (sdp->device);unlock_kernel ();return retval;
@@ -323,6 +331,8 @@ sg_release(struct inode *inode, struct freturn -ENXIO ;SCSI_LOG_TIMEOUT (3 ,printk ("sg_release: %s\n" , sdp->disk->disk_name));sg_fasync (-1 , filp,0 );/* remove filp from async notification list */ +scsi_autosuspend_device (sdp->device); +if (0 ==sg_remove_sfp (sdp, sfp)) {/* Returns 1 when sdp gone */ if (!sdp->detached) {scsi_device_put (sdp->device);
include/scsi/scsi_device.h +21 -2
@@ -36,8 +36,9 @@ enum scsi_device_state {* Only error handler commands allowed */ SDEV_DEL ,/* device deleted * no commands allowed */ -SDEV_QUIESCE ,/* Device quiescent. No block commands -* will be accepted, only specials (which +SDEV_QUIESCE ,/* Device quiescent or suspended. +* No block commands will be accepted, +* only specials (which * originate in the mid-layer) */ SDEV_OFFLINE, /* Device offlined (by error handling or* user request */
@@ -163,6 +164,24 @@ #define SCSI_DEFAULT_DEVICE_BLOCKED 3struct execute_work ew;/* used to get process context on put */ +#ifdef CONFIG_SCSI_DYNAMIC_PM +struct mutex pm_mutex;/* protect PM data & operations */ +struct work_struct autoresume_work; + +unsigned long last_busy;/* time of last use */ +int autosuspend_delay;/* delay in jiffies */ +int pm_usage_cnt;/* usage counter for autosuspend */ + + unsigned is_suspended:1; + unsigned pm_in_progress:1; /* performing suspend or resume */ + unsigned auto_pm:1; /* doing autosuspend or autoresume */ + unsigned autosuspend_disabled:1; /* autosuspend & autoresume */ + unsigned autoresume_disabled:1; /* disabled by the user */ + unsigned skip_sys_resume:1; /* skip the next system resume */ + unsigned use_ULD_pm:1; /* call the Upper-Level Driver's +* suspend/resume methods */ +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +struct scsi_dh_data *scsi_dh_data;enum scsi_device_state sdev_state;unsigned long sdev_data[0 ];
include/scsi/scsi_host.h +5 -0
@@ -659,6 +659,11 @@ struct Scsi_Host {/* ldm bits */ struct device shost_gendev, shost_dev; +#ifdef CONFIG_SCSI_DYNAMIC_PM +struct delayed_work autosuspend_work; + +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +/* * List of hosts per template. *
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 1 line
-ENOPATCH
I was wondering about too little mails in my inbox... Thanks, Rafael!
Pavel
From: Alan Stern <[email protected]>
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.
drivers/scsi/Kconfig +12 -0
@@ -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
drivers/scsi/Makefile +2 -1
@@ -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
drivers/scsi/hosts.c +2 -0
@@ -402,6 +402,8 @@ #endif shost->host_no); shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; +scsi_pm_host_initialize (shost); + shost->ehandler =kthread_run (scsi_error_handler, shost,"scsi_eh_%d" , shost->host_no);if (IS_ERR (shost->ehandler)) {
drivers/scsi/scsi.c +7 -1
@@ -1279,15 +1279,20 @@ static int __init init_scsi(void) error =scsi_init_sysctl ();if (error) goto cleanup_hosts; - error =scsi_sysfs_register (); + error =scsi_init_pm ();if (error) goto cleanup_sysctl; + error =scsi_sysfs_register (); +if (error) + goto cleanup_pm;scsi_netlink_init ();printk (KERN_NOTICE "SCSI subsystem initialized\n" );return 0 ; +cleanup_pm: +scsi_exit_pm (); cleanup_sysctl:scsi_exit_sysctl (); cleanup_hosts:
@@ -1307,6 +1312,7 @@ static void __exit exit_scsi(void) {scsi_netlink_exit ();scsi_sysfs_unregister (); +scsi_exit_pm ();scsi_exit_sysctl ();scsi_exit_hosts ();scsi_exit_devinfo ();
drivers/scsi/scsi_lib.c +4 -3
@@ -67,8 +67,6 @@ #undef SPstruct kmem_cache *scsi_sdb_cache; -static void scsi_run_queue (struct request_queue *q); -/* * Function: scsi_unprep_request() *
@@ -470,6 +468,7 @@ void scsi_device_unbusy(struct scsi_devispin_unlock (shost->host_lock);spin_lock (sdev->request_queue->queue_lock); sdev->device_busy--; +scsi_mark_last_busy (sdev);spin_unlock_irqrestore (sdev->request_queue->queue_lock, flags); }
@@ -531,7 +530,7 @@ static void scsi_single_lun_run(struct s* Notes: The previous command was completely finished, start * a new one if possible. */ -static void scsi_run_queue (struct request_queue *q) +void scsi_run_queue (struct request_queue *q) {struct scsi_device *sdev = q->queuedata;struct Scsi_Host *shost = sdev->host;
@@ -1249,6 +1248,8 @@ int scsi_prep_state_check(struct scsi_de ret =BLKPREP_KILL ;break ;case SDEV_QUIESCE : + ret =scsi_pm_state_check (sdev, req); +break ;case SDEV_BLOCK :/* * If the devices is blocked we defer normal commands.
drivers/scsi/scsi_pm.c new file +742 -0
742 lines not on this page · raw message
drivers/scsi/scsi_priv.h +38 -0
@@ -4,11 +4,13 @@ #define _SCSI_PRIV_H#include <linux/device.h> struct request_queue ; +struct request ;struct scsi_cmnd ;struct scsi_device ;struct scsi_host_template ;struct Scsi_Host ;struct scsi_nl_hdr ; +struct workqueue_struct ;/*
@@ -67,6 +69,7 @@ int scsi_eh_get_sense(struct list_head *extern int scsi_maybe_unblock_host (struct scsi_device *sdev);extern void scsi_device_unbusy (struct scsi_device *sdev);extern int scsi_queue_insert (struct scsi_cmnd *cmd,int reason); +extern void scsi_run_queue (struct request_queue *q);extern void scsi_next_command (struct scsi_cmnd *cmd);extern void scsi_io_completion (struct scsi_cmnd *,unsigned int );extern void scsi_run_host_queues (struct Scsi_Host *shost);
@@ -134,6 +137,41 @@ static inline void scsi_netlink_init(voistatic inline void scsi_netlink_exit (void ) {}#endif +/* scsi_pm.c */ +extern int scsi_bus_suspend (struct device *,pm_message_t ); +extern int scsi_bus_resume (struct device *); +extern int scsi_pm_state_check (struct scsi_device *,struct request *); +extern int scsi_pm_device_stop (struct scsi_device *); +extern int scsi_pm_host_stop (struct Scsi_Host *); +#ifdef CONFIG_SCSI_DYNAMIC_PM +extern void scsi_autosuspend_host (struct Scsi_Host *); +extern int scsi_autoresume_host (struct Scsi_Host *); +extern void scsi_pm_host_initialize (struct Scsi_Host *); +extern void scsi_mark_last_busy (struct scsi_device *); +extern void scsi_use_ULD_pm (struct scsi_device *,int ); +extern void scsi_autosuspend_device (struct scsi_device *); +extern int scsi_autoresume_device (struct scsi_device *); +extern int scsi_pm_create_device_files (struct scsi_device *); +extern void scsi_pm_device_initialize (struct scsi_device *); +extern int scsi_init_pm (void ); +extern void scsi_exit_pm (void ); +#else +static inline void scsi_autosuspend_host (struct Scsi_Host *shost) {} +static inline int scsi_autoresume_host (struct Scsi_Host *shost) + {return 0 ; } +static inline void scsi_pm_host_initialize (struct Scsi_Host *shost) {} +static inline void scsi_mark_last_busy (struct scsi_device *sdev) {} +static inline void scsi_use_ULD_pm (struct scsi_device *sdev,int v) {} +static inline void scsi_autosuspend_device (struct scsi_device *sdev) {} +static inline int scsi_autoresume_device (struct scsi_device *sdev) + {return 0 ; } +static inline int scsi_pm_create_device_files (struct scsi_device *sdev) + {return 0 ; } +static inline void scsi_pm_device_initialize (struct scsi_device *sdev) {} +static inline int scsi_init_pm (void ) {return 0 ; } +static inline void scsi_exit_pm (void ) {} +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +/* * internal scsi timeout functions: for use by mid-layer and transport * classes.
drivers/scsi/scsi_scan.c +2 -0
@@ -297,6 +297,7 @@ static struct scsi_device *scsi_alloc_sdscsi_adjust_queue_depth (sdev,0 , sdev->host->cmd_per_lun);scsi_sysfs_device_initialize (sdev); +scsi_pm_device_initialize (sdev);if (shost->hostt->slave_alloc) { ret = shost->hostt->slave_alloc (sdev);
@@ -1090,6 +1091,7 @@ static int scsi_probe_and_add_lun(struct res =scsi_add_lun (sdev, result, &bflags, shost->async_scan);if (res ==SCSI_SCAN_LUN_PRESENT ) { +scsi_autosuspend_device (sdev);if (bflags &BLIST_KEY ) { sdev->lockable =0 ;scsi_unlock_floptical (sdev, result);
drivers/scsi/scsi_sysfs.c +7 -63
94 lines not on this page · raw message
drivers/scsi/sd.c +10 -0
@@ -61,6 +61,7 @@ #include <scsi/scsicam.h>#include "sd.h" #include "scsi_logging.h" +#include "scsi_priv.h" MODULE_AUTHOR ("Eric Youngdale" );MODULE_DESCRIPTION ("SCSI disk (sd) driver" );
@@ -1815,6 +1816,10 @@ static int sd_probe(struct device *dev)if (error) goto out_put; + error =scsi_autoresume_device (sdp); +if (error) + goto out_put; + error = -EBUSY ;if (index >=SD_MAX_DISKS ) goto out_free_index;
@@ -1880,8 +1885,12 @@ static int sd_probe(struct device *dev)sd_printk (KERN_NOTICE , sdkp,"Attached SCSI %sdisk\n" , sdp->removable ?"removable " :"" ); +scsi_use_ULD_pm (sdp,1 ); +scsi_autosuspend_device (sdp);return 0 ; + out_suspend: +scsi_autosuspend_device (sdp); out_free_index:ida_remove (&sd_index_ida, index); out_put:
@@ -1909,6 +1918,7 @@ static int sd_remove(struct device *dev)device_del (&sdkp->dev);del_gendisk (sdkp->disk); +scsi_use_ULD_pm (sdkp->device,0 );sd_shutdown (dev);mutex_lock (&sd_ref_mutex);
drivers/scsi/sg.c +10 -0
@@ -58,6 +58,7 @@ #include <scsi/scsi_driver.h>#include <scsi/scsi_ioctl.h> #include <scsi/sg.h> +#include "scsi_priv.h" #include "scsi_logging.h" #ifdef CONFIG_SCSI_PROC_FS
@@ -227,6 +228,7 @@ sg_open(struct inode *inode, struct fileSg_fd *sfp;int res;int retval; +int autoresume_rc =1 ;lock_kernel ();nonseekable_open (inode, filp);
@@ -249,6 +251,10 @@ sg_open(struct inode *inode, struct filereturn retval; } + retval = autoresume_rc =scsi_autoresume_device (sdp->device); +if (retval) + goto error_out; +if (!((flags &O_NONBLOCK ) ||scsi_block_when_processing_errors (sdp->device))) { retval = -ENXIO ;
@@ -307,6 +313,8 @@ sg_open(struct inode *inode, struct filereturn 0 ; error_out: +if (autoresume_rc ==0 ) +scsi_autosuspend_device (sdp->device);scsi_device_put (sdp->device);unlock_kernel ();return retval;
@@ -323,6 +331,8 @@ sg_release(struct inode *inode, struct freturn -ENXIO ;SCSI_LOG_TIMEOUT (3 ,printk ("sg_release: %s\n" , sdp->disk->disk_name));sg_fasync (-1 , filp,0 );/* remove filp from async notification list */ +scsi_autosuspend_device (sdp->device); +if (0 ==sg_remove_sfp (sdp, sfp)) {/* Returns 1 when sdp gone */ if (!sdp->detached) {scsi_device_put (sdp->device);
include/scsi/scsi_device.h +21 -2
@@ -36,8 +36,9 @@ enum scsi_device_state {* Only error handler commands allowed */ SDEV_DEL ,/* device deleted * no commands allowed */ -SDEV_QUIESCE ,/* Device quiescent. No block commands -* will be accepted, only specials (which +SDEV_QUIESCE ,/* Device quiescent or suspended. +* No block commands will be accepted, +* only specials (which * originate in the mid-layer) */ SDEV_OFFLINE, /* Device offlined (by error handling or* user request */
@@ -163,6 +164,24 @@ #define SCSI_DEFAULT_DEVICE_BLOCKED 3struct execute_work ew;/* used to get process context on put */ +#ifdef CONFIG_SCSI_DYNAMIC_PM +struct mutex pm_mutex;/* protect PM data & operations */ +struct work_struct autoresume_work; + +unsigned long last_busy;/* time of last use */ +int autosuspend_delay;/* delay in jiffies */ +int pm_usage_cnt;/* usage counter for autosuspend */ + + unsigned is_suspended:1; + unsigned pm_in_progress:1; /* performing suspend or resume */ + unsigned auto_pm:1; /* doing autosuspend or autoresume */ + unsigned autosuspend_disabled:1; /* autosuspend & autoresume */ + unsigned autoresume_disabled:1; /* disabled by the user */ + unsigned skip_sys_resume:1; /* skip the next system resume */ + unsigned use_ULD_pm:1; /* call the Upper-Level Driver's +* suspend/resume methods */ +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +struct scsi_dh_data *scsi_dh_data;enum scsi_device_state sdev_state;unsigned long sdev_data[0 ];
include/scsi/scsi_host.h +5 -0
@@ -659,6 +659,11 @@ struct Scsi_Host {/* ldm bits */ struct device shost_gendev, shost_dev; +#ifdef CONFIG_SCSI_DYNAMIC_PM +struct delayed_work autosuspend_work; + +#endif /* CONFIG_SCSI_DYNAMIC_PM */ +/* * List of hosts per template. *
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Am Montag 25 August 2008 10:19:01 schrieb Pavel Machek:
Quoted 11 lines
From: Alan Stern <[email protected]>
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 <[email protected]>
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
Am Montag 25 August 2008 10:19:01 schrieb Pavel Machek:
Quoted 11 lines
From: Alan Stern <[email protected]>
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 <[email protected]>
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
Quoted 9 lines · Pavel Machek
From: Alan Stern <[email protected]>
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.
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
Quoted 9 lines · Pavel Machek
From: Alan Stern <[email protected]>
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.
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
Quoted 11 lines · Oliver Neukum
Am Montag 25 August 2008 10:19:01 schrieb Pavel Machek:
Quoted 10 lines
From: Alan Stern <[email protected]>
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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Pavel Machek <[email protected]>Hi,
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
Quoted 2 lines
Secondly, it is simply not true that in SCSI suspending the disks is always necessary before suspending the controller.
Ok, will fix the changelog... but it is still true at least for USB controllers.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Tino Keitel
Quoted 9 lines · Pavel Machek
From: Alan Stern <[email protected]>
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.
Quoted 5 lines
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?
Correct. That is the plan for the next patch, when I get this one into reasonable form for acceptance.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Oliver Neukum
Am Montag 25 August 2008 10:19:01 schrieb Pavel Machek:
Quoted 10 lines
From: Alan Stern <[email protected]>
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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Pavel Machek <[email protected]>Hi,
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
Quoted 2 lines
Secondly, it is simply not true that in SCSI suspending the disks is always necessary before suspending the controller.
Ok, will fix the changelog... but it is still true at least for USB controllers.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Tino Keitel
Quoted 9 lines · Pavel Machek
From: Alan Stern <[email protected]>
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.
Quoted 5 lines
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?
Correct. That is the plan for the next patch, when I get this one into reasonable form for acceptance.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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
Quoted 9 lines · Oliver Neukum
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 9 lines · Oliver Neukum
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Am Donnerstag 28 August 2008 10:04:27 schrieb Pavel Machek:
Quoted 7 lines · Oliver Neukum
Quoted 6 lines
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
Quoted 8 lines
Quoted 3 lines
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
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)
Am Donnerstag 28 August 2008 10:04:27 schrieb Pavel Machek:
Quoted 7 lines · Oliver Neukum
Quoted 6 lines
Am Dienstag 26 August 2008 11:43:55 schrieb Pavel Machek:
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
Quoted 8 lines
Quoted 3 lines
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
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)
Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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.
Quoted 7 lines
Quoted 4 lines
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
I am afraid this is not true.
I guess you are right.
Quoted 4 lines
/**
*scsi_block_when_processing_errors- Prevent cmds from being queued.
* @sdev: Device on which we are performing recovery.
*
Quoted 8 lines
* 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.
*/
intscsi_block_when_processing_errors(struct scsi_device *sdev)
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
drivers/scsi/scsi_pm.c +4 -0
@@ -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 scsiif (!(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 ;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
firstly, it doesn't consider error handling before suspending.
What problems do you see with error handling? This patch does not touch the error handling, and I do not think it needs to touch it.
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.
Quoted 7 lines
Quoted 4 lines
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
I am afraid this is not true.
I guess you are right.
Quoted 4 lines
/**
*scsi_block_when_processing_errors- Prevent cmds from being queued.
* @sdev: Device on which we are performing recovery.
*
Quoted 8 lines
* 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.
*/
intscsi_block_when_processing_errors(struct scsi_device *sdev)
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
drivers/scsi/scsi_pm.c +4 -0
@@ -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 scsiif (!(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 ;
Signature · 2 lines
(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:
Hello!
Quoted 14 lines
Quoted 4 lines
/**
*scsi_block_when_processing_errors- Prevent cmds from being queued.
* @sdev: Device on which we are performing recovery.
*Quoted 8 lines
* 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.
*/
intscsi_block_when_processing_errors(struct scsi_device *sdev)
Quoted 1 line
Hmm,
scsi_block_when_function, which does not _block_, and returns
/**
* 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;
}Quoted 18 lines
inverted values from what would people expect.
...but this should fix it, no? [incremental to previous]
Paveldrivers/scsi/scsi_pm.c +1
-0@@ -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>
drivers/scsi/scsi_pm.c static int autosuspend_check(struct scsi · line 133
Quoted 5 lines
drivers/scsi/scsi_pm.c +2
-0@@ -128,8 +129,11 @@ static int autosuspend_check(struct scsiif (!(sdev->sdev_state ==SDEV_RUNNING || sdev->sdev_state ==SDEV_QUIESCE ))return -ENODEV ; +if (!scsi_block_when_processing_errors (sdev)) +return -EBUSY ;
Why this? It seems to me for purpose of autosuspend an offlined device should be totally ignored.
Regards
Oliver
Am Dienstag 02 September 2008 11:08:00 schrieb Pavel Machek:
Hello!
Quoted 14 lines
Quoted 4 lines
/**
*scsi_block_when_processing_errors- Prevent cmds from being queued.
* @sdev: Device on which we are performing recovery.
*Quoted 8 lines
* 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.
*/
intscsi_block_when_processing_errors(struct scsi_device *sdev)
Quoted 1 line
Hmm,
scsi_block_when_function, which does not _block_, and returns
/**
* 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;
}Quoted 18 lines
inverted values from what would people expect.
...but this should fix it, no? [incremental to previous]
Paveldrivers/scsi/scsi_pm.c +1
-0@@ -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>
drivers/scsi/scsi_pm.c static int autosuspend_check(struct scsi · line 133
Quoted 5 lines
drivers/scsi/scsi_pm.c +2
-0@@ -128,8 +129,11 @@ static int autosuspend_check(struct scsiif (!(sdev->sdev_state ==SDEV_RUNNING || sdev->sdev_state ==SDEV_QUIESCE ))return -ENODEV ; +if (!scsi_block_when_processing_errors (sdev)) +return -EBUSY ;
Why this? It seems to me for purpose of autosuspend an offlined device should be totally ignored.
Regards
Oliver
Quoted 31 lines · Pavel Machek
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
I am afraid this is not true.
I guess you are right.
...but this should fix it, no? [incremental to previous]
Paveldrivers/scsi/scsi_pm.c +1
-0@@ -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 ||
drivers/scsi/scsi_pm.c static int autosuspend_check(struct scsi · line 139
Quoted 10 lines
drivers/scsi/scsi_pm.c +3
-0sdev->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 ;
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
Quoted 31 lines · Pavel Machek
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
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.
Well, they have to handle other commands while bus has problems, anyway, right? So I'm not creating any _new_ problems for them.
Pavel
I am afraid this is not true.
I guess you are right.
...but this should fix it, no? [incremental to previous]
Paveldrivers/scsi/scsi_pm.c +1
-0@@ -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 ||
drivers/scsi/scsi_pm.c static int autosuspend_check(struct scsi · line 139
Quoted 10 lines
drivers/scsi/scsi_pm.c +3
-0sdev->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 ;
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