Re: [PATCH] usb: dwc3: Fix an issue that using pm_runtime_get_sync incorrectly

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

 



Hi,

On 11/13/2023 7:35 AM, Kunwu Chan wrote:
pm_runtime_get_sync() also returns 1 on success.
The documentation for pm_runtime_get_sync() suggests using
pm_runtime_resume_and_get() instead.

Fixes: 77adb8bdf422 ("usb: dwc3: gadget: Allow runtime suspend if UDC unbinded")
Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
---
  drivers/usb/dwc3/gadget.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 858fe4c299b7..0330de73cd9c 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2745,7 +2745,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
  	 * successful resume, the DWC3 runtime PM resume routine will handle
  	 * the run stop sequence, so avoid duplicate operations here.
  	 */
-	ret = pm_runtime_get_sync(dwc->dev);
+	ret = pm_runtime_resume_and_get(dwc->dev);

If pm_runtime_get_sync() returns 1, that means that the runtime state is already in RPM_ACTIVE, so in that case, we should allow for the pullup routine to continue.

What is the end issue you're seeing with the current implementation?

  	if (!ret || ret < 0) {
  		pm_runtime_put(dwc->dev);

If you think using pm_runtime_resume_and_get() is still necessary, I think you'll need to figure out how to address the above put call as well. pm_runtime_resume_and_get() already handles error cases and will call a put noidle.

Thanks
Wesley Cheng




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux