From patchwork Tue Oct 18 18:33:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 120484 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07D1FB71D0 for ; Wed, 19 Oct 2011 05:33:25 +1100 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RGETR-0008MV-Bt; Tue, 18 Oct 2011 18:33:13 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RGETR-0001Az-5B; Tue, 18 Oct 2011 18:33:13 +0000 Received: from mail-pz0-f43.google.com ([209.85.210.43]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RGETN-0001AU-RL for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2011 18:33:11 +0000 Received: by pzk33 with SMTP id 33so2299846pzk.2 for ; Tue, 18 Oct 2011 11:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=tWhUr262J1WF64utM8e0dFFRrAC+E4sQ76hnMSsc1xU=; b=U0TjOnz2U4nQUsMHYbUfdzPGjfuLgTyHmgfgHKdaGJO88jjJigtMNUS9Y+bs5f19fr tvBWPpl4meZxYScxue5nsky8kS3GhiqYd8fUmBreoCrW2f9i4OFkb3/+i5GOO9UTtjxJ sFVllzNLl3HaguviduUCy4NuRroA7e6UpASX8= MIME-Version: 1.0 Received: by 10.68.36.106 with SMTP id p10mr6553169pbj.66.1318962788014; Tue, 18 Oct 2011 11:33:08 -0700 (PDT) Received: by 10.68.60.164 with HTTP; Tue, 18 Oct 2011 11:33:07 -0700 (PDT) In-Reply-To: <20111018173744.GQ21648@n2100.arm.linux.org.uk> References: <20111018173744.GQ21648@n2100.arm.linux.org.uk> Date: Tue, 18 Oct 2011 16:33:07 -0200 Message-ID: Subject: Re: Warning at kernel/mutex.c From: Fabio Estevam To: Russell King - ARM Linux X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20111018_143310_038203_B507ACBB X-CRM114-Status: GOOD ( 16.93 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.43 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Sascha Hauer , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On Tue, Oct 18, 2011 at 3:37 PM, Russell King - ARM Linux wrote: > clk_enable() shouldn't be taking a mutex because drivers can _and_ do > call it from non-schedulable contexts.  Unfortunately, some clk_enable > implementations do use a mutex. > > We have a transition path for this, discussed quite a while ago - > introducing clk_prepare() to do the slow bits of enabling a clock, > leaving clk_enable() for the fast stuff. > Thanks for the explanation, Russell. Sascha, Would the conversion from mutex to spinlock in clk_enable/disable work in the meantime? Please see below. OMAP/PXA/Tegra also use spinlock in clk_enable/disable. If this is OK then I can submit a proper patch for mxc and mxs. diff --git a/arch/arm/mach-mxs/clock.c b/arch/arm/mach-mxs/clock.c index a7093c8..1cdc21a 100644 --- a/arch/arm/mach-mxs/clock.c +++ b/arch/arm/mach-mxs/clock.c @@ -42,6 +42,7 @@ static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); +static DEFINE_SPINLOCK(clock_lock); /*------------------------------------------------------------------------- * Standard clock functions defined in include/linux/clk.h @@ -80,13 +81,14 @@ static int __clk_enable(struct clk *clk) int clk_enable(struct clk *clk) { int ret = 0; + unsigned long flags; if (clk == NULL || IS_ERR(clk)) return -EINVAL; - mutex_lock(&clocks_mutex); + spin_lock_irqsave(&clock_lock, flags); ret = __clk_enable(clk); - mutex_unlock(&clocks_mutex); + spin_unlock_irqrestore(&clock_lock, flags); return ret; } @@ -98,12 +100,14 @@ EXPORT_SYMBOL(clk_enable); */ void clk_disable(struct clk *clk) { + unsigned long flags; + if (clk == NULL || IS_ERR(clk)) return; - mutex_lock(&clocks_mutex); + spin_lock_irqsave(&clock_lock, flags); __clk_disable(clk); - mutex_unlock(&clocks_mutex); + spin_unlock_irqrestore(&clock_lock, flags); } EXPORT_SYMBOL(clk_disable);