From patchwork Thu Mar 6 08:57:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 25783 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 16DA2203C3 for ; Thu, 6 Mar 2014 09:15:01 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id oz11sf5752802veb.5 for ; Thu, 06 Mar 2014 01:15:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=F1+TUHN09JlQ83sRrkZUsztAC9eOKvh20Ue+nE1nI8w=; b=KWh5Rz977lDWNMJrKIBSTUX4nkdxpocFfKNd83ack6z532K9wk1TgZX3s0wxUz7jPI pKetOyDx5+PULE+RgHj9XUeECNs+ZTdhS/J6ZFhow6Fs/tOa23H6RgxVjOCE4ZNVrVIb T2k9Ls6nJmADX1SxWC8eeswO/O1ePwLq54Cpks8+odcCmj390iM0mGMWJnXwJwy2BeBh eUs+ivkPsCiW198A45Wd18f2ONXfvRhsut2qCoqbBhPk1fkuxOsyvHAJvUek8wR0gXsh /h24W+0F1vnFyHuYrJK7qpPL9K5EC5TukTVMHtY31BrUmm8/o7GBLA8nvgSQPhXXZCV0 ad2w== X-Gm-Message-State: ALoCoQmGRVHzL6mjEW2IZ5Gc004ngAfcXd2oN5vcvIxY2HfD7wAzAL7/hUMZiIXVe0fpSPpqqPNQ X-Received: by 10.236.144.102 with SMTP id m66mr4498278yhj.50.1394097300834; Thu, 06 Mar 2014 01:15:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.1 with SMTP id v1ls685870qge.50.gmail; Thu, 06 Mar 2014 01:15:00 -0800 (PST) X-Received: by 10.52.81.66 with SMTP id y2mr7068079vdx.23.1394097300699; Thu, 06 Mar 2014 01:15:00 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id dr8si937047vcb.88.2014.03.06.01.15.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 01:15:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so2291308veb.22 for ; Thu, 06 Mar 2014 01:15:00 -0800 (PST) X-Received: by 10.58.188.78 with SMTP id fy14mr4385306vec.23.1394097300617; Thu, 06 Mar 2014 01:15:00 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp24747vck; Thu, 6 Mar 2014 01:14:59 -0800 (PST) X-Received: by 10.14.202.136 with SMTP id d8mr11122975eeo.46.1394097299146; Thu, 06 Mar 2014 01:14:59 -0800 (PST) Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id c43si8555704eeo.185.2014.03.06.01.14.58 for ; Thu, 06 Mar 2014 01:14:59 -0800 (PST) Received-SPF: neutral (google.com: 77.48.224.243 is neither permitted nor denied by best guess record for domain of alsa-devel-bounces@alsa-project.org) client-ip=77.48.224.243; Received: by alsa0.perex.cz (Postfix, from userid 1000) id C854D265913; Thu, 6 Mar 2014 10:14:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.2.4 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A24152658D2; Thu, 6 Mar 2014 10:14:53 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D9DE92658DC; Thu, 6 Mar 2014 10:14:52 +0100 (CET) Received: from mezzanine.sirena.org.uk (mezzanine.sirena.org.uk [106.187.55.193]) by alsa0.perex.cz (Postfix) with ESMTP id ADCD12658D0 for ; Thu, 6 Mar 2014 10:14:45 +0100 (CET) Received: from z88l218.static.ctm.net ([202.175.88.218] helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WLUO3-0003Pp-2q; Thu, 06 Mar 2014 09:14:44 +0000 Received: from broonie by finisterre with local (Exim 4.82) (envelope-from ) id 1WLU7Q-0000XB-6d; Thu, 06 Mar 2014 16:57:32 +0800 From: Mark Brown To: Liam Girdwood Date: Thu, 6 Mar 2014 16:57:17 +0800 Message-Id: <1394096237-2004-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 1.9.0 X-SA-Exim-Connect-IP: 202.175.88.218 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Cc: alsa-devel@alsa-project.org, linaro-kernel@lists.linaro.org, Mark Brown Subject: [alsa-devel] [PATCH] ASoC: dapm: Sprinkle lockdep asserts through the code X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: broonie@kernel.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Mark Brown Try to spot locking issues by asserting that the DAPM mutex is held when it should be. There's a bit of fun due to us not requiring the lock to be held prior to the card being instantiated which mean we need to wrap the assert in some paths and this isn't methodical by any stretch of the imagination. Signed-off-by: Mark Brown --- I've only compile tested this so it's entirely possible there's some oversights here - at this point I'm mostly just throwing it out there for people to play with as a work in progress. sound/soc/soc-dapm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 3728e21..c8a780d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -111,6 +111,12 @@ static int dapm_down_seq[] = { [snd_soc_dapm_post] = 14, }; +static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) +{ + if (dapm->card && dapm->card->instantiated) + lockdep_assert_held(&dapm->card->dapm_mutex); +} + static void pop_wait(u32 pop_time) { if (pop_time) @@ -144,6 +150,8 @@ static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w) static void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason) { + dapm_assert_locked(w->dapm); + if (!dapm_dirty_widget(w)) { dev_vdbg(w->dapm->dev, "Marking %s dirty due to %s\n", w->name, reason); @@ -356,6 +364,8 @@ static void dapm_reset(struct snd_soc_card *card) { struct snd_soc_dapm_widget *w; + lockdep_assert_held(&card->dapm_mutex); + memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); list_for_each_entry(w, &card->widgets, list) { @@ -1750,6 +1760,8 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) ASYNC_DOMAIN_EXCLUSIVE(async_domain); enum snd_soc_bias_level bias; + lockdep_assert_held(&card->dapm_mutex); + trace_snd_soc_dapm_start(card); list_for_each_entry(d, &card->dapm_list, list) { @@ -2045,6 +2057,8 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card, struct snd_soc_dapm_path *path; int found = 0; + lockdep_assert_held(&card->dapm_mutex); + /* find dapm widget path assoc with kcontrol */ dapm_kcontrol_for_each_path(path, kcontrol) { if (!path->name || !e->texts[mux]) @@ -2095,6 +2109,8 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card, struct snd_soc_dapm_path *path; int found = 0; + lockdep_assert_held(&card->dapm_mutex); + /* find dapm widget path assoc with kcontrol */ dapm_kcontrol_for_each_path(path, kcontrol) { found = 1; @@ -2260,6 +2276,8 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm, { struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); + dapm_assert_locked(dapm); + if (!w) { dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin); return -EINVAL;