Message ID | 20231113153515.751823-1-chentao@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1285089vqg; Mon, 13 Nov 2023 07:36:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgiDM7GibfefNigQ/xH8W0cKUfKoolEmL3uiYXhSixanV75xeFs/5PobTpEeMKi/H2yGRP X-Received: by 2002:a17:902:dac8:b0:1cc:5691:5112 with SMTP id q8-20020a170902dac800b001cc56915112mr5829897plx.7.1699889769548; Mon, 13 Nov 2023 07:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699889769; cv=none; d=google.com; s=arc-20160816; b=aOkZ7W1LuZ0ol5LKqZ/OfCgSWojBE3Wxk3iXT34LNndFGTzBF+ItXRbs348HR4wjRK 4sy4zl6S6mNrZ0RcudG5/EOPDL8WxnzOsJvJZ+iS72bCH7QRfZuYnbtQVBfYgwHWQdUO 8wJs8sXtq85+ks9j1YorE0NxLKzNyPWioUJHyjf3gVCRuJp346wB8SnYxjuqdwHCFk+O edEjx4/PuYNb7GLThIrFdF0drrb18M7gagWIkmfbbz2jKE1kuRpRlCk3IvAi7xYlJTG5 rCUACVvz83GPaZz59oWLoFzUM+4YwuGONQonxYP6WCZD/GSb4m3dIXhEdevIPMub7cNN tt5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9+KMUjmS2KGhLj3jlQU5XZRfGUBd9QB096zVNLu0hdw=; fh=z49XAJ+eFCr4Lg6xkq+8k2uXYD5J6yNKFBDrjIi3zq4=; b=IU+h+R63BTKal5kwwBR5zUgDNJmmcKlsxRzMzY6n5TS51Ybap+5aaNmIGDE6anty4I g5jCPIFEA5e9N9iWpsgHlEjk8hDKu/8l4DuHVa7iDC9OIwjT6kuE/3XpoP/obloj/jLx WX0EYCFa8+x3VxK1u2FyNaqRXfOJCUtuRjduaQfDO4zv0inY6RSvmISNQRkjwt8JUGiR /AjrQT71lqpt6shhcB/NdHU8q0jx5GwjufYadNVrdajRtts4OtF9DXYxek1wtk0rd2T1 OVWuuIDEyXqrLTnNvPmEWcvv5remtF35kZUfoPOvR3xeLe1xXS3GM8dewa6EdHhJ4J40 oa/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id i14-20020a17090332ce00b001bc079974dbsi6234373plr.355.2023.11.13.07.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:36:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DC67F8078607; Mon, 13 Nov 2023 07:36:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbjKMPfr (ORCPT <rfc822;heyuhang3455@gmail.com> + 29 others); Mon, 13 Nov 2023 10:35:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjKMPfq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Nov 2023 10:35:46 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F99AD63; Mon, 13 Nov 2023 07:35:40 -0800 (PST) X-UUID: 487f275e4dfa444babf50090781c4288-20231113 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:b64ec300-1827-4b58-ba5f-a43393d2cc7e,IP:15, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:25 X-CID-INFO: VERSION:1.1.32,REQID:b64ec300-1827-4b58-ba5f-a43393d2cc7e,IP:15,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:25 X-CID-META: VersionHash:5f78ec9,CLOUDID:18719972-1bd3-4f48-b671-ada88705968c,B ulkID:2311132329433XNC9A73,BulkQuantity:1,Recheck:0,SF:44|66|38|24|17|19|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL: 0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 487f275e4dfa444babf50090781c4288-20231113 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from <chentao@kylinos.cn>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 616791189; Mon, 13 Nov 2023 23:35:23 +0800 From: Kunwu Chan <chentao@kylinos.cn> To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, quic_wcheng@quicinc.com Cc: kunwu.chan@hotmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan <chentao@kylinos.cn> Subject: [PATCH] usb: dwc3: Fix an issue that using pm_runtime_get_sync incorrectly Date: Mon, 13 Nov 2023 23:35:15 +0800 Message-Id: <20231113153515.751823-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 13 Nov 2023 07:36:06 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782463615387710500 X-GMAIL-MSGID: 1782463615387710500 |
Series |
usb: dwc3: Fix an issue that using pm_runtime_get_sync incorrectly
|
|
Commit Message
Kunwu Chan
Nov. 13, 2023, 3:35 p.m. UTC
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@kylinos.cn>
---
drivers/usb/dwc3/gadget.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
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@kylinos.cn> > --- > 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
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 (!ret || ret < 0) { pm_runtime_put(dwc->dev); if (ret < 0)