From patchwork Wed Oct 16 03:29:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13837671 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C07817C210; Wed, 16 Oct 2024 03:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049367; cv=none; b=i4d0QY/Rz0MQ+bf/eLGPfUPdbbWCyTmvuPOL8hjBsPrWF8pRHtuQQHpbX5MueOzYkWLgJtELeFcqSaklfpoqrJjEjUUtSHi2x6tBkpGNUtEYt9jICly8XrH8+Bwe/2iFQGaYuuHUGS6W+dfenBFeKFl3Q71Y1Hatl4/ZM4LpWyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049367; c=relaxed/simple; bh=oB2x5QGc7JYRpJb1UNT9KfqbRv/o3tDmrF/5qx1mMDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ebiny5rLUGvi0r4Q7LdgJR2n7untSADUC8XbsHeMO9yY7yftDBnxC5MT+SwFbAhJrUzWcx8UcZQv+7Bshk9BMuh8Psk5nbhqUwnL/OkXlzhzVTqR7DpJbe9eBam+NwL0d0Dza1Or5b4mtuVsuJC0QiowLFnWHyu/BDOOF+1bZns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=D+bqdsWq; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D+bqdsWq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729049366; x=1760585366; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oB2x5QGc7JYRpJb1UNT9KfqbRv/o3tDmrF/5qx1mMDQ=; b=D+bqdsWqknFJh0j4vlPLHJYhQqG9knn+l4Y9tXaYUfeGOUU2MaWKA7iR tA7RqQy+mXt3b39i2GQAjY0cVCOC9xCKVtCy+X1e2LLD8QI9eCHdtQvPu WmD+pMxAzPQXNJNC6je1cRphLvD+tSDtR2krh18yrjWNmPkdQBqxlhVi0 LsNcfoEJCRr7eT+shLzLAIBlfSCUzpDCsNHIgLIaKRUqjlVK8dJcUTfp7 EMsW+dtdqB0IyVtX0fk/Efj0e9Y9jWndePAqb4qn4inbXhOevLtk25qYy SKY3Oo/7u1T3bFf3i2ry5CwiBMF2Cb2gNMjDkPeto83iByZFk9Yp2fUl0 w==; X-CSE-ConnectionGUID: WwvGFaNETyqMu4BATs5FLQ== X-CSE-MsgGUID: i01FvqH+SCiAI+6JClqYjA== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="28676505" X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="28676505" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:26 -0700 X-CSE-ConnectionGUID: aYxstxQCQUqiARgbKbOLYQ== X-CSE-MsgGUID: xkI9kYn5TiCOYcPMMxcAxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="78047642" Received: from cvapit-mobl1.ger.corp.intel.com (HELO yungchua-desk.intel.com) ([10.247.118.236]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:23 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com, ranjani.sridharan@linux.intel.com Subject: [PATCH 1/4] ASoC: SOF: ipc4-topology: Do not set ALH node_id for aggregated DAIs Date: Wed, 16 Oct 2024 11:29:07 +0800 Message-ID: <20241016032910.14601-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> References: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ranjani Sridharan For aggregated DAIs, the node ID is set to the group_id during the DAI widget's ipc_prepare op. With the current logic, setting the dai_index for node_id in the dai_config is redundant as it will be overwritten with the group_id anyway. Removing it will also prevent any accidental clearing/resetting of the group_id for aggregated DAIs due to the dai_config calls could that happen before the allocated group_id is freed. Signed-off-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Kai Vehmanen Signed-off-by: Bard Liao --- sound/soc/sof/ipc4-topology.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 56427d6e3679..1fcf4692a21f 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -3250,9 +3250,20 @@ static int sof_ipc4_dai_config(struct snd_sof_dev *sdev, struct snd_sof_widget * * group_id during copier's ipc_prepare op. */ if (flags & SOF_DAI_CONFIG_FLAGS_HW_PARAMS) { + struct sof_ipc4_alh_configuration_blob *blob; + + blob = (struct sof_ipc4_alh_configuration_blob *)ipc4_copier->copier_config; ipc4_copier->dai_index = data->dai_node_id; - copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK; - copier_data->gtw_cfg.node_id |= SOF_IPC4_NODE_INDEX(data->dai_node_id); + + /* + * no need to set the node_id for aggregated DAI's. These will be assigned + * a group_id during widget ipc_prepare + */ + if (blob->alh_cfg.device_count == 1) { + copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK; + copier_data->gtw_cfg.node_id |= + SOF_IPC4_NODE_INDEX(data->dai_node_id); + } } break; From patchwork Wed Oct 16 03:29:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13837672 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB7BC18660A; Wed, 16 Oct 2024 03:29:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049371; cv=none; b=N2s2T3jKRjo7XVS4b3N0tELhg9L7DE4+aRElBrRRRbJMBmPgAUC0O9risIacLMFrA8oQKoxkP42UK68pBaKMc3+avLCGenuPwU869wwy5pVYL8w8PGxFPwpHDL7nqKISy547k24kZDBo4jyIdaUjA9hykKKYZAyRtx7tXqX7ouQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049371; c=relaxed/simple; bh=zUe0gml481yHXpwIeC8XhLuuNu4uRr7bBhyLPhPLgFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i6h/CwnpYaYGOTBSss5XwOr3y4QPPlyiGhWVGCRjPIVNtARWQ54iHpIlq86DmKR54k/F6VIgp8PvQB87KtfhP/EsDvIK1m3GvN9CfVxY/OujX0fTRj5kSRu/N+pfEEF4BUeOZKqHXmPJ8MEeHw9tqtzcQoebJc2M94fNEML8ee0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AU0ZlAcm; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AU0ZlAcm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729049370; x=1760585370; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zUe0gml481yHXpwIeC8XhLuuNu4uRr7bBhyLPhPLgFk=; b=AU0ZlAcmO2NuokBET7ty8hKlwCRwLzEqKist2kZIHcRWqJUT2k/0oCYJ tCFq8VnGqDf6/ALffz//H+u7CveCU1mMhPox61ArnyI0u8LGptDwDGtlk S3vq14tLMiXo80ohyvA74KKruGnWBOg5pnhWvL+VTEcbT0fePnPINVNYU TdJEBXGkblSvCJ4AI0dZ/vimObxx/G4KlYBYow1//kXy6xDPX21a36PJF nHYrOSWHYA5sehR7lMGxN83iYGz9URwCzR+nyH2bVo/AO2TSlGlgv3yHI uVkRlJ48Obi4vFsMHB776Tdm8vCSECPz0wjCOYl1rv49o1a2BksbZfL6E A==; X-CSE-ConnectionGUID: nTdQrlLVQ/y2WDKVQPlrnQ== X-CSE-MsgGUID: 7/lb3oXOQJ2Qagwuy9LOPg== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="28676510" X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="28676510" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:29 -0700 X-CSE-ConnectionGUID: cc6z6LLkSLifWiQh0j6k6A== X-CSE-MsgGUID: VDs+mH0BRQKhTfd21PxD9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="78047659" Received: from cvapit-mobl1.ger.corp.intel.com (HELO yungchua-desk.intel.com) ([10.247.118.236]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:26 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com, ranjani.sridharan@linux.intel.com Subject: [PATCH 2/4] ASoC: SOF: Intel: hda: Handle prepare without close for non-HDA DAI's Date: Wed, 16 Oct 2024 11:29:08 +0800 Message-ID: <20241016032910.14601-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> References: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ranjani Sridharan When a PCM is restarted after a snd_pcm_drain/snd_pcm_drop(), the prepare callback will be invoked and the hw_params will be set again. For the HDA DAI's, the hw_params function handles this case already but not for the non-HDA DAI's. So, add the check for link_prepared to verify if the hw_params should be done again or not. Additionally, for SDW DAI's reset the PCMSyCM registers as would be done in the case of a start after a hw_free. Signed-off-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Kai Vehmanen Signed-off-by: Bard Liao --- sound/soc/sof/intel/hda-dai.c | 36 +++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 1c823f9eea57..8cccf38967e7 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -370,6 +370,13 @@ static int non_hda_dai_hw_params_data(struct snd_pcm_substream *substream, return -EINVAL; } + sdev = widget_to_sdev(w); + hext_stream = ops->get_hext_stream(sdev, cpu_dai, substream); + + /* nothing more to do if the link is already prepared */ + if (hext_stream && hext_stream->link_prepared) + return 0; + /* use HDaudio stream handling */ ret = hda_dai_hw_params_data(substream, params, cpu_dai, data, flags); if (ret < 0) { @@ -377,7 +384,6 @@ static int non_hda_dai_hw_params_data(struct snd_pcm_substream *substream, return ret; } - sdev = widget_to_sdev(w); if (sdev->dspless_mode_selected) return 0; @@ -482,6 +488,31 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream, int ret; int i; + ops = hda_dai_get_ops(substream, cpu_dai); + if (!ops) { + dev_err(cpu_dai->dev, "DAI widget ops not set\n"); + return -EINVAL; + } + + sdev = widget_to_sdev(w); + hext_stream = ops->get_hext_stream(sdev, cpu_dai, substream); + + /* nothing more to do if the link is already prepared */ + if (hext_stream && hext_stream->link_prepared) + return 0; + + /* + * reset the PCMSyCM registers to handle a prepare callback when the PCM is restarted + * due to xruns or after a call to snd_pcm_drain/drop() + */ + ret = hdac_bus_eml_sdw_map_stream_ch(sof_to_bus(sdev), link_id, cpu_dai->id, + 0, 0, substream->stream); + if (ret < 0) { + dev_err(cpu_dai->dev, "%s: hdac_bus_eml_sdw_map_stream_ch failed %d\n", + __func__, ret); + return ret; + } + data.dai_index = (link_id << 8) | cpu_dai->id; data.dai_node_id = intel_alh_id; ret = non_hda_dai_hw_params_data(substream, params, cpu_dai, &data, flags); @@ -490,10 +521,7 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream, return ret; } - ops = hda_dai_get_ops(substream, cpu_dai); - sdev = widget_to_sdev(w); hext_stream = ops->get_hext_stream(sdev, cpu_dai, substream); - if (!hext_stream) return -ENODEV; From patchwork Wed Oct 16 03:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13837673 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A0F6187877; Wed, 16 Oct 2024 03:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049374; cv=none; b=besFlD0pEClCpD4HTlU2O3A3JcD52UGzNbDZ1FTDBfPs9wQatLzk3F52j40Z7y+YjYAJGi4LRpkbVq7DyByT1q5E2eDGAH/1C6eV3I2kzPsd8Maw6UfyvEO5vJleFTmnAm7YcsPn7PCSuGyW3O25B01wVQ/t4fwLNJ0v97E4jQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049374; c=relaxed/simple; bh=ipVGNE72HnzLuRj6oepdeobbxw/astyo5Dsj0YhhbLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u6PqtlP2soZGYGwnb6vcsFJ2DvDXtp9K7yzNmvbqV/kUjzCQlD0gNJVINIGrjLQ4BX48I+/YY0ucJfZevda1Qit+wsry7j5D4IDgNUpBKl8zuJSbk48nC5cVOTrkp1FXQ7GsO3t8UIr6e2QXBmn2wcYSEwaVeWUlVsRDXZecw9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AfUmYMPS; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AfUmYMPS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729049373; x=1760585373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ipVGNE72HnzLuRj6oepdeobbxw/astyo5Dsj0YhhbLI=; b=AfUmYMPSHKFNK9OQL5igU8jGURXuDdF2zE5Ul85jnw6I7Qkif94cte5A KtJg+aQqQ5uvLU3GMrZw9xxEFDzMPN18U6bQX7NPDkKLulpf8AOqsdv97 +whzJpP0GUlxOs7ITs/iLIegXSBM6Z17Y3TmmjGaQ64u/fAk/bFrQ8Wpx sta63DjyAu3M6A1qS9JY+e6otX0ZbWj5CshZwx/sUW8aASmEtD0EvBF5Z 1G3q0dCJi6XEPKHhOV1tpztZvg0HW57nokshrVq6hj70biFajuAXWKOhR ATKPAJ5KVBdAZXxvmU3cmuzbR3dL/mF4e6xcGj2q/cjeKugArPsniTh7/ g==; X-CSE-ConnectionGUID: V7KtIbtDQ7aCOVt60gLylg== X-CSE-MsgGUID: KlyFRyStTLezljB7yJvMgQ== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="28676517" X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="28676517" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:33 -0700 X-CSE-ConnectionGUID: ikVwpVuJSTWym9uOTlh6Kw== X-CSE-MsgGUID: WJ+fZAUYSMqJUeR8jP+yKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="78047690" Received: from cvapit-mobl1.ger.corp.intel.com (HELO yungchua-desk.intel.com) ([10.247.118.236]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:30 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com, ranjani.sridharan@linux.intel.com Subject: [PATCH 3/4] soundwire: intel_ace2x: Send PDI stream number during prepare Date: Wed, 16 Oct 2024 11:29:09 +0800 Message-ID: <20241016032910.14601-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> References: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ranjani Sridharan In the case of a prepare callback after an xrun or when the PCM is restarted after a call to snd_pcm_drain/snd_pcm_drop, avoid reprogramming the SHIM registers but send the PDI stream number so that the link DMA data can be set. This is needed for the case that the DMA data is cleared when the PCM is stopped and restarted without being closed. Link: https://github.com/thesofproject/sof/issues/9502 Signed-off-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Kai Vehmanen Signed-off-by: Bard Liao Acked-by: Vinod Koul --- drivers/soundwire/intel_ace2x.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 3084f0ac7159..a005b63582e9 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -383,11 +383,12 @@ static int intel_hw_params(struct snd_pcm_substream *substream, static int intel_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); struct sdw_intel *sdw = cdns_to_intel(cdns); struct sdw_cdns_dai_runtime *dai_runtime; + struct snd_pcm_hw_params *hw_params; int ch, dir; - int ret = 0; dai_runtime = cdns->dai_runtime_array[dai->id]; if (!dai_runtime) { @@ -396,12 +397,8 @@ static int intel_prepare(struct snd_pcm_substream *substream, return -EIO; } + hw_params = &rtd->dpcm[substream->stream].hw_params; if (dai_runtime->suspended) { - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct snd_pcm_hw_params *hw_params; - - hw_params = &rtd->dpcm[substream->stream].hw_params; - dai_runtime->suspended = false; /* @@ -422,15 +419,11 @@ static int intel_prepare(struct snd_pcm_substream *substream, /* the SHIM will be configured in the callback functions */ sdw_cdns_config_stream(cdns, ch, dir, dai_runtime->pdi); - - /* Inform DSP about PDI stream number */ - ret = intel_params_stream(sdw, substream, dai, - hw_params, - sdw->instance, - dai_runtime->pdi->intel_alh_id); } - return ret; + /* Inform DSP about PDI stream number */ + return intel_params_stream(sdw, substream, dai, hw_params, sdw->instance, + dai_runtime->pdi->intel_alh_id); } static int From patchwork Wed Oct 16 03:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13837674 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5E2918870D; Wed, 16 Oct 2024 03:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049378; cv=none; b=CcmW2+4wpiIMLqRiDciu4QlO81+ZKUtDdnAcn0BSkVNKrx6yXOLgQipaFQzmPAOdywQdn/OoCD4U5PLRttMl1vNKG1bcikHVnfgvCrLnXRsg9gF3iWiiMIr1ICtW4CajHk9JVqnLXvxf7c93EVrTriuj5Ytf9mjeamjLsziDXsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729049378; c=relaxed/simple; bh=5iP9HtC1kQWNvWEhPvnhX/BLx8sgQFO32QZTth0dpKY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=djFlLHisdwsZbbCcGorNhq+9sCnXazbFXGqo7kTT4jqb0KmWiKMyp3SW7R3fha8QCmyLihlMmOcjufdCbibWu/ZpQzTz135t7rbIQ2EA5/U/JdVys680q7p/VT+qY4H0dJINbPnl3uJblrqtINC+d+eG6WsUHSBZPl2/WikNWFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HwocKubb; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HwocKubb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729049377; x=1760585377; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5iP9HtC1kQWNvWEhPvnhX/BLx8sgQFO32QZTth0dpKY=; b=HwocKubbOW8bknNq9xDMlgU2JQQF4Nkkcjlf5HabRBT8DBYFWhZx5349 p20LHXvfcxvHpa13NjDdV6VdAVioVy4Z39seDrQTVv6zOeAkGq0wglbUi 9oRrNBu63azivJTvLoKdWboi4lJdsUQlatLILcqUcZ6/ITYaBdI5a38xt 9VFHd74P6JDn4ozBD3Kq3NfcAg3ZkAhd3ILLSBg3MaED58dK19Lf3nA67 F7mfUQsYEDXFlygbICxbNEXUUvIa0HeM9pKlsVteABu19dpbjnFKzLNYu taIUXj9oeO3cPqCJG9tXz1ZuIN46+pI00LZJcl4LXCZF5QkGzdR/whEL8 Q==; X-CSE-ConnectionGUID: eEewWZN/QTSDzyzFn0wRbw== X-CSE-MsgGUID: Y1eDwj7sQTK7W+muuQoMWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="28676522" X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="28676522" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:36 -0700 X-CSE-ConnectionGUID: bVU95W72Q9yBlZSViMZ9ZA== X-CSE-MsgGUID: F9M7PSCmT2yn7gCt6ls1wQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="78047703" Received: from cvapit-mobl1.ger.corp.intel.com (HELO yungchua-desk.intel.com) ([10.247.118.236]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:29:33 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com, ranjani.sridharan@linux.intel.com Subject: [PATCH 4/4] ASoC: SOF: Intel: hda: Always clean up link DMA during stop Date: Wed, 16 Oct 2024 11:29:10 +0800 Message-ID: <20241016032910.14601-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> References: <20241016032910.14601-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ranjani Sridharan This is required to reset the DMA read/write pointers when the stream is prepared and restarted after a call to snd_pcm_drain()/snd_pcm_drop(). Also, now that the stream is reset during stop, do not save LLP registers in the case of STOP/suspend to avoid erroneous delay reporting. Link: https://github.com/thesofproject/sof/issues/9502 Signed-off-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Kai Vehmanen Signed-off-by: Bard Liao --- sound/soc/sof/intel/hda-dai-ops.c | 23 ++++++++++------------- sound/soc/sof/intel/hda-dai.c | 1 + 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 484c76147885..92681ca7f24d 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -346,20 +346,21 @@ static int hda_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: snd_hdac_ext_stream_start(hext_stream); break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - snd_hdac_ext_stream_clear(hext_stream); - /* - * Save the LLP registers in case the stream is - * restarting due PAUSE_RELEASE, or START without a pcm - * close/open since in this case the LLP register is not reset - * to 0 and the delay calculation will return with invalid - * results. + * Save the LLP registers since in case of PAUSE the LLP + * register are not reset to 0, the delay calculation will use + * the saved offsets for compensating the delay calculation. */ hext_stream->pplcllpl = readl(hext_stream->pplc_addr + AZX_REG_PPLCLLPL); hext_stream->pplcllpu = readl(hext_stream->pplc_addr + AZX_REG_PPLCLLPU); + snd_hdac_ext_stream_clear(hext_stream); + break; + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_STOP: + hext_stream->pplcllpl = 0; + hext_stream->pplcllpu = 0; + snd_hdac_ext_stream_clear(hext_stream); break; default: dev_err(sdev->dev, "unknown trigger command %d\n", cmd); @@ -512,7 +513,6 @@ static const struct hda_dai_widget_dma_ops sdw_ipc4_chain_dma_ops = { static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai, struct snd_pcm_substream *substream, int cmd) { - struct hdac_ext_stream *hext_stream = hda_get_hext_stream(sdev, cpu_dai, substream); struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(cpu_dai, substream->stream); switch (cmd) { @@ -527,9 +527,6 @@ static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c if (ret < 0) return ret; - if (cmd == SNDRV_PCM_TRIGGER_STOP) - return hda_link_dma_cleanup(substream, hext_stream, cpu_dai); - break; } case SNDRV_PCM_TRIGGER_PAUSE_PUSH: diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 8cccf38967e7..ac505c7ad342 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -302,6 +302,7 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i } switch (cmd) { + case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: ret = hda_link_dma_cleanup(substream, hext_stream, dai); if (ret < 0) {