From patchwork Tue Apr 11 15:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 672341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C31F1C76196 for ; Tue, 11 Apr 2023 15:27:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 45149F10; Tue, 11 Apr 2023 17:26:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 45149F10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681226851; bh=pBwFGn9ELKVEU+Rvm8MJHDCKQ1Ly3rABzADXMPiimPw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Reply-To:Cc:From; b=O2I4Acf9ZvTLHCxR54fq+QkENnTOkmrgpT1dzOnc5e2ybAmyq1+dKnmXb1iPYofPQ yzciZkyrFHSAEm3y0DkFRoJo/yt/8fTKdMbtZyQBWFAiYpQw+LJSOkTwJk7/AsMBVw FrbDRAro1besIeG0zn9de+i//v6nPgSctfcNZsnU= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 74306F80448; Tue, 11 Apr 2023 17:25:48 +0200 (CEST) To: Subject: [PATCH 1/6] ASoC: cs35l56: Remove quick-cancelling of dsp_work() Date: Tue, 11 Apr 2023 16:25:23 +0100 In-Reply-To: <20230411152528.329803-1-rf@opensource.cirrus.com> References: <20230411152528.329803-1-rf@opensource.cirrus.com> X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <168122674746.26.16881587647873355224@mailman-core.alsa-project.org> X-Patchwork-Original-From: Richard Fitzgerald via Alsa-devel From: Richard Fitzgerald Reply-To: Richard Fitzgerald Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, Richard Fitzgerald Content-Disposition: inline Delete the 'removing' flag and don't kick init_completion to make a quick cancel of dsp_work(). Just let it timeout on the wait for the completion. Simplify the code to standard cancelling or flushing of the work. This avoids introducing corner cases from a layer of custom signalling. It also avoids potential race conditions when system-suspend handling is added. Unless the hardware is broken, the dsp_work() will already have started and passed the completion before the driver would want to cancel it. Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/cs35l56.c | 8 +------- sound/soc/codecs/cs35l56.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index d97b465f0d3c..675aad8e909f 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -867,7 +867,7 @@ static void cs35l56_dsp_work(struct work_struct *work) goto complete; } - if (!cs35l56->init_done || cs35l56->removing) + if (!cs35l56->init_done) goto complete; cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x", @@ -917,9 +917,6 @@ static void cs35l56_dsp_work(struct work_struct *work) goto err; } - if (cs35l56->removing) - goto err; - mutex_lock(&cs35l56->irq_lock); init_completion(&cs35l56->init_completion); @@ -967,7 +964,6 @@ static int cs35l56_component_probe(struct snd_soc_component *component) BUILD_BUG_ON(ARRAY_SIZE(cs35l56_tx_input_texts) != ARRAY_SIZE(cs35l56_tx_input_values)); - cs35l56->removing = false; cs35l56->component = component; wm_adsp2_component_probe(&cs35l56->dsp, component); @@ -984,8 +980,6 @@ static void cs35l56_component_remove(struct snd_soc_component *component) { struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); - cs35l56->removing = true; - complete(&cs35l56->init_completion); cancel_work_sync(&cs35l56->dsp_work); } diff --git a/sound/soc/codecs/cs35l56.h b/sound/soc/codecs/cs35l56.h index efc4b99180f9..dc91cd7d877f 100644 --- a/sound/soc/codecs/cs35l56.h +++ b/sound/soc/codecs/cs35l56.h @@ -49,7 +49,6 @@ struct cs35l56_private { bool soft_resetting; bool init_done; bool sdw_attached; - bool removing; bool fw_patched; bool can_hibernate; struct completion init_completion;