Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp403885ybg; Thu, 19 Mar 2020 01:51:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsFnixICDJiT+I9Ixrt3SZ7fneKNhegoPGaTrYNZmNL3Hg9juwRWTg2iWe0cJKOZfFAJfh+ X-Received: by 2002:a9d:23e4:: with SMTP id t91mr1375697otb.125.1584607871077; Thu, 19 Mar 2020 01:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584607871; cv=none; d=google.com; s=arc-20160816; b=GuPpW+cjviw4z+Sr1c7Wjji91lLxrlaS7LH8spdDCgJajwz7PAdnfJam3cwX0INmMx SoGPhVtuSggpK/vqKDsDj541IfOlHWX2+rAopmVHKQmEPpdU2rqteH/u9bgBUVHYjJgL KBfQfT3Qk7gwNgGDvsq0bAOQ4TUcK73wXDKIupIyF+Etn1h6ulEQ5Iqw2YHPkqjbjhIy tMBIQGoLkV05Uj6EB5EH/HKqWWH1+qA3FqyEoPNhAG3Pw/EgPDcm+qhmvrBDa7WiFqIS pY7UplTlNEEzB51NN00u5r3MbUhFHtmcD101bRBKvHikeIjM/dmKp0/5tbdFkZvmpwHD zXjA== 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=OohcahJ/U2KAsfyXpT9imKi9ISIjs15dfFcQvaRoqwk=; b=HefircDntf/pB70nvWRjtJIerUTQOzsYBs/oCwZsnb7cw9Pu7KwsJ3N0plW/8uNJZA 8rXz7SIKnmPzHFcER3OXKqaU7p239JOD4N4UGTxIYopR0YWoSp4DK0097QuFMfye71pt d+rJdcjI5kRbzJiA/IIFGh8gjF8WAWFC+HjWqaDFF8Gyvi1ThXhw+WV+KgjQ81T4AafA BvnLB5dAX0NnF1aNv7AxvqsOOLSg0+lZUEnHFZFi/fjZlxxLobJGAbNRwF8V+8DPoiCr MsBY2AD+K00wgL6T6pmfcgTEC3Bqr3euwl7FTuxznS1b7RzX9xEOomcuu6IvVOKopAkp qX6A== 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 p189si776148oic.178.2020.03.19.01.50.59; Thu, 19 Mar 2020 01:51:11 -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 S1726912AbgCSIul (ORCPT + 99 others); Thu, 19 Mar 2020 04:50:41 -0400 Received: from comms.puri.sm ([159.203.221.185]:33218 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgCSIul (ORCPT ); Thu, 19 Mar 2020 04:50:41 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 79038DFD58; Thu, 19 Mar 2020 01:50:40 -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 mVIS9R2TCHKD; Thu, 19 Mar 2020 01:50:39 -0700 (PDT) From: Martin Kepplinger To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, rogerq@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH v2] usb: dwc3: support continuous runtime PM with dual role Date: Thu, 19 Mar 2020 09:49:02 +0100 Message-Id: <20200319084902.24747-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 pugged in. In order to support continuous runtime power management when plugging in / unplugging a cable, we need to call pm_runtime_get() in this path. Signed-off-by: Martin Kepplinger --- revision history ---------------- v2: move pm_rumtime calls into workqueue (thanks Roger) remove unrelated documentation patch 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..0c058b2ac21d 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(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