From patchwork Fri May 12 17:46:06 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: 681224 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 01C54C77B75 for ; Fri, 12 May 2023 17:48:12 +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 AF5A3E89; Fri, 12 May 2023 19:47:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AF5A3E89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913690; bh=NXWEW2uL0MZdzPaFwT9g5wKRsXZ6EYOMBJswLRp4reE=; 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=HG3qTEi8Ip2ww1TLEmX4Xa6OO0lravmszIJEByC/9oCOyiXtI42WvzJybJ0N2B1fJ 8erj7uQQseJLQQZyocVnAK/tQ/f6+vBClvWKlOtzq7LrQvjJoYh/GY+eKq+yXrQYGK Oc/1KyGxJR6Jtq+GUXtzydEoOjWDMC3m7zC3t+0k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E8DA9F80534; Fri, 12 May 2023 19:46:32 +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 202C0F8055A; Fri, 12 May 2023 19:46:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1982F80542; Fri, 12 May 2023 19:46:27 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 84749F802E8 for ; Fri, 12 May 2023 19:46:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 84749F802E8 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=XM4deN7m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913584; x=1715449584; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NXWEW2uL0MZdzPaFwT9g5wKRsXZ6EYOMBJswLRp4reE=; b=XM4deN7mEMDusm7iMtqfvzTPNISodULJdDSojRqAA/E91AV6Dz6o+IKR jkL9Ix9TffbZyL391npctt/SrN86gzZlf7UsVT9O0exqeTyONUaC/gV6K s3yaYN0md0gY8gz6LOzPDVX5yiYLtaV4fKW7DIsN4WGzBeaiTC7Cc2DBy pSWo1Tf0XqR+NV+ali779W7Om8lJUgH/hBgtDTEBH2zRAnkpAuJ+FMw3K qpZw7Noaas7O/SXFY76S+QK5VdDybCi8hU6BEHXPo58zwrSuFfUrA69K4 pMNwJguK8pBUA3Md0nQ2Moa1wwuQ1VjMmjwFvzQkAolYFTFiqH27nW5QB w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688046" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688046" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167745" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167745" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:19 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , Bard Liao Subject: [PATCH 1/6] ASoC: SOF: Intel: hda-mlink: fix sublink refcounting Date: Fri, 12 May 2023 12:46:06 -0500 Message-Id: <20230512174611.84372-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: T2ZNESELO4VDMYIEDSKAEPQE2GTKVDBB X-Message-ID-Hash: T2ZNESELO4VDMYIEDSKAEPQE2GTKVDBB 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: In hindsight it was a very bad idea to use the same refcount for Extended and 'legacy' HDaudio multi-links. The existing solution only powers-up the first sublink, which causes SoundWire and SSP tests to fail when more than one DAI is used concurrently. Solving this problem requires per-sublink refcounting, as suggested in this patch. The existing refcounting remains for 'legacy' HdAudio links, mainly to avoid changing the obscure programming sequence in snd_hdac_ext_bus_link_put(). Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao --- sound/soc/sof/intel/hda-mlink.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index 775582ab7494..6d0145c30afe 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -19,6 +19,9 @@ #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_MLINK) +/* worst-case number of sublinks is used for sublink refcount array allocation only */ +#define HDAML_MAX_SUBLINKS (AZX_ML_LCTL_CPA_SHIFT - AZX_ML_LCTL_SPA_SHIFT) + /** * struct hdac_ext2_link - HDAudio extended+alternate link * @@ -33,6 +36,7 @@ * @leptr: extended link pointer * @eml_lock: mutual exclusion to access shared registers e.g. CPA/SPA bits * in LCTL register + * @sublink_ref_count: array of refcounts, required to power-manage sublinks independently * @base_ptr: pointer to shim/ip/shim_vs space * @instance_offset: offset between each of @slcount instances managed by link * @shim_offset: offset to SHIM register base @@ -53,6 +57,7 @@ struct hdac_ext2_link { u32 leptr; struct mutex eml_lock; /* prevent concurrent access to e.g. CPA/SPA */ + int sublink_ref_count[HDAML_MAX_SUBLINKS]; /* internal values computed from LCAP contents */ void __iomem *base_ptr; @@ -641,8 +646,13 @@ static int hdac_bus_eml_power_up_base(struct hdac_bus *bus, bool alt, int elid, if (eml_lock) mutex_lock(&h2link->eml_lock); - if (++hlink->ref_count > 1) - goto skip_init; + if (!alt) { + if (++hlink->ref_count > 1) + goto skip_init; + } else { + if (++h2link->sublink_ref_count[sublink] > 1) + goto skip_init; + } ret = hdaml_link_init(hlink->ml_addr + AZX_REG_ML_LCTL, sublink); @@ -684,9 +694,13 @@ static int hdac_bus_eml_power_down_base(struct hdac_bus *bus, bool alt, int elid if (eml_lock) mutex_lock(&h2link->eml_lock); - if (--hlink->ref_count > 0) - goto skip_shutdown; - + if (!alt) { + if (--hlink->ref_count > 0) + goto skip_shutdown; + } else { + if (--h2link->sublink_ref_count[sublink] > 0) + goto skip_shutdown; + } ret = hdaml_link_shutdown(hlink->ml_addr + AZX_REG_ML_LCTL, sublink); skip_shutdown: From patchwork Fri May 12 17:46:07 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: 681223 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 F3FE1C77B7F for ; Fri, 12 May 2023 17:48:39 +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 E7C1BE8D; Fri, 12 May 2023 19:47:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E7C1BE8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913718; bh=MNGWA3vmWo08eGxBJmdouKC0KZWye9m7SyWKKawgpi4=; 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=UkmdKFJxVdHjYS6fp1P+WHtC2rfmRhOGbvtcXcu/A/goirEwCblz3cbximv8gJ+vB PUcdNrFN6lWeWpZCfVBpMJ00xYnYtK2+4PxpluBMtLD/c4kGnKzQbck7ataAZ6FB3s DEQFq0Xv0mHxfrLE0Br5+cXBTGo2KbctosMpL9FU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3D72DF8059F; Fri, 12 May 2023 19:46:38 +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 9EEE9F8059F; Fri, 12 May 2023 19:46:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2756F80558; Fri, 12 May 2023 19:46:29 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 CE9B5F8052E for ; Fri, 12 May 2023 19:46:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE9B5F8052E 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=bW7lEI+B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913585; x=1715449585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MNGWA3vmWo08eGxBJmdouKC0KZWye9m7SyWKKawgpi4=; b=bW7lEI+Bh/W9I9FGr+JZXwFHCltuIvlkW9YlgGobRWGfyRVcSdCeBUM1 0g79kinrGaJiGz1T3Uscv+1Xi1deXRLW+fmHsHP5AALwT4j0O7lo+X1xB Gb0TclY2lb6aRcnFphUOjMT/+FbznB3Wr8zzYJ+3ielg/AmnHyGg0AD6z qKRcm7g0S0V98ZHoOYVDCrX4jTZjvRRCiIU/okRk4r5gkM2SmCM4vGyhk yyNCVbPXL0wIqX8Jn/ST2Vkyg+dUWXxpn2kA6Q9khZIKP+mJUPqef96Ti LyQ/5THFQmO/ILjrGy5F8xkvI3AVxKLIL0iqprH5Ga3svKpT0raqtlHst g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688054" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688054" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167767" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167767" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:20 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, Pierre-Louis Bossart , Rander Wang , Ranjani Sridharan , Bard Liao Subject: [PATCH 2/6] ASoC: SOF: Intel: hda-mlink: add helper to get SoundWire hlink Date: Fri, 12 May 2023 12:46:07 -0500 Message-Id: <20230512174611.84372-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: JEQ6B7GTL24KCHVK6OZQ364OGGUSYHBM X-Message-ID-Hash: JEQ6B7GTL24KCHVK6OZQ364OGGUSYHBM 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: Same functionality as for DMIC/SSP with different ID. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao --- include/sound/hda-mlink.h | 4 ++++ sound/soc/sof/intel/hda-mlink.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/sound/hda-mlink.h b/include/sound/hda-mlink.h index dbc47af08135..5bfa8ae940e4 100644 --- a/include/sound/hda-mlink.h +++ b/include/sound/hda-mlink.h @@ -51,6 +51,7 @@ int hda_bus_ml_suspend(struct hdac_bus *bus); struct hdac_ext_link *hdac_bus_eml_ssp_get_hlink(struct hdac_bus *bus); struct hdac_ext_link *hdac_bus_eml_dmic_get_hlink(struct hdac_bus *bus); +struct hdac_ext_link *hdac_bus_eml_sdw_get_hlink(struct hdac_bus *bus); struct mutex *hdac_bus_eml_get_mutex(struct hdac_bus *bus, bool alt, int elid); @@ -155,6 +156,9 @@ hdac_bus_eml_ssp_get_hlink(struct hdac_bus *bus) { return NULL; } static inline struct hdac_ext_link * hdac_bus_eml_dmic_get_hlink(struct hdac_bus *bus) { return NULL; } +static inline struct hdac_ext_link * +hdac_bus_eml_sdw_get_hlink(struct hdac_bus *bus) { return NULL; } + static inline struct mutex * hdac_bus_eml_get_mutex(struct hdac_bus *bus, bool alt, int elid) { return NULL; } diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index 6d0145c30afe..cfa43d93cbd0 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -850,6 +850,18 @@ struct hdac_ext_link *hdac_bus_eml_dmic_get_hlink(struct hdac_bus *bus) } EXPORT_SYMBOL_NS(hdac_bus_eml_dmic_get_hlink, SND_SOC_SOF_HDA_MLINK); +struct hdac_ext_link *hdac_bus_eml_sdw_get_hlink(struct hdac_bus *bus) +{ + struct hdac_ext2_link *h2link; + + h2link = find_ext2_link(bus, true, AZX_REG_ML_LEPTR_ID_SDW); + if (!h2link) + return NULL; + + return &h2link->hext_link; +} +EXPORT_SYMBOL_NS(hdac_bus_eml_sdw_get_hlink, SND_SOC_SOF_HDA_MLINK); + int hdac_bus_eml_enable_offload(struct hdac_bus *bus, bool alt, int elid, bool enable) { struct hdac_ext2_link *h2link; From patchwork Fri May 12 17:46:08 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: 681840 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 E4F4FC77B75 for ; Fri, 12 May 2023 17:49:30 +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 AABCBE93; Fri, 12 May 2023 19:48:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AABCBE93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913768; bh=kdPzUEGBiRONzOrtlvhSKrrsD3Yy1AgHk6Vy5KKO4L8=; 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=Lv8St3uBdNAmTfha5aN1MN3F1PjmBREldnN03oKWiMkUHzZeSFas75dU2qA9tZeZC hjtoYswFTvxsccJyCtWbUNYltFY9uLgH1HFXIPI7KbDfGZQe5M6b2U2OTpr5Z3LsFp BpUfOAQno8oOO6fl94ettbxLJQo6K99yrvOksZME= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C653FF805A9; Fri, 12 May 2023 19:48:05 +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 62F26F80589; Fri, 12 May 2023 19:48:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 55FEBF8055C; Fri, 12 May 2023 19:46:33 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 10CB1F8053B for ; Fri, 12 May 2023 19:46:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 10CB1F8053B 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=VLNq4XAw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913587; x=1715449587; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kdPzUEGBiRONzOrtlvhSKrrsD3Yy1AgHk6Vy5KKO4L8=; b=VLNq4XAwNL0Qjqp03Vo1SEqJkpuaI2N7HrzuFuJz/sqagYD1s69tq/YU kI/wFuz9yM18mw2HLNiI5+UU5egdAidA7z+fP+fCwjuYhb5OsbCe4mz59 QGv4dslD4wY7zbg5NfSA/NXXi5MgdH0cEag0Hh0P8i08VW+4gd2PKH+/r mK/FCFIE7yo50eFnAebeEEOa2H2Q2DqC4g93XgkFZMt2cgEYy9eosfYR8 c9BBYk3fTWn1B9AT5oxDj3jbqV27bteRSylbWBckrMcGI5pksD1pDkRC4 vNp7SkSaFT/7A5qEfaxu1l/8Uv7aL4glMidoCDy7QH0AVKVIzgKgkprT8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688061" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688061" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167779" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167779" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:21 -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 , Ranjani Sridharan Subject: [PATCH 3/6] ASoC: SOF: Intel: hda-mlink: fix base_ptr computation Date: Fri, 12 May 2023 12:46:08 -0500 Message-Id: <20230512174611.84372-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: HZT4ASXCE7IBNGGYLGRYIDOEEOAGHCIF X-Message-ID-Hash: HZT4ASXCE7IBNGGYLGRYIDOEEOAGHCIF 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: The base_ptr value needs to be derived from the remap_addr pointer, not the ml_addr. This base_ptr was used only in debug logs that were so far not contributed upstream so the issue was not detected. It needs to be fixed for SoundWire support on LunarLake. Fixes: 17c9b6ec35c0 ("ASoC: SOF: Intel: hda-mlink: add structures to parse ALT links") Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan --- sound/soc/sof/intel/hda-mlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index cfa43d93cbd0..7f5d0ea4abeb 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -96,7 +96,7 @@ struct hdac_ext2_link { */ static int hdaml_lnk_enum(struct device *dev, struct hdac_ext2_link *h2link, - void __iomem *ml_addr, int link_idx) + void __iomem *remap_addr, void __iomem *ml_addr, int link_idx) { struct hdac_ext_link *hlink = &h2link->hext_link; u32 base_offset; @@ -136,7 +136,7 @@ static int hdaml_lnk_enum(struct device *dev, struct hdac_ext2_link *h2link, h2link->elid = FIELD_GET(AZX_REG_ML_LEPTR_ID, h2link->leptr); base_offset = FIELD_GET(AZX_REG_ML_LEPTR_PTR, h2link->leptr); - h2link->base_ptr = hlink->ml_addr + base_offset; + h2link->base_ptr = remap_addr + base_offset; switch (h2link->elid) { case AZX_REG_ML_LEPTR_ID_SDW: @@ -369,7 +369,7 @@ static int hda_ml_alloc_h2link(struct hdac_bus *bus, int index) hlink->bus = bus; hlink->ml_addr = bus->mlcap + AZX_ML_BASE + (AZX_ML_INTERVAL * index); - ret = hdaml_lnk_enum(bus->dev, h2link, hlink->ml_addr, index); + ret = hdaml_lnk_enum(bus->dev, h2link, bus->remap_addr, hlink->ml_addr, index); if (ret < 0) { kfree(h2link); return ret; From patchwork Fri May 12 17:46:09 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: 681842 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 9B6E1C77B75 for ; Fri, 12 May 2023 17:48:22 +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 55045E7A; Fri, 12 May 2023 19:47:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55045E7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913700; bh=G5gbNgfeg4XZDB9YlQebK9EWfdde2xq8U1cJ5PdQ4XY=; 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=hFh3M+rWOLrLa3EslgFwsNEJdVJ8U+JUffz6O/2MZT5gL6QibCiu3Od82E49jlo6C NhVbovavZLl12imLgEr5vPJhWaE6Kx+GdIyfgSoG6nWDWbLNZSLntBk22jVeBBb6HU pzZg7vHfW1mbFFmVhMhrAccAYBj/BnklddXZfjcM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1351FF80564; Fri, 12 May 2023 19:46:35 +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 9F14DF80564; Fri, 12 May 2023 19:46:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5747FF8014C; Fri, 12 May 2023 19:46:29 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7C441F8032D for ; Fri, 12 May 2023 19:46:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7C441F8032D 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=Clk6Q+UW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913586; x=1715449586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G5gbNgfeg4XZDB9YlQebK9EWfdde2xq8U1cJ5PdQ4XY=; b=Clk6Q+UWw0ESsUvxLhFqP29UFGembgpACS1deySm0t6WWHk5+8OfALQM b4/srXa8nq5z3Yal4KFz/Dqf3JR+YLEMUeXD6ki07DnjMj/0IEJOCJ2fl qBKIdv1kDoITBRduVO6sxhjaesJApeYvfDe8CFpusK1XTYw6/JqeaZcnd Wy1IPnVx0COW1fP04GSCEhOOTX7X0uBtgynO/zMcNm01WUgDiBCDAchxQ qpmxOWSzkBAlUxQnghmb+NojKJDEfKP92Hq774Q5sC5w4HQj5Nj08NDAx XbTTtX6KGxKx2CwIbZZqGXC7K9O6FOR0Yp5WJ9cCO6Ih9Ba0aMb3bflan A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688067" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688067" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167791" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167791" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:22 -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 , Ranjani Sridharan Subject: [PATCH 4/6] ASoC: SOF: Intel: hda-mlink: use 'ml_addr' parameter consistently Date: Fri, 12 May 2023 12:46:09 -0500 Message-Id: <20230512174611.84372-5-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: EH3UYBVNCKYLGR7XEC5IWCW2ZCRUOI4Z X-Message-ID-Hash: EH3UYBVNCKYLGR7XEC5IWCW2ZCRUOI4Z 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: We mix the use of hlink->ml_addr and the 'ml_addr' parameter. It's the same thing, let's align on using the parameter. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan --- sound/soc/sof/intel/hda-mlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index 7f5d0ea4abeb..c540b1d75451 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -131,7 +131,7 @@ static int hdaml_lnk_enum(struct device *dev, struct hdac_ext2_link *h2link, link_idx, h2link->slcount); /* find IP ID and offsets */ - h2link->leptr = readl(hlink->ml_addr + AZX_REG_ML_LEPTR); + h2link->leptr = readl(ml_addr + AZX_REG_ML_LEPTR); h2link->elid = FIELD_GET(AZX_REG_ML_LEPTR_ID, h2link->leptr); From patchwork Fri May 12 17:46:10 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: 681841 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 2D522C77B75 for ; Fri, 12 May 2023 17:49:04 +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 13755EA4; Fri, 12 May 2023 19:48:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 13755EA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913742; bh=GPyB5hYoL6NUcQCPdbqVoFTExK4bHxVxYeWygZQmxs0=; 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=jkwAe+SpomSDuyY/0e25bxW2fvK86Jre5fA2Az4N1bITe9XhFfxW+aozYrkxjNMjH NCpZWqQP/m1QjdOZoPSrgToJ+yv6cgyfd5QQS4cdjUsamzWXE6a1lU0IpFDIleDSxW SYwae0pL/rEE6ueExWE9RbXEBBm/JV8HD1T3MErg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C5025F802E8; Fri, 12 May 2023 19:48:04 +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 775ACF8053D; Fri, 12 May 2023 19:48:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2FC4F80557; Fri, 12 May 2023 19:46:30 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 CDBACF80534 for ; Fri, 12 May 2023 19:46:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CDBACF80534 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=f3ml3dBf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913587; x=1715449587; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GPyB5hYoL6NUcQCPdbqVoFTExK4bHxVxYeWygZQmxs0=; b=f3ml3dBfgySuAIqKl0yPhUvGyIvVcFckjiYKydTlqrSBRgRwrzSJifm7 GxHgMaQcFFmHQVmqNnJojXw3/3hR29MjRyaXuUZaMdBLpo4U0z7zB1Jce Vuddfp1ar3M/x4R6J+NG3arsQEbkG0mB+ND8nKun2LHqT1akeV6Gdr0BE ME/fzqH4VqhPPCekspMgaxWMxFIRW5C2t/VTcRLzsZs3gIzkKQ8auR9EC skmJaHdAz63y93JIjsczFmklo76qkPWPnMU+rA1zqoM02T7V4sdqKgugZ eFonj8jKx5jUnnlV0h7opMf6fSfDfBJ7iyOG6xTAhhFuAr+6/kGBw5gWl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688073" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688073" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167797" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167797" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:23 -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 , Ranjani Sridharan Subject: [PATCH 5/6] ASoC: SOF: Intel: hda-mlink: initialize instance_offset member Date: Fri, 12 May 2023 12:46:10 -0500 Message-Id: <20230512174611.84372-6-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: FWKUGUI4SNFRULNPTMQ3R65EBPJXHEPC X-Message-ID-Hash: FWKUGUI4SNFRULNPTMQ3R65EBPJXHEPC 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: We defined the values but never initialized it for SoundWire/SSP, fix this miss. A Fixes: tag is not provided as instance_offset was not used so far, so nothing was really broken. This patch is only required for the SoundWire support in the following patch. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan --- sound/soc/sof/intel/hda-mlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index c540b1d75451..2d0c5d5914b1 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -140,6 +140,7 @@ static int hdaml_lnk_enum(struct device *dev, struct hdac_ext2_link *h2link, switch (h2link->elid) { case AZX_REG_ML_LEPTR_ID_SDW: + h2link->instance_offset = AZX_REG_SDW_INSTANCE_OFFSET; h2link->shim_offset = AZX_REG_SDW_SHIM_OFFSET; h2link->ip_offset = AZX_REG_SDW_IP_OFFSET; h2link->shim_vs_offset = AZX_REG_SDW_VS_SHIM_OFFSET; @@ -154,6 +155,7 @@ static int hdaml_lnk_enum(struct device *dev, struct hdac_ext2_link *h2link, link_idx, base_offset); break; case AZX_REG_ML_LEPTR_ID_INTEL_SSP: + h2link->instance_offset = AZX_REG_INTEL_SSP_INSTANCE_OFFSET; h2link->shim_offset = AZX_REG_INTEL_SSP_SHIM_OFFSET; h2link->ip_offset = AZX_REG_INTEL_SSP_IP_OFFSET; h2link->shim_vs_offset = AZX_REG_INTEL_SSP_VS_SHIM_OFFSET; From patchwork Fri May 12 17:46:11 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: 681222 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 1A4A7C77B7F for ; Fri, 12 May 2023 17:49:15 +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 9DA87E88; Fri, 12 May 2023 19:48:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9DA87E88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683913752; bh=dt1NhGCq6KNz+7Q8rqjoCnEoN9cKfME3q2gb3EFAMLs=; 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=A8Nlw/NEsde961A/PI7Miz6Q8VB1+0rcGKzAE3NUQCnshWWl0785RLgXS7Q6yRzuf REW10S57CgxXD7GDnqJ104ILUhwfizDasGXkRfAasstOIaoG3Ee75qIGX6pxgTKkuc Sm5kIcmnQ1Ra453mIEcvVpyFUvkCZA/MrQrow6J8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 526EEF80553; Fri, 12 May 2023 19:48:05 +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 EB671F80578; Fri, 12 May 2023 19:48:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA354F80563; Fri, 12 May 2023 19:46:32 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 61144F8053D for ; Fri, 12 May 2023 19:46:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 61144F8053D 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=UdFgc1tg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683913588; x=1715449588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dt1NhGCq6KNz+7Q8rqjoCnEoN9cKfME3q2gb3EFAMLs=; b=UdFgc1tgd7N4gdDhQ4S0P+aVajxNBMrfBfJR6Oi4JNAAzlBmUo7UdH+9 8/smNyGH9rpt/ykf5vVFaS+7l+uDTAlvoPXdUxA9LEETZBYLibstQwmBk JVEmpX5kaHhSTFFLYYw6NAK7AK4nYDN4khBlVzG3+JJkf4j0EVcMr8crI CeH+Z65AcZeT7OL+DfZxLJG/Dl62C9urmi+aXnXCCJmDvLSa8oP1vO6eg IWJZHSndDC64GkA0oDumtJwLsvy0nUA+wggaWEcgIIWHwjZOkN2N+4ycB 2eRyb+zvhvcaYr309ZDhgzccIUeoSHti89sVPz1Gng4dAFKd0QBbzlOnS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349688080" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349688080" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="812167807" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="812167807" Received: from winkelru-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.144.249]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 10:46:24 -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 , Ranjani Sridharan Subject: [PATCH 6/6] ASoC: SOF: Intel: hda-mlink: add helper to program SoundWire PCMSyCM registers Date: Fri, 12 May 2023 12:46:11 -0500 Message-Id: <20230512174611.84372-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> References: <20230512174611.84372-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 3S7ZTPGFHSRAU2EKROOMPDDWPPC4T3CE X-Message-ID-Hash: 3S7ZTPGFHSRAU2EKROOMPDDWPPC4T3CE 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: These registers enable the HDaudio DMA hardware to split/merge data from different PDIs, possibly on different links. This capability exists for all types of HDaudio extended links, but for now is only required for SoundWire. In the SSP/DMIC case, the IP is programmed by the DSP firmware. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Rander Wang Reviewed-by: Ranjani Sridharan --- include/sound/hda-mlink.h | 10 +++++++ sound/soc/sof/intel/hda-mlink.c | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/include/sound/hda-mlink.h b/include/sound/hda-mlink.h index 5bfa8ae940e4..4f44f0bd5388 100644 --- a/include/sound/hda-mlink.h +++ b/include/sound/hda-mlink.h @@ -44,6 +44,9 @@ int hdac_bus_eml_sdw_power_down_unlocked(struct hdac_bus *bus, int sublink); int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num); +int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y, + int channel_mask, int stream_id, int dir); + void hda_bus_ml_put_all(struct hdac_bus *bus); void hda_bus_ml_reset_losidv(struct hdac_bus *bus); int hda_bus_ml_resume(struct hdac_bus *bus); @@ -145,6 +148,13 @@ hdac_bus_eml_sdw_power_down_unlocked(struct hdac_bus *bus, int sublink) { return static inline int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num) { return 0; } +static inline int +hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y, + int channel_mask, int stream_id, int dir) +{ + return 0; +} + static inline void hda_bus_ml_put_all(struct hdac_bus *bus) { } static inline void hda_bus_ml_reset_losidv(struct hdac_bus *bus) { } static inline int hda_bus_ml_resume(struct hdac_bus *bus) { return 0; } diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c index 2d0c5d5914b1..b7cbf66badf5 100644 --- a/sound/soc/sof/intel/hda-mlink.c +++ b/sound/soc/sof/intel/hda-mlink.c @@ -73,6 +73,7 @@ struct hdac_ext2_link { #define AZX_REG_SDW_SHIM_OFFSET 0x0 #define AZX_REG_SDW_IP_OFFSET 0x100 #define AZX_REG_SDW_VS_SHIM_OFFSET 0x6000 +#define AZX_REG_SDW_SHIM_PCMSyCM(y) (0x16 + 0x4 * (y)) /* only one instance supported */ #define AZX_REG_INTEL_DMIC_SHIM_OFFSET 0x0 @@ -340,6 +341,21 @@ static void hdaml_link_set_lsdiid(u32 __iomem *lsdiid, int dev_num) writel(val, lsdiid); } +static void hdaml_shim_map_stream_ch(u16 __iomem *pcmsycm, int lchan, int hchan, + int stream_id, int dir) +{ + u16 val; + + val = readw(pcmsycm); + + u16p_replace_bits(&val, lchan, GENMASK(3, 0)); + u16p_replace_bits(&val, hchan, GENMASK(7, 4)); + u16p_replace_bits(&val, stream_id, GENMASK(13, 8)); + u16p_replace_bits(&val, dir, BIT(15)); + + writew(val, pcmsycm); +} + static void hdaml_lctl_offload_enable(u32 __iomem *lctl, bool enable) { u32 val = readl(lctl); @@ -756,6 +772,40 @@ int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num) return 0; } EXPORT_SYMBOL_NS(hdac_bus_eml_sdw_set_lsdiid, SND_SOC_SOF_HDA_MLINK); +/* + * the 'y' parameter comes from the PCMSyCM hardware register naming. 'y' refers to the + * PDI index, i.e. the FIFO used for RX or TX + */ +int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y, + int channel_mask, int stream_id, int dir) +{ + struct hdac_ext2_link *h2link; + u16 __iomem *pcmsycm; + u16 val; + + h2link = find_ext2_link(bus, true, AZX_REG_ML_LEPTR_ID_SDW); + if (!h2link) + return -ENODEV; + + pcmsycm = h2link->base_ptr + h2link->shim_offset + + h2link->instance_offset * sublink + + AZX_REG_SDW_SHIM_PCMSyCM(y); + + mutex_lock(&h2link->eml_lock); + + hdaml_shim_map_stream_ch(pcmsycm, 0, hweight32(channel_mask), + stream_id, dir); + + mutex_unlock(&h2link->eml_lock); + + val = readw(pcmsycm); + + dev_dbg(bus->dev, "channel_mask %#x stream_id %d dir %d pcmscm %#x\n", + channel_mask, stream_id, dir, val); + + return 0; +} EXPORT_SYMBOL_NS(hdac_bus_eml_sdw_map_stream_ch, SND_SOC_SOF_HDA_MLINK); + void hda_bus_ml_put_all(struct hdac_bus *bus) { struct hdac_ext_link *hlink;