Re: [PATCH v1] usb: gadget: udc: core: Offload usb_udc_vbus_handler processing
From: Badhri Jagan Sridharan
Date: Wed May 17 2023 - 13:20:10 EST
On Wed, May 17, 2023 at 7:44 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, May 17, 2023 at 11:59:55AM +0000, Badhri Jagan Sridharan wrote:
> > chipidea udc calls usb_udc_vbus_handler from udc_start gadget
> > ops causing a deadlock. Avoid this by offloading usb_udc_vbus_handler
> > processing.
>
> Surely that is the wrong approach.
>
> The real problem here is that usb_udc_vbus_handler() gets called from
> within a udc_start routine. But this is totally unnecessary, because
> the UDC core will call usb_udc_connect_control_locked() itself, later on
> during gadget_bind_driver().
Hi Alan,
usb_udc_vbus_handler sets the udc->vbus flag as well apart from
calling usb_udc_connect_control_locked(). So, removing usb_udc_vbus_handler
from chip specific start callback might prevent the controller from
starting.
void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status)
{
struct usb_udc *udc = gadget->udc;
mutex_lock(&udc->connect_lock);
if (udc) {
udc->vbus = status;
usb_udc_connect_control_locked(udc);
Thanks,
Badhri
>
> So a proper solution would be simply to remove the unnecessary
> usb_udc_vbus_handler() call from the chipidea driver (and similarly for
> the max3420_udc driver).
>
> Similar changes may be needed in these drivers' udc_stop routines.
>
> Alan Stern