From patchwork Tue Nov 29 16:48:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9452741 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 16DF160710 for ; Tue, 29 Nov 2016 16:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 066B5283BB for ; Tue, 29 Nov 2016 16:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF62A283D3; Tue, 29 Nov 2016 16:53:56 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA7B2283BB for ; Tue, 29 Nov 2016 16:53:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBldd-0002Lw-Bn; Tue, 29 Nov 2016 16:52:13 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBlaT-0006O7-Jn for linux-arm-kernel@lists.infradead.org; Tue, 29 Nov 2016 16:49:01 +0000 Received: by mail-wm0-x22f.google.com with SMTP id f82so194266564wmf.1 for ; Tue, 29 Nov 2016 08:48:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Wfi62EuZGegmn4Eo4bc/9y83CWv43QzQFbnslFBaUnQ=; b=W8AC3m55G5/veIympmv8YU3ARqlSDeOZxtJajF0NlghrO/Bb9JvkUWqKOwfp1Y5fxZ djltE8BEu/UxTzfOFr7n+9jIZ5f1nwDdi8Nyn8KJa4cZSaw93fk0iE9Z2bg7MBlS8P5I eTeoC1x5m4ySg3rlSqrbmUp/hK/rnUYWtirPj3Zhn/B0+PlVpSYwQHw0BrvJam5bFTW5 A4LbSPuOquYhzaDA71OtI//3iL6iX3gJS2GoBi1UyQ4pJ0xrpC8ktb0fzAEWn4y0/0Dy VPb+sHVLJLBEhF6c4gsA38JiL7Ak29R5OtRWuKu1YfQHJ7w+mt5wq2hyQesGErl/pFyL bkdQ== 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; bh=Wfi62EuZGegmn4Eo4bc/9y83CWv43QzQFbnslFBaUnQ=; b=P+32BUc6gPAceBhVkGwQ+SD4ulLB2l5BSCgkBROakKZjD76Dd897jgGEbv38TFympL MEcNvitNQPmygVqVaH0ZaqS7vG+uI3bZ2cgCqEdRowA8MurLuFf1P+nBrCz8uHbaAQgs onEhhoMpbLnRdJn0tG5HPdY1KAc56N4aHJ1q9ssuU85P6rTO3tNDQXBfFSMERKGgLrF3 ynsb97qGK6ghWZ6IvhVInBrgu/tmYchKI/RdJf/l286e4s3cRZW8kqe5MqyLSVK8mBch 68/ifYLcrbHkOL2yaN3IRG4hq/o0u4TgNfOTwyx+hYJ+cfSQadtA32A52nzUi8WRf3Hc 3PcA== X-Gm-Message-State: AKaTC02WlP8vOHHTJFYJ+RvbwBPz+uGog+KRr10oh7shS+0+OSrt7ZOcjWmdHa3M83nD28Y2 X-Received: by 10.28.209.7 with SMTP id i7mr26252546wmg.62.1480438114395; Tue, 29 Nov 2016 08:48:34 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id x140sm3666244wme.19.2016.11.29.08.48.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 08:48:33 -0800 (PST) From: Alexandre Bailon To: nsekhar@ti.com Subject: [PATCH v2] ARM: davinci: da8xx: Fix sleeping function called from invalid context Date: Tue, 29 Nov 2016 17:48:31 +0100 Message-Id: <1480438111-11801-1-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_084858_147271_D12AE275 X-CRM114-Status: GOOD ( 14.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@lechnology.com, ahaslam@baylibre.com, khilman@baylibre.com, Alexandre Bailon , ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Everytime the usb20 phy is enabled, there is a "sleeping function called from invalid context" BUG. clk_enable() from arch/arm/mach-davinci/clock.c uses spin_lock_irqsave() before to invoke the callback usb20_phy_clk_enable(). usb20_phy_clk_enable() uses clk_get() and clk_enable_prepapre() which may sleep. Move clk_get() to da8xx_register_usb20_phy_clk() and replace clk_prepare_enable() by clk_enable(). Signed-off-by: Alexandre Bailon --- arch/arm/mach-davinci/usb-da8xx.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index b010e5f..2baa0e1 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -156,23 +156,18 @@ int __init da8xx_register_usb_refclkin(int rate) return 0; } +static struct clk *usb20_clk; + static void usb20_phy_clk_enable(struct clk *clk) { - struct clk *usb20_clk; int err; u32 val; u32 timeout = 500000; /* 500 msec */ val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); - usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20"); - if (IS_ERR(usb20_clk)) { - pr_err("could not get usb20 clk: %ld\n", PTR_ERR(usb20_clk)); - return; - } - /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ - err = clk_prepare_enable(usb20_clk); + err = clk_enable(usb20_clk); if (err) { pr_err("failed to enable usb20 clk: %d\n", err); clk_put(usb20_clk); @@ -197,8 +192,7 @@ static void usb20_phy_clk_enable(struct clk *clk) pr_err("Timeout waiting for USB 2.0 PHY clock good\n"); done: - clk_disable_unprepare(usb20_clk); - clk_put(usb20_clk); + clk_disable(usb20_clk); } static void usb20_phy_clk_disable(struct clk *clk) @@ -287,9 +281,15 @@ int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) struct clk *parent; int ret = 0; + usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20"); + if (IS_ERR(usb20_clk)) + return PTR_ERR(parent); + parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); - if (IS_ERR(parent)) + if (IS_ERR(parent)) { + clk_put(usb20_clk); return PTR_ERR(parent); + } usb20_phy_clk.parent = parent; ret = clk_register(&usb20_phy_clk);