From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 010C5293C4E; Thu, 30 Oct 2025 07:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807824; cv=none; b=Uoqn2jXs4c1+pcXCN8G1rSgBvZqcmjIHnhv3hQ8xunBAnWBddFJEteoHCeIsn8rMrERsC7baXFH/cBXquZ1dPIraeHiRxrXQqBxiKJwPstVWcFcEBs2AcumW0B74Pk0pKi5WycRh1+dQM7p88ubyG21rmuQ+KwR2WXM/jJl4N9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807824; c=relaxed/simple; bh=fPrn5rSywxhgIBMOoYkamAw00lrPDv+ETPbiLdOq2eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BS59+8U8s7oLK20KC+82SeaH/AqbS8vD2sKmwbUqYJNPOBByvR3q2Q4YCj5QB5Amh2Wa7rnoy4IBA3RXsc99clJEEPokpHVjo245Qb9V3fhZQzK5LmRWs96pghO8qEqV3ZVHYrcr2R9dskriySodKB+YVV114CAF82LzaZdjqu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jL9LNJTu; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jL9LNJTu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807824; x=1793343824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fPrn5rSywxhgIBMOoYkamAw00lrPDv+ETPbiLdOq2eU=; b=jL9LNJTuU5SKoCfjrYF2QN6SkHYPGKKjkHppa8RCLwS5DCEAwTTLGJut PZcywToci8dGKzeFqfA9YJ4zd/nnqDj49cSdWnJ0bDx8gLPKHn9masuVp ScPKPPYuIDtZJMFeI+86bEYXD09OIErTl7mCv6JoW6MbTiMUV8QhZE6Db RrYf09lNXCIbQjQ9/OpIb6hMOfpnHiIzr+tDPKqMLyrfL0l/ZaOPSBNTY eCSo7vXMVzTNMcPhF/0ZHUIvoc/ieOt8UjyEaSORx8zUA4MXVojJQaXy/ 9XJlrVnOSynf1fYYR+Rgs7JeVOwBUUYb0sqbRv4Z0yRSqKLsTc2Y59iR1 w==; X-CSE-ConnectionGUID: bm8Ob5hqSm2TmO3idaseJA== X-CSE-MsgGUID: Fz8JBHPiT3afTQf4Xrjgdg== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359518" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359518" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:43 -0700 X-CSE-ConnectionGUID: kX2G1+xhTSOoWT30jVIGEw== X-CSE-MsgGUID: /N11j5TKR6iWFzdwzo8GOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621363" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:40 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 1/7] soundwire: cadence_master: make frame index trace more readable Date: Thu, 30 Oct 2025 15:02:47 +0800 Message-ID: <20251030070253.1216871-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing code uses i as the frame index which is 0 based. And "bad frame %d/%d", i, num_frames where num_frames is 1 based. Change the frame index to i + 1 to align with num_frames and more readable. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/cadence_master.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence= _master.c index 21bb491d026b..c59a98b408b3 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -2495,14 +2495,14 @@ int sdw_cdns_check_write_response(struct device *de= v, u8 *dma_buffer, ret =3D check_frame_start(header, counter); if (ret < 0) { dev_err(dev, "%s: bad frame %d/%d start header %x\n", - __func__, i, num_frames, header); + __func__, i + 1, num_frames, header); return ret; } =20 ret =3D check_frame_end(footer); if (ret < 0) { dev_err(dev, "%s: bad frame %d/%d end footer %x\n", - __func__, i, num_frames, footer); + __func__, i + 1, num_frames, footer); return ret; } =20 @@ -2573,7 +2573,7 @@ int sdw_cdns_check_read_response(struct device *dev, = u8 *dma_buffer, int dma_buf ret =3D check_frame_start(header, counter); if (ret < 0) { dev_err(dev, "%s: bad frame %d/%d start header %x\n", - __func__, i, num_frames, header); + __func__, i + 1, num_frames, header); return ret; } =20 @@ -2588,7 +2588,7 @@ int sdw_cdns_check_read_response(struct device *dev, = u8 *dma_buffer, int dma_buf =20 if (crc !=3D expected_crc) { dev_err(dev, "%s: bad frame %d/%d crc %#x expected %#x\n", - __func__, i, num_frames, crc, expected_crc); + __func__, i + 1, num_frames, crc, expected_crc); return -EIO; } =20 @@ -2599,7 +2599,7 @@ int sdw_cdns_check_read_response(struct device *dev, = u8 *dma_buffer, int dma_buf ret =3D check_frame_end(footer); if (ret < 0) { dev_err(dev, "%s: bad frame %d/%d end footer %x\n", - __func__, i, num_frames, footer); + __func__, i + 1, num_frames, footer); return ret; } =20 --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 3954833508F; Thu, 30 Oct 2025 07:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807826; cv=none; b=B47K528xPBrIL9hOSTiuP954X0zaKkOCMrpwsvEdnsiUMCoVztr2m7tpNy1WsKqihwLbBgBR4NVw/irpxaISKf1H+DWbfRcHCJ5KbI7mM+J2KtbVdJfpOnTUkFFwpksgxtKylnrWT7fAzZWbrJDQ+IJ3Or4//xUopVZB8or/obM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807826; c=relaxed/simple; bh=PPSvyxYNGECSmWuUNiSzRgy7V8JVaZlBRY2HYixRPPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOJah0QzesGS4t0phaSujo6R1+CJRRVMywNU450VWqQGhGTHTfZI8JRJXE1wjtQ1ck0BIQmiHAJ8AN9VqQZht5XPw04VJ97UmBwcduGpZrEbTZTwkZ0qd2KrzrgI6tFkJjZdoEQ4eW4zC4rpjO9wSjXJsuVelaTpWQrm3xdeK4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Dtm81jK+; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Dtm81jK+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807826; x=1793343826; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PPSvyxYNGECSmWuUNiSzRgy7V8JVaZlBRY2HYixRPPE=; b=Dtm81jK+BwwttXkmOgcf1bWkUjm8wkScIA0EDIEic00C6EmTLmF0WlnZ zGDcfdikY4+GxDIcSBboPXBbd8nCalj7ROqFw7iZh4hMwiHBIec03/ggv +H2HZhWYmNpZ9BTe9uG95026cAx+4lifPfkiWYv6RPfQgDcaYtt+vdkGd CPXb4bO7aseLk3yiBrgGynhwLMFqlH/tmcr7UgPFoblfIiu/ybbvfk7+8 31L+d+sN9dFSiDyh9cYr2hXCdgoYbiy0Oo1PjoYoSIt54S5jHcZBLukTb 70nM0Vqip1Uusuih8/OZ0R00TarjQmBZbUoU2H/El1WMgAL8JPIDT57At w==; X-CSE-ConnectionGUID: cY/bo//jRYKst5VS8cB9Ig== X-CSE-MsgGUID: fj70Ml2jStC51gHxER9iuQ== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359520" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359520" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:45 -0700 X-CSE-ConnectionGUID: DPFO5W/oRUW0iw7bnqGpnw== X-CSE-MsgGUID: BoNrOX7qSRO/TdhwDG/DUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621371" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:43 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 2/7] soundwire: only compute BPT stream in sdw_compute_dp0_port_params Date: Thu, 30 Oct 2025 15:02:48 +0800 Message-ID: <20251030070253.1216871-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DP0 is only for BPT stream. We should not compute and update the port params of the normal audio streams. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/generic_bandwidth_allocation.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soundwire/generic_bandwidth_allocation.c b/drivers/sou= ndwire/generic_bandwidth_allocation.c index c18f0c16f929..530ac66ac6fa 100644 --- a/drivers/soundwire/generic_bandwidth_allocation.c +++ b/drivers/soundwire/generic_bandwidth_allocation.c @@ -124,6 +124,9 @@ static void sdw_compute_dp0_port_params(struct sdw_bus = *bus) struct sdw_master_runtime *m_rt; =20 list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { + /* DP0 is for BPT only */ + if (m_rt->stream->type !=3D SDW_STREAM_BPT) + continue; sdw_compute_dp0_master_ports(m_rt); sdw_compute_dp0_slave_ports(m_rt); } --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 49F5C3358BD; Thu, 30 Oct 2025 07:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807828; cv=none; b=LHpVYfFrdY7npIBOYKEVmj/jGdlmGXbiXyQYICBZ6rNOtYqEtQylwVS+R1K0E2QKkauQ6b5EcJPmiZ07bqk5udPQVAV+lnNDAtyoNs2Nr/GFdsefoyKcXphwUJc1g43RRN2+NdeY5l5fW7A2iqsY7y7QPdwT+Vpc2FdfsXqnyO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807828; c=relaxed/simple; bh=QMApVb7vwwvBCryw7oaYh9kuIeLOvRukrcN3SkjHiCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HDn7jdKizppAFALcLvueb3k9rCg9s8GG5enTWF3CWOiR3qmFIKYnjXoFSsWCqWmxaZ12gMBjX4x+d192i/FaqkVTELlQB73LpUjMgB+WMpED8O1droRUTno/P2FQurg62B2nAiwQDABvlf5XjnS1JETNtJlglo7FORqQeUnsgcY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ilRyRZJl; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ilRyRZJl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807828; x=1793343828; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QMApVb7vwwvBCryw7oaYh9kuIeLOvRukrcN3SkjHiCw=; b=ilRyRZJllU8i6vNm6th9Xi6ZLrldVebOTjtlnT3yo/eFEGfkjlSB/gWh iwycb3kz7oJ13M8budBXbxOVT2BNHKoLUepuSpSNYyNivmbU0BIViyOj+ Ld1BbGpkcAWIpUELaqa6UffHn/cBPLJMnvGFWrWxaKDJre8yj17tOCep3 3rHtLsdM+X06IulHoH74OM3J3xo4bfv2qua8liGZ4JSZWyFRx/yuwtlST LyjA9eP0TKTNlDohw2t26qPuzeX3/7qyKxihynbmlTZR77wWPhRAYxVoZ 18YjiJqdi1C0oHXT3yE7DJOanVvYvm7wEV60RsjH/lBD2iM5R3ohKTYSq w==; X-CSE-ConnectionGUID: CC92KasBRzKlNgEr4Astkw== X-CSE-MsgGUID: q5pNviYVRx+r9v8abbXkLA== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359523" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359523" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:48 -0700 X-CSE-ConnectionGUID: 0Nb65DsBRIusOfpvZhi2Fw== X-CSE-MsgGUID: VD01LurZT8CKgOuasKyD1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621387" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:45 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 3/7] soundwire: cadence_master: set data_per_frame as frame capability Date: Thu, 30 Oct 2025 15:02:49 +0800 Message-ID: <20251030070253.1216871-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" data_per_frame will be used for preparing the TX buffer and we may add some fake frames to ensure the data in the buffer will be flushed. So that it should indicate the frame capability even if the required data bytes are less than the frame capability. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/cadence_master.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence= _master.c index c59a98b408b3..178341410909 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -2114,9 +2114,6 @@ int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0:= write, 1: read */ if (!actual_bpt_bytes) return -EINVAL; =20 - if (data_bytes < actual_bpt_bytes) - actual_bpt_bytes =3D data_bytes; - /* * the caller may want to set the number of bytes per frame, * allow when possible @@ -2126,6 +2123,9 @@ int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0:= write, 1: read */ =20 *data_per_frame =3D actual_bpt_bytes; =20 + if (data_bytes < actual_bpt_bytes) + actual_bpt_bytes =3D data_bytes; + if (command =3D=3D 0) { /* * for writes we need to send all the data_bytes per frame, --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 9370B335BAF; Thu, 30 Oct 2025 07:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807831; cv=none; b=KDdfwsIvx7d3/Yi8jPmxQwfWPXgLHlPSm6qe3VIVD3JjmVvAaRGytbbUctssr71LUmK0oPN23sXss5/5sOfYrpXHyzUz8wYYeMsKl6RpInbPsGH0IHxaohXrfeIH/4vzcXQtrYkWxDbeBBOYFsH3UX4THJOADeiAGZHFSYgalko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807831; c=relaxed/simple; bh=UbR/bMPXxaB/zDQV3v8s7FcdG+sxaTfUHnva5xYqVNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jYUFGBYcXGO/13sAl41WP/K8jkAuIGPQt7IyllhQjhIQqMGbcjXOLp8Jud3F5l2JvZvL1M0v/kpAU+wyd4pix3Jt30o2yAmoLUjD77uCZzN2ZDaCdHzhun5GICtu6aDM9tT68U2t0uZpGl3RxhErTqUjtziKbQAxGk+pZFmAnT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LDZI71M4; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LDZI71M4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807830; x=1793343830; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UbR/bMPXxaB/zDQV3v8s7FcdG+sxaTfUHnva5xYqVNc=; b=LDZI71M4rpFfGX0USgnVKYdD8yReVeMEi2m9SnjUdIfAY8l/m5Ebs5hU 2cKX49hqgYwF0o9R8mxpHX9w82MCwLTBX5tPrUCALNQXeMlve47Rrobd5 9Qhg34arc2r9dgjTllYB95TYKrEc+uzLMz8/QIP6vVIG96iPpcgG7iBgD JS5O3C7vHbLOYbziDNCNFwrz9uvZbGKGyrfgH+zeUX5dptiQI8RMC/MrF 7ascp7thQQSf1+z3QDUchXQ6GQIB6kE+9OFtqLzej5MYHu1e2YqfFoBjW IzL0b2H/DjfJZB2McbNHMj3y410n0kqYWFNcVjxpx3PMzh+L4ljMQuRZB w==; X-CSE-ConnectionGUID: y7tTLHlST3e666If/uCKjg== X-CSE-MsgGUID: UOqZV3ZNTtGBYSWLBs3gjA== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359530" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359530" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:50 -0700 X-CSE-ConnectionGUID: eouuUOc4Rdi1JeFpnsvpLg== X-CSE-MsgGUID: UsNEoUIVQr+J5uDUeZ353Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621397" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:47 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 4/7] soundwire: cadence: export sdw_cdns_bpt_find_bandwidth Date: Thu, 30 Oct 2025 15:02:50 +0800 Message-ID: <20251030070253.1216871-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, we calculate the required bandwidth after the PDI buffer size is calculated. However as we need to add some fake frame to align the data block size, the final PDI size and the frame number will change. Besides, we need the required bandwidth to decide the DMA channel number and the channel number will be used to calculate the data block size. Therefore, we calculate the required bandwidth and export a helper for the caller to get the required bandwidth. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/cadence_master.c | 30 ++++++++++++++++++++++++++++++ drivers/soundwire/cadence_master.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence= _master.c index 178341410909..57671f9b3e9c 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -2094,6 +2094,36 @@ static unsigned int sdw_cdns_read_pdi1_buffer_size(u= nsigned int actual_data_size return total * 2; } =20 +int sdw_cdns_bpt_find_bandwidth(int command, /* 0: write, 1: read */ + int row, int col, int frame_rate, + unsigned int *tx_dma_bandwidth, + unsigned int *rx_dma_bandwidth) +{ + unsigned int bpt_bits =3D row * (col - 1); + unsigned int bpt_bytes =3D bpt_bits >> 3; + unsigned int pdi0_buffer_size; + unsigned int pdi1_buffer_size; + unsigned int data_per_frame; + + data_per_frame =3D sdw_cdns_bra_actual_data_size(bpt_bytes); + if (!data_per_frame) + return -EINVAL; + + if (command =3D=3D 0) { + pdi0_buffer_size =3D sdw_cdns_write_pdi0_buffer_size(data_per_frame); + pdi1_buffer_size =3D SDW_CDNS_WRITE_PDI1_BUFFER_SIZE; + } else { + pdi0_buffer_size =3D SDW_CDNS_READ_PDI0_BUFFER_SIZE; + pdi1_buffer_size =3D sdw_cdns_read_pdi1_buffer_size(data_per_frame); + } + + *tx_dma_bandwidth =3D pdi0_buffer_size * 8 * frame_rate; + *rx_dma_bandwidth =3D pdi1_buffer_size * 8 * frame_rate; + + return 0; +} +EXPORT_SYMBOL(sdw_cdns_bpt_find_bandwidth); + int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */ int row, int col, unsigned int data_bytes, unsigned int requested_bytes_per_frame, diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence= _master.h index 9373426c7f63..6830d7f2d772 100644 --- a/drivers/soundwire/cadence_master.h +++ b/drivers/soundwire/cadence_master.h @@ -209,6 +209,11 @@ void sdw_cdns_config_update(struct sdw_cdns *cdns); int sdw_cdns_config_update_set_wait(struct sdw_cdns *cdns); =20 /* SoundWire BPT/BRA helpers to format data */ +int sdw_cdns_bpt_find_bandwidth(int command, /* 0: write, 1: read */ + int row, int col, int frame_rate, + unsigned int *tx_dma_bandwidth, + unsigned int *rx_dma_bandwidth); + int sdw_cdns_bpt_find_buffer_sizes(int command, /* 0: write, 1: read */ int row, int col, unsigned int data_bytes, unsigned int requested_bytes_per_frame, --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 BB8AF33506D; Thu, 30 Oct 2025 07:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807833; cv=none; b=HLMMTa3LElVsCsAnXqMxXbsrKpfxp0NIcXDbYkGGiXc6mjpIWo+S9D4jOZUTb11Sw3gSlQeqz3GEkXjvo807XaWpoe2fvnFSEix4zlBNYrdBZicAVYE2ufTHWIxkF8NIJXNbldF+pN6ac1dtmIMU2hJXPno9oOVRH6y52ROpF+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807833; c=relaxed/simple; bh=NKISwiKLowTCj5FE4+obKXi2pLfUB24Cz31GCbDWA3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GKnvvW+kiGKGKTx8N4u8W5V31gwjHYqWBNzkCC2hQX3gm7byyPybpe8vqmAXIbEcbs138SHZDW9tEQhNBQxDaG3awC/UG+8+WM2t5icBDHpYjgCochmDhLGKYMArnFVh8o50feBLFnoiY1XTlat+Ikk42e5d9cOfwL1YGuH0iBQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wy1AmEHg; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wy1AmEHg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807832; x=1793343832; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NKISwiKLowTCj5FE4+obKXi2pLfUB24Cz31GCbDWA3s=; b=Wy1AmEHgYXsv4iPVsC6CgaB9QqV7uGWraz/Hf5RNBjdk+Rnxh0AAa2KL TFtcfzmFXPuxz+hHK5wT6JyKNF8eJogQ9Xd36bnBnQP8WR0cTJo/c/k7Q ZhO3KzHNCcLYFTLdyn/8er1UaEAi7PdyB2HKZHZsfkUAxhzL8pn7yj7hQ oO0AzSB43I9QvUgCGMLVz15YQ6oycFKrt7wgixyKsAgELh3aabKAYqoF/ RoGn2d6UtEU0k0LfrfHDtDLgipc3YPtyI0V7MwB0gt5RCsetk0R5gL9gG 5REiPIvRx9aziXPLHNrOLtWftXCMTAufcTHU1oglOvEOvCeUnHNJDgfok w==; X-CSE-ConnectionGUID: FBs+k0G5SQq+OKW6ediYvQ== X-CSE-MsgGUID: LpYUBL/OQe+ANBRnflJwXw== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359541" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359541" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:52 -0700 X-CSE-ConnectionGUID: 9iO1glVpS261SlEpEKQ2ww== X-CSE-MsgGUID: n2ijog74QTWRmeyfQCTbWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621408" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:50 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment Date: Thu, 30 Oct 2025 15:02:51 +0800 Message-ID: <20251030070253.1216871-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dma buffer need to be a multiple of data block size and the fifo size. Export a function to return the LCM of data block size and the fifo size. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan Acked-by: Mark Brown --- include/sound/hda-sdw-bpt.h | 7 +++++++ sound/soc/sof/intel/hda-sdw-bpt.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sound/hda-sdw-bpt.h b/include/sound/hda-sdw-bpt.h index f649549b75d5..9b654c31829a 100644 --- a/include/sound/hda-sdw-bpt.h +++ b/include/sound/hda-sdw-bpt.h @@ -30,6 +30,8 @@ int hda_sdw_bpt_wait(struct device *dev, struct hdac_ext_= stream *bpt_tx_stream, int hda_sdw_bpt_close(struct device *dev, struct hdac_ext_stream *bpt_tx_s= tream, struct snd_dma_buffer *dmab_tx_bdl, struct hdac_ext_stream *bpt_rx= _stream, struct snd_dma_buffer *dmab_rx_bdl); + +unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth= ); #else static inline int hda_sdw_bpt_open(struct device *dev, int link_id, struct hdac_ext_stream **bpt_tx_stream, @@ -64,6 +66,11 @@ static inline int hda_sdw_bpt_close(struct device *dev, = struct hdac_ext_stream * WARN_ONCE(1, "SoundWire BPT is disabled"); return -EOPNOTSUPP; } + +static inline unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int= dma_bandwidth) +{ + return 0; +} #endif =20 #endif /* __HDA_SDW_BPT_H */ diff --git a/sound/soc/sof/intel/hda-sdw-bpt.c b/sound/soc/sof/intel/hda-sd= w-bpt.c index ff5abccf0d88..e45dd051ab8c 100644 --- a/sound/soc/sof/intel/hda-sdw-bpt.c +++ b/sound/soc/sof/intel/hda-sdw-bpt.c @@ -10,6 +10,7 @@ * Hardware interface for SoundWire BPT support with HDA DMA */ =20 +#include #include #include #include @@ -236,6 +237,18 @@ static int hda_sdw_bpt_dma_disable(struct device *dev,= struct hdac_ext_stream *s return ret; } =20 +#define FIFO_ALIGNMENT 64 + +unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth) +{ + unsigned int num_channels =3D DIV_ROUND_UP(dma_bandwidth, BPT_FREQUENCY *= 32); + unsigned int data_block =3D num_channels * 4; + unsigned int alignment =3D lcm(data_block, FIFO_ALIGNMENT); + + return alignment; +} +EXPORT_SYMBOL_NS(hda_sdw_bpt_get_buf_size_alignment, "SND_SOC_SOF_INTEL_HD= A_SDW_BPT"); + int hda_sdw_bpt_open(struct device *dev, int link_id, struct hdac_ext_stre= am **bpt_tx_stream, struct snd_dma_buffer *dmab_tx_bdl, u32 bpt_tx_num_bytes, u32 tx_dma_bandwidth, struct hdac_ext_stream **bpt_rx_stream, --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 2D528336EEC; Thu, 30 Oct 2025 07:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807835; cv=none; b=q4V+5Cu8hhS/9fcK/Ly3o48bspHKf5M8LA6Vb3+zv3ThLfs8AkVQK5rZTf2aPI5PNzStr20KqZdfXN9J8/WchN4yRIzb5hBE+4JziACcyjQKgrNJqkOQhVtGW/IGjYiIsuocD/WBF4SDKS7ECjUpL16/R1Oune5cNxyz2LTJBWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807835; c=relaxed/simple; bh=bST5A1RZ2UDNZ/IHVgdVziruZsuAPXLZmxs9N0Kmacw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aD025DnWyt04/NyqrjYXx6yG6qPEg+7mJdW7wPNMhIsMoZRS051IEuiaKhlLnEzaDvZF8ePduusYoRk/Ix8JqbWo9GlnanU8Wp36EP7DTO1T/+jMg0yHf+P2KFFMh51sdB/HY764N4CQfOjWum1R49NkXac+L50WtNu1Fm6OrrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EQJZFthu; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EQJZFthu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807835; x=1793343835; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bST5A1RZ2UDNZ/IHVgdVziruZsuAPXLZmxs9N0Kmacw=; b=EQJZFthuZmplBOgFcw0rVmR0jhY7BIn7XEfsc11pT2ioJyeiAzimoyrK hUt1PLm8klyk7hAcjArLwJuM8TrUqbMB5jz9JTk+h1wx6ltuWdXd4X2bi CE6wclyskZgMr/z3UJPna5ho9ryKfX6GcLglJ6fjmKjZyeNGqHAb3DTaw b/iO2Ic0rPfHsaMg+m/urOIaet5VR1JExrDecMf8WK8JPC82+TOPHigOg 5enkpZnnDJtaoWQyG0ZcDpF/x4iHL+rICD9gk2UJo8/P9ivS+RFX5Crcm 5fxHGhp29wcqLLmDnZkGEeEoTkeT6NetvvwLNEhlqGHjtMyjGXXL3Xp3d A==; X-CSE-ConnectionGUID: l7FKqHVzSxelnilNxvrYAg== X-CSE-MsgGUID: sByx1oIkTK6Mw5vsb0CKHQ== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359546" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359546" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:54 -0700 X-CSE-ConnectionGUID: CEJ/rbLlQ/izTKvnAAUSDg== X-CSE-MsgGUID: Lk/DruQ4SLaiEIlbL+HGwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621416" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:52 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 6/7] soundwire: cadence_master: add fake_size parameter to sdw_cdns_prepare_read_dma_buffer Date: Thu, 30 Oct 2025 15:02:52 +0800 Message-ID: <20251030070253.1216871-7-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We may need to add few fake frames to fit the aligned read dma buffer size. Add a fake_size parameter to allow the caller to set the fake data size. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/cadence_master.c | 39 +++++++++++++++++++++++++++++- drivers/soundwire/cadence_master.h | 2 +- drivers/soundwire/intel_ace2x.c | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence= _master.c index 57671f9b3e9c..4e94da28d8ad 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -2393,7 +2393,7 @@ EXPORT_SYMBOL(sdw_cdns_prepare_write_dma_buffer); =20 int sdw_cdns_prepare_read_dma_buffer(u8 dev_num, u32 start_register, int d= ata_size, int data_per_frame, u8 *dma_buffer, int dma_buffer_size, - int *dma_buffer_total_bytes) + int *dma_buffer_total_bytes, unsigned int fake_size) { int total_dma_data_written =3D 0; u8 *p_dma_buffer =3D dma_buffer; @@ -2445,6 +2445,43 @@ int sdw_cdns_prepare_read_dma_buffer(u8 dev_num, u32= start_register, int data_si if (ret < 0) return ret; =20 + counter++; + + p_dma_buffer +=3D dma_data_written; + dma_buffer_size -=3D dma_data_written; + total_dma_data_written +=3D dma_data_written; + } + + /* Add fake frame */ + header[0] &=3D ~GENMASK(7, 6); /* Set inactive flag in BPT/BRA frame head= e */ + while (fake_size >=3D data_per_frame) { + header[1] =3D data_per_frame; + ret =3D sdw_cdns_prepare_read_pd0_buffer(header, SDW_CDNS_BRA_HDR, p_dma= _buffer, + dma_buffer_size, &dma_data_written, + counter); + if (ret < 0) + return ret; + + counter++; + + fake_size -=3D data_per_frame; + p_dma_buffer +=3D dma_data_written; + dma_buffer_size -=3D dma_data_written; + total_dma_data_written +=3D dma_data_written; + } + + if (fake_size) { + header[1] =3D fake_size; + ret =3D sdw_cdns_prepare_read_pd0_buffer(header, SDW_CDNS_BRA_HDR, p_dma= _buffer, + dma_buffer_size, &dma_data_written, + counter); + if (ret < 0) + return ret; + + counter++; + + p_dma_buffer +=3D dma_data_written; + dma_buffer_size -=3D dma_data_written; total_dma_data_written +=3D dma_data_written; } =20 diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence= _master.h index 6830d7f2d772..a269a87486fc 100644 --- a/drivers/soundwire/cadence_master.h +++ b/drivers/soundwire/cadence_master.h @@ -226,7 +226,7 @@ int sdw_cdns_prepare_write_dma_buffer(u8 dev_num, u32 s= tart_register, u8 *data, =20 int sdw_cdns_prepare_read_dma_buffer(u8 dev_num, u32 start_register, int d= ata_size, int data_per_frame, u8 *dma_buffer, int dma_buffer_size, - int *dma_buffer_total_bytes); + int *dma_buffer_total_bytes, unsigned int fake_size); =20 int sdw_cdns_check_write_response(struct device *dev, u8 *dma_buffer, int dma_buffer_size, int num_frames); diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2= x.c index 5d08364ad6d1..22118b053d56 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -177,7 +177,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel= *sdw, struct sdw_slave * ret =3D sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->addr, msg->l= en, data_per_frame, sdw->bpt_ctx.dmab_tx_bdl.area, - pdi0_buffer_size, &tx_total_bytes); + pdi0_buffer_size, &tx_total_bytes, 0); } =20 if (!ret) --=20 2.43.0 From nobody Sun Dec 14 05:53:25 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 8A4EA337689; Thu, 30 Oct 2025 07:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807838; cv=none; b=VQb8nIf8uab0dCLH7CQC2efiw7lqyCYRFSDUJZ0N0+9WMgXjuNiB9kjpn/kv3L36gB+3Raoq7qxbtTAqi5GcBFbT54jcDNWvtopwYbdqZvqGwtmoeHoi+KSIxepBu8p8qHxIqZZ77V0bKaIoY1XlkdVJ34QcADZDOm4FA8Cg0Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761807838; c=relaxed/simple; bh=v+WcglJ6UXH86GdyEUHRefAusu8oSl3s/X5EonJZUY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lDZ1u4wWjnljhQ3VscxZ96iQhPkhLA+jdQIzadBde5aRaaJ9Dl/bGgcPWRrWPoCtJBVkQh8u6Hru9buXtxjuLiV8jDp3oDyaxONnyfLIiDd4IlMf80Xe4XGsDWekVz17HXntNt7WcY/BLkb8iGfO+yfz3qIDrwweQrWwyVgaiqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bqV2wohc; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bqV2wohc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761807837; x=1793343837; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v+WcglJ6UXH86GdyEUHRefAusu8oSl3s/X5EonJZUY0=; b=bqV2wohcLz+BYipyHNXe88azDfFBmsyjwXPpNysXfDdoHfLJu9EBjamA rLxksmkP9XIfYcSj/XKsjs60bg3Pg1Ti7NPBYk1kKa1+jzSdMqNSPvCeE bsTtCfJyPYvlmMH+C9Js+rdz30O0OXRiWLQMMGH0YCKttRK3EZncp6okq N6a2+u/T4uzqZnl3Ru7PaBkw7VXHl47OIsOQy72rfkYKjp0uw+eriChpe I74tNtbHO/aopQsjt2+pN/RaV1CoHepZO66M3VXE6L83n6PDWU1SR8LqN i547zoS5gIdlNbfjyR4sf1CUdIhD3BP148lVHEdTgkJf4aZFMJhg2U/io g==; X-CSE-ConnectionGUID: yPrABiJMTiqdP2Vexb4+6Q== X-CSE-MsgGUID: 6v5qOYNOTXuOGD91IFjfzg== X-IronPort-AV: E=McAfee;i="6800,10657,11597"; a="81359552" X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="81359552" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:57 -0700 X-CSE-ConnectionGUID: EKvw8hzGTWuKhTB1CuvjhA== X-CSE-MsgGUID: E2ki0vuAS0KmSPmFwQjmfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,266,1754982000"; d="scan'208";a="186621429" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2025 00:03:54 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH RESEND 7/7] soundwire: intel_ace2x: add fake frame to BRA read command Date: Thu, 30 Oct 2025 15:02:53 +0800 Message-ID: <20251030070253.1216871-8-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> References: <20251030070253.1216871-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Intel DMA buffer size need to be a multiple of data block size. Find the minimal fake data size and extra buffer size to meet the requirement. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan --- drivers/soundwire/intel_ace2x.c | 61 ++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2= x.c index 22118b053d56..e11a0cf77193 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -44,6 +44,8 @@ static int sdw_slave_bpt_stream_add(struct sdw_slave *sla= ve, struct sdw_stream_r return ret; } =20 +#define READ_PDI1_MIN_SIZE 12 + static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_s= lave *slave, struct sdw_bpt_msg *msg) { @@ -53,15 +55,23 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel= *sdw, struct sdw_slave * struct sdw_stream_runtime *stream; struct sdw_stream_config sconfig; struct sdw_port_config *pconfig; + unsigned int pdi0_buf_size_pre_frame; + unsigned int pdi1_buf_size_pre_frame; unsigned int pdi0_buffer_size; unsigned int tx_dma_bandwidth; unsigned int pdi1_buffer_size; unsigned int rx_dma_bandwidth; + unsigned int fake_num_frames; unsigned int data_per_frame; unsigned int tx_total_bytes; struct sdw_cdns_pdi *pdi0; struct sdw_cdns_pdi *pdi1; + unsigned int rx_alignment; + unsigned int tx_alignment; unsigned int num_frames; + unsigned int fake_size; + unsigned int tx_pad; + unsigned int rx_pad; int command; int ret1; int ret; @@ -138,6 +148,13 @@ static int intel_ace2x_bpt_open_stream(struct sdw_inte= l *sdw, struct sdw_slave * =20 command =3D (msg->flags & SDW_MSG_FLAG_WRITE) ? 0 : 1; =20 + ret =3D sdw_cdns_bpt_find_bandwidth(command, cdns->bus.params.row, + cdns->bus.params.col, + prop->default_frame_rate, + &tx_dma_bandwidth, &rx_dma_bandwidth); + if (ret < 0) + goto deprepare_stream; + ret =3D sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row, cdn= s->bus.params.col, msg->len, SDW_BPT_MSG_MAX_BYTES, &data_per_frame, &pdi0_buffer_size, &pdi1_buffer_size, &num_frames); @@ -148,10 +165,43 @@ static int intel_ace2x_bpt_open_stream(struct sdw_int= el *sdw, struct sdw_slave * sdw->bpt_ctx.pdi1_buffer_size =3D pdi1_buffer_size; sdw->bpt_ctx.num_frames =3D num_frames; sdw->bpt_ctx.data_per_frame =3D data_per_frame; - tx_dma_bandwidth =3D div_u64((u64)pdi0_buffer_size * 8 * (u64)prop->defau= lt_frame_rate, - num_frames); - rx_dma_bandwidth =3D div_u64((u64)pdi1_buffer_size * 8 * (u64)prop->defau= lt_frame_rate, - num_frames); + + rx_alignment =3D hda_sdw_bpt_get_buf_size_alignment(rx_dma_bandwidth); + tx_alignment =3D hda_sdw_bpt_get_buf_size_alignment(tx_dma_bandwidth); + + if (command) { /* read */ + /* Get buffer size of a full frame */ + ret =3D sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row, + cdns->bus.params.col, + data_per_frame, SDW_BPT_MSG_MAX_BYTES, + &data_per_frame, &pdi0_buf_size_pre_frame, + &pdi1_buf_size_pre_frame, &fake_num_frames); + if (ret < 0) + goto deprepare_stream; + + /* find fake pdi1 buffer size */ + rx_pad =3D rx_alignment - (pdi1_buffer_size % rx_alignment); + while (rx_pad <=3D READ_PDI1_MIN_SIZE) + rx_pad +=3D rx_alignment; + + pdi1_buffer_size +=3D rx_pad; + /* It is fine if we request more than enough byte to read */ + fake_num_frames =3D DIV_ROUND_UP(rx_pad, pdi1_buf_size_pre_frame); + fake_size =3D fake_num_frames * data_per_frame; + + /* find fake pdi0 buffer size */ + pdi0_buffer_size +=3D (fake_num_frames * pdi0_buf_size_pre_frame); + tx_pad =3D tx_alignment - (pdi0_buffer_size % tx_alignment); + pdi0_buffer_size +=3D tx_pad; + } else { /* write */ + /* + * For the write command, the rx data block is 4, and the rx buffer size= of a frame + * is 8. So the rx buffer size (pdi0_buffer_size) is always a multiple o= f rx + * alignment. + */ + tx_pad =3D tx_alignment - (pdi0_buffer_size % tx_alignment); + pdi0_buffer_size +=3D tx_pad; + } =20 dev_dbg(cdns->dev, "Message len %d transferred in %d frames (%d per frame= )\n", msg->len, num_frames, data_per_frame); @@ -177,7 +227,8 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel= *sdw, struct sdw_slave * ret =3D sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->addr, msg->l= en, data_per_frame, sdw->bpt_ctx.dmab_tx_bdl.area, - pdi0_buffer_size, &tx_total_bytes, 0); + pdi0_buffer_size, &tx_total_bytes, + fake_size); } =20 if (!ret) --=20 2.43.0