Patch "usb: dwc3: gadget: Queue PM runtime idle on disconnect event" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: dwc3: gadget: Queue PM runtime idle on disconnect event

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-dwc3-gadget-queue-pm-runtime-idle-on-disconnect-.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3685641a97ea691f4361bc2d9f6a98cdebea549b
Author: Wesley Cheng <quic_wcheng@xxxxxxxxxxx>
Date:   Wed Jan 3 13:49:46 2024 -0800

    usb: dwc3: gadget: Queue PM runtime idle on disconnect event
    
    [ Upstream commit 3c7af52c7616c3aa6dacd2336ec748d4a65df8f4 ]
    
    There is a scenario where DWC3 runtime suspend is blocked due to the
    dwc->connected flag still being true while PM usage_count is zero after
    DWC3 giveback is completed and the USB gadget session is being terminated.
    This leads to a case where nothing schedules a PM runtime idle for the
    device.
    
    The exact condition is seen with the following sequence:
      1.  USB bus reset is issued by the host
      2.  Shortly after, or concurrently, a USB PD DR SWAP request is received
          (sink->source)
      3.  USB bus reset event handler runs and issues
          dwc3_stop_active_transfers(), and pending transfer are stopped
      4.  DWC3 usage_count decremented to 0, and runtime idle occurs while
          dwc->connected == true, returns -EBUSY
      5.  DWC3 disconnect event seen, dwc->connected set to false due to DR
          swap handling
      6.  No runtime idle after this point
    
    Address this by issuing an asynchronous PM runtime idle call after the
    disconnect event is completed, as it modifies the dwc->connected flag,
    which is what blocks the initial runtime idle.
    
    Fixes: fc8bb91bc83e ("usb: dwc3: implement runtime PM")
    Cc:  <stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Wesley Cheng <quic_wcheng@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240103214946.2596-1-quic_wcheng@xxxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 339e8c3f7c50..5617a75b0d74 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3860,6 +3860,13 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
 	usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED);
 
 	dwc3_ep0_reset_state(dwc);
+
+	/*
+	 * Request PM idle to address condition where usage count is
+	 * already decremented to zero, but waiting for the disconnect
+	 * interrupt to set dwc->connected to FALSE.
+	 */
+	pm_request_idle(dwc->dev);
 }
 
 static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux