Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp179226ybc; Mon, 18 Nov 2019 22:53:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxDoxbiZw/4yX+pKQDQ1pPfgWntne2bPaA56bsTNjhPvA/duVxp8UgcKbBNZHXC9KayIcr9 X-Received: by 2002:a17:906:19d0:: with SMTP id h16mr3873188ejd.301.1574146425109; Mon, 18 Nov 2019 22:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574146425; cv=none; d=google.com; s=arc-20160816; b=dQcQKlHIG9S51xhSaqpa/9jazuCSFd+X3rAAXhstO21gyUYSht4nCUaH8J9ZN6BBQp mf9Do3nXYH2zE9h1t1eVUmZ6XipX4O5lsQ6M/h5ZQY7repPGkG7CdBwnwoOvbhz+R82q WkAQvUeHeWtDxyvE7J1DYWgsTAv+EAdXE1PvGBjhpjxyvI8AmNWepc7hZrzqwxSeNRld hI6fpcJp0s98WKG2iLZQm99D0PDJUuZbu1JLrIYME95zBE+k7JjrWGMXnJaCKGe01PoC JwlSvMNN9MVeigJDL6Nli9ftWEurGLox6/HyMdnVbWUjMrdkRKNEjRht1LChvPGAR7MD YCEQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gqCrDOWhcNfPjUIkC6VDbQn+VcsXhMq3C8c3d5eRYuw=; b=Hqbktc/4tvWWZFs0qpYGeGpOKO2rjeErcOgNfJhq8vLZSpFv2DY9vMX1ZQrDwxggWe FsgSDEULCwUQuYMq3MJtqn2ADh6oAQ+qozw5e4bv78XwhTIcbwHDmZhBbt+84e1k2ELf AKqDi7Mfivgoe7EEus0UB3I9zPRgkkVj9BFLw9M5rVrC0qRRZwNudNjslOYLBbssFwVX NlLhOA6g5nMV+RcGbCbzH92syR16quBJufOESar5VdhBH1fr16dZZxSvKRjf1wpCLctQ JH3XvlX2jrA726CpImpx+LYtQV5fJKBDnzQB+6TlOS1YqTMn8Nttq1w89vU+Jd19Cbnm EaJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KVeZ9wBp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si13227927edy.41.2019.11.18.22.53.20; Mon, 18 Nov 2019 22:53:45 -0800 (PST) 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=@kernel.org header.s=default header.b=KVeZ9wBp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731877AbfKSF5G (ORCPT + 99 others); Tue, 19 Nov 2019 00:57:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:50326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731919AbfKSFwd (ORCPT ); Tue, 19 Nov 2019 00:52:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3916420721; Tue, 19 Nov 2019 05:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142752; bh=XSc49gLZDnT5iD6+dqt3KN9TjzN4HO4lpDf5yK9KBYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KVeZ9wBpApyddv9d5GIwpQYVSdEkAvp2MIZJE24Kd5+3aNz4AJgjnK0NjwXMzrciF EDYKGAQqxbCC4R8Xzxitk03nfzYkm9M+XxpQgmNqDM7GEf+hvQT93bwzEtIE3lYQok HUS/u6q3vG6W8be7BhdOLcUmsuQxH1IZhzxPC0O4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Kemnade , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 4.14 188/239] phy: phy-twl4030-usb: fix denied runtime access Date: Tue, 19 Nov 2019 06:19:48 +0100 Message-Id: <20191119051335.323621818@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Kemnade [ Upstream commit 6c7103aa026094a4ee2c2708ec6977a6dfc5331d ] 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, disable irq on suspend and recheck on resume. Practically this happens when the device is woken up from suspend by plugging in usb. Signed-off-by: Andreas Kemnade Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/phy/ti/phy-twl4030-usb.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c index a44680d64f9b4..c267afb68f077 100644 --- a/drivers/phy/ti/phy-twl4030-usb.c +++ b/drivers/phy/ti/phy-twl4030-usb.c @@ -144,6 +144,7 @@ #define PMBR1 0x0D #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) +static irqreturn_t twl4030_usb_irq(int irq, void *_twl); /* * If VBUS is valid or ID is ground, then we know a * cable is present and we need to be runtime-enabled @@ -395,6 +396,33 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on) WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0); } +static int __maybe_unused twl4030_usb_suspend(struct device *dev) +{ + struct twl4030_usb *twl = dev_get_drvdata(dev); + + /* + * we need enabled runtime on resume, + * so turn irq off here, so we do not get it early + * note: wakeup on usb plug works independently of this + */ + dev_dbg(twl->dev, "%s\n", __func__); + disable_irq(twl->irq); + + return 0; +} + +static int __maybe_unused twl4030_usb_resume(struct device *dev) +{ + struct twl4030_usb *twl = dev_get_drvdata(dev); + + dev_dbg(twl->dev, "%s\n", __func__); + enable_irq(twl->irq); + /* check whether cable status changed */ + twl4030_usb_irq(0, twl); + + return 0; +} + static int __maybe_unused twl4030_usb_runtime_suspend(struct device *dev) { struct twl4030_usb *twl = dev_get_drvdata(dev); @@ -655,6 +683,7 @@ static const struct phy_ops ops = { static const struct dev_pm_ops twl4030_usb_pm_ops = { SET_RUNTIME_PM_OPS(twl4030_usb_runtime_suspend, twl4030_usb_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(twl4030_usb_suspend, twl4030_usb_resume) }; static int twl4030_usb_probe(struct platform_device *pdev) -- 2.20.1