Re: [PATCH] usb: core: Don't wait for completion of urbs

From: Alan Stern
Date: Tue Oct 13 2020 - 11:24:29 EST


On Tue, Oct 13, 2020 at 04:17:02PM +0530, Pratham Pratap wrote:
> Consider a case where host is trying to submit urbs to the
> connected device while holding the us->dev_mutex and due to
> some reason it is stuck while waiting for the completion of
> the urbs. Now the scsi error mechanism kicks in and it calls

Are you talking about usb-storage? You should describe the context
better -- judging by the patch title, it looks like you're talking
about a core driver instead.

> the device reset handler which is trying to acquire the same
> mutex causing a deadlock situation.

That isn't supposed to happen. The SCSI error handler should always
cancel all the outstanding commands before invoking the device reset
handler. Cancelling the commands will cause the URBs to complete.

If you found a test case where this doesn't happen, it probably means
there's a bug in the SCSI core code or the USB host controller driver.
That bug should be fixed; don't introduce random timeout values to try
and work around it.

Alan Stern