On Wed, May 8, 2013 at 4:01 PM, Vladimir Zapolskiy <vladimir_zapolskiy@xxxxxxxxxx> wrote: > 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. > Yes, it is UDC's bug. for UDC, which support runtime-pm, it should consider the exported APIs might be called when udc is in suspend mode. -- 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