Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp463630ybg; Thu, 19 Mar 2020 03:04:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vthItVKjGWgTgN/ZxVDFzRKsqumc701sg3SozzoQDowe/IV4vLAIYSyDOFgkRFb+Kqa8Vep X-Received: by 2002:a9d:5ad:: with SMTP id 42mr1670008otd.231.1584612255133; Thu, 19 Mar 2020 03:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584612255; cv=none; d=google.com; s=arc-20160816; b=s5reaB56OWc4U0ekQIh6F8DvM0jThS6CBTqF0kqqi3ZBG0Th6zWaedIFF88jRaNHM9 Ut0A0udZEXKvd7TW5fqUpm+SzmKXnxjha4ShPR+aFLYLXJGF4DfNc7bhzZykSmdq43IV y0wgSNEUQAIknYfU8S+JThoRfZH77iZzh0+/PH8UFIAJ5pz+YbXo+1Di3gEfsEB9FhO+ 4Gt3mQazkXpD9sDLySE9YWNiKFtjy0FuIGb/bud75+WfIb8VYBLKj4JBe/hVJytFRMJp 5x05rBaJY352z2FhSYo7KZmvRn1Y8wwEIP5qnqM8Jm+SXBFvuvbHkDQJrZOh1ljfJq6C DnFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from; bh=/dbMIo02VYEFZMK1rOmc2DRtTh22cN5fH6AnO26h8L4=; b=ajwzZGBkpDHqgRsuWmeKH5fEO5NJwcwef9mpB6uEIIa1RXM6sy1v/SXL5YMEOmEGro t8X9YQ5Db3WUyvIT/VAlFBW/J3ARDw5kIS448G7Kt5KwtPv0SUYzHQw++9MjG8Yvbcog 5pm4SGqV6TZaeeQ7vjSwaO9UtnHeJhDMSVLF3khJCqY+nTC3pzB1pYraaSeSukGRKvm9 9CGZisWhb+pt6OYLX6Jc7KsoyaVd8424e9ccjkg/FrStZKi886BLJUsULaFl9lldBNT+ 6tlueqNXQ7n2XFtPpZ4x9Zz+gr0qkb9IlwywDljYitcERo5laf1xuCXlXdsTuhErunBQ fiNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si683834oix.42.2020.03.19.03.03.59; Thu, 19 Mar 2020 03:04:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbgCSKC1 (ORCPT + 99 others); Thu, 19 Mar 2020 06:02:27 -0400 Received: from comms.puri.sm ([159.203.221.185]:37248 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgCSKC0 (ORCPT ); Thu, 19 Mar 2020 06:02:26 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 4D3CBDF787; Thu, 19 Mar 2020 03:02:26 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hkicrNzMPrA9; Thu, 19 Mar 2020 03:02:25 -0700 (PDT) From: Martin Kepplinger To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, sergei.shtylyov@cogentembedded.com, rogerq@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role Date: Thu, 19 Mar 2020 11:02:07 +0100 Message-Id: <20200319100207.19957-1-martin.kepplinger@puri.sm> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is being plugged in. In order to support continuous runtime power management when plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in this path. Signed-off-by: Martin Kepplinger --- revision history ---------------- v3: call pm_runtime_get_sync() and fix commit message typo (thanks Sergei) v2: move pm_rumtime calls into workqueue (thanks Roger) remove unrelated documentation patch https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/ v1: https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/ drivers/usb/dwc3/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1d85c42b9c67..da93faef74a6 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work) if (dwc->dr_mode != USB_DR_MODE_OTG) return; + pm_runtime_get_sync(dwc->dev); + if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG) dwc3_otg_update(dwc, 0); if (!dwc->desired_dr_role) - return; + goto out; if (dwc->desired_dr_role == dwc->current_dr_role) - return; + goto out; if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev) - return; + goto out; switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_HOST: @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work) break; } +out: + pm_runtime_mark_last_busy(dwc->dev); + pm_runtime_put_autosuspend(dwc->dev); } void dwc3_set_mode(struct dwc3 *dwc, u32 mode) -- 2.20.1