From patchwork Mon Jan 14 17:37:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10763237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5518A184E for ; Mon, 14 Jan 2019 17:38:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F80229262 for ; Mon, 14 Jan 2019 17:38:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33D7B29270; Mon, 14 Jan 2019 17:38:14 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 864D529262 for ; Mon, 14 Jan 2019 17:38:13 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8335D266C08; Mon, 14 Jan 2019 18:38:12 +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 D6C1E2670C7; Mon, 14 Jan 2019 18:38:09 +0100 (CET) Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by alsa0.perex.cz (Postfix) with ESMTP id C30ED266C08 for ; Mon, 14 Jan 2019 18:38:07 +0100 (CET) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 15220788-1500050 for multiple; Mon, 14 Jan 2019 17:37:53 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 14 Jan 2019 17:37:53 +0000 Message-Id: <20190114173753.472-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114173753.472-1-chris@chris-wilson.co.uk> References: <20190114173753.472-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Cc: Takashi Iwai , Jani Nikula , alsa-devel@alsa-project.org, Chris Wilson Subject: [alsa-devel] [PATCH 3/3] snd/hda: Protect concurrent display_power_status with a mutex X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Just in case the audio linkage is swapped between components during the runtime pm sequence, we need to protect the rpm tracking with a mutex. Signed-off-by: Chris Wilson Cc: Takashi Iwai Cc: Jani Nikula --- include/sound/hdaudio.h | 1 + sound/hda/hdac_component.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 39761120ee76..497335b24e18 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -368,6 +368,7 @@ struct hdac_bus { struct drm_audio_component *audio_component; unsigned long display_power_status; unsigned long display_power_active; + struct mutex display_power_lock; /* parameters required for enhanced capabilities */ int num_streams; diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c index 2702548b788a..ea76c1de2927 100644 --- a/sound/hda/hdac_component.c +++ b/sound/hda/hdac_component.c @@ -77,6 +77,7 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) if (!acomp || !acomp->ops) return; + mutex_lock(&bus->display_power_lock); if (bus->display_power_status) { if (!bus->display_power_active) { unsigned long cookie = -1; @@ -98,6 +99,7 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) bus->display_power_active = 0; } } + mutex_unlock(&bus->display_power_lock); } EXPORT_SYMBOL_GPL(snd_hdac_display_power); @@ -290,6 +292,9 @@ int snd_hdac_acomp_init(struct hdac_bus *bus, GFP_KERNEL); if (!acomp) return -ENOMEM; + + mutex_init(&bus->display_power_lock); + acomp->audio_ops = aops; bus->audio_component = acomp; devres_add(dev, acomp); @@ -336,6 +341,8 @@ int snd_hdac_acomp_exit(struct hdac_bus *bus) bus->display_power_active = 0; bus->display_power_status = 0; + mutex_destroy(&bus->display_power_lock); + component_master_del(dev, &hdac_component_master_ops); bus->audio_component = NULL;