* [PATCH] usb-storage: implement autosuspend
@ 2010-07-28 21:12 Alan Stern
2010-07-28 21:16 ` James Bottomley
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Alan Stern @ 2010-07-28 21:12 UTC (permalink / raw)
To: James Bottomley, Greg KH
Cc: Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
This patch (as1400) adds runtime-PM support to usb-storage. It
utilizes the SCSI layer's runtime-PM implementation, so its scope is
limited. Currently the only effect is that disk-like devices (such as
card readers or flash drives) will be autosuspended if they aren't
mounted and their device files aren't open. This would apply, for
example, to card readers that don't contain a memory card.
Unfortunately this won't interact very well with the removable-media
polling normally carried out by hal or DeviceKit. Maybe those
programs can be changed to use a longer polling interval, or maybe the
default autosuspend time for usb-storage should be set to something
below 1 second.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
Now that the SCSI runtime-PM patches have been accepted for the
upcoming merge window, it's time to make use of the new mechanism in
usb-storage. That's what this does.
Because this patch depends on those SCSI changes, either it should also
go via James's tree or else the SCSI patches should be imported into
Greg's tree first. James and Greg, which route is easier for you?
Alan Stern
Index: usb-2.6/drivers/usb/storage/usb.c
===================================================================
--- usb-2.6.orig/drivers/usb/storage/usb.c
+++ usb-2.6/drivers/usb/storage/usb.c
@@ -336,6 +336,7 @@ static int usb_stor_control_thread(void
else {
US_DEBUG(usb_stor_show_command(us->srb));
us->proto_handler(us->srb, us);
+ usb_mark_last_busy(us->pusb_dev);
}
/* lock access to the state */
@@ -845,6 +846,7 @@ static int usb_stor_scan_thread(void * _
/* Should we unbind if no devices were detected? */
}
+ usb_autopm_put_interface(us->pusb_intf);
complete_and_exit(&us->scanning_done, 0);
}
@@ -968,6 +970,7 @@ int usb_stor_probe2(struct us_data *us)
goto BadDevice;
}
+ usb_autopm_get_interface_no_resume(us->pusb_intf);
wake_up_process(th);
return 0;
@@ -1040,6 +1043,7 @@ static struct usb_driver usb_storage_dri
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
.id_table = usb_storage_usb_ids,
+ .supports_autosuspend = 1,
.soft_unbind = 1,
};
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:12 [PATCH] usb-storage: implement autosuspend Alan Stern
@ 2010-07-28 21:16 ` James Bottomley
2010-07-28 21:25 ` Greg KH
2010-08-02 14:36 ` Oliver Neukum
2010-08-02 23:47 ` patch "USB: usb-storage: implement autosuspend" added to gregkh-2.6 tree gregkh
2 siblings, 1 reply; 12+ messages in thread
From: James Bottomley @ 2010-07-28 21:16 UTC (permalink / raw)
To: Alan Stern
Cc: Greg KH, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> Because this patch depends on those SCSI changes, either it should also
> go via James's tree or else the SCSI patches should be imported into
> Greg's tree first. James and Greg, which route is easier for you?
They're USB patches, so they should be in a USB tree. Just do a
standard postmerge tree based on SCSI.
James
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:16 ` James Bottomley
@ 2010-07-28 21:25 ` Greg KH
2010-07-28 21:29 ` James Bottomley
0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2010-07-28 21:25 UTC (permalink / raw)
To: James Bottomley
Cc: Alan Stern, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, Jul 28, 2010 at 09:16:25PM +0000, James Bottomley wrote:
> On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> > Because this patch depends on those SCSI changes, either it should also
> > go via James's tree or else the SCSI patches should be imported into
> > Greg's tree first. James and Greg, which route is easier for you?
>
> They're USB patches, so they should be in a USB tree. Just do a
> standard postmerge tree based on SCSI.
Yeah, but then for now my tree will not build on its own, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:25 ` Greg KH
@ 2010-07-28 21:29 ` James Bottomley
2010-07-28 21:35 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: James Bottomley @ 2010-07-28 21:29 UTC (permalink / raw)
To: Greg KH
Cc: Alan Stern, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, 2010-07-28 at 14:25 -0700, Greg KH wrote:
> On Wed, Jul 28, 2010 at 09:16:25PM +0000, James Bottomley wrote:
> > On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> > > Because this patch depends on those SCSI changes, either it should also
> > > go via James's tree or else the SCSI patches should be imported into
> > > Greg's tree first. James and Greg, which route is easier for you?
> >
> > They're USB patches, so they should be in a USB tree. Just do a
> > standard postmerge tree based on SCSI.
>
> Yeah, but then for now my tree will not build on its own, right?
Yes it will: a postmerge tree contains a buildable merge base and the
additional patches. You can see how this is done at
http://git.kernel.org/?p=linux/kernel/git/jejb/scsi-post-merge-2.6.git
Which contains the ibft tree and scsi-misc as the merge base then has
be2iscsi patches that depend on both. The tree is individually
buildable and linux-next only pulls in from merge-base to the top (have
to make sure it's included after all the other trees, though).
James
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:29 ` James Bottomley
@ 2010-07-28 21:35 ` Greg KH
2010-07-28 22:56 ` James Bottomley
0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2010-07-28 21:35 UTC (permalink / raw)
To: James Bottomley
Cc: Alan Stern, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, Jul 28, 2010 at 04:29:42PM -0500, James Bottomley wrote:
> On Wed, 2010-07-28 at 14:25 -0700, Greg KH wrote:
> > On Wed, Jul 28, 2010 at 09:16:25PM +0000, James Bottomley wrote:
> > > On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> > > > Because this patch depends on those SCSI changes, either it should also
> > > > go via James's tree or else the SCSI patches should be imported into
> > > > Greg's tree first. James and Greg, which route is easier for you?
> > >
> > > They're USB patches, so they should be in a USB tree. Just do a
> > > standard postmerge tree based on SCSI.
> >
> > Yeah, but then for now my tree will not build on its own, right?
>
> Yes it will: a postmerge tree contains a buildable merge base and the
> additional patches. You can see how this is done at
>
> http://git.kernel.org/?p=linux/kernel/git/jejb/scsi-post-merge-2.6.git
>
> Which contains the ibft tree and scsi-misc as the merge base then has
> be2iscsi patches that depend on both. The tree is individually
> buildable and linux-next only pulls in from merge-base to the top (have
> to make sure it's included after all the other trees, though).
I think you forgot that I use quilt for my trees :)
thanks,
greg "old-skool" k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:35 ` Greg KH
@ 2010-07-28 22:56 ` James Bottomley
2010-07-28 23:09 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: James Bottomley @ 2010-07-28 22:56 UTC (permalink / raw)
To: Greg KH
Cc: Alan Stern, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, 2010-07-28 at 14:35 -0700, Greg KH wrote:
> On Wed, Jul 28, 2010 at 04:29:42PM -0500, James Bottomley wrote:
> > On Wed, 2010-07-28 at 14:25 -0700, Greg KH wrote:
> > > On Wed, Jul 28, 2010 at 09:16:25PM +0000, James Bottomley wrote:
> > > > On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> > > > > Because this patch depends on those SCSI changes, either it should also
> > > > > go via James's tree or else the SCSI patches should be imported into
> > > > > Greg's tree first. James and Greg, which route is easier for you?
> > > >
> > > > They're USB patches, so they should be in a USB tree. Just do a
> > > > standard postmerge tree based on SCSI.
> > >
> > > Yeah, but then for now my tree will not build on its own, right?
> >
> > Yes it will: a postmerge tree contains a buildable merge base and the
> > additional patches. You can see how this is done at
> >
> > http://git.kernel.org/?p=linux/kernel/git/jejb/scsi-post-merge-2.6.git
> >
> > Which contains the ibft tree and scsi-misc as the merge base then has
> > be2iscsi patches that depend on both. The tree is individually
> > buildable and linux-next only pulls in from merge-base to the top (have
> > to make sure it's included after all the other trees, though).
>
> I think you forgot that I use quilt for my trees :)
There is a way of doing this in quilt. I think you checkout my tree,
add the patch and some type of annotation for the top so linux-next
knows when to pull it in.
You just want me to put it in my tree, don't you ... ?
James
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 22:56 ` James Bottomley
@ 2010-07-28 23:09 ` Greg KH
2010-07-29 14:14 ` Alan Stern
0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2010-07-28 23:09 UTC (permalink / raw)
To: James Bottomley
Cc: Alan Stern, Matthew Dharm, Oliver Neukum, SCSI development list,
USB Storage list
On Wed, Jul 28, 2010 at 05:56:52PM -0500, James Bottomley wrote:
> On Wed, 2010-07-28 at 14:35 -0700, Greg KH wrote:
> > On Wed, Jul 28, 2010 at 04:29:42PM -0500, James Bottomley wrote:
> > > On Wed, 2010-07-28 at 14:25 -0700, Greg KH wrote:
> > > > On Wed, Jul 28, 2010 at 09:16:25PM +0000, James Bottomley wrote:
> > > > > On Wed, 2010-07-28 at 17:12 -0400, Alan Stern wrote:
> > > > > > Because this patch depends on those SCSI changes, either it should also
> > > > > > go via James's tree or else the SCSI patches should be imported into
> > > > > > Greg's tree first. James and Greg, which route is easier for you?
> > > > >
> > > > > They're USB patches, so they should be in a USB tree. Just do a
> > > > > standard postmerge tree based on SCSI.
> > > >
> > > > Yeah, but then for now my tree will not build on its own, right?
> > >
> > > Yes it will: a postmerge tree contains a buildable merge base and the
> > > additional patches. You can see how this is done at
> > >
> > > http://git.kernel.org/?p=linux/kernel/git/jejb/scsi-post-merge-2.6.git
> > >
> > > Which contains the ibft tree and scsi-misc as the merge base then has
> > > be2iscsi patches that depend on both. The tree is individually
> > > buildable and linux-next only pulls in from merge-base to the top (have
> > > to make sure it's included after all the other trees, though).
> >
> > I think you forgot that I use quilt for my trees :)
>
> There is a way of doing this in quilt. I think you checkout my tree,
> add the patch and some type of annotation for the top so linux-next
> knows when to pull it in.
Yeah, there is a way, but it's a major pain and a divergant way of
handling my tree from what I do today :(
> You just want me to put it in my tree, don't you ... ?
I do :)
Please add an:
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
to it and have fun :)
If you really don't want to, just let me know and I'll handle it and the
merge issues myself, that's what the subsystem maintainer is for...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 23:09 ` Greg KH
@ 2010-07-29 14:14 ` Alan Stern
2010-07-29 14:19 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: Alan Stern @ 2010-07-29 14:14 UTC (permalink / raw)
To: Greg KH
Cc: James Bottomley, Matthew Dharm, Oliver Neukum,
SCSI development list, USB Storage list
On Wed, 28 Jul 2010, Greg KH wrote:
> > > I think you forgot that I use quilt for my trees :)
> >
> > There is a way of doing this in quilt. I think you checkout my tree,
> > add the patch and some type of annotation for the top so linux-next
> > knows when to pull it in.
>
> Yeah, there is a way, but it's a major pain and a divergant way of
> handling my tree from what I do today :(
>
> > You just want me to put it in my tree, don't you ... ?
>
> I do :)
>
> Please add an:
> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> to it and have fun :)
>
> If you really don't want to, just let me know and I'll handle it and the
> merge issues myself, that's what the subsystem maintainer is for...
If James is willing to take the patch, that's fine.
If not, it can go into Greg's tree without any serious effect. The
nice thing about this patch is that it will build okay without the
SCSI changes -- it just won't work properly if autosuspend is enabled
for a usb-storage device. Since the default is to leave autosuspend
disabled, people won't get into trouble unless they deliberately try
to.
Alan Stern
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-29 14:14 ` Alan Stern
@ 2010-07-29 14:19 ` Greg KH
0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-07-29 14:19 UTC (permalink / raw)
To: Alan Stern
Cc: James Bottomley, Matthew Dharm, Oliver Neukum,
SCSI development list, USB Storage list
On Thu, Jul 29, 2010 at 10:14:45AM -0400, Alan Stern wrote:
> On Wed, 28 Jul 2010, Greg KH wrote:
>
> > > > I think you forgot that I use quilt for my trees :)
> > >
> > > There is a way of doing this in quilt. I think you checkout my tree,
> > > add the patch and some type of annotation for the top so linux-next
> > > knows when to pull it in.
> >
> > Yeah, there is a way, but it's a major pain and a divergant way of
> > handling my tree from what I do today :(
> >
> > > You just want me to put it in my tree, don't you ... ?
> >
> > I do :)
> >
> > Please add an:
> > Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> > to it and have fun :)
> >
> > If you really don't want to, just let me know and I'll handle it and the
> > merge issues myself, that's what the subsystem maintainer is for...
>
> If James is willing to take the patch, that's fine.
>
> If not, it can go into Greg's tree without any serious effect. The
> nice thing about this patch is that it will build okay without the
> SCSI changes -- it just won't work properly if autosuspend is enabled
> for a usb-storage device. Since the default is to leave autosuspend
> disabled, people won't get into trouble unless they deliberately try
> to.
Ah, I thought it would break my build. Ok, I'll take it then, James,
don't worry about it.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-07-28 21:12 [PATCH] usb-storage: implement autosuspend Alan Stern
2010-07-28 21:16 ` James Bottomley
@ 2010-08-02 14:36 ` Oliver Neukum
2010-08-02 15:07 ` Alan Stern
2010-08-02 23:47 ` patch "USB: usb-storage: implement autosuspend" added to gregkh-2.6 tree gregkh
2 siblings, 1 reply; 12+ messages in thread
From: Oliver Neukum @ 2010-08-02 14:36 UTC (permalink / raw)
To: Alan Stern
Cc: James Bottomley, Greg KH, Matthew Dharm, SCSI development list,
USB Storage list
Am Mittwoch, 28. Juli 2010, 23:12:39 schrieb Alan Stern:
>
> This patch (as1400) adds runtime-PM support to usb-storage. It
> utilizes the SCSI layer's runtime-PM implementation, so its scope is
> limited. Currently the only effect is that disk-like devices (such as
> card readers or flash drives) will be autosuspended if they aren't
> mounted and their device files aren't open. This would apply, for
> example, to card readers that don't contain a memory card.
So it will autosuspend devices that do contain a medium, which
is not mounted? This is a bit problematic, as some card readers
will report a medium change upon resumption?
How does user space deal with this?
Regards
Oliver
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] usb-storage: implement autosuspend
2010-08-02 14:36 ` Oliver Neukum
@ 2010-08-02 15:07 ` Alan Stern
0 siblings, 0 replies; 12+ messages in thread
From: Alan Stern @ 2010-08-02 15:07 UTC (permalink / raw)
To: Oliver Neukum
Cc: James Bottomley, Greg KH, Matthew Dharm, SCSI development list,
USB Storage list
On Mon, 2 Aug 2010, Oliver Neukum wrote:
> Am Mittwoch, 28. Juli 2010, 23:12:39 schrieb Alan Stern:
> >
> > This patch (as1400) adds runtime-PM support to usb-storage. It
> > utilizes the SCSI layer's runtime-PM implementation, so its scope is
> > limited. Currently the only effect is that disk-like devices (such as
> > card readers or flash drives) will be autosuspended if they aren't
> > mounted and their device files aren't open. This would apply, for
> > example, to card readers that don't contain a memory card.
>
> So it will autosuspend devices that do contain a medium, which
> is not mounted? This is a bit problematic, as some card readers
> will report a medium change upon resumption?
>
> How does user space deal with this?
For the most part it won't matter. It's rare to open a card reader's
device file without mounting it.
If it does matter, the user can disable autosuspend (or more
accurately, avoid enabling it) for that device.
Alan Stern
^ permalink raw reply [flat|nested] 12+ messages in thread
* patch "USB: usb-storage: implement autosuspend" added to gregkh-2.6 tree
2010-07-28 21:12 [PATCH] usb-storage: implement autosuspend Alan Stern
2010-07-28 21:16 ` James Bottomley
2010-08-02 14:36 ` Oliver Neukum
@ 2010-08-02 23:47 ` gregkh
2 siblings, 0 replies; 12+ messages in thread
From: gregkh @ 2010-08-02 23:47 UTC (permalink / raw)
To: stern, gregkh, greg, James.Bottomley, linux-scsi, mdharm-usb,
oliver, usb-storage
This is a note to let you know that I've just added the patch titled
USB: usb-storage: implement autosuspend
to my gregkh-2.6 tree which can be found in directory form at:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
and in git form at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/patches.git
The filename of this patch is:
usb-usb-storage-implement-autosuspend.patch
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
If this patch meets the merge guidelines for a bugfix, it should be
merged into Linus's tree before the next major kernel release.
If not, it will be merged into Linus's tree during the next merge window.
Either way, you will probably be copied on the patch when it gets sent
to Linus for merging so that others can see what is happening in kernel
development.
If you have any questions about this process, please let me know.
>From stern+4c5c36d6@rowland.harvard.edu Mon Aug 2 16:02:08 2010
Date: Wed, 28 Jul 2010 17:12:39 -0400 (EDT)
From: Alan Stern <stern@rowland.harvard.edu>
To: James Bottomley <James.Bottomley@suse.de>, Greg KH <greg@kroah.com>
cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>,
Oliver Neukum <oliver@neukum.org>,
SCSI development list <linux-scsi@vger.kernel.org>,
USB Storage list <usb-storage@lists.one-eyed-alien.net>
Subject: USB: usb-storage: implement autosuspend
Message-ID: <Pine.LNX.4.44L0.1007281702030.1744-100000@iolanthe.rowland.org>
This patch (as1400) adds runtime-PM support to usb-storage. It
utilizes the SCSI layer's runtime-PM implementation, so its scope is
limited. Currently the only effect is that disk-like devices (such as
card readers or flash drives) will be autosuspended if they aren't
mounted and their device files aren't open. This would apply, for
example, to card readers that don't contain a memory card.
Unfortunately this won't interact very well with the removable-media
polling normally carried out by hal or DeviceKit. Maybe those
programs can be changed to use a longer polling interval, or maybe the
default autosuspend time for usb-storage should be set to something
below 1 second.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <James.Bottomley@suse.de>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/storage/usb.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -336,6 +336,7 @@ static int usb_stor_control_thread(void
else {
US_DEBUG(usb_stor_show_command(us->srb));
us->proto_handler(us->srb, us);
+ usb_mark_last_busy(us->pusb_dev);
}
/* lock access to the state */
@@ -845,6 +846,7 @@ static int usb_stor_scan_thread(void * _
/* Should we unbind if no devices were detected? */
}
+ usb_autopm_put_interface(us->pusb_intf);
complete_and_exit(&us->scanning_done, 0);
}
@@ -968,6 +970,7 @@ int usb_stor_probe2(struct us_data *us)
goto BadDevice;
}
+ usb_autopm_get_interface_no_resume(us->pusb_intf);
wake_up_process(th);
return 0;
@@ -1040,6 +1043,7 @@ static struct usb_driver usb_storage_dri
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
.id_table = usb_storage_usb_ids,
+ .supports_autosuspend = 1,
.soft_unbind = 1,
};
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-08-02 23:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-28 21:12 [PATCH] usb-storage: implement autosuspend Alan Stern
2010-07-28 21:16 ` James Bottomley
2010-07-28 21:25 ` Greg KH
2010-07-28 21:29 ` James Bottomley
2010-07-28 21:35 ` Greg KH
2010-07-28 22:56 ` James Bottomley
2010-07-28 23:09 ` Greg KH
2010-07-29 14:14 ` Alan Stern
2010-07-29 14:19 ` Greg KH
2010-08-02 14:36 ` Oliver Neukum
2010-08-02 15:07 ` Alan Stern
2010-08-02 23:47 ` patch "USB: usb-storage: implement autosuspend" added to gregkh-2.6 tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox