From patchwork Fri Apr 5 09:09:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618732 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 79C21611E for ; Fri, 5 Apr 2024 09:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308089; cv=none; b=ZdZlMAaAL3oMWC2Vwr3Kizp7gSk6vyzNnM63/KCajQcmjuapWJGUIaU3Ltyue6wu9vuneTnysFsCDH/WTb+gVDouLncOj1W+O1lqG4uBd59xmztnZ8/7aSBs3CDOqpbQn8Z9cdVyT0cyvfVWtXqW6wIN/cetFZKCQPoTL3QnYe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308089; c=relaxed/simple; bh=dxCLzaInWEDf5H8sovQbT5x3OpdikXTGyLfkyz6cQ0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O6vpf1mPM19g7RLKaA5FAKAUqUvxdHIrJr3qJduocyQha+z8WymfOtH8P1kn5RnmB5Lg5doIQOaD3bm9YshmQHjnKobALPQD9v6KOmYaltZE8EAjIsZ+DSH2Xue8iH/+kEC/7dsKujp8hxpKhNkV8RSx2OQm6zl1YMpnLYhFAAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mv3U8p6q; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mv3U8p6q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308088; x=1743844088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dxCLzaInWEDf5H8sovQbT5x3OpdikXTGyLfkyz6cQ0s=; b=mv3U8p6qVuBLk5tyJIYKaIdgxYtaGwLziforeWXojqP2nU9aesLfQbgW GDJWUQVVupaM6/R0DcxBNQ7UsHHlOqqop15OWb9PB++ONxOVxvOny/oh5 nH4mBKwqOGGaQ5Y8TOHkQPhEbMqgcdiHsoaQkztgmRWl+XjQBv8NwGr0I z1HZV+tJSPbjBYOcxAwyVo5g9+0Z9c0nx0Z51XNoLWFIIL726FkdUHylZ 9f46yFrBnoJvqwDny4ir5NszScrvRn6VWZ+BFbsTKLX/hXkFAV25vlD0W LOGlPBkXf2R47jZzvr4RdCa0moFUfiYf9qzwBJ2TEjQ9I9o/F3RdwbtPE Q==; X-CSE-ConnectionGUID: Rs0oDMJnR5GPCKm4EgMtbA== X-CSE-MsgGUID: uKOHv+eaQSqq5Swxb+6STg== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787403" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787403" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:08 -0700 X-CSE-ConnectionGUID: 2UhNxsTeSLyumSvGXGHIVg== X-CSE-MsgGUID: RZThk3YiQX2P0wyvKq62Dw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042412" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:05 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 01/13] ASoC: Intel: avs: Restore stream decoupling on prepare Date: Fri, 5 Apr 2024 11:09:17 +0200 Message-Id: <20240405090929.1184068-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Amadeusz Sławiński Revert changes from commit b87b8f43afd5 ("ASoC: Intel: avs: Drop superfluous stream decoupling") to restore working streaming during S3. Fixes: b87b8f43afd5 ("ASoC: Intel: avs: Drop superfluous stream decoupling") Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 2cafbc392cdb..72f1bc3b7b1f 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -356,6 +356,7 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn stream_info->sig_bits); format_val = snd_hdac_stream_format(runtime->channels, bits, runtime->rate); + snd_hdac_ext_stream_decouple(bus, link_stream, true); snd_hdac_ext_stream_reset(link_stream); snd_hdac_ext_stream_setup(link_stream, format_val); @@ -611,6 +612,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so struct avs_dev *adev = to_avs_dev(dai->dev); struct hdac_ext_stream *host_stream; unsigned int format_val; + struct hdac_bus *bus; unsigned int bits; int ret; @@ -620,6 +622,8 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so if (hdac_stream(host_stream)->prepared) return 0; + bus = hdac_stream(host_stream)->bus; + snd_hdac_ext_stream_decouple(bus, data->host_stream, true); snd_hdac_stream_reset(hdac_stream(host_stream)); stream_info = snd_soc_dai_get_pcm_stream(dai, substream->stream); From patchwork Fri Apr 5 09:09:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618733 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 4873215F30D for ; Fri, 5 Apr 2024 09:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308090; cv=none; b=uiIa/cq1lsy5PCduFbAWxsSbfWdnEqQHHN0OIfoHBQzJShTvIpGL7WJ8no0U1zc1/lLz2cpiF1Ktm8FO0vO99QNcqltSxHj4Eu1IKxshu7ED7ACXfqHOM1VUBn6NW2ZwVM5JiKw83ZBD4phd8rfsrl4J5Eg/PI/jXBI1BgYwiIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308090; c=relaxed/simple; bh=ZgplaqLEKcHbdbGlQoIaQOYnXMm8Ux7CECBvT2X2vUw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KhqkgdHzEmdUabW59XbHka25YYEJKxyf974EPq5QfZKYRpHaO7QGcvyOF7K2tzPDSTqB7X3ApWR/EmZcioHGQZQ45KTe7Zi99znE7P5ceCt8Gl5R6ObqqtP3sjeMzPk9tqazBlRUzl0Z/8m9PQHCZV2bZLRcP9dAq14gR3eA8Rk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gpyNBjzW; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gpyNBjzW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308090; x=1743844090; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZgplaqLEKcHbdbGlQoIaQOYnXMm8Ux7CECBvT2X2vUw=; b=gpyNBjzWv2snsXPeEGtsUXVKhyQgHq99q62otK+fWtdqaH21QM0jJKh/ ayQrdqVvmkmpS4M8sM+kPHzkSdjzw+AnxILCgJ4sXpL6wokFn7nq5zcs2 Ma6PDe/7MvnkihcGhNdmCnBcWPl/Pn9W0aaIBNov0E7Cy29pwpQfBFs3T Twvviep8qvkZd04LsWYtf+F9LFA1dI8yuqonU/7DAcO9vvPO/5gC395n4 ZOQITSqHkB8cLkDHKUBOhqNza8Q2W/hFb7lo/TSwz3RySJpah+04RsXu9 BulsO8B3S2Ewf6EIzZrGShos/6x8JQ3feI+etiNDptazulnf2TU1ZWYfW g==; X-CSE-ConnectionGUID: XZzBu8mjRRKJklgwT0bb9w== X-CSE-MsgGUID: 8OQOZ+MgT9aQSNGH2EDlZQ== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787413" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787413" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:10 -0700 X-CSE-ConnectionGUID: 7wtEnBnqSO+hGljq1HrA+g== X-CSE-MsgGUID: nZVPK7doQn+TTQ1mUsHP8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042415" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:08 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 02/13] ASoC: Intel: avs: Fix debug-slot offset calculation Date: Fri, 5 Apr 2024 11:09:18 +0200 Message-Id: <20240405090929.1184068-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For resources with ID other than 0 the current calculus is incorrect. Fixes: 275b583d047a ("ASoC: Intel: avs: ICL-based platforms support") Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/icl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/avs/icl.c b/sound/soc/intel/avs/icl.c index 9d9921e1cd4d..3e0716160f5a 100644 --- a/sound/soc/intel/avs/icl.c +++ b/sound/soc/intel/avs/icl.c @@ -66,7 +66,7 @@ struct avs_icl_memwnd2 { struct avs_icl_memwnd2_desc slot_desc[AVS_ICL_MEMWND2_SLOTS_COUNT]; u8 rsvd[PAGE_SIZE]; }; - u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][PAGE_SIZE]; + u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][SZ_4K]; } __packed; #define AVS_ICL_SLOT_UNUSED \ @@ -89,8 +89,7 @@ static int avs_icl_slot_offset(struct avs_dev *adev, union avs_icl_memwnd2_slot_ for (i = 0; i < AVS_ICL_MEMWND2_SLOTS_COUNT; i++) if (desc[i].slot_id.val == slot_type.val) - return offsetof(struct avs_icl_memwnd2, slot_array) + - avs_skl_log_buffer_offset(adev, i); + return offsetof(struct avs_icl_memwnd2, slot_array) + i * SZ_4K; return -ENXIO; } From patchwork Fri Apr 5 09:09:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618734 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 6679D15F30D for ; Fri, 5 Apr 2024 09:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308092; cv=none; b=TZyQ8o/A8zsG/9DQVa38IZUH9/vy3/UUM7FMPnz6OTJJoFRg3Y2nNXtsfdAOMnjgLJ5iv8s5yW6l6JDcbW4TWWWhWlRawnsTP8Lg4pjRtmubfxqRMbUG4gWl82heo6nLTCYXmOF+mLBrm1qXQlQGZAS7PgJyK8fYNopzYAPXR3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308092; c=relaxed/simple; bh=ANzCgsUumNqSlnkBuuI/derpqfxzEvU8fc97dO+tuUg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PaiP83ab4ZZVP9hvNHEEOz4QPD2Si7oheQAkg3sVgP3kwYV8sruOUaSxYGIAkK/Ak6qGUR68WgMqJiVE/S6ZM7ZvqGEGScgTa80tAVLZTuwiWwEYnijFdqO2b9169Jk+Z/23jTsyHJCbeu6phBCoElEy+toVBgx4lUJxjC4ycUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EDjslzU+; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EDjslzU+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308092; x=1743844092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ANzCgsUumNqSlnkBuuI/derpqfxzEvU8fc97dO+tuUg=; b=EDjslzU+byozNthrOkoroeHdbOiSx1222kHMqdg7gZUTd9iGwzGOOymq Bju2bkBffpP14vbu5/D1UFEA7rDCChvs8fKZ0WLuEhEqwYW4ZsTG4DJKx s+z1s8PNNkUXKzwy55DHPZMYgIsN54asj03dt2p43d9XQCcw/ZXq1NFxA tJ5tmpES0h+yXy+OTy/h50KbZiK4RxJshxOnceJ4q955ySf5xN+nY0lJu JEwr+3IwtTkn71ERPIiyp8gWPyLbpg3Nvv0bp2k/K4jhtkjvWNr7VYM5e oujh42TNknMxKAhwQ6qaJJ9AK4ok2rXPyzL1k2ZQtZzxBUShoORMLtOca Q==; X-CSE-ConnectionGUID: kTFZxo6oSP2+Zs5Yxm04sg== X-CSE-MsgGUID: fmQ5Y+yiTDelYCRl0Th1Mw== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787419" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787419" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:12 -0700 X-CSE-ConnectionGUID: hKJQVxYSTlCYR2ZSlDf7gg== X-CSE-MsgGUID: 9bXG8zgCTZyHsmKCPdogHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042420" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:10 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 03/13] ASoC: Intel: avs: Silence false-positive memcpy() warnings Date: Fri, 5 Apr 2024 11:09:19 +0200 Message-Id: <20240405090929.1184068-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") enforced strict flex array declarations. This generates false-positive in form of: "memcpy: detected field-spanning write". Avoid it by utilizing the DECLARE_FLEX_ARRAY() macro. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/messages.h | 4 ++-- sound/soc/intel/avs/path.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/avs/messages.h b/sound/soc/intel/avs/messages.h index 4e609a08863c..007bc4fb6d99 100644 --- a/sound/soc/intel/avs/messages.h +++ b/sound/soc/intel/avs/messages.h @@ -752,9 +752,9 @@ struct avs_copier_gtw_cfg { union avs_connector_node_id node_id; u32 dma_buffer_size; u32 config_length; - struct { + union { union avs_gtw_attributes attrs; - u32 blob[]; + DECLARE_FLEX_ARRAY(u32, blob); } config; } __packed; diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index e785fc2a7008..5944865a1193 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -254,7 +254,7 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) /* config_length in DWORDs */ cfg->gtw_cfg.config_length = DIV_ROUND_UP(data_size, 4); if (data) - memcpy(&cfg->gtw_cfg.config, data, data_size); + memcpy(&cfg->gtw_cfg.config.blob, data, data_size); mod->gtw_attrs = cfg->gtw_cfg.config.attrs; From patchwork Fri Apr 5 09:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618735 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 744171465B4 for ; Fri, 5 Apr 2024 09:08:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308095; cv=none; b=S5QhlaGzYD28cACiBbCYBppc0Vo/n/tIDmP+vSqRaNMlV47iGu4+Am1Eyc0SbrRt/NMKgoLA6MyGEpSW5PVmmNvba6PeWct1PmA4OqQ2UypU1AN/03ocpQTu4xNWVOtwF/sS9y8Xbxe6COOVgqOJK0cXCnLPVPpJgjX0hcx6XqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308095; c=relaxed/simple; bh=4U5eUPSVHVLioRHAIf9Fo+vGvEmxAF6r2cSIUvxQg8w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tdU3EKewprUguOQroSAzPk2QH3U/GEr5vVlgkozGUt84dZhuOErGPIikKYC0weYixqGS1ih+x+Dxn0S2tt6jixc+9IqisNmn8eiQrxQ/J5B2TDl296jC197cungen1pq5HkRbwBUk+S/kUO+EVdgRU1swC4m5wy8JlAuEmDPTOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=C2e7BQa7; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="C2e7BQa7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308094; x=1743844094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4U5eUPSVHVLioRHAIf9Fo+vGvEmxAF6r2cSIUvxQg8w=; b=C2e7BQa7dcbvv/f3U2gXYXF5hVOqzRjm6be8obcK6S0udwQq6zlcOteC Aw5tS7T3eEwhVHLtnuihgT2KRgplpNDBOljoKBa/u9e7FiyiLjnywqNhU rBkA9Fn2P+vmcV17QTWPBdqndAiF+A23d9gjjuAsdewi2M4X+zFIr3G43 SICkDK9mEr47jjhSYrzVDSeQaz9Ft6SqIbklgqL80zAQILqpjvxmNB6XU 9RsRxRLGhI4KYrxugd9Cpspf+um1wQSOTlhOcedEXyzxxDl0PWKJKh5yo HLLPsPoXunTSVrnS/0sGAxizUXDlAk/VDc5R1FNcFrDQYhzuIPzEOiiyO A==; X-CSE-ConnectionGUID: azHe7kXEQAquKGuOB9eRsw== X-CSE-MsgGUID: DZWtMqYCTQyGJ7eZtgXV1g== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787426" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787426" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:14 -0700 X-CSE-ConnectionGUID: kkSYAi88Tcm5aM5jnaFeSw== X-CSE-MsgGUID: 8CaWEeVRR+C5q++h6+JdbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042424" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:12 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 04/13] ASoC: Intel: avs: Fix config_length for config-less copiers Date: Fri, 5 Apr 2024 11:09:20 +0200 Message-Id: <20240405090929.1184068-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Copier's config_length shall always be at least one even if there is no configuration payload to carry. While the firmware treats config_length=0 or 1 in the same manner, the driver shall initialize the module properly. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/path.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 5944865a1193..9bd03a44fcb9 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -148,11 +148,12 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) struct avs_copier_cfg *cfg; struct nhlt_specific_cfg *ep_blob; union avs_connector_node_id node_id = {0}; - size_t cfg_size, data_size = 0; + size_t cfg_size, data_size; void *data = NULL; u32 dma_type; int ret; + data_size = sizeof(cfg->gtw_cfg.config); dma_type = t->cfg_ext->copier.dma_type; node_id.dma_type = dma_type; @@ -233,10 +234,7 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod) break; } - cfg_size = sizeof(*cfg) + data_size; - /* Every config-BLOB contains gateway attributes. */ - if (data_size) - cfg_size -= sizeof(cfg->gtw_cfg.config.attrs); + cfg_size = offsetof(struct avs_copier_cfg, gtw_cfg.config) + data_size; if (cfg_size > AVS_MAILBOX_SIZE) return -EINVAL; From patchwork Fri Apr 5 09:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618736 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 858971465B4 for ; Fri, 5 Apr 2024 09:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308096; cv=none; b=HCSilr+Bd0FW5Ghw0RXt61WhKdxuUziJbfLvX9AYAu2Zv/9k7TUisX5nTumDVw4SLG0Nc1nAuN3RKUC63eZvA8zysgGZFlVDiUToaQX3Wtvw/+kDgG6AKlxdSzYW+F47AdV5v5E+2h5LMelwg3HdFDEFkFzgDWTyNEFZ5EQcXtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308096; c=relaxed/simple; bh=8IPnmYlyD9UIlHOOUBWMwrj2iTulN0YzLI+v4m5ePr8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uw1GayFxQ5ouzNSVNHVZcgZVCCs5gN1y56FLpOLIXYo9eTG/IHttDXVdTjMu++7WQNcYKqSWaiFyohpBmzIz6bJwDP13+SOQTpXRrbf0k4UZVvCk9mFaAXIrbcjVX9gVvH/GVuVs4m+dt7s3y9smDf+qri+loHArW4owQ43fy/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nrTfMGbi; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nrTfMGbi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308096; x=1743844096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8IPnmYlyD9UIlHOOUBWMwrj2iTulN0YzLI+v4m5ePr8=; b=nrTfMGbimP/Rh6fVQGZSDlEjoR0H4YuZAyp2kTBokwnmH7k5dnSK27sZ e0Uo7mRHWk9WWppC5y9P0R7uIrXBaLGt4UF/3vZmCBibOwNpiVTofoLCd QSCEUXl0urqsKDvimuRUww3UuZj30vPNJsl6m/y0H7EVFoGDknqmmfjPP ETmlfAGbz+ZPQY5qdueAo/SrzZi1QQFUvjAqT7B1R8uIk5/u+cpWyV19c t054ra/4z71w1bEu02rYiBt0l16DsFx0voTU1jdw/MonkVYQ3H8R86U1j q0oNF5R9FWiuchF6x0tZ0KBadgBvVUdSg1JIdocc2ZlL6tvuMwLD+KhO6 Q==; X-CSE-ConnectionGUID: 7lSGmjjnSpyRIaJ/Um7dXA== X-CSE-MsgGUID: xh0tSW6VRJ6OoT9U+z40pQ== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787433" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787433" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:16 -0700 X-CSE-ConnectionGUID: I/Z/6ZVZRxi/zlU0Dn1bIg== X-CSE-MsgGUID: 2SClKS10TI+qMFEtok2pOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042427" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:14 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 05/13] ASoC: Intel: avs: Fix ASRC module initialization Date: Fri, 5 Apr 2024 11:09:21 +0200 Message-Id: <20240405090929.1184068-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The ASRC module configuration consists of several reserved fields. Zero them out when initializing the module to avoid sending invalid data. Fixes: 274d79e51875 ("ASoC: Intel: avs: Configure modules according to their type") Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/path.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 9bd03a44fcb9..8dfd90587427 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -365,6 +365,7 @@ static int avs_asrc_create(struct avs_dev *adev, struct avs_path_module *mod) struct avs_tplg_module *t = mod->template; struct avs_asrc_cfg cfg; + memset(&cfg, 0, sizeof(cfg)); cfg.base.cpc = t->cfg_base->cpc; cfg.base.ibs = t->cfg_base->ibs; cfg.base.obs = t->cfg_base->obs; From patchwork Fri Apr 5 09:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618737 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 9F5E11465B4 for ; Fri, 5 Apr 2024 09:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308099; cv=none; b=t3vyHPdwF447SwOTe5DDG4+KB9p+3sMlhlDsh1xzCQbz+jYC8eqd8ktqqBWLYBK+Rn9pJgD2UZL2ZVJzVxwjGuIC3higdvnHU/rwhYaY3yrdEPeBT0cDvZmFS6k/AAVGF8W2WFz/mn2v89wmkwyHO+izb1x/KiCIbWEEaJcyl98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308099; c=relaxed/simple; bh=7o8XbCGvId3xPxY/IVwzWfcwOdaHK6AoLQbT+r4Ziy0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oIa5ArNT12bwIiavkyjvhQ2WpnWv4375buPwEETBGuPvjRKvWZHBPN3kgzWYWJ2V+1S2divjED8H5h9ysT4LJksH6Yux+4I1iROQ6q4e939vOu1UUWuz/fLFA+BONsY8imq5FYSyh/D5Oy/pP3vWdK7tgKQt5Vn/h6OP2jw7o9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SvT+TcVK; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SvT+TcVK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308098; x=1743844098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7o8XbCGvId3xPxY/IVwzWfcwOdaHK6AoLQbT+r4Ziy0=; b=SvT+TcVKMOW90Pgbk5G5YAxOHJva+bj6Di2sXsxnFmiYdkrd/jrbsQl4 03Iw83K3gEUwqaPcpx/ljNJhZFfXWfgvmA1Ri29BHrjSU1oDVkZ4jhVD9 POGLpwHXvQn0BpQXjZGAJein/SUgYnYeSBpWxdREyItBBrBnKldp+/4Ob bRSnImEmGA3jJk9Mbrd/NEZtj0c3FzwNLoTHRQcU3vj+4ouPmmaU/xT3j fPukVYw85TNa5So+1ae46BXTwxWTHNbArS1SkBEs2acFliFJsmqsrmlA1 EpqpUDg2tdAlLUjTro740IqhSOkFJF9WORzdXnPvxjal5JR5Ij5WfcQ9u A==; X-CSE-ConnectionGUID: 3e3SS7pSR3OL2o6CeUXG7A== X-CSE-MsgGUID: aBLXQfWSSFqCNN7EKaNegw== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787441" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787441" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:18 -0700 X-CSE-ConnectionGUID: ae6VOqs8TWSObeFA2A55zA== X-CSE-MsgGUID: GkZWwU/wTmC+y2HQTvtLXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042430" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:16 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 06/13] ASoC: Intel: avs: Replace risky functions with safer variants Date: Fri, 5 Apr 2024 11:09:22 +0200 Message-Id: <20240405090929.1184068-7-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 strscpy() and snprintf() are the recommended equivalents of their riskier friends. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/loader.c | 4 ++-- sound/soc/intel/avs/pcm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/avs/loader.c b/sound/soc/intel/avs/loader.c index 8e34d3536082..57370f0905dc 100644 --- a/sound/soc/intel/avs/loader.c +++ b/sound/soc/intel/avs/loader.c @@ -535,7 +535,7 @@ int avs_dsp_load_libraries(struct avs_dev *adev, struct avs_tplg_library *libs, if (ret) return ret; - strncpy(adev->lib_names[id], man->name, AVS_LIB_NAME_SIZE); + strscpy(adev->lib_names[id], man->name, AVS_LIB_NAME_SIZE); id++; next_lib: i++; @@ -698,7 +698,7 @@ int avs_dsp_first_boot_firmware(struct avs_dev *adev) } /* basefw always occupies slot 0 */ - strcpy(&adev->lib_names[0][0], "BASEFW"); + strscpy(adev->lib_names[0], "BASEFW", AVS_LIB_NAME_SIZE); ida_init(&adev->ppl_ida); diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 72f1bc3b7b1f..405de1d58178 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1420,7 +1420,7 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen mach = dev_get_platdata(component->card->dev); codec = mach->pdata; - sprintf(name, "%s-cpu", dev_name(&codec->core.dev)); + snprintf(name, sizeof(name), "%s-cpu", dev_name(&codec->core.dev)); for_each_component_dais_safe(component, dai, save) { int stream; From patchwork Fri Apr 5 09:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618738 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 B2D511465B4 for ; Fri, 5 Apr 2024 09:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308101; cv=none; b=ehgoVTddLzVTuEtY/l2JKxpkFBBYAlJNwmLlOZQ4q/RWOqbT3Qu4Gj3HNITMsTh7o2bZUUf5DJbm8dfo4f65QUurf/rBWhnym02LcLyXMAPh65cK9pne1Ok8fSy6HYO4ISJq3F/7w4Lu/1D+sZhZxGT1Fex8ZnTI5Hvmfd6EAUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308101; c=relaxed/simple; bh=57TGCSCkjrsonGnK9tulnMl2oRX3ewM3Ljw5o763Gfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XgpmuJOGdC1kUc/Y//FR05qEmNZvR8Dv1hqUNhE8M+JD4+c2w6QbROR5C7orf/KD0Yti4jh90F31r//YfVhTt9fw7Yk3ypcM13Bd9tjApbE7jAc+paHpiTH0IalHWZUREgxWm7rbk57ePs2SDYQXg9FEPRaf+6w+6uV2J7hM3NQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HFLwr6X7; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HFLwr6X7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308100; x=1743844100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=57TGCSCkjrsonGnK9tulnMl2oRX3ewM3Ljw5o763Gfs=; b=HFLwr6X7c0rw2lWuiUuP2AVd6uYubVkqRETAD0WoU/tlR6PTk0+tHFBh RI6dOWDN1HOFIWH4rStvpVpF9yoOaeO3zeyqN6Cj1gfkJyxmgUA3SfYCI ujx3ZbpOJBk7p/IUSJ4onkjk/XkS26UBqSY66f7Hdy3W9RNrdL1WQhqpw QuNobfz4s1sJd23kG5qDhnRmkh9EJcizOXypCeGY2qVFZ6lTJl1xpFoDU BqLDTk59z5T6v13LPT224heMYH63eSgaMcB/Y6GHaMvyMg51PchUHt+OG PY61phQBFBjYgJAMRNgdDKw6zfWQX82U3jagU00J1TNAiGSyVSzVPnHav w==; X-CSE-ConnectionGUID: B31WyWUYTVuBS6ftsc6pmA== X-CSE-MsgGUID: s0j0eOd/T2iSuKchCfIV6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787449" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787449" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:20 -0700 X-CSE-ConnectionGUID: QmZPM82BR9WvruM1H3RJDg== X-CSE-MsgGUID: uQ0JU06KTxySXF9any7D8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042433" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:18 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 07/13] ASoC: Intel: avs: Fix potential integer overflow Date: Fri, 5 Apr 2024 11:09:23 +0200 Message-Id: <20240405090929.1184068-8-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While stream_tag for CLDMA on SKL-based platforms is always 1, function hda_cldma_setup() uses AZX_SD_CTL_STRM() macro which does: stream_tag << 20 what combined with stream_tag type of 'unsigned int' generates a potential overflow issue. Update the field type to fix that. Fixes: 45864e49a05a ("ASoC: Intel: avs: Implement CLDMA transfer") Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/cldma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/avs/cldma.c b/sound/soc/intel/avs/cldma.c index d7a9390b5e48..585579840b64 100644 --- a/sound/soc/intel/avs/cldma.c +++ b/sound/soc/intel/avs/cldma.c @@ -35,7 +35,7 @@ struct hda_cldma { unsigned int buffer_size; unsigned int num_periods; - unsigned int stream_tag; + unsigned char stream_tag; void __iomem *sd_addr; struct snd_dma_buffer dmab_data; From patchwork Fri Apr 5 09:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618739 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 C31301465B4 for ; Fri, 5 Apr 2024 09:08:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308103; cv=none; b=i6+Uu5jmFSFNxeSYlzsd8qnzbUCwJGAYGfzroZpffyhwYxGyGhwFZG0ZOnh+HqoVezRxsD/FsUEJs4dPdNePtlxHixHXeZlwbqpEBXd53S71qyl0ufFad3aa9Ct64P0qWDUcqrEMIYHBsHoeD83zIvc6Hkpnuvqn7xs7I+jHSDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308103; c=relaxed/simple; bh=lBShL+hehblXjeItUaZJSU0+d9b1UISWY/cyd8pfpqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SLp+YF/79dV4LUTDNjvVdqPYUoFB62N5j8Dk+sd5zcMsaUpcJUYkb8tWezCCh9BpTZhl6MdYyqiFtyx1MKeyMhXopYJO6VmWapHIjxzi5WNgnmZNlLghdNEnXGI3yVsPYeG8QyHNskZk6dT8FGf2Kfa0/kkkHSJBscrvUWxoVdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CmAnPL6n; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CmAnPL6n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308102; x=1743844102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lBShL+hehblXjeItUaZJSU0+d9b1UISWY/cyd8pfpqg=; b=CmAnPL6n3ONh0wg5XE4WAK7sqlUuYYHKLvpOOPGuguLTSzQUZwyDswua snp7t7BvOlePbsh4od1mpt+Rtl3b6KjKFCF6v1alH600JmViIsCA4F87R NYVHQRLqvkJPKM38HmndfgjybBteL3XTvghMhSeEYKxDpLI+BiqKg5mSj uwWfZC5C/M+uY/BZ4SsqfIirNlye1TNjZ8DBsGzymUw2B+vkjP2oSKtlf k8XOZrlYSWulkqMs4vZrqLqHyYQAwS/AgOl3b/wEx2iq7+pXt6Ke/rDHR K9KQ2vbujHPzfEYPNBKyxWmEu+4FsxFEardaB54OwTthoUXhoI3SYQuh0 g==; X-CSE-ConnectionGUID: y6dbbpIuSRCmTxAarH3TQg== X-CSE-MsgGUID: bUdWTAWDR62YoD46lGJO3g== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787458" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787458" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:22 -0700 X-CSE-ConnectionGUID: cGhFZmbzQvu/P6HmVY4FtQ== X-CSE-MsgGUID: wFPh7wH6Q/CZtRYYpiEwyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042437" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:20 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 08/13] ASoC: Intel: avs: Test result of avs_get_module_entry() Date: Fri, 5 Apr 2024 11:09:24 +0200 Message-Id: <20240405090929.1184068-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While PROBE_MOD_UUID is always part of the base AudioDSP firmware manifest, from maintenance point of view it is better to check the result. Fixes: dab8d000e25c ("ASoC: Intel: avs: Add data probing requests") Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/probes.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/avs/probes.c b/sound/soc/intel/avs/probes.c index 817e543036f2..7e781a315690 100644 --- a/sound/soc/intel/avs/probes.c +++ b/sound/soc/intel/avs/probes.c @@ -19,8 +19,11 @@ static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_id struct avs_probe_cfg cfg = {{0}}; struct avs_module_entry mentry; u8 dummy; + int ret; - avs_get_module_entry(adev, &AVS_PROBE_MOD_UUID, &mentry); + ret = avs_get_module_entry(adev, &AVS_PROBE_MOD_UUID, &mentry); + if (ret) + return ret; /* * Probe module uses no cycles, audio data format and input and output @@ -39,11 +42,12 @@ static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_id static void avs_dsp_delete_probe(struct avs_dev *adev) { struct avs_module_entry mentry; + int ret; - avs_get_module_entry(adev, &AVS_PROBE_MOD_UUID, &mentry); - - /* There is only ever one probe module instance. */ - avs_dsp_delete_module(adev, mentry.module_id, 0, INVALID_PIPELINE_ID, 0); + ret = avs_get_module_entry(adev, &AVS_PROBE_MOD_UUID, &mentry); + if (!ret) + /* There is only ever one probe module instance. */ + avs_dsp_delete_module(adev, mentry.module_id, 0, INVALID_PIPELINE_ID, 0); } static inline struct hdac_ext_stream *avs_compr_get_host_stream(struct snd_compr_stream *cstream) From patchwork Fri Apr 5 09:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618740 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 D8BD61465B4 for ; Fri, 5 Apr 2024 09:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308105; cv=none; b=SfDOUzDfl0s8q33WETxXEIG3klN9Bi2vBr2io7tX/b4RQrLQYs//EONyMd1rr/XNabPJ+AhNPiP3Nz34q6l93+JfTZUFINK0XG4eTl3za/h+xczEG/jvzbmUOJk3MZ/VkSwBCWOO2UAgxi6oPkGpJiGXrOtleOcBYGTyKtSb11s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308105; c=relaxed/simple; bh=/l8JmGiEYsduQSPVUJfW308+QOvtWeS4SnQ3Hl92vdM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HHwThSarOLMC8ywFuUr3ZvLgyP0Ynml8jUl0sz3WTwYTBpGQIlNQr9vqdWlo0oylUO4t5z5bEtQQN/3QAl0gbJIYrPPcPFWMnpiasuStQ0cZHhDmeHG9Yv2pVracJzgr2Vo2JBctH9cueD4jHRS1AclUrwb6xUr/J4RdX9HXlxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XtFDBxBw; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XtFDBxBw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308104; x=1743844104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/l8JmGiEYsduQSPVUJfW308+QOvtWeS4SnQ3Hl92vdM=; b=XtFDBxBwa4ZCdIuyJIC3gxICoTRbZFKFvNH7hAAMAP3G+xyy879vDw1s XvptNw6YjZHlEtZpIjnCRta+8N7/j7C67LVn4OULhCJ/kjwbT5y/8R+A+ cwMD4X85DYJTk1nAMUdCvWvLSNX5e9nZehuFVunwp5LQz0FIXrbUlGefL hnJhk9NMQ7K0i5d7n9qG2NCI1GyGx9PEIJJUt/PPYKDnKfW/T4PSXoWap oePijTCvPltwZ9xvpj4M4dItkYqii+GWvGeqGMazoJaOypssqhPabeKJB oonNUR1ExYBT9xvmIZO5q2eYCzuAg/vbT6fW16vPN6jjfGaDCENGsC2TQ Q==; X-CSE-ConnectionGUID: GqBetrxiTKuifzZ7bYk/XA== X-CSE-MsgGUID: d1xBFx8RTsa1eEp1IYotdg== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787466" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787466" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:24 -0700 X-CSE-ConnectionGUID: nmem/xb6S6qGGj8tgyE1aQ== X-CSE-MsgGUID: pV4bRyYsTg2Q8ULE1MHDGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042443" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:22 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 09/13] ASoC: Intel: avs: Remove dead code Date: Fri, 5 Apr 2024 11:09:25 +0200 Message-Id: <20240405090929.1184068-10-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The result of list_next_entry()/list_last_entry() is never null. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/path.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 8dfd90587427..fa3fec339548 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -709,8 +709,6 @@ static int avs_path_pipeline_arm(struct avs_dev *adev, /* bind current module to next module on list */ source = mod; sink = list_next_entry(mod, node); - if (!source || !sink) - return -EINVAL; ret = avs_ipc_bind(adev, source->module_id, source->instance_id, sink->module_id, sink->instance_id, 0, 0); From patchwork Fri Apr 5 09:09:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618741 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 EE6C31465B4 for ; Fri, 5 Apr 2024 09:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308107; cv=none; b=d9x/huWcyDSsUE91CcjZQh0Ltlnr8kYX0JHLIUOt8R7fy31PXMJp8FOKo8Ym2OsBg9Hz1/EY+5rxIJxigs62TBjom2ap6oYUXKZBP54a/7WCaO6taM5LRmnj9bW6OiyuxX0v0PIgdD+Hh8hTHogNqCc1mj/jfMBFJ+3oATDjRdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308107; c=relaxed/simple; bh=A+RaWNl0uAuzryi863scci2ttj6MV/67NVWw5IM4vVw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eWx3rpxD/fSbXyzJhQhXtGzrQCVBLvU9xScm6RJ3xFKhGwHxUY9xMo0kYw783EC9AHez0bmMDejfH8AVPp8Y2idC3505QVhPw54JtlukYI0pLe3L/7yX31f7uiYS7WYFiznErUelUo47BaN7flLMIu2yNLPtIdkXb02oCNjeHVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KK/RgxVk; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KK/RgxVk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308106; x=1743844106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A+RaWNl0uAuzryi863scci2ttj6MV/67NVWw5IM4vVw=; b=KK/RgxVkht4SdTn9FymH7QQws2vfUa1jqBm22WAfZaRiGGFfYehGxxyA 5CTTI7aaiX2WzkzdT3wHOhO96/Tkp1GzhMxKCzGrVDKllGO22v767cVPQ mgINFUCrmmTYatDZorEJQJg8xx0V3Wshl8boi6v/6HpEkEWq/lqrxe+wg lSEC8dru6ILyFEMT4cYDqnN4znKRaXA2Gh1UxRuY42sl2Zsp/BRn+uhlM YJ3kdnW/5Z0kUJi/9/YfH4X2dLGaMUVRQ6NH8zqVDRh8S9158CHNJvDew 2fzAyjLB91sP7/AA2x1sBO6E2InaKrzCeWJxpjUyVeRrX9LrkhOnVF2yg g==; X-CSE-ConnectionGUID: qFhlgYJISJyIivWAxyvKNw== X-CSE-MsgGUID: SN03lC57QaiWQcp6VqQBXw== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787473" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787473" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:26 -0700 X-CSE-ConnectionGUID: zvIWjhjbTNSy0k0A6X8rQA== X-CSE-MsgGUID: wqVJDZEbTjmmSOhCNILeLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042447" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:24 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 10/13] ASoC: Intel: avs: Wake from D0ix when starting streaming Date: Fri, 5 Apr 2024 11:09:26 +0200 Message-Id: <20240405090929.1184068-11-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It is recommended to keep the DSP domain in full-power when starting DMA engines. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/icl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/intel/avs/icl.c b/sound/soc/intel/avs/icl.c index 3e0716160f5a..d279ec1e0ad0 100644 --- a/sound/soc/intel/avs/icl.c +++ b/sound/soc/intel/avs/icl.c @@ -109,6 +109,10 @@ int avs_icl_log_buffer_offset(struct avs_dev *adev, u32 core) bool avs_icl_d0ix_toggle(struct avs_dev *adev, struct avs_ipc_msg *tx, bool wake) { + /* Full-power when starting DMA engines. */ + if (tx->glb.set_ppl_state.state == AVS_PPL_STATE_RUNNING) + return true; + /* Payload-less IPCs do not take part in d0ix toggling. */ return tx->size; } From patchwork Fri Apr 5 09:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618742 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 3412D1465B4 for ; Fri, 5 Apr 2024 09:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308109; cv=none; b=PYlqBv/1nET7XEipmiwgRRu2ViQSR2IJgHif3SwB6qHaghi2piL1HhTbpzkAolhCKhBQYwilL/I2xLmd2GsWc7H6qAk0MkYfiaZ47bRaQ9RC38U5bvo8FO+YjyEvO9JAcx3hxnzPbWGQLZd3QUhiD0AaKQULmhQ/hHUXEycGN2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308109; c=relaxed/simple; bh=BFKhp2p2cRaZeTDBNXe7r5uMuOf4g9Fj5CtNhBTFbc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CMVUrUkEWLbxCfpxWhWXrmG1Wq/hNMPsE7csAvX9qVv/r5gqsQGPjeJ7iSybGNBZaRUiialPc05A5r6+GX9L9W4gB85cZNN6sdJCnmvfXk+xVXb/+RdWi8seZZMDMEj+RUE2W3clinxshRCI5ynZIi25NS2/Cz1g6Ii7LT4rUYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=O7KfdJPB; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="O7KfdJPB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308109; x=1743844109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BFKhp2p2cRaZeTDBNXe7r5uMuOf4g9Fj5CtNhBTFbc8=; b=O7KfdJPBR6yxGOcfsa418vQEhkDDd4yQyEMp71aTjhHkpZeooPY69/6s XiAHJK2Nu1761DiopoM6BgF9a4zn28TStHEBz83lR10DR2mV1c5loKqIZ U/2I22V1dPvT1xWrOO0YYna+/qm6fXabJgzkSMU/RkRKwHmIVjnEVrI4Y YH0z861jkU4z5Y7VgTBfnCmBSsvSiL8iwRAJQOCZhROBcoWo14CVozmGM Eox+ZDsQuwVa2A31BZajcZzQp+IobwbVM7tb9nYFQ2NnsrBhdJ1l8Icwt lX5JWshi+lrJpVKmxz+koJ+0mRGG9VUH5RPIh9zIiQfwL/8vvrN47y+dK A==; X-CSE-ConnectionGUID: aAog7NNgSD6h1qKJrk+eBg== X-CSE-MsgGUID: e+L1+LufTpO5DC14ZKwYig== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787483" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787483" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:29 -0700 X-CSE-ConnectionGUID: c8jiGaVGR6eC+hJmH3y1xA== X-CSE-MsgGUID: 4olMcQRLTv2YzPbZfkb8cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042451" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:26 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 11/13] ASoC: Intel: avs: Init debugfs before booting firmware Date: Fri, 5 Apr 2024 11:09:27 +0200 Message-Id: <20240405090929.1184068-12-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When bringing up setups it's vital to have access to debug functionality even if firmware boot fails. As order of probe()ing operations is changed, update remove() procedure accordingly. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c index d7f8940099ce..76782a0f32bc 100644 --- a/sound/soc/intel/avs/core.c +++ b/sound/soc/intel/avs/core.c @@ -209,6 +209,7 @@ static void avs_hda_probe_work(struct work_struct *work) snd_hdac_ext_bus_ppcap_enable(bus, true); snd_hdac_ext_bus_ppcap_int_enable(bus, true); + avs_debugfs_init(adev); ret = avs_dsp_first_boot_firmware(adev); if (ret < 0) @@ -217,7 +218,6 @@ static void avs_hda_probe_work(struct work_struct *work) adev->nhlt = intel_nhlt_init(adev->dev); if (!adev->nhlt) dev_info(bus->dev, "platform has no NHLT\n"); - avs_debugfs_init(adev); avs_register_all_boards(adev); @@ -548,9 +548,9 @@ static void avs_pci_remove(struct pci_dev *pci) avs_unregister_all_boards(adev); - avs_debugfs_exit(adev); if (adev->nhlt) intel_nhlt_free(adev->nhlt); + avs_debugfs_exit(adev); if (avs_platattr_test(adev, CLDMA)) hda_cldma_free(&code_loader); From patchwork Fri Apr 5 09:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618743 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 E9CAA15FA95 for ; Fri, 5 Apr 2024 09:08:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308112; cv=none; b=HxgqvjA6btyJa4rRqy+WvdSd0YLJQ8hrr2NyGpgqsdZVCtkIg6N7qhPbKO6B3+WD2EMLWA3BQWIg/W1ALkw4fH3zf7JfLclnsXfir6tV9nWVIrpGuvgoSpiymx4xzYFXmAxTBErsrsBq7VNnddnqZruWJNjkrPIknCb1OYG18EQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308112; c=relaxed/simple; bh=Xz+EuLu3mCummqDYZn0YkU1RdW1rHBp9cTQ43JeIyqA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=asdaPdzhk4u9uBG+eW3XVx3quM4C7mM3hzc6YAzae7wyHsilVo947XmXMt3BRCCCdg68D7kPftn2A6PRodmUS4UXEFm2T2vSlBxIUOGL7u4V+ewgYt0PWK9yn6RvFmTzWTBLctKfgElp43C//8nC6b8a4wXFBuZWKEjeHAeYkCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dQxDHhCH; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dQxDHhCH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308111; x=1743844111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xz+EuLu3mCummqDYZn0YkU1RdW1rHBp9cTQ43JeIyqA=; b=dQxDHhCHQdX0g+wI1y7XanOVOIV+gw2jlHxxvsQjHfGPu6QqPyMRQmi0 bajcO+XdVjrcOZgGUWXVAARj/4oVlziNPGQKv+DQza3w7cP0ZAvmUEBtQ Wr3IQUgS5hh5znIJTd7/dHLx98lsp7tX4kvJED21yt2cM4bAIX9Cl9mqr qnk7Aw4iv5IkxEUNF670kMrIMphUa1QOUJIuIsUjRbqDQE2MHXKn6WqI6 abTH4gxV3KHAdfCId4bOAttX1W2HxoGCn900KL7QtpNM57a9IzRmkVX41 hX4T4wybfBF+yZz85pVK/Hgj5icpCDUFDkUuVDl/HgxkHlE75edRno6Xj g==; X-CSE-ConnectionGUID: sUruKs8TTcWUSPbGo4aJhQ== X-CSE-MsgGUID: p2EhlWnPR0mbz7LIsuHABQ== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787490" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787490" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:31 -0700 X-CSE-ConnectionGUID: LduCTjZ2RCaMazriHeaqkw== X-CSE-MsgGUID: RWcv0VeWSZ6wy4gl1dvmgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042454" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:29 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 12/13] ASoC: Intel: avs: Add assert_static to guarantee ABI sizes Date: Fri, 5 Apr 2024 11:09:28 +0200 Message-Id: <20240405090929.1184068-13-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Amadeusz Sławiński In order to make sure that IPC interface is stable use assert_static to check union and struct sizes that describe communication interface. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/avs.h | 1 + sound/soc/intel/avs/icl.c | 3 +++ sound/soc/intel/avs/loader.c | 2 ++ sound/soc/intel/avs/messages.h | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/sound/soc/intel/avs/avs.h b/sound/soc/intel/avs/avs.h index f80f79415344..39bdec591d58 100644 --- a/sound/soc/intel/avs/avs.h +++ b/sound/soc/intel/avs/avs.h @@ -381,6 +381,7 @@ struct avs_apl_log_buffer_layout { u32 write_ptr; u8 buffer[]; } __packed; +static_assert(sizeof(struct avs_apl_log_buffer_layout) == 8); #define avs_apl_log_payload_size(adev) \ (avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout)) diff --git a/sound/soc/intel/avs/icl.c b/sound/soc/intel/avs/icl.c index d279ec1e0ad0..e8b4983e03e9 100644 --- a/sound/soc/intel/avs/icl.c +++ b/sound/soc/intel/avs/icl.c @@ -52,12 +52,14 @@ union avs_icl_memwnd2_slot_type { u32 type:24; }; } __packed; +static_assert(sizeof(union avs_icl_memwnd2_slot_type) == 4); struct avs_icl_memwnd2_desc { u32 resource_id; union avs_icl_memwnd2_slot_type slot_id; u32 vma; } __packed; +static_assert(sizeof(struct avs_icl_memwnd2_desc) == 12); #define AVS_ICL_MEMWND2_SLOTS_COUNT 15 @@ -68,6 +70,7 @@ struct avs_icl_memwnd2 { }; u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][SZ_4K]; } __packed; +static_assert(sizeof(struct avs_icl_memwnd2) == 65536); #define AVS_ICL_SLOT_UNUSED \ ((union avs_icl_memwnd2_slot_type) { 0x00000000U }) diff --git a/sound/soc/intel/avs/loader.c b/sound/soc/intel/avs/loader.c index 57370f0905dc..c255c898b7a8 100644 --- a/sound/soc/intel/avs/loader.c +++ b/sound/soc/intel/avs/loader.c @@ -56,6 +56,7 @@ struct avs_fw_manifest { u32 feature_mask; struct avs_fw_version version; } __packed; +static_assert(sizeof(struct avs_fw_manifest) == 36); struct avs_fw_ext_manifest { u32 id; @@ -64,6 +65,7 @@ struct avs_fw_ext_manifest { u16 version_minor; u32 entries; } __packed; +static_assert(sizeof(struct avs_fw_ext_manifest) == 16); static int avs_fw_ext_manifest_strip(struct firmware *fw) { diff --git a/sound/soc/intel/avs/messages.h b/sound/soc/intel/avs/messages.h index 007bc4fb6d99..285d89607b6a 100644 --- a/sound/soc/intel/avs/messages.h +++ b/sound/soc/intel/avs/messages.h @@ -93,12 +93,14 @@ union avs_global_msg { } ext; }; } __packed; +static_assert(sizeof(union avs_global_msg) == 8); struct avs_tlv { u32 type; u32 length; u32 value[]; } __packed; +static_assert(sizeof(struct avs_tlv) == 8); enum avs_module_msg_type { AVS_MOD_INIT_INSTANCE = 0, @@ -155,6 +157,7 @@ union avs_module_msg { } ext; }; } __packed; +static_assert(sizeof(union avs_module_msg) == 8); #define AVS_IPC_NOT_SUPPORTED 15 @@ -190,6 +193,7 @@ union avs_reply_msg { } ext; }; } __packed; +static_assert(sizeof(union avs_reply_msg) == 8); enum avs_notify_msg_type { AVS_NOTIFY_PHRASE_DETECTED = 4, @@ -226,6 +230,7 @@ union avs_notify_msg { } ext; }; } __packed; +static_assert(sizeof(union avs_notify_msg) == 8); #define AVS_MSG(hdr) { .val = hdr } @@ -264,6 +269,7 @@ struct avs_notify_voice_data { u16 kpd_score; u16 reserved; } __packed; +static_assert(sizeof(struct avs_notify_voice_data) == 4); struct avs_notify_res_data { u32 resource_type; @@ -272,6 +278,7 @@ struct avs_notify_res_data { u32 reserved; u32 data[6]; } __packed; +static_assert(sizeof(struct avs_notify_res_data) == 40); struct avs_notify_mod_data { u32 module_instance_id; @@ -279,6 +286,7 @@ struct avs_notify_mod_data { u32 data_size; u32 data[]; } __packed; +static_assert(sizeof(struct avs_notify_mod_data) == 12); /* ROM messages */ enum avs_rom_control_msg_type { @@ -332,6 +340,7 @@ struct avs_dxstate_info { u32 core_mask; /* which cores are subject for power transition */ u32 dx_mask; /* bit[n]=1 core n goes to D0, bit[n]=0 it goes to D3 */ } __packed; +static_assert(sizeof(struct avs_dxstate_info) == 8); int avs_ipc_set_dx(struct avs_dev *adev, u32 core_mask, bool powerup); int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming); @@ -367,11 +376,13 @@ struct avs_skl_log_state { u32 enable; u32 min_priority; } __packed; +static_assert(sizeof(struct avs_skl_log_state) == 8); struct avs_skl_log_state_info { u32 core_mask; struct avs_skl_log_state logs_core[]; } __packed; +static_assert(sizeof(struct avs_skl_log_state_info) == 4); struct avs_apl_log_state_info { u32 aging_timer_period; @@ -379,6 +390,7 @@ struct avs_apl_log_state_info { u32 core_mask; struct avs_skl_log_state logs_core[]; } __packed; +static_assert(sizeof(struct avs_apl_log_state_info) == 12); enum avs_icl_log_priority { AVS_ICL_LOG_CRITICAL = 0, @@ -403,6 +415,7 @@ struct avs_icl_log_state_info { u32 enable; u32 logs_priorities_mask[]; } __packed; +static_assert(sizeof(struct avs_icl_log_state_info) == 12); int avs_ipc_set_enable_logs(struct avs_dev *adev, u8 *log_info, size_t size); @@ -521,6 +534,7 @@ struct avs_module_type { u32 lib_code:1; u32 rsvd:24; } __packed; +static_assert(sizeof(struct avs_module_type) == 4); union avs_segment_flags { u32 ul; @@ -537,12 +551,14 @@ union avs_segment_flags { u32 length:16; }; } __packed; +static_assert(sizeof(union avs_segment_flags) == 4); struct avs_segment_desc { union avs_segment_flags flags; u32 v_base_addr; u32 file_offset; } __packed; +static_assert(sizeof(struct avs_segment_desc) == 12); struct avs_module_entry { u16 module_id; @@ -559,11 +575,13 @@ struct avs_module_entry { u16 instance_bss_size; struct avs_segment_desc segments[3]; } __packed; +static_assert(sizeof(struct avs_module_entry) == 116); struct avs_mods_info { u32 count; struct avs_module_entry entries[]; } __packed; +static_assert(sizeof(struct avs_mods_info) == 4); static inline bool avs_module_entry_is_loaded(struct avs_module_entry *mentry) { @@ -577,6 +595,7 @@ struct avs_sys_time { u32 val_l; u32 val_u; } __packed; +static_assert(sizeof(struct avs_sys_time) == 8); int avs_ipc_set_system_time(struct avs_dev *adev); @@ -680,6 +699,7 @@ struct avs_audio_format { u32 sample_type:8; u32 reserved:8; } __packed; +static_assert(sizeof(struct avs_audio_format) == 24); struct avs_modcfg_base { u32 cpc; @@ -688,12 +708,14 @@ struct avs_modcfg_base { u32 is_pages; struct avs_audio_format audio_fmt; } __packed; +static_assert(sizeof(struct avs_modcfg_base) == 40); struct avs_pin_format { u32 pin_index; u32 iobs; struct avs_audio_format audio_fmt; } __packed; +static_assert(sizeof(struct avs_pin_format) == 32); struct avs_modcfg_ext { struct avs_modcfg_base base; @@ -703,6 +725,7 @@ struct avs_modcfg_ext { /* input pin formats followed by output ones */ struct avs_pin_format pin_fmts[]; } __packed; +static_assert(sizeof(struct avs_modcfg_ext) == 56); enum avs_dma_type { AVS_DMA_HDA_HOST_OUTPUT = 0, @@ -726,6 +749,7 @@ union avs_virtual_index { u8 instance:3; } dmic; } __packed; +static_assert(sizeof(union avs_virtual_index) == 1); union avs_connector_node_id { u32 val; @@ -735,6 +759,7 @@ union avs_connector_node_id { u32 rsvd:19; }; } __packed; +static_assert(sizeof(union avs_connector_node_id) == 4); #define INVALID_PIPELINE_ID 0xFF #define INVALID_NODE_ID \ @@ -747,6 +772,7 @@ union avs_gtw_attributes { u32 rsvd:31; }; } __packed; +static_assert(sizeof(union avs_gtw_attributes) == 4); struct avs_copier_gtw_cfg { union avs_connector_node_id node_id; @@ -757,6 +783,7 @@ struct avs_copier_gtw_cfg { DECLARE_FLEX_ARRAY(u32, blob); } config; } __packed; +static_assert(sizeof(struct avs_copier_gtw_cfg) == 16); struct avs_copier_cfg { struct avs_modcfg_base base; @@ -764,6 +791,7 @@ struct avs_copier_cfg { u32 feature_mask; struct avs_copier_gtw_cfg gtw_cfg; } __packed; +static_assert(sizeof(struct avs_copier_cfg) == 84); struct avs_volume_cfg { u32 channel_id; @@ -772,22 +800,26 @@ struct avs_volume_cfg { u32 reserved; /* alignment */ u64 curve_duration; } __packed; +static_assert(sizeof(struct avs_volume_cfg) == 24); struct avs_peakvol_cfg { struct avs_modcfg_base base; struct avs_volume_cfg vols[]; } __packed; +static_assert(sizeof(struct avs_peakvol_cfg) == 40); struct avs_micsel_cfg { struct avs_modcfg_base base; struct avs_audio_format out_fmt; } __packed; +static_assert(sizeof(struct avs_micsel_cfg) == 64); struct avs_mux_cfg { struct avs_modcfg_base base; struct avs_audio_format ref_fmt; struct avs_audio_format out_fmt; } __packed; +static_assert(sizeof(struct avs_mux_cfg) == 88); struct avs_updown_mixer_cfg { struct avs_modcfg_base base; @@ -796,21 +828,25 @@ struct avs_updown_mixer_cfg { s32 coefficients[AVS_CHANNELS_MAX]; u32 channel_map; } __packed; +static_assert(sizeof(struct avs_updown_mixer_cfg) == 84); struct avs_src_cfg { struct avs_modcfg_base base; u32 out_freq; } __packed; +static_assert(sizeof(struct avs_src_cfg) == 44); struct avs_probe_gtw_cfg { union avs_connector_node_id node_id; u32 dma_buffer_size; } __packed; +static_assert(sizeof(struct avs_probe_gtw_cfg) == 8); struct avs_probe_cfg { struct avs_modcfg_base base; struct avs_probe_gtw_cfg gtw_cfg; } __packed; +static_assert(sizeof(struct avs_probe_cfg) == 48); struct avs_aec_cfg { struct avs_modcfg_base base; @@ -818,6 +854,7 @@ struct avs_aec_cfg { struct avs_audio_format out_fmt; u32 cpc_lp_mode; } __packed; +static_assert(sizeof(struct avs_aec_cfg) == 92); struct avs_asrc_cfg { struct avs_modcfg_base base; @@ -828,11 +865,13 @@ struct avs_asrc_cfg { u32 disable_jitter_buffer:1; u32 rsvd3:27; } __packed; +static_assert(sizeof(struct avs_asrc_cfg) == 48); struct avs_wov_cfg { struct avs_modcfg_base base; u32 cpc_lp_mode; } __packed; +static_assert(sizeof(struct avs_wov_cfg) == 44); /* Module runtime parameters */ @@ -845,6 +884,7 @@ struct avs_copier_sink_format { struct avs_audio_format src_fmt; struct avs_audio_format sink_fmt; } __packed; +static_assert(sizeof(struct avs_copier_sink_format) == 52); int avs_ipc_copier_set_sink_format(struct avs_dev *adev, u16 module_id, u8 instance_id, u32 sink_id, @@ -878,6 +918,7 @@ struct avs_probe_dma { union avs_connector_node_id node_id; u32 dma_buffer_size; } __packed; +static_assert(sizeof(struct avs_probe_dma) == 8); enum avs_probe_type { AVS_PROBE_TYPE_INPUT = 0, @@ -894,6 +935,7 @@ union avs_probe_point_id { u32 index:6; } id; } __packed; +static_assert(sizeof(union avs_probe_point_id) == 4); enum avs_connection_purpose { AVS_CONNECTION_PURPOSE_EXTRACT = 0, @@ -906,6 +948,7 @@ struct avs_probe_point_desc { u32 purpose; union avs_connector_node_id node_id; } __packed; +static_assert(sizeof(struct avs_probe_point_desc) == 12); int avs_ipc_probe_get_dma(struct avs_dev *adev, struct avs_probe_dma **dmas, size_t *num_dmas); int avs_ipc_probe_attach_dma(struct avs_dev *adev, struct avs_probe_dma *dmas, size_t num_dmas); From patchwork Fri Apr 5 09:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13618744 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 CAD4C15FA9C for ; Fri, 5 Apr 2024 09:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308114; cv=none; b=dY4mVBYtx4An4Tp9GOb2axbyIrZMD63VqOY8aKC9/0saI6i+LyU6Xh/U9WAKhHrvdpWy0byKZQa+D+ziCU8pSNInYZhaZfF8Z6jgwb9j3OPtp0phb7N9QJ82gwQfJLyUORerM6FWuspN409F2dqC/6CiXzstMMETg+pXU5qvmGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308114; c=relaxed/simple; bh=nu1C7rngL8VEfilTEnqoMiTpOUoFjJN8vPw+PIeQe88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mQ9dzzWT79RSJZsyIxxjarAlPHYVTFPlu8FErDDF8CcxmBGcBmSb9YKswkwY1TwEIHo3Xq2OMl1EX0f54VRAAezNg91kR/680sMvvfFDq2wfsNflhVE+utknyHtmKg8lzdT7LAlkWkXS9idgBNDkujcthBl5vsVhLB4ZPBHH5qc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A475mYJP; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A475mYJP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712308113; x=1743844113; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nu1C7rngL8VEfilTEnqoMiTpOUoFjJN8vPw+PIeQe88=; b=A475mYJP+IfkROh3WHAO/r8DFU+CAhZQy+hiPNv6ArcraZtBiKpbXGGf VN1D5Rd6p1aObQ2nkak8qrAevHNBvq85tmrIhfieuhb++QLcDapXQdcir 5FYefqY8bbookVG1VqEtVbj82vZT/Xd5Ox7Vtof6YzYyi1NrqBNi6BO/+ 7/T1RVUOvSYBsLQU0X7EEvsFVDfaIpSVvCSNG+hGWTJwxBbNlIEaT/Iig 9TntXjExrzZ2LuYExXC1+5tLP62Y2lb4XvYjs2nYYiGACqNRvz4zQTaUS GbWgEL36h7YCyEDWnaKvTghG2daoTWF4XTRO9gF4JDtwDccY3RXaW6/Nm Q==; X-CSE-ConnectionGUID: OA9VMTTSTPiFUxsaUJEHoA== X-CSE-MsgGUID: iGB1wOt4RBqoTltSpXYF3g== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="7787496" X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="7787496" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2024 02:08:33 -0700 X-CSE-ConnectionGUID: wJrbcTmtSC62zFon9zUb0g== X-CSE-MsgGUID: 0vISobsHTRuHu26OpjfAvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,181,1708416000"; d="scan'208";a="19042463" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orviesa009.jf.intel.com with ESMTP; 05 Apr 2024 02:08:31 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 13/13] ASoC: Intel: avs: Rule invalid buffer and period sizes out Date: Fri, 5 Apr 2024 11:09:29 +0200 Message-Id: <20240405090929.1184068-14-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240405090929.1184068-1-cezary.rojewski@intel.com> References: <20240405090929.1184068-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While HDAudio controller supports buffer packets up to 128 bytes low, audio format shall be taken into consideration when calculating buffer and period sizes to avoid undesired xruns. As *_size in ALSA terms means frames (channels times bit-depth-bytes), hw_rules can calculate minimal buffer and period sizes solely from sample rate and the number of milliseconds commonly used on the AudioDSP firmware side. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 405de1d58178..77a7e8f93951 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -457,6 +457,26 @@ static const struct snd_pcm_hw_constraint_list hw_rates = { const struct snd_soc_dai_ops avs_dai_fe_ops; +static int hw_rule_param_size(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) +{ + struct snd_interval *interval = hw_param_interval(params, rule->var); + struct snd_interval to; + + snd_interval_any(&to); + to.integer = interval->integer; + to.max = interval->max; + /* + * Commonly 2ms buffer size is used in HDA scenarios whereas 4ms is used + * when streaming through GPDMA. Align to the latter to account for both. + */ + to.min = params_rate(params) / 1000 * 4; + + if (rule->var == SNDRV_PCM_HW_PARAM_PERIOD_SIZE) + to.min /= params_periods(params); + + return snd_interval_refine(interval, &to); +} + static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -492,6 +512,14 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so if (ret < 0) goto err; + /* Adjust buffer and period size based on the audio format. */ + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, hw_rule_param_size, NULL, + SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_CHANNELS, + SNDRV_PCM_HW_PARAM_RATE, -1); + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, hw_rule_param_size, NULL, + SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_CHANNELS, + SNDRV_PCM_HW_PARAM_RATE, -1); + snd_pcm_set_sync(substream); dev_dbg(dai->dev, "%s fe STARTUP tag %d str %p",