From patchwork Fri Sep 15 11:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 723177 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 9D1A4EE6459 for ; Fri, 15 Sep 2023 11:40:46 +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 2636B950; Fri, 15 Sep 2023 13:39:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2636B950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694778044; bh=cV7AHlontMovqDlnpniU2t4nIcmYa9dc2wIMkhwQasI=; 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=gxORaET5Bc9n8oggIXhZF/qtHJNFJyDYZ+Iz/MrJ45QDQ3FI8crEPv7MfnZyPjtpQ NlOBNiRJabyHdQeKKdZr9pcZu6KCBm28akFU3s6JUpofTdMxggMiDyQvI6Noefu0v/ tA/jVoFU4/qbyKZp0S8JKAb45PeyOGGLt9Njns0Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 731CEF8055A; Fri, 15 Sep 2023 13:39:31 +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 BA723F80425; Fri, 15 Sep 2023 13:39:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F6B1F80537; Fri, 15 Sep 2023 13:39:25 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (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 74EE0F80141 for ; Fri, 15 Sep 2023 13:39:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 74EE0F80141 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=TwvSAvpY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694777958; x=1726313958; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cV7AHlontMovqDlnpniU2t4nIcmYa9dc2wIMkhwQasI=; b=TwvSAvpYeNTba+pGtc0HSIIyqT6XwA0VenIbEBfy+EA+ZuGXRYKrw+ZC bWnAGkPEIY/FK/ogf9gbm/VItLneSQKw283KyAy0cv9eoSGtox2oj+Mae Pj+jhGtcB0pCJ61S+L3DGsAcOmU7GbLceKGkP/yZKjdSM/+JuSy6AglKq +8h9h9cql1KyXi3ZxD6MUvREw/c+XIO8GFmsR9dh29JAXQxV2KXrVhG6l 9f0aMt4jFCpPXT0QkD4Gj4cXVEB/lUsC3ldKH/otufQbMRiKPL28xFMkY 9PQTlO/CuIxqmPpb40dwJWzH+PLHCiZyyrgMSTINlhuXz0ZE4+EnZh8Wr A==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="465590996" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="465590996" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="918629479" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="918629479" Received: from brhacker-mobl26.amr.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.48.34]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:09 -0700 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, guennadi.liakhovetski@linux.intel.com, chao.song@linux.intel.com Subject: [PATCH 1/3] ASoC: SOF: Intel: hda: Add definition for SDxFIFOS.FIFOS mask Date: Fri, 15 Sep 2023 14:39:10 +0300 Message-ID: <20230915113912.1405-2-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> References: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: KUEVWFNKLR7RGAUR6XLQYJNIXW7CQ2NQ X-Message-ID-Hash: KUEVWFNKLR7RGAUR6XLQYJNIXW7CQ2NQ X-MailFrom: peter.ujfalusi@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: The FIFOS (FIFO Size) field is in bit 0-15 of the register. Use the defined mask instead of a magic number for the FIFOS value masking in hda_dsp_stream_hw_params(). Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Ranjani Sridharan Reviewed-by: Chao Song --- sound/soc/sof/intel/hda-stream.c | 2 +- sound/soc/sof/intel/hda.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 0b0087abcc50..65e9242365be 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -668,7 +668,7 @@ int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev, snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, sd_offset + SOF_HDA_ADSP_REG_SD_FIFOSIZE); - hstream->fifo_size &= 0xffff; + hstream->fifo_size &= SOF_HDA_SD_FIFOSIZE_FIFOS_MASK; hstream->fifo_size += 1; } else { hstream->fifo_size = 0; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 5c517ec57d4a..2b228c63905b 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -135,6 +135,9 @@ #define SOF_HDA_ADSP_REG_SD_BDLPU 0x1C #define SOF_HDA_ADSP_SD_ENTRY_SIZE 0x20 +/* SDxFIFOS FIFOS */ +#define SOF_HDA_SD_FIFOSIZE_FIFOS_MASK GENMASK(15, 0) + /* CL: Software Position Based FIFO Capability Registers */ #define SOF_DSP_REG_CL_SPBFIFO \ (SOF_HDA_ADSP_LOADER_BASE + 0x20) From patchwork Fri Sep 15 11:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 723972 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 D2A6CEE6457 for ; Fri, 15 Sep 2023 11:41:14 +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 BC44AA4E; Fri, 15 Sep 2023 13:40:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC44AA4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694778072; bh=gHKQXhlXpmwvd4kYxW5s3at1ALBR2eYH3m6GCf/yc1k=; 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=o7I30o+FofizzQym7GJNREIBwJY/dBx2PTRM+N3t8faixOu1ILxjT14dgCgDOsZsJ F7m1lBwsmNxek//cYSLsb+90T0lnEJxbDJTYFvZp9Ltw8vbpThaxZLBlVY2Xq7CZPa d/S2KcLpSbOG6/X2EDbSORye4ti2kaSmZqqEkwhw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3955F80568; Fri, 15 Sep 2023 13:39:31 +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 89360F8055C; Fri, 15 Sep 2023 13:39:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A41EF8047D; Fri, 15 Sep 2023 13:39:28 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (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 A89D4F80246 for ; Fri, 15 Sep 2023 13:39:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A89D4F80246 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=lZgotgku DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694777960; x=1726313960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gHKQXhlXpmwvd4kYxW5s3at1ALBR2eYH3m6GCf/yc1k=; b=lZgotgkuUyoaQSOzy/zveqwjzArXLUbNaCSl4lFSA6+r3oLMsFW9wfrX husAvXmPf0HvReRyimCx6H4G6d0q+f09USVfnsO80I6yRxi1hAAahQtHT eRGMxZ/qmgNgYjSm7FnT8XsZFVQ5e1agrmuG3HlGMAAhZ5JiQnaQrkImM nwO3q71Gqi2qnObNqfX4+jVud5wZg5jQfHJBjhSsWSrnXjkqGn8yZ89FR rVrSxviqZkI0O1cD3aOqP6GUqp0BcU5eryPsP9ul6lYtRIHFDdIoBYfG4 /SrPVqdLA0Q+WxR6MadKURVwayB3F3MuZAdsU9s7hfGQyTRyLUPFu6fwL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="465591003" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="465591003" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="918629493" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="918629493" Received: from brhacker-mobl26.amr.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.48.34]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:12 -0700 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, guennadi.liakhovetski@linux.intel.com, chao.song@linux.intel.com Subject: [PATCH 2/3] ASoC: SOF: ipc4: Add new message type: SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE Date: Fri, 15 Sep 2023 14:39:11 +0300 Message-ID: <20230915113912.1405-3-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> References: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: SYZQ4QIMFWRU2X2P4Y6ARCPFFVPUZVHU X-Message-ID-Hash: SYZQ4QIMFWRU2X2P4Y6ARCPFFVPUZVHU X-MailFrom: peter.ujfalusi@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: On Intel platforms there is a strict order requirement for the DMA programming: DSP side configures the buffer and sets the GEN bit Host side sets the RUN bit. In order to follow this flow, a new global message type has been added to prepare the DSP side of the DMA: host sends LOAD_LIBRARY_PREPARE with the dma_id DSP side sets its buffer and sets the GEN bit Host sets the RUN bit Host sends LOAD_LIBRARY with dma_id and lib_id DSP receives the library data. It is up to the platform code to use the new prepare stage message and how to handle the reply to it from the firmware, which can indicate that the message type is not supported/handled. In this case the kernel should proceed to the LOAD_LIBRARY stage assuming a single stage library loading: host sends LOAD_LIBRARY_PREPARE with the dma_id DSP replies that the message type is not supported/handled Host acknowledges the return code and sets the RUN bit Host sends LOAD_LIBRARY with dma_id and lib_id DSP receives the library data. Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Ranjani Sridharan Reviewed-by: Chao Song --- include/sound/sof/ipc4/header.h | 15 +++++++++++---- sound/soc/sof/ipc4.c | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/sound/sof/ipc4/header.h b/include/sound/sof/ipc4/header.h index 78568abe2673..c58f00ef054a 100644 --- a/include/sound/sof/ipc4/header.h +++ b/include/sound/sof/ipc4/header.h @@ -106,12 +106,19 @@ enum sof_ipc4_global_msg { SOF_IPC4_GLB_SAVE_PIPELINE, SOF_IPC4_GLB_RESTORE_PIPELINE, - /* Loads library (using Code Load or HD/A Host Output DMA) */ + /* + * library loading + * + * Loads library (using Code Load or HD/A Host Output DMA) + */ SOF_IPC4_GLB_LOAD_LIBRARY, + /* + * Prepare the host DMA channel for library loading, must be followed by + * a SOF_IPC4_GLB_LOAD_LIBRARY message as the library loading step + */ + SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE, - /* 25: RESERVED - do not use */ - - SOF_IPC4_GLB_INTERNAL_MESSAGE = 26, + SOF_IPC4_GLB_INTERNAL_MESSAGE, /* Notification (FW to SW driver) */ SOF_IPC4_GLB_NOTIFICATION, diff --git a/sound/soc/sof/ipc4.c b/sound/soc/sof/ipc4.c index 24e9c29f3579..e14924048eb5 100644 --- a/sound/soc/sof/ipc4.c +++ b/sound/soc/sof/ipc4.c @@ -157,6 +157,7 @@ static const char * const ipc4_dbg_glb_msg_type[] = { DBG_IPC4_MSG_TYPE_ENTRY(GLB_SAVE_PIPELINE), DBG_IPC4_MSG_TYPE_ENTRY(GLB_RESTORE_PIPELINE), DBG_IPC4_MSG_TYPE_ENTRY(GLB_LOAD_LIBRARY), + DBG_IPC4_MSG_TYPE_ENTRY(GLB_LOAD_LIBRARY_PREPARE), DBG_IPC4_MSG_TYPE_ENTRY(GLB_INTERNAL_MESSAGE), DBG_IPC4_MSG_TYPE_ENTRY(GLB_NOTIFICATION), }; From patchwork Fri Sep 15 11:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 723971 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 BCA19EE6457 for ; Fri, 15 Sep 2023 11:41:36 +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 C1E32DF1; Fri, 15 Sep 2023 13:40:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1E32DF1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694778094; bh=R5UmcmMi+0KGyQh2g1ZKzfiwXf75bbklKGGQF55+D5w=; 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=lM3LXs1U5tHwHvYT7wyGa01Lua56mf216XhpWXhCJF0HT0llBcoFLoBLLJ3u9nsRI jXxd1OzV5UC32jtHHT9rZEea7yD3OGjBXVlVgXAzaTfMFPEhg1HT4/iz6GSeRqahLu afYM86LCC13AjeJxFAjJ9Pzd/QbLQQqqLAHq0yyQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8C34CF8057B; Fri, 15 Sep 2023 13:39:37 +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 06577F80589; Fri, 15 Sep 2023 13:39:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CC569F80537; Fri, 15 Sep 2023 13:39:30 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (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 D4291F80431 for ; Fri, 15 Sep 2023 13:39:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D4291F80431 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=G8V0O6Xn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694777963; x=1726313963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R5UmcmMi+0KGyQh2g1ZKzfiwXf75bbklKGGQF55+D5w=; b=G8V0O6XnLv9NT3pnuMDfrbK5Kd24JsG8hJ4qLs4WjPZWsaeyEFZzooE4 RAlXwEvRST0nvSYbm4gASavFJN13589PEiNrlKQVr0+gP1FbsEqBXOfAS shFxPg9Qu1qkYnDxy1BA3tIMJlSOxr1Yqv5QiXjcOnbyDk7v7VxogIACC IElikc46zlsNAPU7ffATkPW8r09/XZ/oDsH+iowj7as+pN2nC+KScVduR Z2GU9Nh+b+R1RS+CeUt1MB8N662WylYXqXHBhciT2S4jn6hdbXGdbWZjF +oxUISi5X097LGXWuGNqjCGjYhtnV5TeNtgmnC912ZdmzE/q/ZgTAaCFa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="465591008" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="465591008" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="918629516" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="918629516" Received: from brhacker-mobl26.amr.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.48.34]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 04:39:15 -0700 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, guennadi.liakhovetski@linux.intel.com, chao.song@linux.intel.com Subject: [PATCH 3/3] ASoC: SOF: Intel: hda-loader: Add support for split library loading Date: Fri, 15 Sep 2023 14:39:12 +0300 Message-ID: <20230915113912.1405-4-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> References: <20230915113912.1405-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: UBMXRFAVOOPRWOVMBZNK3OHEPJ2HBXKI X-Message-ID-Hash: UBMXRFAVOOPRWOVMBZNK3OHEPJ2HBXKI X-MailFrom: peter.ujfalusi@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: There is a certain sequence needs to be followed when configuring the HDA DMA in host and DSP. The firmware provides a way to handle this two stage sequencing by splitting the library loading into two stage: 1st stage: LOAD_LIBRARY_PREPARE message the lib_id is 0, used to configure the DMA on DSP side 2nd stage: LOAD_LIBRARY message both dma_id and lib_id is valid, used for the actual transfer of the library In case a firmware without support for this two stage loading is used then the second stage message will trigger the loading and the first stage will return with error, which is ignored by the kernel. Signed-off-by: Peter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Ranjani Sridharan Reviewed-by: Chao Song --- sound/soc/sof/intel/hda-loader.c | 42 ++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c index 50ce6b190002..1e2669a8088d 100644 --- a/sound/soc/sof/intel/hda-loader.c +++ b/sound/soc/sof/intel/hda-loader.c @@ -545,11 +545,40 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, memcpy(dmab.area, stripped_firmware.data, stripped_firmware.size); + /* + * 1st stage: SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE + * Message includes the dma_id to be prepared for the library loading. + * If the firmware does not have support for the message, we will + * receive -EOPNOTSUPP. In this case we will use single step library + * loading and proceed to send the LOAD_LIBRARY message. + */ msg.primary = hext_stream->hstream.stream_tag - 1; - msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_LOAD_LIBRARY); + msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE); msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_FW_GEN_MSG); - msg.primary |= SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(fw_lib->id); + ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); + if (!ret) { + int sd_offset = SOF_STREAM_SD_OFFSET(&hext_stream->hstream); + unsigned int status; + + /* + * Make sure that the FIFOS value is not 0 in SDxFIFOS register + * which indicates that the firmware set the GEN bit and we can + * continue to start the DMA + */ + ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_HDA_BAR, + sd_offset + SOF_HDA_ADSP_REG_SD_FIFOSIZE, + status, + status & SOF_HDA_SD_FIFOSIZE_FIFOS_MASK, + HDA_DSP_REG_POLL_INTERVAL_US, + HDA_DSP_BASEFW_TIMEOUT_US); + + if (ret < 0) + dev_warn(sdev->dev, + "%s: timeout waiting for FIFOS\n", __func__); + } else if (ret != -EOPNOTSUPP) { + goto cleanup; + } ret = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_START); if (ret < 0) { @@ -557,8 +586,17 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, goto cleanup; } + /* + * 2nd stage: LOAD_LIBRARY + * Message includes the dma_id and the lib_id, the dma_id must be + * identical to the one sent via LOAD_LIBRARY_PREPARE + */ + msg.primary &= ~SOF_IPC4_MSG_TYPE_MASK; + msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_LOAD_LIBRARY); + msg.primary |= SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(fw_lib->id); ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); + /* Stop the DMA channel */ ret1 = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_STOP); if (ret1 < 0) { dev_err(sdev->dev, "%s: DMA trigger stop failed\n", __func__);