Re: Patch to fix USB CDC ACM devices staying throttled forever

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

 



On Mon, Jun 04, 2012 at 07:04:34PM +0200, Otto Meta wrote:
> Hi Johan,
> 
> while working with a USB CDC ACM device I noticed that communication
> with the device dies when its TTY is closed while there’s still a lot
> of unread data. After reopening the TTY only a few blocks of data are
> received and then nothing. This state persists until the device is
> disconnected or the kernel module is unloaded.
> 
> This can easily be reproduced if you have a device that sends data which
> you can ignore for a while (at least 3968 bytes):
> - Have the device send data until usbmon shows no more read URB
>   submissions
> - Close the TTY without reading the data
> - Open the TTY and have the device send some data: usbmon shows 16 read
>   URB submissions at the beginning but once those return, no more
>   submissions are sent.
> 
> After consulting the source I believe this is caused by a missing
> unthrottle in the TTY open/activate function: If the TTY of a CDC ACM
> device is closed while it’s throttled, it will stay throttled after
> reopening, even though the initial 16 read URB submissions are sent.
> 
> The last working release is 2.6.39.4, the first affected release is 3.0.0
> and all releases since then, including 3.5-rc1, behave the same.
> 
> The problem was probably introduced with this patch:
> http://marc.info/?l=linux-usb&m=130104758422681&w=2
> 
> In acm_tty_open() "acm->throttle = 0;" was removed and no replacement
> seems to have been added. The patch below adds throttle-clearing akin to
> what happens in acm_tty_unthrottle().

You're absolutely right -- the throttle flags needs to be cleared at
open.

> The patch was created for 3.5-rc1 but has also been tested successfully
> with the stable releases 3.0.32, 3.2.18 and 3.3.7.

Yes, this should go into all stable trees >= 3.0.

Care to re-submit your patch with a suitable subject line, short
description of the problem, and a Signed-of-by-tag? (See
Documentation/SubmittingPatches in the kernel source tree for details.)

You can add the following tag to your mail to mark that the fix needs to
be applied to the stable trees:

	Cc: <stable@xxxxxxxxxxxxxxx>

Please send the patch to Greg KH (CC:ed) while CC:ing the usb mailing
list linux-usb@xxxxxxxxxxxxxxx.

Thanks for catching this,
Johan


> Cheers,
> Otto

> --- linux-3.5-rc1/drivers/usb/class/cdc-acm.c	2012-06-03 03:29:26.000000000 +0200
> +++ linux-3.5-rc1-mod/drivers/usb/class/cdc-acm.c	2012-06-04 16:23:31.038410396 +0200
> @@ -567,6 +567,14 @@
>  
>  	usb_autopm_put_interface(acm->control);
>  
> +	/*
> +	 * Unthrottle device in case the TTY was closed while throttled.
> +	 */
> +	spin_lock_irq(&acm->read_lock);
> +	acm->throttled = 0;
> +	acm->throttle_req = 0;
> +	spin_unlock_irq(&acm->read_lock);
> +
>  	if (acm_submit_read_urbs(acm, GFP_KERNEL))
>  		goto error_submit_read_urbs;
>  

--
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