lkml.org 
[lkml]   [2002]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: usb storage cleanup
On Thu, Jul 04, 2002 at 07:12:40PM +0200, Manfred Spraul wrote:
> Matthew Dharm wrote:
> >
> >>E.g. queue_command stored new commands in ->queue_srb. The worker thread
> >>then moved it from queue_srb to srb and set sm_state to RUNNING.
> >>
> >>But what if command_abort() is called before the worker thread is scheduled?
> >
> >
> > Then we have a serious problem, because the aborts are on the order of
> > several seconds. If the thread hasn't gotten scheduled by then it _should_
> > cause a BUG_ON.
> >
>
> First of all, it's dead ugly. usb-storage crashes if the scheduler is
> overloaded. IMHO that's a bug, especially since it's simple to avoid it.
>
> And what about storage_disconnect()?
>
> Test case: user pulls out the usb cable while a transfer is in progress.
> urb submitted to the device, reply not yet received.
> Result: storage_disconnect() would hang for 20 seconds until
> command_abort() is called.

No, not quite. The HCD accelerates the URBs to completion if the device
is removed with an URB pending on it. It therefore shouldn't hang for the
timeout -- if you're seeing this behavior, then the HCD is broken.

> Read through my proposal: With current_urb_sem [I've called it urb_sem,
> but it's the same concept], the synchronization between abort and new
> commands is guaranteed.
>
> The only difference is that I've moved testing ->abort_cmd and
> down(&->urb_sem) into usb_stor_msg_common: Requesting that the callers
> must acquire the semaphore and check abort_cmd() is unnecessary code
> duplication and just asks for bugs.

The reason it was moved up was to save lots of processing (including memory
allocation paths) if the abort had already been requested. Which is a
common case.

> >>>You're reverting the new mechanism to determine device state... why?
> >>
> >>Unnesessary duplication. Device disconnected is equivalent to
> >>->pusb_dev==NULL. Why do you need a special variable?
> >
> >
> > Because relying on a pointer has caused problems in the past, especially
> > when there are concerns that the pointer might be invalid.
> >
>
> Could you explain a bit more? How could the pointer become invalid?

There was a large discussion of this in relation to another driver on
linux-usb-devel... basically, the pointer is just an address to a structure
owned by an HCD... it's entirely possible for the structure to go away on
us unexpectedly. We _should_ get the notification via the _disconnect()
call, but real-world experience showed us that this wasn't always
happening.

Matt

--
Matthew Dharm Home: mdharm-usb@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver

I need a computer?
-- Customer
User Friendly, 2/19/1998
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.087 / U:1.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site