RE: cdc_acm device - unexpected characters sent to USB device

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

 



Hi, Oliver 

> -----Original Message-----
> From: Oliver Neukum [mailto:oliver@xxxxxxxxxx] 
> Sent: Saturday, March 30, 2013 10:34 AM
> To: Mike Verstegen
> Cc: linux-usb@xxxxxxxxxxxxxxx
> Subject: Re: cdc_acm device - unexpected characters sent to USB device
> 
> On Saturday 30 March 2013 03:20:15 Mike Verstegen wrote:
> 
> >  -  Downloaded the source code for the cdc_acm driver. 
> >  -  Added a bunch of printk debug messages and stack_dumps 
> to follow what's going on. 
> >  -  I rmmod'd the "stock" cdc_acm and insmod'd my 
> instrumented module. 
> >  -  All the device enumeration works, right driver attached, etc. 
> >  -  Since the code works on Ubuntu 12.04/Linux 3.2, I 
> grabbed the 3.2 cdc_acm code and compiled that module on the 
> Centos 6 / Linux 3.6 platform. Using that 3.2 module instead 
> of the 3.6 module did not make a difference. I reverted to 
> the 3.6 module. 
> >  -  Turned on the debug file system with usbmon and watched 
> the USB traffic. I can see that there are extra characters 
> being sent on the USB interface. 
> >  -  To watch what's going on, on top of the printk's in the 
> cdc_acm module, I've merged the output of usb mon (cat 
> /sys/kernel/debug/usb/usbmon/3u | logger) and the output of 
> the test application (scan_example /dev/ttyACM0 | logger -s) 
> so I have a single stream of time correlated debug trail. 
> >  -  The spurious characters sent on the USB endpoint are 
> x5E x40 x5E x40 x5E x40 x5E x40 x41 (in ASCII its ^@^@^@^@A ) 
> which looks like some sort of probing or trying to get the 
> attention of a modem These characters are sent immediately 
> after the application's write() causes the 4 hello bytes to 
> be sent to the end point.
> 
> To clarify, is acm_tty_write() called with the additional 
> bytes or isn't it?
> 
> 	Regards
> 		Oliver
> 
> 

Hi, Oliver

Such a simple question you asked -- but it lead to a useful discovery.

My logs show that acm_tty_write is called multiple times

- The application opens the device and then calls write() to send the 4 byte message to the fd. This results in a call to acm_tty_write
- From somewhere else, acm_tty_write is called several times, each with a count=1 and one of the offending characters noted above.

To get find out where the unexpected calls to acm_tty_write were coming from, I added a dump_stack at the entry point to acm_tty_write. From those stack frames, I can see that the first acm_tty_write call is from my application, but the second and subsequent calls are from  a kworker thread.

So at this point, it doesn't look like a cdc_acm driver problem, but instead an unexpected call to acm_tty_write from another process. Having briefly looked the trace output of the kworker queue, it may a challenge to find out what thread in there is making this call.

Thanks

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