Re: [PATCH 0/2] usb: gadget/uvc: remove connect/disconnect calls on open/release

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

 



Hi Peter,

On 05/07/13 04:39, Peter Chen wrote:
On Fri, May 3, 2013 at 6:13 AM, Vladimir Zapolskiy
<vladimir_zapolskiy@xxxxxxxxxx>  wrote:
This change removes calls of uvc_function_connect()/uvc_function_disconnect()
functions from open()/close() syscalls.

This is a bugfix in g_webcam module, in some test scenarios (e.g. UDC in
suspend mode or OTG in host mode) straightforward control of D+ pull-up
might lead to system's misbehaviour.


When UDC is in suspend mode, pull-up dp is controller's behavior.
Can you give an explanation how the system will go to abnormal
when UDC in suspend mode or OTG in host mode?

one of the examples:

1. boot a kernel with runtime pm and g_webcam support, UDC driver supports
   runtime PM, no USB cable connected to a board
2. UDC goes to suspend mode, because there is no USB connections
3. g_webcam registers itself, /dev/video0 node is created
4. udev forks v4l_id, which opens /dev/video0 to query V4L2 capabilities
5. on open() UVC gadget commands UDC to pull-up D+ line, there is
   no connected USB cable though
6. the system stalls/panics after an attempt to access mapped UDC
   registers while UDC controller is in suspend.

A regular .pullup function from a UDC controller driver looks like:

---8<---
static int omap_pullup(struct usb_gadget *gadget, int is_on)
{
	struct omap_udc	*udc;
	unsigned long	flags;

	udc = container_of(gadget, struct omap_udc, gadget);
	spin_lock_irqsave(&udc->lock, flags);
	udc->softconnect = (is_on != 0);
	if (can_pullup(udc))
		pullup_enable(udc);
	else
		pullup_disable(udc);
	spin_unlock_irqrestore(&udc->lock, flags);
	return 0;
}
---8<---

can_pullup() is false, pullup_disable() attempts to read/write to
controller's registers, which causes system crash.

There is definitely a bug, and according to Laurent's explanation UDC
drivers should be fixed, I'll check that version.

With best wishes,
Vladimir

Most probably a root cause of some reported system freezes on g_webcam
module probe [1] is related to the issue described above, for instance
if udev's v4l_id helper opens a new V4L2 device node to query device
capabilities.

Alternatively to this chage checks may be added to UDC driver's .pullup
functions, however presence of pullup controls from uvcvideo seems to
be redundant.

[1] http://kerneltrap.org/mailarchive/linux-usb/2010/12/29/6268355/thread

Vladimir Zapolskiy (2):
   usb: gadget/uvc: remove connect/disconnect calls on open/release
   usb: gadget/uvc: remove connection/disconnection routines

  drivers/usb/gadget/f_uvc.c    |   24 ------------------------
  drivers/usb/gadget/uvc.h      |    3 ---
  drivers/usb/gadget/uvc_v4l2.c |    5 -----
  3 files changed, 32 deletions(-)

--
1.7.10.4

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



-
BR,
Peter Chen
--
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