Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "usb: gadget: f_uvc: change endpoint allocation in uvc_function_bind()"

This reverts commit 3c5b006f3ee800b4bd9ed37b3a8f271b8560126e.

gadget_is_{super|dual}speed() API check UDC controller capitblity. It
should pass down highest speed endpoint descriptor to UDC controller. So
UDC controller driver can reserve enough resource at check_config(),
especially mult and maxburst. So UDC driver (such as cdns3) can know need
at least (mult + 1) * (maxburst + 1) * wMaxPacketSize internal memory for
this uvc functions.

Cc: <stable@vger.kernel.org>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231224153816.1664687-5-Frank.Li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Frank Li and committed by
Greg Kroah-Hartman
895ee5ae 40c30410

+17 -1
+17 -1
drivers/usb/gadget/function/f_uvc.c
··· 721 721 } 722 722 uvc->enable_interrupt_ep = opts->enable_interrupt_ep; 723 723 724 - ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); 724 + /* 725 + * gadget_is_{super|dual}speed() API check UDC controller capitblity. It should pass down 726 + * highest speed endpoint descriptor to UDC controller. So UDC controller driver can reserve 727 + * enough resource at check_config(), especially mult and maxburst. So UDC driver (such as 728 + * cdns3) can know need at least (mult + 1) * (maxburst + 1) * wMaxPacketSize internal 729 + * memory for this uvc functions. This is the only straightforward method to resolve the UDC 730 + * resource allocation issue in the current gadget framework. 731 + */ 732 + if (gadget_is_superspeed(c->cdev->gadget)) 733 + ep = usb_ep_autoconfig_ss(cdev->gadget, &uvc_ss_streaming_ep, 734 + &uvc_ss_streaming_comp); 735 + else if (gadget_is_dualspeed(cdev->gadget)) 736 + ep = usb_ep_autoconfig(cdev->gadget, &uvc_hs_streaming_ep); 737 + else 738 + ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); 739 + 725 740 if (!ep) { 726 741 uvcg_info(f, "Unable to allocate streaming EP\n"); 727 742 goto error; 728 743 } 729 744 uvc->video.ep = ep; 730 745 746 + uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; 731 747 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; 732 748 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; 733 749