From patchwork Mon Aug 7 21:09:51 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: 711153 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 AB67AC001DE for ; Mon, 7 Aug 2023 21:16:11 +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 D7073868; Mon, 7 Aug 2023 23:15:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D7073868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691442969; bh=QA7kHUykPDd0YjBfngflhZUlLrAxS1GzAate3UJRT+4=; 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=d5xo/QUEoxEl0/lWHsoQ8pWcyJOuhZNu8kLKF3ej26n+w6aApsS7+RUQO+2Nccpei u+9lZXhek+U6eszhi+e9Uy1Rc6XuNOeNjMYDHjTWAIki2piZlf/DO021pVySy36Yd7 ieLT+hZFK3pSCi1kYuTB37+xpIYhR4wqYkjb/+m0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B8F6EF80639; Mon, 7 Aug 2023 23:11:12 +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 D482BF80634; Mon, 7 Aug 2023 23:11:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id ACFF3F805BB; Mon, 7 Aug 2023 23:10:44 +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 CB4EEF80548 for ; Mon, 7 Aug 2023 23:10:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CB4EEF80548 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=khjj8lSp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691442625; x=1722978625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QA7kHUykPDd0YjBfngflhZUlLrAxS1GzAate3UJRT+4=; b=khjj8lSpXg2vySdK23RHo163JKYVfknQWvMQxtTm1WKHW1gJZa6tYKCp DpzcFD3lJYi3UwUpIS52mrqI4yy2G1+8B+/CdoYZZah1qp5pSZE17QTX8 H754vmcolFJsK8cga47hcgmZiT1EQVhPWdp75zu6yBXaYOwMtGsqseJFO Dfrcgz8ZYqZJ7NOzMYGaTmZVNcyVpvjKi1ZcKZKc6nUvU1J32tTQNV/R3 csaOSCcTh3rjQWOQvzbVZwixK9PNqvtNoICgRs4gbKhFSar/LTpYVnop5 e0SooKsL6o/LUKtx06BK/LAu0p2kuzl54PqWaXBcqLBsvy8r9gih0fiER g==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="350244359" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="350244359" 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:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="796465237" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="796465237" 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:15 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, Pierre-Louis Bossart , Bard Liao , Rander Wang Subject: [PATCH 12/20] ASoC: SOF: Intel: hda-dai-ops: only allocate/release streams for first CPU DAI Date: Mon, 7 Aug 2023 16:09:51 -0500 Message-Id: <20230807210959.506849-13-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: WQW4WAZZQBEWCGOXQIYVDOVNG3C5JDAJ X-Message-ID-Hash: WQW4WAZZQBEWCGOXQIYVDOVNG3C5JDAJ 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: When we have multiple CPU DAIs in a dailink, typically for SoundWire aggregated solutions with amplifiers on multiple links, we only want to allocate one HDaudio stream_tag. The simplest solution is to allocate the hext_stream/stream_tag for the DAI with index 0 in the dailink, and reuse the same stream for all other CPU DAIs. This assumption relies on serialization of DAIs by the ASoC core, where all CPU DAIs are handled in a loop. The stream release follows the same idea of releasing the tag for the first DAI only. Ideally we would want the loop to be handled in reverse-order to summetry, but there is no risk of reusing a stream_tag which is no longer valid. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Rander Wang --- sound/soc/sof/intel/hda-dai-ops.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index b66886244f24..9a6d995a8453 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -145,9 +145,17 @@ static struct hdac_ext_stream *hda_assign_hext_stream(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *dai; struct hdac_ext_stream *hext_stream; - hext_stream = hda_link_stream_assign(sof_to_bus(sdev), substream); + /* only allocate a stream_tag for the first DAI in the dailink */ + dai = asoc_rtd_to_cpu(rtd, 0); + if (dai == cpu_dai) + hext_stream = hda_link_stream_assign(sof_to_bus(sdev), substream); + else + hext_stream = snd_soc_dai_get_dma_data(dai, substream); + if (!hext_stream) return NULL; @@ -160,9 +168,14 @@ static void hda_release_hext_stream(struct snd_sof_dev *sdev, struct snd_soc_dai struct snd_pcm_substream *substream) { struct hdac_ext_stream *hext_stream = hda_get_hext_stream(sdev, cpu_dai, substream); + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *dai; + /* only release a stream_tag for the first DAI in the dailink */ + dai = asoc_rtd_to_cpu(rtd, 0); + if (dai == cpu_dai) + snd_hdac_ext_stream_release(hext_stream, HDAC_EXT_STREAM_TYPE_LINK); snd_soc_dai_set_dma_data(cpu_dai, substream, NULL); - snd_hdac_ext_stream_release(hext_stream, HDAC_EXT_STREAM_TYPE_LINK); } static void hda_setup_hext_stream(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream,