From patchwork Wed Jun 18 17:01:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 4378131 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 502E4BEEAA for ; Wed, 18 Jun 2014 17:01:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E51F201DD for ; Wed, 18 Jun 2014 17:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81157201D3 for ; Wed, 18 Jun 2014 17:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753645AbaFRRBP (ORCPT ); Wed, 18 Jun 2014 13:01:15 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:62967 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753635AbaFRRBN (ORCPT ); Wed, 18 Jun 2014 13:01:13 -0400 Received: by mail-we0-f169.google.com with SMTP id t60so1195900wes.28 for ; Wed, 18 Jun 2014 10:01:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6fyg3WGoJFM2krf3KGPZwbzPSuV7PROC7rWs0zd4BYE=; b=TgvzwSg5nrex2yPkk7CXM1MR6tB6NuUmwCRsN7aKheYAzYIWV6i1oN2PmvJlGg2Ar7 V6ED0schU9WuIAOW1SfI3onOSyaQq+rzqOs7NtTCdvGyXouMFnQZSHQ7cqvHb0dn6DX8 p2RRF9iYXqX8hHjo3lQC3NTbQkvDr9/jB3HtD1lfNwJ13wuYlnRU49REqvy854eff1+b R4kdX545PbqogyZWZJcIuMsri02f64q3nLUi8X1SKCbTvvwnngE1uvu+xwHn5iubtxhL gZOTBfMjgpNgIHDtY+ueVY4CzqtXfXht3mie1Q43anQFuNQylR9gc890/qGf5X4ayGIe /V/g== X-Gm-Message-State: ALoCoQmFuvBeo52qxnkObPhnsewiFWGJXXl02BqY9MC2OYb+xdnZunr/8ois/VinOA4diiMNlvN5 X-Received: by 10.180.183.131 with SMTP id em3mr7007000wic.56.1403110872063; Wed, 18 Jun 2014 10:01:12 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-99-228-46.as13285.net. [2.99.228.46]) by mx.google.com with ESMTPSA id o12sm26611840wiw.5.2014.06.18.10.01.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jun 2014 10:01:11 -0700 (PDT) From: Srinivas Kandagatla To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH 3/3] usb: phy: msm: Do not do runtime pm if the phy is not idle Date: Wed, 18 Jun 2014 18:01:08 +0100 Message-Id: <1403110868-3924-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403110801-3790-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1403110801-3790-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use case is when the phy is configured in host mode and a usb device is attached to board before bootup. On bootup, with the existing code and runtime pm enabled, the driver would decrement the pm usage count without checking the current state of the phy. This pm usage count decrement would trigger the runtime pm which than would abort the usb enumeration which was in progress. In my case a usb stick gets detected and then immediatly the driver goes to low power mode which is not correct. log: [ 1.631412] msm_hsusb_host 12520000.usb: EHCI Host Controller [ 1.636556] msm_hsusb_host 12520000.usb: new USB bus registered, assigned bus number 1 [ 1.642563] msm_hsusb_host 12520000.usb: irq 220, io mem 0x12520000 [ 1.658197] msm_hsusb_host 12520000.usb: USB 2.0 started, EHCI 1.00 [ 1.659473] hub 1-0:1.0: USB hub found [ 1.663415] hub 1-0:1.0: 1 port detected ... [ 1.973352] usb 1-1: new high-speed USB device number 2 using msm_hsusb_host [ 2.107707] usb-storage 1-1:1.0: USB Mass Storage device detected [ 2.108993] scsi0 : usb-storage 1-1:1.0 [ 2.678341] msm_otg 12520000.phy: USB in low power mode [ 3.168977] usb 1-1: USB disconnect, device number 2 This issue was detected on IFC6410 board. This patch fixes the intial runtime pm trigger by checking the phy state and decrementing the pm use count only when the phy state is IDLE. Signed-off-by: Srinivas Kandagatla --- drivers/usb/phy/phy-msm-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 3bb559d..78cc870 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1229,7 +1229,9 @@ static void msm_otg_sm_work(struct work_struct *w) motg->chg_state = USB_CHG_STATE_UNDEFINED; motg->chg_type = USB_INVALID_CHARGER; } - pm_runtime_put_sync(otg->phy->dev); + + if (otg->phy->state == OTG_STATE_B_IDLE) + pm_runtime_put_sync(otg->phy->dev); break; case OTG_STATE_B_PERIPHERAL: dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n");