From patchwork Mon Aug 7 21:09:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 712013 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 29062C001DE for ; Mon, 7 Aug 2023 21:12:41 +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 49DE1857; Mon, 7 Aug 2023 23:11:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 49DE1857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691442759; bh=F7Xf71XGltG9msm9mvPvcAgXO6d+o/snjd471X8mCgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NdJTFxnWmgIGVNyiGTv9Zg7m1u76VkOYQpc+QVcpK2ynDKo7RKEoi6kX//qsNIhvG EPhpm3KpnniZiwPq1tvlXZP9FwCR8N1bKMzGKMnqzWTTPqzRnFsBXFoFnPfTlKuQEJ OP8cbQu7eP+Dk6G+kEbz8nDKdqIBXTXCHn4jyyEM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB594F805AE; Mon, 7 Aug 2023 23:10:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 052B0F805A0; Mon, 7 Aug 2023 23:10:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7004F80564; Mon, 7 Aug 2023 23:10:28 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D439EF8016B for ; Mon, 7 Aug 2023 23:10:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D439EF8016B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Qzx1BIkj DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691442619; x=1722978619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F7Xf71XGltG9msm9mvPvcAgXO6d+o/snjd471X8mCgY=; b=Qzx1BIkjGexV5XGBubrpS627EEi2I4wbHLFBOZhLD+diX5gyFA03sqOQ so+o6qeBt7VhVUUmhSd2owTQFfPp7ZBRfnpEPtiLcZT8Y+FAdZMya0FCe NZrB7ih0S2f2eHoiHiHiyxXIIIu03+hlpbpMnnu9PxvDO/xjvidIptq6+ jFBrWBXHQsSyqCHzuU9cc2lgDV8abfbsDtF3OTvLBCkjXoY14TeFIpIDo X8Ibx2qktTA5w7Nece2roVUK11NfuV5qI17xKOHwhmCqcqRyuBvj6QFrB XCxPakhnI4q3PlTPe0Zl3e3jduDiCMuUxeNY/AP/ZmaQH8GTDNsfj3IOz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="350244314" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="350244314" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 14:10:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="796465165" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="796465165" Received: from hweelee-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.209.181.215]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 14:10:10 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, Ranjani Sridharan , Pierre-Louis Bossart , Bard Liao Subject: [PATCH 03/20] ASoC: SOF: ipc4: avoid uninitialized default instance 0 Date: Mon, 7 Aug 2023 16:09:42 -0500 Message-Id: <20230807210959.506849-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807210959.506849-1-pierre-louis.bossart@linux.intel.com> References: <20230807210959.506849-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: CFLKQFUUHKWAPYFWIAZH5TINSZE7BD4Z X-Message-ID-Hash: CFLKQFUUHKWAPYFWIAZH5TINSZE7BD4Z X-MailFrom: pierre-louis.bossart@linux.intel.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: From: Ranjani Sridharan When a pipeline contains multiple DAI widgets, the pipe_widget is not set up except for the first DAI. This result in the pipe_widget having a default instance 0, which can conflict with another real the pipeline instance 0 and leads to spurious transitions. This patch makes sure the instance_id is properly initialized to a -EINVAL value. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda-dai-ops.c | 6 ++++++ sound/soc/sof/ipc4-topology.c | 1 + sound/soc/sof/topology.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index f3513796c189..e9ae38916434 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -234,6 +234,9 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp pipe_widget = swidget->spipe->pipe_widget; pipeline = pipe_widget->private; + if (pipe_widget->instance_id < 0) + return 0; + mutex_lock(&ipc4_data->pipeline_state_mutex); switch (cmd) { @@ -297,6 +300,9 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c pipe_widget = swidget->spipe->pipe_widget; pipeline = pipe_widget->private; + if (pipe_widget->instance_id < 0) + return 0; + mutex_lock(&ipc4_data->pipeline_state_mutex); switch (cmd) { diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index a4e1a70b607d..9bc94be072aa 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -2319,6 +2319,7 @@ static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget pipeline->mem_usage = 0; pipeline->state = SOF_IPC4_PIPE_UNINITIALIZED; ida_free(&pipeline_ida, swidget->instance_id); + swidget->instance_id = -EINVAL; } else { struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget; struct sof_ipc4_pipeline *pipeline = pipe_widget->private; diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 698129dccc7d..1afcbb134d2c 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2157,6 +2157,8 @@ static int sof_complete(struct snd_soc_component *scomp) struct snd_sof_widget *pipe_widget = spipe->pipe_widget; struct snd_sof_widget *swidget; + pipe_widget->instance_id = -EINVAL; + /* Update the scheduler widget's IPC structure */ if (widget_ops && widget_ops[pipe_widget->id].ipc_setup) { ret = widget_ops[pipe_widget->id].ipc_setup(pipe_widget);