Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5466036imm; Tue, 18 Sep 2018 09:57:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYgR7hYeH2f1Kl8GvtiYpA1GEUFzPpozn53YXVx/AgLzEPubnihCYmYJmX1uzLH23pxVxlz X-Received: by 2002:a63:ac11:: with SMTP id v17-v6mr28559092pge.196.1537289831135; Tue, 18 Sep 2018 09:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537289831; cv=none; d=google.com; s=arc-20160816; b=RMGs7MmRePLJzPpqZ2IjBi2MgSRQii2X13s2ZXNqVGWbJojP+5x95MZLvT3Nw5x5vA y2M6pJAosBC5dF9/Slqjo+UloY648aP6TuTj97qMZq/UNaKEqpvMDODpTRN3qZSSnH95 U1IuXQVokNLm0onNJ5cUX9Y++PSDdSVNrtuex1WwbXuVSawPvtmDgQ4GJqm19CsD12qQ uzge6AOrNVq/rvRA08GzJlP84ui6UIa0u4Xx1/AjxmZcZEW/3qKTYm1d7KBnTxCx8Q58 ojEjCst8evs4bHI8anVQWvlCaNMAbnkAO6cKucR0Wm1L11+N5VHg0CrxKx0xRzNBTHg7 5Ezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=v9yxKlhdbAJO33IdLZGWGHGBz2zpZVT7MlHi2+CTTkY=; b=nuPdz2LmggrBNhy/wO5bQV2A2dBcyEWpqUU5cr8xe7RTbmIcRMyM1/jFe991Z2fsJx 7vL94rc9Pxrz5mv4RsZYEkCY8VfEt5wwEyurww3pWbm7prNzIP8HYmYY/BXxCpOfEhXO PJN9xhBg55zRFMZSbPSPhIl875p3SQrpEMgRWDv82YIYQDjQzTYf2zWyC/lSMDl3Qebu 1BXMSZ2IWkMSxUH+yNDCyBhIIFguJob/CxXPuTO/zvuZ1k8Rpt/H1ERb3ZAAKKzwN9Hy 0yefhmbdc/cB7fOXsiXvk5O0rXW6UZNtzHBMkovvUNnkMlOQR2tbuiFSuasQYSPVH5+o jTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oIU2qbii; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si18944259pgg.341.2018.09.18.09.56.56; Tue, 18 Sep 2018 09:57: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oIU2qbii; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730216AbeIRW3z (ORCPT + 99 others); Tue, 18 Sep 2018 18:29:55 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46007 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729037AbeIRW3z (ORCPT ); Tue, 18 Sep 2018 18:29:55 -0400 Received: by mail-pf1-f193.google.com with SMTP id i26-v6so1292234pfo.12; Tue, 18 Sep 2018 09:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=v9yxKlhdbAJO33IdLZGWGHGBz2zpZVT7MlHi2+CTTkY=; b=oIU2qbiiN4AXM2axSYWJbwrtwBXw0FnvrMX/NsrkuoKDz7m8PcdlkxQT5AEkMzSbZP TRMNjAjGU/Aix1e5SnzqHp17k7bNVzcuglGBgXI5cHZFWWRna2DlZUvyEPmyzwWlZ4+6 lRKZsx10FjAK6GuXcsSb+rQKPm1y50f3/ylHB+gOlzjIIDSOrA32LwRWnsoVsn9vfrbx QlinvffQ8mkOzsxxpZZ6fhXbnn5ZfA/AkoVCkAivQ3Y/KuevILdzG5SRVfqRsmK3s1cZ sWumk/vZsU1detur9vT+xqLkRnT8XWpyK3E6xCWr26EiR4LcApSj7Rlo0X6rKjqP0BzH QC6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=v9yxKlhdbAJO33IdLZGWGHGBz2zpZVT7MlHi2+CTTkY=; b=jlMUBm2/Ki2BHE8Z/b1+IDTwxUt0T8ywffiA8LRpAOUA+0t1UVYgiFaZ5M4PoWLckr u8Hwr/ImRjwXYZbiezL9XGXlejnYu5XzNJFtsQMydzDH/aLWX2k+Yif4FXNbieZv6zV4 HmdypVpQ5ZriLB9b27n9tTo3i18Il6cwO3noSjGeKy1J0C8ykTmL+TcU40olLdmOf84K zOFocMS/sMArvLR976pznRI0HK8+tAPyRE9mZ9VYx/ZET7VH5vfAxDTnh0jR8+wa+QiJ Z7UwpJ/eHspX6KuDwsTpAQWm8P2FHJfCEEIjmpflACOoB39ua8speQU+kbTIIsjLJfnf iUhw== X-Gm-Message-State: APzg51AcbuybxGV/ZqQLoYp/GodZvSpS6OOJJT89BSqJaKsfQj8hr0po ISbmNsX1kLChxBb4w3Ltfjs= X-Received: by 2002:a62:4808:: with SMTP id v8-v6mr32005405pfa.89.1537289787691; Tue, 18 Sep 2018 09:56:27 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id f87-v6sm49888090pfh.168.2018.09.18.09.56.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 09:56:26 -0700 (PDT) Date: Tue, 18 Sep 2018 09:56:24 -0700 From: Dmitry Torokhov To: Andreas Kemnade Cc: kishon@ti.com, lee.jones@linaro.org, daniel.thompson@linaro.org, wsa@the-dreams.de, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Discussions about the Letux Kernel Subject: Re: [PATCH RESEND] phy: phy-twl4030-usb: fix denied runtime access Message-ID: <20180918165624.GB177805@dtor-ws> References: <20180917052254.12336-1-andreas@kemnade.info> <20180917175131.GA104770@dtor-ws> <20180917205634.6a320cad@aktux> <20180917222345.GA203020@dtor-ws> <20180918181619.2e266f0d@aktux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180918181619.2e266f0d@aktux> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 18, 2018 at 06:16:19PM +0200, Andreas Kemnade wrote: > Hi, > > On Mon, 17 Sep 2018 15:23:45 -0700 > Dmitry Torokhov wrote: > > > On Mon, Sep 17, 2018 at 08:56:34PM +0200, Andreas Kemnade wrote: > > > Hi Dmitry, > > > > > > On Mon, 17 Sep 2018 10:51:31 -0700 > > > Dmitry Torokhov wrote: > > > > > > > Hi Andreas, > > > > > > > > On Mon, Sep 17, 2018 at 07:22:54AM +0200, Andreas Kemnade wrote: > > > > > When runtime is not enabled, pm_runtime_get_sync() returns -EACCESS, > > > > > the counter will be incremented but the resume callback not called, > > > > > so enumeration and charging will not start properly. > > > > > To avoid that happen, wait and try again later. > > > > > > > > > > Practically this happens when the device is woken up from suspend by > > > > > plugging in usb. > > > > > > > > > > Signed-off-by: Andreas Kemnade > > > > > --- > > > > > drivers/phy/ti/phy-twl4030-usb.c | 9 +++++++++ > > > > > 1 file changed, 9 insertions(+) > > > > > > > > > > diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c > > > > > index a44680d64f9b..1f3cf4e48383 100644 > > > > > --- a/drivers/phy/ti/phy-twl4030-usb.c > > > > > +++ b/drivers/phy/ti/phy-twl4030-usb.c > > > > > @@ -552,6 +552,15 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) > > > > > > > > > > status = twl4030_usb_linkstat(twl); > > > > > > > > > > + /* we might get here too early when runtime is not ready yet > > > > > + * and we will get an EACCESS later, so try again later > > > > > + */ > > > > > > > > How exactly can this happen? What disables (and later re-enables) > > > > runtime PM? > > > If the whole resume process is started by plugging in usb, the > > > interrupt will be triggered still in the resume process so that > > > runtime resume is not yet possible, pm_runtime_get_sync() returns > > > EACCESS > > > > I see. This all seems a bit wonky, to be honest. I would expect that the > > driver would have a suspend routine that disables interrupt and also > > configure interrupt for wakeup (enable_irq_wake) and kick bus scanning > > from there instead of aborting interrupt handler... > > > well, that seems doable. So there will be a v2. > > > > > > > > How can we guarantee that the interrupt will be > > > > re-triggered? > > > > > > > The interrupt will not be re-triggered but the handler will be > > > called at some other places... > > > > > > > > + if (!pm_runtime_enabled(twl->dev)) { > > > > > + cancel_delayed_work(&twl->id_workaround_work); > > > > > + schedule_delayed_work(&twl->id_workaround_work, HZ); > > > > > + return IRQ_HANDLED; > > > > > + } > > > > > + > > > ... for example by this delayed work which is already there. > > > > If we decide to keep this, it should be mod_delayed_work() I think. > > > Well, is that valid for the other uses of id_workaround_work() (which > are clearly required)? So there should be a second, independent > cleanup patch for the existing uses? Yes, mod_delayed_work() is replacement for cancel + reschedule. I guess this driver was created before mod_delayed_work() was added to the kernel. Thanks. -- Dmitry