Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp589426ybh; Thu, 12 Mar 2020 07:33:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuhjUYBCVTVmSnJgReVXkz8dgfGQ32ytkGYsy1v4Bjn/j3XEoBvOqA1Jl5RO0zlrcvPKgsf X-Received: by 2002:a05:6830:1d75:: with SMTP id l21mr1962598oti.59.1584023601089; Thu, 12 Mar 2020 07:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584023601; cv=none; d=google.com; s=arc-20160816; b=rivK/D2m+m5vKv4PGtZJvKkQqAfJBfmZ/RR537+ysa/sHy9HvctuorGLOB0194kimU /eWgOOOQhOL4Ej+P7a11885i5bfJANbc6cBL10VdULxqFja3r+QEMstPxRBWCI8soTA4 OOODGv0o6SJPAilqaZJ8PJxKIn5WMwCvKJfhGQVPmL2iHnJqrV6fxGZEGI6obZpB5J+A seUcR1amUD4ASM+LtiQR5Arbsc6XZj1by4tW3DnIdVd1XQzhaB5pOxYaJUVBCKeznNrP JHrI04PpmCjGdvmUyzZx7fuHiCLWNSViL7VwcsCOCQViGluEyTdSDRKsnlFev4szN4JO nFyA== 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=fQJYuQCZBmvwleSrrxOf7py2NbTfN3oJR+7JbEjwSwU=; b=iPvs0VvXqFddkwkpbCpSVeCYa/NMRjIO4T1ptcvxfxbNhweMhWmR1g3H4RGiDTETYL /E9hd7luY8y/4tOCpV/K6UoR619b/kkiRK35rKTk7SXCjUxyCIp7qIZMf0vQRNI/kUNn 7yrVFulA4F9wlUR5Kw5mbhPsSobymhfri7eJeIfRdyPgO2/dQ95Vw/4lKX2J+8lDohk4 Gin0jmmnoKPcZwsOB4KiU7adP8+4EVJ2eEkx7sjk6TH+f242xQUWcyQkuY2NjRoly6Qb ih5wc4l7+nVmGbgjTTA1gTbeuGx7jK0JKIvYhXUL6nipRmi4Vrbbmm8ATSHA0M9zobJ2 OqOw== 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 q13si780741otn.141.2020.03.12.07.33.07; Thu, 12 Mar 2020 07:33:21 -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 S1727740AbgCLOa6 (ORCPT + 99 others); Thu, 12 Mar 2020 10:30:58 -0400 Received: from comms.puri.sm ([159.203.221.185]:44610 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727716AbgCLOa5 (ORCPT ); Thu, 12 Mar 2020 10:30:57 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id A94B4DF78E; Thu, 12 Mar 2020 07:30:56 -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 QBVKPZ1-cdnn; Thu, 12 Mar 2020 07:30:55 -0700 (PDT) From: Martin Kepplinger To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [RFC PATCH] usb: dwc3: enable runtime PM for drd role switch / extcon Date: Thu, 12 Mar 2020 15:30:38 +0100 Message-Id: <20200312143038.11719-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 Note: runtime PM currently needs to be enabled ("auto") manually via sysfs as its power/control is set to "on" by the driver. When runtime PM enabled, dwc3 currently doesn't resume when a cable is connected. It only suspends after a cable is disconnected. When using an extcon driver (for a different chip on the board), dwc3 can register a hook for that. (Still undocumented -> TODO?). Make sure, dwc3 is resumed when "set_mode" is being called by drd. this is only a question about what's missing to properly keep runtime PM enabled for dwc3 and if my change makes any sense at all. It seems to work fine for me... I'm glad about any hints on how to keep runtime PM enabled (at least when having an extcon hook set up). thanks, martin --- drivers/usb/dwc3/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1d85c42b9c67..201b712bd961 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -118,6 +118,9 @@ static void __dwc3_set_mode(struct work_struct *work) unsigned long flags; int ret; + pm_runtime_mark_last_busy(dwc->dev); + pm_runtime_put_sync_autosuspend(dwc->dev); + if (dwc->dr_mode != USB_DR_MODE_OTG) return; @@ -196,6 +199,8 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) { unsigned long flags; + pm_runtime_get_sync(dwc->dev); + spin_lock_irqsave(&dwc->lock, flags); dwc->desired_dr_role = mode; spin_unlock_irqrestore(&dwc->lock, flags); @@ -1552,7 +1557,7 @@ static int dwc3_probe(struct platform_device *pdev) goto err5; dwc3_debugfs_init(dwc); - pm_runtime_put(dev); + pm_runtime_put_sync(dev); return 0; -- 2.20.1