Hi Alan,

here's a simple implementation to handle ioctl() by blocking
autosuspend until the device is closed again.

It is relative to your patch set.

Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>

----

--- linux-as/drivers/scsi/sd.c  2008-01-15 14:17:05.000000000 +0100
+++ linux-2.6.24-scsi-pm/drivers/scsi/sd.c      2008-01-15 14:20:13.000000000 
+0100
@@ -633,6 +633,13 @@ static int sd_release(struct inode *inod
                        scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
        }
 
+#ifdef CONFIG_SCSI_DYNAMIC_PM
+       if (sdev->autosuspend_ioctl_blocked) {
+               sdev->autosuspend_ioctl_blocked = 0;
+               scsi_autosuspend_device(sdev);
+       }
+#endif
+
        /*
         * XXX and what if there are packets in flight and this close()
         * XXX is followed by a "rmmod sd_mod"?
@@ -711,6 +718,19 @@ static int sd_ioctl(struct inode * inode
                case SCSI_IOCTL_GET_BUS_NUMBER:
                        return scsi_ioctl(sdp, cmd, p);
                default:
+                       /* closer filtering should go here */
+#ifdef CONFIG_SCSI_DYNAMIC_PM
+                       if (!sdp->autosuspend_ioctl_blocked) {
+                               error = scsi_autoresume_device(sdp);
+                               if (error < 0)
+                                       return error;
+                               /* check for lost race due to drop of BKL */
+                               if (sdp->autosuspend_ioctl_blocked)
+                                       scsi_autosuspend_device(sdp);
+                               else
+                                       sdp->autosuspend_ioctl_blocked = 1;
+                       }
+#endif
                        error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p);
                        if (error != -ENOTTY)
                                return error;
--- linux-as/include/scsi/scsi_device.h 2008-01-15 14:17:05.000000000 +0100
+++ linux-2.6.24-scsi-pm/include/scsi/scsi_device.h     2008-01-14 
12:45:12.000000000 +0100
@@ -177,6 +177,7 @@ struct scsi_device {
        unsigned auto_pm:1;             /* doing autosuspend or autoresume */
        unsigned autosuspend_disabled:1;        /* autosuspend & autoresume */
        unsigned autoresume_disabled:1;         /*  disabled by the user */
+       unsigned autosuspend_ioctl_blocked:1;   /* disabled due to ioctl use */
        unsigned skip_sys_resume:1;     /* skip the next system resume */
        unsigned use_ULD_pm:1;          /* call the Upper-Level Driver's
                                         *   suspend/resume methods */
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to