Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1406178ybh; Sun, 15 Mar 2020 02:13:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvfsc888b2pB1x8jytDmCQDdiI/J5eSF0K/koOIursN5UDRO6xVBc3M2BL2r8CSawFobqoU X-Received: by 2002:a9d:74cf:: with SMTP id a15mr14039148otl.258.1584263639475; Sun, 15 Mar 2020 02:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584263639; cv=none; d=google.com; s=arc-20160816; b=WElKKXeyUkIsK8I78+4LJ7AfZisFPPfLYeNbCg90NbcCLU/kzEjJuwgWcA/cH0zrXQ 691Lq1u73NoBs6zjZrHRnPh/xYPwsm5/1Q9wyegwaS6mReophXR6GkeojERd+38oWWi5 PQluh9pE7nhgnFzDQTuS+FYelIAFNCrgBCXelmlYNZoOe5JkaFoVr3JrpLg3Ah5F4sr1 iFHuGUThR9+ly+lGkOGxiIqYGsaymflNarygXPKuMvL1JdQM1Tjw5tzDrgtjBgAO4hJz oB81vistFzZiSbqRFECHT7/04kxXOS8cYzhvSTR2MtqELw2ds+TnkN3qGR3mg08/7NN2 6vdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=UghuRGGoBIV+FWQNja4tOmhBFo0fndDmk5q2GT0GtOQ=; b=gtuMNhU77HwbdPbCX4ZPHm/EzhS+js5Vmq/v+WArnkia5RvW7FKJZNTdSOblKfWC05 uP9dnEOxVcL3ptMVe/QfzQIkyuWFx8xx2TI5YpXv/K3KVyJnL77Z3f6qTZnCBOzhSHlb l9k4jyVqgg9l5q2kAfvAkOX1Tfb27tOdVcg4JTZ+a88k1753sJlVME/buuZ5KbaJHF7v w5v48alY4rLLozlqCaHbV5aTdzLarY1350j378BlygzN3UGZGK9M1DU1K/1XkSoiVu9z mn4M4KK/FkR8lfSW6f2nsRd5JeRWMphGJ9AHwgvLeOBzl2HWYt7HHsMXHxTAsQMfzAZ7 XbRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OE8rpn8b; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si7997321otq.73.2020.03.15.02.13.46; Sun, 15 Mar 2020 02:13:59 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OE8rpn8b; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728090AbgCOJNb (ORCPT + 99 others); Sun, 15 Mar 2020 05:13:31 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33039 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728068AbgCOJNa (ORCPT ); Sun, 15 Mar 2020 05:13:30 -0400 Received: by mail-lf1-f67.google.com with SMTP id c20so11458693lfb.0; Sun, 15 Mar 2020 02:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=UghuRGGoBIV+FWQNja4tOmhBFo0fndDmk5q2GT0GtOQ=; b=OE8rpn8bhJf6/2wBB0yTz/U4GXx+xKixWRRwr2wc5+EqGaZFRPriQK1OrVqsX1oZuZ wat6Cqp3HQJMcSAo0401k+5UcTCTBgyYVJ491vPpFJ10o54BSxxjW40dwzq+iYSkPorX XsVnx7J5zD7iJEcLb1S0O/ZQ1EodC/17BMHDiF5Ix9aD4p7FoszX+PZYal5s7+pnxQVI SADdSdNusXj0nb4kcbhOw3iMj0LF1FvgvgbTdhcb8AWcLBsR+SB4tqBnX/wyzb7h+Ma+ z7Gl0bi5Jl/ZTnOXMwvjWLPgwrNSwkrXcu9KvMyta2+aRIRgkv1K7mQkiK6gQrqTkWq4 vxLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :date:message-id:mime-version; bh=UghuRGGoBIV+FWQNja4tOmhBFo0fndDmk5q2GT0GtOQ=; b=FdObk1E7dRm8IRzgSNvKJ0LZPDnzLdVA9eaoznAabN/ietdnfkJ1dvEATTwAMjWRhN 3831BLBtbqHW6Lla0/POcSogAcPiPzvvUd0/WM/PeEa9MSVkUQrlSE6MNOokKxo0pSoE b3za459FJiT6DodDXqT3W2Q8Sa0g3rSjmHwaeYBoIILi818qPpxZ7BjTA538OJvWJWK3 G0UTRJuks9LWq1SxLZNl4BbsdIDPq5t6hngnP5CAajKZYWNhePKrw5qR5rYSaHlXvmwE nS6YKuI33ROPAqaDo04iggwlX6U5g0Rbm8OC0nR99f8/IpkeOwfWD7mn4mpiDIavVjfR 6oDg== X-Gm-Message-State: ANhLgQ1zIIsgbyq+4yhTB5aFaH2SahOHc+wx4vfDimg3p8Bl2NKePlrA WPhuVtfQ45yxydFjkkXLVwTyC1EPdlcH+Q== X-Received: by 2002:ac2:41c2:: with SMTP id d2mr7639986lfi.164.1584263608304; Sun, 15 Mar 2020 02:13:28 -0700 (PDT) Received: from saruman (88-113-215-213.elisa-laajakaista.fi. [88.113.215.213]) by smtp.gmail.com with ESMTPSA id s10sm5099137ljp.87.2020.03.15.02.13.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 15 Mar 2020 02:13:27 -0700 (PDT) From: Felipe Balbi To: Martin Kepplinger , gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: Re: [RFC PATCH] usb: dwc3: enable runtime PM for drd role switch / extcon In-Reply-To: <20200312143038.11719-1-martin.kepplinger@puri.sm> References: <20200312143038.11719-1-martin.kepplinger@puri.sm> Date: Sun, 15 Mar 2020 11:13:22 +0200 Message-ID: <87fteaf0b1.fsf@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, (for commit logs, please break your lines at 72 characters) Martin Kepplinger writes: > Note: runtime PM currently needs to be enabled ("auto") manually via > sysfs as its power/control is set to "on" by the driver. Right, that's on purpose > 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). You need to remember that what you write here is going to be placed in the commit log and will survive forever in the history of the project. Can you be a little bit more technical? For example, why did you change the asynchronous pm_runtime_put() to synchronous versions? Why was that necessary? Also, you're missing your Signed-off-by line. Please, read the documentation about how to write patches. > 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; >=20=20 > + pm_runtime_mark_last_busy(dwc->dev); > + pm_runtime_put_sync_autosuspend(dwc->dev); why synchronous? > + > if (dwc->dr_mode !=3D USB_DR_MODE_OTG) > return; >=20=20 > @@ -196,6 +199,8 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) > { > unsigned long flags; >=20=20 > + pm_runtime_get_sync(dwc->dev); why get here and put on another function? > + > spin_lock_irqsave(&dwc->lock, flags); > dwc->desired_dr_role =3D mode; > spin_unlock_irqrestore(&dwc->lock, flags); > @@ -1552,7 +1557,7 @@ static int dwc3_probe(struct platform_device *pdev) > goto err5; >=20=20 > dwc3_debugfs_init(dwc); > - pm_runtime_put(dev); > + pm_runtime_put_sync(dev); why the conversion to synchronous? =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEElLzh7wn96CXwjh2IzL64meEamQYFAl5t8bIACgkQzL64meEa mQakMw/+JBJsuNCsHdTwzzkUPzdrQhbOijneHyRWoV1l1SRSkouGw64jbY5hjNgi r9tWUq5gcxoEhPqvnl+Ay/qoZE81hAFZPK0qgng9rfDEFi99R26zZrr66SbZmoAi FJAZgYmLN8xeqaU+wjBTiEaj72+FYHRlFvUDzi/9ZcjNwJiyv8QREGl4J03OTwRy 6XDFNyWe9kTs0dP7J71OUn2P037qBj78SRBhGkZwUjEMvfLXDmpA1yBovzHVV0tD ysuVOYrCESLMgZVNDF33gEtRjuZIZXxCuNUqUpDBd3IE4i9uxfNIrfP73HkDp6mS jFGv8ee6kOup8jJUUFPJleBztFzZaa31kysdX+8nR4sa6tikdkoF8v0AHjbQdEjL hF1SilSACtkBj+OduYR2xhHQkonGhB6V9Ygi15BpshZt94VYIwWslTKn7cJA9CJe w+lA6y87H2CtE8/iIvvYmIF8mkQe2Q46wcMYpX3canfHnNePGbvtXJf6gl12TmQ3 HgAG6vkAriYUu9vUCKRxLTVuTMCiFBacXjHAYQnFwXXgRWCKE9eWl5ZghnPXI285 3879mS+07bTH2hO/8CKkhHvz0dCV38tuMTGdj1RZcKzuPn6nSrP9CBoPFPmv03aU JYv997O4NCp4eedoI/SWIG2xEbb40h8rP1lH8YIeJILGt6mwuro= =g/OV -----END PGP SIGNATURE----- --=-=-=--