This is a note to let you know that I've just added the patch titled
Subject: [PATCH 2/2] usb-storage: implement autosuspend
to my gregkh-2.6 tree. Its filename is
usb-storage-implement-autosuspend.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From [email protected] Fri Jul 6 11:24:35 2007
From: Alan Stern <[email protected]>
Date: Fri, 6 Jul 2007 14:24:27 -0400 (EDT)
Subject: [PATCH 2/2] usb-storage: implement autosuspend
To: Greg KH <[email protected]>
Cc: Matthew Dharm <[email protected]>, Oliver Neukum <[email protected]>, USB Storage list <[email protected]>, USB development list <[email protected]>
Message-ID: <[email protected]>
This patch (as930) implements autosuspend for usb-storage. It is
adapted from a patch by Oliver Neukum. Autosuspend is allowed except
during LUN scanning, resets, and command execution.
Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/usb/storage/scsiglue.c | 13 +++++++++----
drivers/usb/storage/usb.c | 27 ++++++++++++++++++++-------
2 files changed, 29 insertions(+), 11 deletions(-)
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -285,10 +285,15 @@ static int device_reset(struct scsi_cmnd
US_DEBUGP("%s called\n", __FUNCTION__);
- /* lock the device pointers and do the reset */
- mutex_lock(&(us->dev_mutex));
- result = us->transport_reset(us);
- mutex_unlock(&us->dev_mutex);
+ result = usb_autopm_get_interface(us->pusb_intf);
+ if (result == 0) {
+
+ /* lock the device pointers and do the reset */
+ mutex_lock(&(us->dev_mutex));
+ result = us->transport_reset(us);
+ mutex_unlock(&us->dev_mutex);
+ usb_autopm_put_interface(us->pusb_intf);
+ }
return result < 0 ? FAILED : SUCCESS;
}
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -191,16 +191,14 @@ static int storage_suspend(struct usb_in
{
struct us_data *us = usb_get_intfdata(iface);
+ US_DEBUGP("%s\n", __FUNCTION__);
+
/* Wait until no command is running */
mutex_lock(&us->dev_mutex);
- US_DEBUGP("%s\n", __FUNCTION__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_SUSPEND);
- /* When runtime PM is working, we'll set a flag to indicate
- * whether we should autoresume when a SCSI request arrives. */
-
mutex_unlock(&us->dev_mutex);
return 0;
}
@@ -209,13 +207,11 @@ static int storage_resume(struct usb_int
{
struct us_data *us = usb_get_intfdata(iface);
- mutex_lock(&us->dev_mutex);
-
US_DEBUGP("%s\n", __FUNCTION__);
+
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_RESUME);
- mutex_unlock(&us->dev_mutex);
return 0;
}
@@ -313,6 +309,7 @@ static int usb_stor_control_thread(void
{
struct us_data *us = (struct us_data *)__us;
struct Scsi_Host *host = us_to_host(us);
+ int autopm_rc;
current->flags |= PF_NOFREEZE;
@@ -323,6 +320,9 @@ static int usb_stor_control_thread(void
US_DEBUGP("*** thread awakened.\n");
+ /* Autoresume the device */
+ autopm_rc = usb_autopm_get_interface_burst(us->pusb_intf);
+
/* lock the device pointers */
mutex_lock(&(us->dev_mutex));
@@ -381,6 +381,12 @@ static int usb_stor_control_thread(void
us->srb->result = SAM_STAT_GOOD;
}
+ /* Did the autoresume fail? */
+ else if (autopm_rc < 0) {
+ US_DEBUGP("Could not wake device\n");
+ us->srb->result = DID_ERROR << 16;
+ }
+
/* we've got a command, let's do it! */
else {
US_DEBUG(usb_stor_show_command(us->srb));
@@ -423,6 +429,10 @@ SkipForAbort:
/* unlock the device pointers */
mutex_unlock(&us->dev_mutex);
+
+ /* Start an autosuspend */
+ if (autopm_rc == 0)
+ usb_autopm_put_interface(us->pusb_intf);
} /* for (;;) */
/* Wait until we are told to stop */
@@ -939,6 +949,7 @@ retry:
}
scsi_host_put(us_to_host(us));
+ usb_autopm_put_interface(us->pusb_intf);
complete_and_exit(&threads_gone, 0);
}
@@ -1028,6 +1039,7 @@ static int storage_probe(struct usb_inte
* start it up. */
scsi_host_get(us_to_host(us));
atomic_inc(&total_threads);
+ usb_autopm_get_interface(intf); /* dropped in the scanning thread */
wake_up_process(th);
return 0;
@@ -1065,6 +1077,7 @@ static struct usb_driver usb_storage_dri
.pre_reset = storage_pre_reset,
.post_reset = storage_post_reset,
.id_table = storage_usb_ids,
+ .supports_autosuspend = 1,
};
static int __init usb_stor_init(void)
Patches currently in gregkh-2.6 which might be from [email protected] are
driver/sysfs-implement-sysfs_find_dirent-and-sysfs_get_dirent.patch
driver/sysfs-use-sysfs_mutex-to-protect-the-sysfs_dirent-tree.patch
driver/pm-remove-pm_parent-from-struct-dev_pm_info.patch
driver/pm-remove-saved_state-from-struct-dev_pm_info.patch
driver/pm-simplify-suspend_device.patch
driver/sysfs-consolidate-sysfs-spinlocks.patch
driver/sysfs-implement-sysfs_flag_removed-flag.patch
driver/sysfs-implement-sysfs_get_dentry.patch
driver/sysfs-make-directory-dentries-and-inodes-reclaimable.patch
driver/sysfs-make-kobj-point-to-sysfs_dirent-instead-of-dentry.patch
driver/sysfs-make-sysfs_drop_dentry-access-inodes-using-ilookup.patch
driver/sysfs-move-sysfs_drop_dentry-to-dir.c-and-make-it-static.patch
driver/sysfs-rename-sysfs_dirent-s_type-to-s_flags-and-make-room-for-flags.patch
driver/sysfs-restructure-add-remove-paths-and-fix-inode-update.patch
driver/pm-remove-prev_state-from-struct-dev_pm_info.patch
driver/pm-do-not-check-parent-state-in-suspend-and-resume-core-code.patch
driver/pm-remove-power_state.event-checks-from-suspend-core-code.patch
usb/usb-add-usb-persist-facility.patch
usb/usb-core-hub.c-prevent-re-enumeration-on-hnp.patch
usb/usb-add-reset_resume-device-quirk.patch
usb/usb-don-t-unsuspend-for-a-new-connection.patch
usb/usb-implement-pm-freeze-and-prethaw.patch
usb/usb-add-usb_autopm_get_interface_burst.patch
usb/usb-disable-file_storage-usb_config_att_wakeup.patch
usb/usb-interface-pm-state.patch
usb/usb-make-hub-driver-s-release-more-robust.patch
usb/usb-move-bus_suspend-and-bus_resume-method-calls.patch
usb/usb-remove-locktree-routine-from-the-hub-driver.patch
usb/usb-remove-references-to-dev.power.power_state.patch
usb/usb-make-device-reset-stop-retrying-after-disconnect.patch
usb/usb-add-power-persist-device-attribute.patch
usb/usb-add-reset_resume-method.patch
usb/usb-remove-__usb_port_suspend.patch
usb/usb-remove-excess-code-from-hub.c.patch
usb/usb-separate-root-and-non-root-suspend-resume.patch
usb/usb-unify-reset_resume-and-normal-resume.patch
usb/usb-add-usb_device_and_interface_info-for-device-matching.patch
usb/usb-ehci-fix-handover-for-designated-full-speed-ports.patch
usb/usb-ehci-ohci-handover-changes.patch
usb/usb-option-fix-usage-of-urb-status-abuse.patch
usb/usb-prevent-char-device-open-deregister-race.patch
usb/usb-rework-c-style-comments.patch
usb/usb-usb-storage-use-kthread_stop-for-the-control-thread.patch
usb/usb-handle-bogus-low-speed-bulk-endpoints.patch
usb/usb-don-t-resume-root-hub-if-the-controller-is-suspended.patch
usb/usb-fix-off-by-1-error-in-the-scatter-gather-library.patch
usb/usb-fix-up-full-speed-binterval-values-in-high-speed-interrupt-descriptor.patch
usb/usb-remove-usages-of-dev-power.power_state.patch
usb/usb-drivers-usb-storage-unusual_devs.h-whitespace-cleanup.patch
usb/usb-storage-implement-autosuspend.patch
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.