[PATCH] usb: cdc-wdm: cannot wait forever for blocking read/write on reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We need to ensure that no URBs are submitted during reset.  Taking any of
the mutexes can deadlock against either wdm_read or wdm_write. Use the
WDM_SUSPENDING flag instead to indicate that no IO is possible, as the
requirements for suspend and reset are similar

Signed-off-by: Bjørn Mork <bjorn@xxxxxxx>
---
How about something like this?  I don't think we need a new dedicated flag
as the semantics are the same for suspend.  But maybe it should be renamed?

I've also added the cancel_work_sync() call which is in suspend, as I
believe that is necessary to avoid submitting any URBs.

Should this go to stable as well?  It won't apply directly due to the
read/write mutex lock split, but I can prepare a patch.



Bjørn


 drivers/usb/class/cdc-wdm.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index f63601a..64778df 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -859,10 +859,6 @@ static int wdm_pre_reset(struct usb_interface *intf)
 {
 	struct wdm_device *desc = usb_get_intfdata(intf);
 
-	mutex_lock(&desc->rlock);
-	mutex_lock(&desc->wlock);
-	kill_urbs(desc);
-
 	/*
 	 * we notify everybody using poll of
 	 * an exceptional situation
@@ -870,8 +866,11 @@ static int wdm_pre_reset(struct usb_interface *intf)
 	 * message from the device is lost
 	 */
 	spin_lock_irq(&desc->iuspin);
+	set_bit(WDM_SUSPENDING, &desc->flags);
 	desc->rerr = -EINTR;
 	spin_unlock_irq(&desc->iuspin);
+	kill_urbs(desc);
+	cancel_work_sync(&desc->rxwork);
 	wake_up_all(&desc->wait);
 	return 0;
 }
@@ -881,9 +880,8 @@ static int wdm_post_reset(struct usb_interface *intf)
 	struct wdm_device *desc = usb_get_intfdata(intf);
 	int rv;
 
+	clear_bit(WDM_SUSPENDING, &desc->flags);
 	rv = recover_from_urb_loss(desc);
-	mutex_unlock(&desc->wlock);
-	mutex_unlock(&desc->rlock);
 	return 0;
 }
 
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux