]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: udc: core: Offload usb_udc_vbus_handler processing
authorBadhri Jagan Sridharan <badhri@google.com>
Fri, 9 Jun 2023 01:02:26 +0000 (01:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jun 2023 14:02:12 +0000 (16:02 +0200)
commit632afdf2f782bf48b01877bcd29370ba6e7fc7e4
tree4600fe1456d90db4b6f537ce8595c063c351a382
parent45ae0c32d81632753e9d00af2279c52d234af0d9
usb: gadget: udc: core: Offload usb_udc_vbus_handler processing

commit 50966da807c81c5eb3bdfd392990fe0bba94d1ee upstream.

usb_udc_vbus_handler() can be invoked from interrupt context by irq
handlers of the gadget drivers, however, usb_udc_connect_control() has
to run in non-atomic context due to the following:
a. Some of the gadget driver implementations expect the ->pullup
   callback to be invoked in non-atomic context.
b. usb_gadget_disconnect() acquires udc_lock which is a mutex.

Hence offload invocation of usb_udc_connect_control()
to workqueue.

UDC should not be pulled up unless gadget driver is bound. The new flag
"allow_connect" is now set by gadget_bind_driver() and cleared by
gadget_unbind_driver(). This prevents work item to pull up the gadget
even if queued when the gadget driver is already unbound.

Cc: stable@vger.kernel.org
Fixes: 1016fc0c096c ("USB: gadget: Fix obscure lockdep violation for udc_mutex")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Message-ID: <20230609010227.978661-1-badhri@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/core.c