From patchwork Fri Dec 9 16:59:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 87531 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp410452qgi; Fri, 9 Dec 2016 09:01:38 -0800 (PST) X-Received: by 10.84.217.70 with SMTP id e6mr158444539plj.161.1481302898370; Fri, 09 Dec 2016 09:01:38 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id a96si34698501pli.233.2016.12.09.09.01.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 09:01:38 -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 1cFOX1-0007Qj-8m; Fri, 09 Dec 2016 17:00:23 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cFOWi-0006PY-LY for linux-arm-kernel@lists.infradead.org; Fri, 09 Dec 2016 17:00:06 +0000 Received: by mail-wm0-x229.google.com with SMTP id f82so32741274wmf.1 for ; Fri, 09 Dec 2016 08:59:43 -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:in-reply-to:references; bh=jvu1j8wwjLxAU3Dbi4aP7GtaSHeTi09kSSU2dJvBeTM=; b=FQl64D/64K1wtlnDdu13KzgyH4PmLDCN0cOTVRJcwynL8d6kfashNbJ2aVF8wdKmhd niaEeJ3DugYkFDXTJQRlhU7+H2V2+dplLwXW3Ky0dxCrYLOai6RTccQEt2KhNey+kLVu 7bbbdNpUwwHqt6qEBBQRF12O1ODLJlcwvEE4hNgW/OxVncCypCRzlu7Nj0ydh8lKCAtl E1n4orPV7v8dj1i3G8RsgfQ95OhdZ0RXcBVon3LdhpdSMrdYXxjhJDQSsHsLPgMVSqV1 ISb+/UzOwJaV5BhOyGVYUtDAEauKiX11f3PCcF1kaxS8YdkBuHHn+9z4ymBE6+z19+kV C/JA== 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=jvu1j8wwjLxAU3Dbi4aP7GtaSHeTi09kSSU2dJvBeTM=; b=laWSSSSUJkVbNawRqqF+vaSbJOU7vcMKui+wiaFz2QLJPmDi/bkF9Fj1qZyf/cZUK4 x/Xv9p9HvxO1taIg8LHC+1xVqli2tOEEIMY8TMP61//JDNCMflyXh4U532/Cm5+o1r5x zO7Z/M0uYlSFUeye35FuQVmtdm5QCrR793Il+0IzB0aIxk0z28H0pGRigiKyzDCUDq35 XqZq/mzdDpf/OfKsomCCCgHoDo6CPplYnC1XML9Ms5gWavgYNduFhd/CTittfnLhRHgG jhJGwuys2QPbkzugeufshl1V5W+a/VTwc5nzvYzm08nWAEmqKpXyiVqtX0rEQ0tmqhrL pLsA== X-Gm-Message-State: AKaTC03no1wcoJXbk3wKsAhUb9S6o3iHZypiRk4HFi7Ea8LO0FpHjxQ4rvQDRyQBUNNAFkmf X-Received: by 10.28.94.76 with SMTP id s73mr4210526wmb.107.1481302782438; Fri, 09 Dec 2016 08:59:42 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id kp5sm43250827wjb.8.2016.12.09.08.59.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Dec 2016 08:59:41 -0800 (PST) From: Alexandre Bailon To: nsekhar@ti.com Subject: [PATCH v7 2/2] ARM: davinci: da8xx: Fix sleeping function called from invalid context Date: Fri, 9 Dec 2016 17:59:33 +0100 Message-Id: <1481302773-14181-2-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1481302773-14181-1-git-send-email-abailon@baylibre.com> References: <1481302773-14181-1-git-send-email-abailon@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161209_090005_001351_48ADEB31 X-CRM114-Status: GOOD ( 15.54 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 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: arnd@arndb.de, ahaslam@baylibre.com, khilman@baylibre.com, Alexandre Bailon , ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org, david@lechnology.com 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. In addition, there is a recursive locking happening because of the recurse call to clk_enable(). 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. replace clk_prepare_enable() by davinci_clk_enable(). Signed-off-by: Alexandre Bailon Suggested-by: David Lechner --- arch/arm/mach-davinci/usb-da8xx.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 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..71f1e81 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -22,6 +22,8 @@ #define DA8XX_USB0_BASE 0x01e00000 #define DA8XX_USB1_BASE 0x01e25000 +static struct clk *usb20_clk; + static struct platform_device da8xx_usb_phy = { .name = "da8xx-usb-phy", .id = -1, @@ -158,26 +160,13 @@ int __init da8xx_register_usb_refclkin(int rate) 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); - if (err) { - pr_err("failed to enable usb20 clk: %d\n", err); - clk_put(usb20_clk); - return; - } + davinci_clk_enable(usb20_clk); /* * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1 @@ -197,8 +186,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); + davinci_clk_disable(usb20_clk); } static void usb20_phy_clk_disable(struct clk *clk) @@ -285,11 +273,19 @@ static struct clk_lookup usb20_phy_clk_lookup = int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) { struct clk *parent; - int ret = 0; + int ret; + + usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20"); + ret = PTR_ERR_OR_ZERO(usb20_clk); + if (ret) + return ret; parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); - if (IS_ERR(parent)) - return PTR_ERR(parent); + ret = PTR_ERR_OR_ZERO(parent); + if (ret) { + clk_put(usb20_clk); + return ret; + } usb20_phy_clk.parent = parent; ret = clk_register(&usb20_phy_clk);