From patchwork Mon Nov 28 16:29:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 84425 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1212586qgi; Mon, 28 Nov 2016 08:31:10 -0800 (PST) X-Received: by 10.98.7.151 with SMTP id 23mr22789521pfh.5.1480350670805; Mon, 28 Nov 2016 08:31:10 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v4si55739521pgb.232.2016.11.28.08.31.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 08:31:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1cBOoa-0003Vg-8F; Mon, 28 Nov 2016 16:30:00 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBOoS-0003Qn-AO for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2016 16:29:54 +0000 Received: by mail-wm0-x22d.google.com with SMTP id a197so210753747wmd.0 for ; Mon, 28 Nov 2016 08:29:31 -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=lQnqIYmKwhmN5djifQ9HpAMJR5K8a1nb+XbSCeUOh7M=; b=E/oto4igAAEX7n0QkgiVB+pKNQTwkLpT47iBpbXQCP1+WjLjRO/Iss0zu5lyJdr/Dc C74bSyIfHOSo5jz70S4jnvW1RR9ndlnhY2m86pddwCWMXV6kqK1WPOg2Th5o7atJ6rSU SyCh6anzUjpzZRmXZrkug6hjbwuy9SRI6DrNneWskPCwUT9uo7IrwliOWZZu/3mnBGe9 b0G37Whd4FRu3sh62JBDKzPAks/PFM7ohmbNSp1oFC5h+ZKFuyqWYSociUFwJ7H5M5ar LL6CBcgkIJ+S6Z69lIfXLdjuQFd658yRxuhw31BvUQ/Wir6cdNErfkrtpSVfpSl/quG0 XV0Q== 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=lQnqIYmKwhmN5djifQ9HpAMJR5K8a1nb+XbSCeUOh7M=; b=lvlpvLZekHp2kw7L9uHa1ckP0bHeToGZhJcH7O/0rtjSChZhK3QUPJGiGqLK8gueTF n2lVmd2cInsds5DSPlHJJj6bxKCErzdVsiUiet3mE6RD/29+iDEZ1zxYQjj2VcknbeNB nQx8EBfwZcgqQUOqkwH80oFjPI9ehzCQ1vQtqyl1hRAkg8zr7X30ZBbFYJuBloGzB+A1 dlByUQ1EmXIz8ZNQHNBBmDiAdcBnRaZaFbx8ipMqWq8+6eojvAq9GKeZpwrvaahLwcJ/ gBthvlKgbEtE9VGSmLNi+uAf80bqEmTc9T2v1+cHPQcNiWHZx4Pn9iqcQ2f2HriAyaNC 0rjA== X-Gm-Message-State: AKaTC02KglYE8usBLbI+gI9XewIjbwcyjFOXpuSA28sQCtMhbWROLVlpS3UYhjj2jQW0Q2M/ X-Received: by 10.28.16.65 with SMTP id 62mr21935772wmq.81.1480350570360; Mon, 28 Nov 2016 08:29:30 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id e6sm63278315wjw.33.2016.11.28.08.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 08:29:30 -0800 (PST) From: Alexandre Bailon To: nsekhar@ti.com Subject: [PATCH] ARM: davinci: da8xx: Fix sleeping function called from invalid context Date: Mon, 28 Nov 2016 17:29:26 +0100 Message-Id: <1480350566-26225-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-20161128_082952_578541_C6D2ADDE X-CRM114-Status: GOOD ( 13.31 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org, Alexandre Bailon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Everytime the usb20 phy is enabled, there is a "sleeping function called from invalid context" BUG. usb20_phy_clk_enable(), called with the irq disabled 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- 2.7.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index b010e5f..c9b5cd4 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -156,23 +156,23 @@ 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)) { + if (!usb20_clk || 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 +197,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,6 +286,10 @@ 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)) return PTR_ERR(parent);