Re: [PATCH v5] usb: gadget: udc: Handle gadget_connect failure during bind operation

From: Krishna Kurapati PSSNV
Date: Wed Sep 27 2023 - 04:47:55 EST




On 9/27/2023 1:46 PM, Greg Kroah-Hartman wrote:
On Wed, Sep 27, 2023 at 01:00:27PM +0530, Krishna Kurapati wrote:
In the event gadget_connect call (which invokes pullup) fails,
propagate the error to udc bind operation which in turn sends the
error to configfs. The userspace can then retry enumeration if
it chooses to.

Will this break userspace that is not expecting error codes to be
returned? What userspace code will now be modified to handle this?
Where is that work happening?

thanks,

Hi Greg,

This only handles cases where the pullup failed but the error code wasn't returned to configfs_udc_store approrpiately. In userspace when we do the following:

echo "UDC NAME" > /usb_gadget/<>/UDC

in the issue I was facing, the core soft reset was failing and we return -110 from dwc3/core.c to udc's bind_to_driver call, but it is not checked any where today and we return 0 to udc_store in configfs. The userspace assumes the UDC write went through (and enum happened) but it actually doesn't. If we propagate the -ETIMEDOUT coming from dwc3-core all the way to configfs_udc_store, it will reach userspace as well indicating that the echo command was not successful which then the user can choose to retry or not. On Android devices, I saw userspace retry happening when we propagate dwc3-core error to userspace. So nothing in userspace breaks. It can stay as it but this time, the echo in userspace will fail if pullup fails for some reason.

Regards,
Krishna,