Files
linux/drivers
William Wu 8a63243979 usb: gadget: uvc: wait for req complete before free req
when uvc calls uvcg_video_enable() to disable the video
stream, it dequeues all requests from the usb endpoint,
and it expects the usb controller to giveback the requests
immediately, and then it can free the requests safely.
But for usb dwc3 controller, it doesn't giveback the
started requests in dequeue ops. Instead, it issues the
end transfer command and  wait for the command completion
IRQ, then giveback the requests to uvc. If the uvc driver
free req before the command completion IRQ, it will led
to null pointer dereference problem. So need to wait
for the req complete before free it.

Example call stack on RK3588 platform:

Thread#1:
uvcg_video_enable()
 -> usb_ep_dequeue()
  -> dwc3_gadget_ep_dequeue()
   -> dwc3_stop_active_transfer()
      issue end transfer command
    -> dwc3_gadget_move_cancelled_request()
     ...
      -> uvc_video_free_requests()
       -> Thread#2 executes

Thread#2:
dwc3 end transfer command completion IRQ occurs
dwc3_gadget_endpoint_command_complete()
 -> dwc3_gadget_ep_cleanup_cancelled_requests()
  -> dwc3_gadget_giveback()
   -> usb_gadget_giveback_request()
    -> uvc_video_complete()

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I0bcb8d18e851448fc973f901d74afa19ab1e2406
2022-11-22 17:35:43 +08:00
..
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-05-21 17:43:58 +08:00
2022-09-08 16:17:54 +08:00
2022-11-14 19:46:58 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-09-08 16:17:54 +08:00
2022-03-18 12:13:27 +01:00