Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp404162imm; Sat, 22 Sep 2018 02:45:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV61H30YEOVBSXKYipZwwZYnpKubIJQTjCNDZ3pmwKUJjdEmBW+p8wMXV5/pvE0xFvo13lAVR X-Received: by 2002:a63:5660:: with SMTP id g32-v6mr1586706pgm.227.1537609519439; Sat, 22 Sep 2018 02:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537609519; cv=none; d=google.com; s=arc-20160816; b=vV9x6I1AXw6tZ7h304Mb8FimnwcWPgQUJJsVH6z2PC/wFAa6dMP8S//nWHXCV4Pzrr xzHPXyckS3yqMnhsZg3ODD9MsF/2MpU9QwrX4a5ShFdJUJYqluyfuCokY+75x0HRcxer cvuO6SdQrO428cEPFZ+Qufrg7kXaEQ0x3xD7QHWd4bens14vuRMrhdDWlCGwUXeRlVNK TQ11VQWPk2b1XymZhkwJAF1+aA4WPvxwbAtg7CwXwrvghVsLZUQc7r6ELz+yihVJZ9kH VgdZrYhv0FlJkkMRQrFkgEM1kV7foHYJ22kFWF1B6smCB05sN+Yu2F5TD0VoBjcEwUe1 aejA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ckfTIXZPLRCZnGBAzYwpuhaAlRMMQuVslbM+FoejtXQ=; b=cgkrxIGLPSdzOheuzBNKCmrmqs6B8143Xl+Xdgoge3r8eFQKo8B1wwXjIVa4QE4M3e Y/sV2o3gAtAqMDrHOmBcfL4vsfOpYoklY3R2iTBbbAu0tOz5yvtz10Jh8Dmf5bTvtFrf dLKYfWd1+gWsEAe+oatlWMTerkrZ29MbCApE5sJgpSQnJ29rMW5n7809hpkxdXht7O1S CVPHXgyQh0TySFnL3GYKzy9aimQq18fslwSxnohQCqmmWvGCPxjNjqGGQEZvPxYGMcVB FHhQFYeui2z5NMEn4/c8SwBeHbOnjexAOSAgfwjheapIXJf1xI3d5NXk4gIbEYnQELDQ P7IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b=VcC6bwAV; 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 f62-v6si30579173pfg.35.2018.09.22.02.45.03; Sat, 22 Sep 2018 02:45:19 -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=@kemnade.info header.s=20180802 header.b=VcC6bwAV; 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 S1728096AbeIVPha (ORCPT + 99 others); Sat, 22 Sep 2018 11:37:30 -0400 Received: from mail.andi.de1.cc ([85.214.239.24]:54562 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbeIVPha (ORCPT ); Sat, 22 Sep 2018 11:37:30 -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=ckfTIXZPLRCZnGBAzYwpuhaAlRMMQuVslbM+FoejtXQ=; b=VcC6bwAVAmM1NEJeqC0j7Qlw9w ioWzonIkFenLbXyCq0WNBjPMUWw0VjoiC+/cRssMx9eiNdMdVAetOHdT7q5IPLhe6a1Nql8gs7c10 HHz274bTRZEJ0Aatpe8xML4fkV2XEBlQl+IqltC7McOp1+bxB/ggjhAP+qoGILMtCM6U=; Received: from p200300ccfbf756001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbf7:5600: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 1g3eSi-00083Y-21; Sat, 22 Sep 2018 11:44:28 +0200 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1g3eSh-00014W-J9; Sat, 22 Sep 2018 11:44:27 +0200 From: Andreas Kemnade To: Dmitry Torokhov , 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 Cc: Andreas Kemnade Subject: [PATCH v2] phy: phy-twl4030-usb: fix denied runtime access Date: Sat, 22 Sep 2018 11:44:05 +0200 Message-Id: <20180922094405.4067-1-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v2: * use pm suspend/resume callback instead of delayed_work as suggested by Dmitry 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 a44680d64f9b..c267afb68f07 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.11.0