From patchwork Wed Jul 26 15:00:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9865251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C34DD60382 for ; Wed, 26 Jul 2017 15:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9CBD28733 for ; Wed, 26 Jul 2017 15:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE3172876B; Wed, 26 Jul 2017 15:02:04 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 67EFE28733 for ; Wed, 26 Jul 2017 15:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751777AbdGZPBq (ORCPT ); Wed, 26 Jul 2017 11:01:46 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34569 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbdGZPBN (ORCPT ); Wed, 26 Jul 2017 11:01:13 -0400 Received: by mail-lf0-f65.google.com with SMTP id d80so5169405lfg.1; Wed, 26 Jul 2017 08:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=m6y5Aw8YIssvm84P/lGgViSg+jk6F3UZh1Z2xNlBLQ8=; b=LaiiRo1yedjMG3eYCeuNao5dthaaiz/CugDJQ+F4///YP1EpKACNT4oz6MkcEeO19B TzfFT+7FHmZM2RiTqX5QpmeuCPqsyU1w/k0rYL6K4WSJL1Zgr6BqSVfNcZaJUs1lNZc8 zU3hVd5ItyRQrlD1FPAGHB8E3lQ58RLMSCLHfBWuPjlf9nTbaC5sy2Qp8jnB71U20rzF DEsmg3+Y9riSn2of/dpGlOMwTkXE0zeUOpm6U3yd9Qfln59/ADo12AoYwmVe4WZeFiCC 1znyIsyVtM3ahBDyBoVPSA5m3/B3bTscMt+KQqoAnShk7x2pQK6P/dzaeY+UW43HcN9N XQmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=m6y5Aw8YIssvm84P/lGgViSg+jk6F3UZh1Z2xNlBLQ8=; b=TvVZdYImUz5AHHvTr4bqD4XMghvyoMF9mNVwb8gOKOp5oMq2VWQPP1PP6Kk6p0Cwsl hQB66G4vWh3ZBDpiBCgfVIkEcMc2LQw95NVljcKdOyyJDTiW8UlMr2CQNF8FB0W6cGIO HUSBA2pjfSzUOjfkOvLzS0ERaLw/f6BAQApukgMqPpY1xynXVxHckWhnTj3IIU8nwqA9 39QOKbsm+02XYLxhS6VMk9oloAHKuHkAW1pRXfufKTuwkJZ78BtOWyMvhMoJQbcpZ1Z/ N3NlP2KrngWBgipRBTBPoKMmUSjZDxIyOajzhhRN01HwXEctkAPkbFEIzVhfm3y9w9uR Akyw== X-Gm-Message-State: AIVw112PVMV4pe6Qg/9IEFvt7lXQGBroGRWrqgZeaI7UQTsQ5dO9Nke8 bCLExuONKX8lrw== X-Received: by 10.25.23.106 with SMTP id n103mr446091lfi.97.1501081271629; Wed, 26 Jul 2017 08:01:11 -0700 (PDT) Received: from xi.terra (c-42c8e255.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.226.200.66]) by smtp.gmail.com with ESMTPSA id h15sm2969135lfk.31.2017.07.26.08.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 08:01:09 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1daNoB-0005vv-49; Wed, 26 Jul 2017 17:01:07 +0200 From: Johan Hovold To: Bin Liu Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Alan Stern , Daniel Mack , Tony Lindgren Subject: [PATCH v2 2/2] USB: musb: dsps: add explicit runtime resume at suspend Date: Wed, 26 Jul 2017 17:00:46 +0200 Message-Id: <20170726150046.22757-3-johan@kernel.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170726150046.22757-1-johan@kernel.org> References: <20170726150046.22757-1-johan@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The musb_dsps driver is special in that the parent (glue) device's driver is accessing registers mapped by the child. The clock is however shared and is managed by the grandparent device. Since commit 869c59782981 ("usb: musb: dsps: add support for suspend and resume") the dsps driver has been accessing these registers as part of suspend and resume. The parent driver obviously cannot runtime resume the child during system suspend and is currently relying on the fact that the child will be RPM_ACTIVE throughout suspend. The suspend implementation also makes sure to check that the child is indeed present (and hence the clock enabled) before accessing the registers. Let's add an explicit runtime resume of the glue device itself to enable the clock before doing the register accesses in case these assumptions ever change (i.e. if the child is left runtime suspended). Note that the glue-timer cancellation is moved after the child-presence check to keep error handling simple. This should be fine as the timer is not setup until the controller is being registered and at that time glue->musb and its driver data have already been initialised. Cc: Alan Stern Cc: Daniel Mack Cc: Tony Lindgren Signed-off-by: Johan Hovold --- drivers/usb/musb/musb_dsps.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index bc6a9be2ccc5..f6b526606ad1 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -1015,13 +1015,20 @@ static int dsps_suspend(struct device *dev) const struct dsps_musb_wrapper *wrp = glue->wrp; struct musb *musb = platform_get_drvdata(glue->musb); void __iomem *mbase; - - del_timer_sync(&glue->timer); + int ret; if (!musb) /* This can happen if the musb device is in -EPROBE_DEFER */ return 0; + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } + + del_timer_sync(&glue->timer); + mbase = musb->ctrl_base; glue->context.control = musb_readl(mbase, wrp->control); glue->context.epintr = musb_readl(mbase, wrp->epintr_set); @@ -1060,6 +1067,8 @@ static int dsps_resume(struct device *dev) musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) dsps_mod_timer(glue, -1); + pm_runtime_put(dev); + return 0; } #endif