Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4505377imm; Mon, 17 Sep 2018 15:24:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZuhep/0S21j81bVPx//lQ8KtNCiooix1trYvcCvenKECRfXnMm6s0PWBE+pzHMZHCIjXEW X-Received: by 2002:a17:902:4503:: with SMTP id m3-v6mr26408160pld.168.1537223079835; Mon, 17 Sep 2018 15:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537223079; cv=none; d=google.com; s=arc-20160816; b=w/7n39wqA/o847B2hF3AjYe/Yfko7VEdoS9fuZz1Tk2vBcWBriJFMhxj3JwgGyYrIJ 5HK3oX7GOzGLQ6wKBKcM1g1SKK9MlJ5EPP77zHlTZ3qEb80fTsdSfroKBTHYvCdRp6rN hsWcou8NX+VIZ863IxoPOiosh2KxGdbrWygLPoLSTnLQEsBC95mk84qKKJE4OpW1wnls 8E1Y0MYBTuQuiK5IMQ3LJ6k32OB1avIhGSxKik8tGyKKsjgdVCZtMcAcwlWNjyHVEEul OKAbEF+UI9LETvufgK+BW8xyz7JoM2y4QCRLvZE6XkzlvPsiOj98O9jby14CkOzBfQcv nqRQ== 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=eaekUQ9eV4wEvO33KdfURJwGZi80tEEamCz+pDEq8FY=; b=kL9R9KN3PKlK1WftrLOKGhncxPRIse03UQJRMgE+p3fQjRE9VUGtSa48HhaWveEPM6 kT9m6b9GEFcTZd1IdDYvFOv9ak3Oa3KIZykyN4owUIhXc1/MDb6scvojgjLLiSHJTLVt Xo3YbHkP9nqDfZnPYN5rmNqj9s0yjorCeh7fLE6NTR0nc0Yz0swUKXnF8Bir7qIilrbC Rzc1TJGnr33L4xavC9F1TXGcYOV/zz3hoiopHNLwi7tmN7/I2fAXC/Q8jp9fkpYX9nDd fbhKK1vRvaR8CODEFM7MNVRiFMxyB4KhSwmcxwLYH4fZlE6ioKaVGNrRFQCwevIhe6gH 2rDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="af/Isp8E"; 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 o20-v6si16348806pgk.120.2018.09.17.15.24.23; Mon, 17 Sep 2018 15:24:39 -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="af/Isp8E"; 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 S1728601AbeIRDxH (ORCPT + 99 others); Mon, 17 Sep 2018 23:53:07 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37938 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbeIRDxH (ORCPT ); Mon, 17 Sep 2018 23:53:07 -0400 Received: by mail-pl1-f195.google.com with SMTP id u11-v6so8073774plq.5; Mon, 17 Sep 2018 15:23:49 -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=eaekUQ9eV4wEvO33KdfURJwGZi80tEEamCz+pDEq8FY=; b=af/Isp8EW6XdbOX7rtm/6KwEc79E1YZgtjJ1lDb+9RVDo+xRM4onGP4QL+t5edi25q FHPCUudIcL5nmvuWBMVXxbBjECDnepb29+A5kHlzz0UGk1+e6Jwbt+k583uEe8uud25L EOhRu9cywhnuTeRQ5WA3LU37svbjHf7/o1m70m3249FbRclkdWKt+Aje1vuAyUR8Z33L MEnhey90VwXinMnDrPxJSCq1pVH3wDNyesahZfiq1Vlm4QQFIRtgZhtK3z/1B99q0amh SyuYHbRZ9pPfaIb/0UBqZ4hjLy8IF1Ff6P1mIcByvmlMuHGu15cJPKw+cJGxZ7fAqQCw RlSQ== 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=eaekUQ9eV4wEvO33KdfURJwGZi80tEEamCz+pDEq8FY=; b=A1xB0YO4dTYCH+p5IU3QNM8mJUy+h4rJpFaT8qQC+rPM3Dfv8UXbxemdvkXPl9m4ee /xgyVYxU5OPDftoTgvHC0OA7rGKmcj8M6WKXkJMVLKJC8BUXT7kzlwnV2NO8sZ3w284M +x7napzihiuB+EtGu2h4/5pk6nH66G+43JSqWeRWS6aPn75Eco6Lw+GLOfTB92wOOFB6 O1vM+ZV4lbva6FZYKpRxpsoxD0aeLO8Jvqk+r7JIrGv5+9T6kzwnSf1ayIE08YFutgDz 9xTGDtW3MiadIYr8H1JoGZj28ihTOUTADdS5wDvRdGeCxnQjB/zOKZlNDQIZDD5L7VK/ Sr6w== X-Gm-Message-State: APzg51Dq4NH4gMQoebGI8f2I81ZyrpuDkzxlYATP3v1KJICE74SGqwEG 2jmCPrdCESxynfCp2mHzmBY= X-Received: by 2002:a17:902:8b8b:: with SMTP id ay11-v6mr26211982plb.1.1537223028691; Mon, 17 Sep 2018 15:23:48 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id 8-v6sm18904083pgu.10.2018.09.17.15.23.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Sep 2018 15:23:47 -0700 (PDT) Date: Mon, 17 Sep 2018 15:23:45 -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: <20180917222345.GA203020@dtor-ws> References: <20180917052254.12336-1-andreas@kemnade.info> <20180917175131.GA104770@dtor-ws> <20180917205634.6a320cad@aktux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180917205634.6a320cad@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 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... > > > 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. Thanks. -- Dmitry