From patchwork Wed Jul 26 15:00:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9865243 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 4F8EA60382 for ; Wed, 26 Jul 2017 15:01:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54F622876E for ; Wed, 26 Jul 2017 15:01:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 499192878E; Wed, 26 Jul 2017 15:01:34 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 206782876F for ; Wed, 26 Jul 2017 15:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751646AbdGZPBQ (ORCPT ); Wed, 26 Jul 2017 11:01:16 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38361 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751510AbdGZPBN (ORCPT ); Wed, 26 Jul 2017 11:01:13 -0400 Received: by mail-lf0-f66.google.com with SMTP id y15so7144748lfd.5; Wed, 26 Jul 2017 08:01:11 -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=afB9f+CcHNzyCtb2F1NjufKnNId6aRJtvBxTDaJDx0g=; b=fyzs6SpkxqI9ENfsF+PBYkHoaT00fcglRqrOAn6J6ZA4c3kq4tJvVk8tMl9zMwLwo8 lk5uAqiJs6cE7B34ehKI3tNXtYVCiBPreMcNJKJMvgBy923Uv5mrhoXNzYjnFna/1wdS Jkb/NwoWELx6rkqe1b91ItDVVbN5oyUzKS7RffvHxsB1+sd+sl+l94HN+pLPAdpdoFkE tgejzh6ZkPNe1vlu1hLC5mm+87bazQAe27DOMIvprIemu/4evJoag1Fvew2C+CuQIdsT nU3qltk1vPMkxgK5xfOxXFI8F4Vkuu8WdjpaXcV9+vN9wCUi0DUXewkTt9cTbrKwE0di Tk5w== 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=afB9f+CcHNzyCtb2F1NjufKnNId6aRJtvBxTDaJDx0g=; b=ULzevuLfX1f1Q2+D3Xht3MstOcXD/jPvxROG41hYspY+rjv9WT/f6lkJ4ZnrxouA/4 c6Q/Au1VC65hsGBIIBpJ1QnAmOxpVycVaUCZqCqAaTyTxc0ovbSyfAV9ND77JEC+jNTj 6UFH4kCe7+UtWgkbzOAfcP2pqDKENUQMc60h/31/QMwJLh2OaSFJabqIMoQUTrHb5vHS 2Bd6pUBRUKDvU49bhKn+6RqHnpyW3j9A0grff1RpBdcblLbZhZKIFS0zxJAGFXRRwH2m O0TiqW5fTI9Sy8Zjn7+vmDbjlivqEwTOm3lwAMPW4RL3yaorl3qTm9u2FrUsc+t5NrcG YTeA== X-Gm-Message-State: AIVw113WHza2ghZUdxRXYf6wahhn9fH+JPdrwkfOGGFNqfyxuBXoREGn X6CP7BuZffB9rg== X-Received: by 10.25.93.70 with SMTP id p6mr428400lfj.56.1501081271126; 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 r25sm3259544lfi.70.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-0005vq-1y; 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 , stable , Alan Stern , Daniel Mack , Dave Gerlach , "Rafael J . Wysocki" , Sebastian Andrzej Siewior , Tony Lindgren Subject: [PATCH v2 1/2] USB: musb: fix external abort on suspend Date: Wed, 26 Jul 2017 17:00:45 +0200 Message-Id: <20170726150046.22757-2-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 Make sure that the controller is runtime resumed when system suspending to avoid an external abort when accessing the interrupt registers: Unhandled fault: external abort on non-linefetch (0x1008) at 0xd025840a ... [] (musb_default_readb) from [] (musb_disable_interrupts+0x84/0xa8) [] (musb_disable_interrupts) from [] (musb_suspend+0x38/0xb8) [] (musb_suspend) from [] (platform_pm_suspend+0x3c/0x64) This is easily reproduced on a BBB by enabling the peripheral port only (as the host port may enable the shared clock) and keeping it disconnected so that the controller is runtime suspended. (Well, you would also need to the not-yet-merged am33xx-suspend patches by Dave Gerlach to be able to suspend the BBB.) This is a regression that was introduced by commit 1c4d0b4e1806 ("usb: musb: Remove pm_runtime_set_irq_safe") which allowed the parent glue device to runtime suspend and thereby exposed a couple of older issues: Register accesses without explicitly making sure the controller is runtime resumed during suspend was first introduced by commit c338412b5ded ("usb: musb: unconditionally save and restore the context on suspend") in 3.14. Commit a1fc1920aaaa ("usb: musb: core: make sure musb is in RPM_ACTIVE on resume") later started setting the RPM status to active during resume, and this was also implicitly relying on the parent always being active. Since commit 71723f95463d ("PM / runtime: print error when activating a child to unactive parent") this now also results in the following warning: musb-hdrc musb-hdrc.0: runtime PM trying to activate child device musb-hdrc.0 but parent (47401400.usb) is not active This patch has been verified on 4.13-rc2, 4.12 and 4.9 using a BBB (the dsps glue would always be active also in 4.8). Fixes: c338412b5ded ("usb: musb: unconditionally save and restore the context on suspend") Fixes: a1fc1920aaaa ("usb: musb: core: make sure musb is in RPM_ACTIVE on resume") Fixes: 1c4d0b4e1806 ("usb: musb: Remove pm_runtime_set_irq_safe") Cc: stable # 4.8 Cc: Alan Stern Cc: Daniel Mack Cc: Dave Gerlach Cc: Rafael J. Wysocki Cc: Sebastian Andrzej Siewior Cc: Tony Lindgren Signed-off-by: Johan Hovold --- drivers/usb/musb/musb_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 87cbd56cc761..b67692857daf 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2671,6 +2671,13 @@ static int musb_suspend(struct device *dev) { struct musb *musb = dev_to_musb(dev); unsigned long flags; + int ret; + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } musb_platform_disable(musb); musb_disable_interrupts(musb); @@ -2721,14 +2728,6 @@ static int musb_resume(struct device *dev) if ((devctl & mask) != (musb->context.devctl & mask)) musb->port1_status = 0; - /* - * The USB HUB code expects the device to be in RPM_ACTIVE once it came - * out of suspend - */ - pm_runtime_disable(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - musb_start(musb); spin_lock_irqsave(&musb->lock, flags); @@ -2738,6 +2737,9 @@ static int musb_resume(struct device *dev) error); spin_unlock_irqrestore(&musb->lock, flags); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; }