From patchwork Mon Sep 17 05:22:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10602073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDF6114DA for ; Mon, 17 Sep 2018 05:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB75294A8 for ; Mon, 17 Sep 2018 05:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0CF4294F2; Mon, 17 Sep 2018 05:23:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75442294A8 for ; Mon, 17 Sep 2018 05:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbeIQKtf (ORCPT ); Mon, 17 Sep 2018 06:49:35 -0400 Received: from mail.andi.de1.cc ([85.214.239.24]:40190 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbeIQKtf (ORCPT ); Mon, 17 Sep 2018 06:49:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rmr8r/dvg5zBfzVzBC6i7VTPg85Egzw2u+whUMYD8Oc=; b=ksb3gIPgbAQi0oL1iCZk+LwADH b5jjVmNTUkTp5lzG50Bfu2V7b0+vh03kbeWhHadu/+GZWt6uARMyMP+h3CeIA76dFilf1bj03J/wi PEw7BAl51GL0/eVGpiZV0AbpXq60iavoqAN+4B+e1hM8JEm5HNFoSwNcct231e+dbVRM=; Received: from p200300ccfbca24001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbca:2400:1a3d:a2ff:febf:d33a] helo=aktux) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g1m0g-0006W0-3k; Mon, 17 Sep 2018 07:23:46 +0200 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1g1m0f-0003Gz-Rk; Mon, 17 Sep 2018 07:23:45 +0200 From: Andreas Kemnade To: kishon@ti.com, lee.jones@linaro.org, dmitry.torokhov@gmail.com, daniel.thompson@linaro.org, wsa@the-dreams.de, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Discussions about the Letux Kernel Cc: Andreas Kemnade Subject: [PATCH RESEND] phy: phy-twl4030-usb: fix denied runtime access Date: Mon, 17 Sep 2018 07:22:54 +0200 Message-Id: <20180917052254.12336-1-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 + */ + if (!pm_runtime_enabled(twl->dev)) { + cancel_delayed_work(&twl->id_workaround_work); + schedule_delayed_work(&twl->id_workaround_work, HZ); + return IRQ_HANDLED; + } + mutex_lock(&twl->lock); if (status >= 0 && status != twl->linkstat) { status_changed =