From nobody Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 E5761307AD4; Tue, 14 Oct 2025 03:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411710; cv=none; b=ApGbFr4Q5q6qXU0LuGt4rcrBLtZsHl38/VxXbHloNtybYv2j56RW/HtHWtibIOWzGaPK6ZqzAK24x0/pFetdi3TtnmFk3y90kQ2BdhO1rCnUKNdQVn4FsMPi1VUrqtB1mtOVEou8aPrt7bsfjvSNXxxvIA41Zkg4Zww3RRz2dus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411710; c=relaxed/simple; bh=fPrn5rSywxhgIBMOoYkamAw00lrPDv+ETPbiLdOq2eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t6coeQyhs7U/C1r0uP821sehNZE0LigfwY3k2E2hr+gkb0L4DMy6lgT9frOq5/xAsQBr1CUs1Mb1OvO/2VXn7bQa+3IIFdA5aWsIg4UD7weNaQCLE8NbtenifX0xjpNgUSGsfo/u/1+wGF6SzMRJfgJ81XmrzTvo8iUk2Wb9tgA= 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=DpwJbPRc; arc=none smtp.client-ip=192.198.163.15 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="DpwJbPRc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411708; x=1791947708; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fPrn5rSywxhgIBMOoYkamAw00lrPDv+ETPbiLdOq2eU=; b=DpwJbPRcOSe96y+jCHle5XWHiCx3bt14k4BV46jrpEoPvwQTYkRIkM8h JH99+436DqBPHxQ4Bl0zZnsmH/n8gwoQQSLRsRMq1GCAdcOYlZdYfwJyp 3qs1cSliX2PB35oKegbNCPkFrkH5TXbRhHw6lyG+GZ3xK7N5rspd9oVI9 HlIdSmWgUmnoTNJYGVlzQGkyICj3LBMttsBbzgjk+ksfJFd4wjpRCl3FI BJTzZdGMacwzfIgZrHxp/2jpCXzqk28ok68GTNjOF62k93E303EDD7GYc YiZwe3A6ZX8Jk1m8t+Fi651vOxci4EghhlCdknhEDXdmIwbyIxZCbdYN+ w==; X-CSE-ConnectionGUID: T0O9xYdAQY+83D7RrqqTGQ== X-CSE-MsgGUID: T8T7uF7aT+GnYrQGUqsc/Q== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662065" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662065" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:05 -0700 X-CSE-ConnectionGUID: d7OU7aiLTCeCT1Zlq8JZJA== X-CSE-MsgGUID: SHOwYc1OSESFwglFAFNG7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198542" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:03 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 1/7] soundwire: cadence_master: make frame index trace more readable Date: Tue, 14 Oct 2025 11:14:44 +0800 Message-ID: <20251014031450.3781789-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 1A390303A33; Tue, 14 Oct 2025 03:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411709; cv=none; b=ntmbjayVHMQc2Ofpc4TKB47AmvXT0uOX7a91kw3YVMubdDqdPeABeum7RgGyRwN/xGs0oP8QxxlS7T+DGD+uNSTCqBvEU0w09z3pglX+8pKtG/4oAa8Ca8Ua1BoDJ7GkRWp0EnqIQcgXQudicMs0QkJ4T41CfUNeP2hcPRpitFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411709; c=relaxed/simple; bh=PPSvyxYNGECSmWuUNiSzRgy7V8JVaZlBRY2HYixRPPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHhasGO2ZAes+MfhqaF/dIR/txnSGjsW1dgDtrWT2CLoQtgB33MrH4G867uBoDwj1biJdwvjvHeBx/RHvVjkd3VFNS1/x8ul5jpmPSkt9Egy8UlMKDlfM09qoitDTZNIT7QFtaD1MegYy9yh5vofH+XWC9/ejUOz2ENcmsa6KPw= 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=iWBiAdpf; arc=none smtp.client-ip=192.198.163.15 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="iWBiAdpf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411707; x=1791947707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PPSvyxYNGECSmWuUNiSzRgy7V8JVaZlBRY2HYixRPPE=; b=iWBiAdpfoVP53OTng0icKgBgf0VcrjUlgsOf20g9T4W8/8VRUcY+YgYl rqfBBb0Nwaxyls+ithym98V4PghuOFRoXze3mDPCRA6aee4xYtv/OW7w1 WweyXYTHNFZIBF03/AiD8678hskmoh2fTAbrJjvicpe5gM78EpbWP2yvS 3eCGoRrqcHUz1Mp4ijqrwu5ussDpSk8ANHUZHs/WvA+cya0BAr4nzLrRv 22pRSU/Rp9CV4dfbE+Zgtqx+b3dhCbzpVNQ0yBSKQfIYColWwyAKAmPmq zGnB1005SvFYQhiiypQZMF92jMyYLkejA+9j3QMZikTZj1MgLKdgz6OQf g==; X-CSE-ConnectionGUID: YW7+WajgSAKVKZxUo2essw== X-CSE-MsgGUID: XmabuKnOSD2IV01TAchKoQ== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662070" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662070" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:06 -0700 X-CSE-ConnectionGUID: BNWxzroNTMq4ZduWPzAu0A== X-CSE-MsgGUID: oe0MB1VFTNa2Z+A1achI7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198549" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:05 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 2/7] soundwire: only compute BPT stream in sdw_compute_dp0_port_params Date: Tue, 14 Oct 2025 11:14:45 +0800 Message-ID: <20251014031450.3781789-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 65EC23093D2; Tue, 14 Oct 2025 03:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411712; cv=none; b=K+2dWsza4C3LL8LPqRWlPphJyPEassUJf4YFyG69BDizLv160laCIVOlae5puIY+VeNX9RM+aYaxO0ZmZ2W40PrW1JrAgMXMIFZGSwnTqRpiPBIPBbGn8exYFVqnMH7MNOA+SKf2+IqjxNLV7TK2oNSdNgj+sR0bDpHvTpf1yrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411712; c=relaxed/simple; bh=QMApVb7vwwvBCryw7oaYh9kuIeLOvRukrcN3SkjHiCw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EY8G+as3cU5K0ujKnLnuA2gnUmFSvPEo7Un5zb0N9M7XCH795tOvfCk/7ZHA+KHDSrbzElbsJByInUfFXG6zq7Iaryh+unFVjitn5a34/q7SkBK/RPY8uSPDXyo38NgRrET7EbAcdsShVdOCdwyTwZ317ZzEfFqBOQg2480oG+0= 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=GE7lunKF; arc=none smtp.client-ip=192.198.163.15 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="GE7lunKF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411710; x=1791947710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QMApVb7vwwvBCryw7oaYh9kuIeLOvRukrcN3SkjHiCw=; b=GE7lunKFTamYMml7xm7uO1Pz0/JpNPqJLZZLpr/SctxBquScMamSFM+S zFLR9TWfGkSqeSwoVuoWLtdeqGdYUfiPiNgmuySTlpLYYmHVB/BGTdCf6 jpxVyJ2v5cdkuhFd+X84W3cT958LytadYrAporfTig1fP5+pzUfyOtqS2 dOE5ZD6F98B3LJFv8rQiCEii1vHEU+k/yWbfosg0jMUHoUUSaLVeX+OiE uXDugENwhXD+8zVZi0fwB+zc77VArQm6P3LxXNLIKQRaPGFMDTR5YRrGJ +fWlZPMRy+WNmg0/4XfUuerjWmsnQNKGb4RnCu3+W/uL1ozEx/lNu7qL5 Q==; X-CSE-ConnectionGUID: FCzyZQT+TCO+K96hgNspGA== X-CSE-MsgGUID: NMuLKMiQQiG8ogtuPaDq9w== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662076" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662076" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:08 -0700 X-CSE-ConnectionGUID: FyBSfeamQjeLbSHrL5UZww== X-CSE-MsgGUID: qly7j5GuQa+BEipwpHV4aA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198556" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:07 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 3/7] soundwire: cadence_master: set data_per_frame as frame capability Date: Tue, 14 Oct 2025 11:14:46 +0800 Message-ID: <20251014031450.3781789-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 3AC7230AAA6; Tue, 14 Oct 2025 03:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411715; cv=none; b=D7tEuyEWq9nwZonzRPsj4OWevLa56lkpp0LqUt2FORGuBnFsEboY+J5ErA6FNpsglAAaAIopfAPDW7K91YfMRQeQixuYPf0cddzUAQqHrm+ZsHRo+dYG9Yd8iG/Qf6pJ3Rxc/MvarMBzetYYby9zndBzR1Qx0w79PH0digxV5ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411715; c=relaxed/simple; bh=UbR/bMPXxaB/zDQV3v8s7FcdG+sxaTfUHnva5xYqVNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ox4ya94Vj1LaaRH0HB/n+A/q8m9o3W8ZZKzzhUqyiC26pY7lFDF4riZJuG2SGcEPHI073JiiTRb3J52RFQRkfK1gI52Cs+0EHKaHe1anmtAgFYcV6OhlN5VCT1aksR/Mt49v6Lu/ruWH0P+e+4dFjjg7EnFyzaQdT3AXIoYTwjg= 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=CWaXOlo8; arc=none smtp.client-ip=192.198.163.15 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="CWaXOlo8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411712; x=1791947712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UbR/bMPXxaB/zDQV3v8s7FcdG+sxaTfUHnva5xYqVNc=; b=CWaXOlo8lNGFtg+TenB2ElAj9gQMrGl3MsZ/8y6Idxc4eULyZS+W/wOn BL2zL94dvJZA9a1UQJ5/XtVeyKLLIcDU+NA6NjJ2ij2vsH0PMRbKXjRfz 5Gbx62UGtbzLkWKm0izLqSnb+EO0+/9ECpmcOrtCH3vp4s8lVrBtlv4eE cOrEkKJxxO5Niel/+sXuryGIYDdmsW5IKsxQY49yYdVUezJFEhiEb+aqz wE5o8K51d4mrf8zUXrsMw8rPQ7VSOuzXgWUDkuMHqdr3xEoRX4zRml3qN 7Q7RT6+EpvZjeW1c/Yh2HO8aYIBBFYxooX+gWZU7ThYHkiUIDqKgek6V2 A==; X-CSE-ConnectionGUID: wyd901gsS/6nnJP335+8Dw== X-CSE-MsgGUID: HiQq1K1QQ8ea+0eG76YThw== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662083" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662083" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:10 -0700 X-CSE-ConnectionGUID: IvQirI/MRiuns8MxPpTAAA== X-CSE-MsgGUID: buJ3+V1ZRGSO4XX5aVHlMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198568" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:08 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 4/7] soundwire: cadence: export sdw_cdns_bpt_find_bandwidth Date: Tue, 14 Oct 2025 11:14:47 +0800 Message-ID: <20251014031450.3781789-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 8B6AA126C02; Tue, 14 Oct 2025 03:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411714; cv=none; b=kfqN7DdLp3drp1xnsaf7pVfqpLfNg4hgvCraK0ihOHb9AYJiKHekMR9RlKYPY47RxdWiT+q9Vmhulv3Ghx2CZpbVgJPQ2uJWpQ+hRClpx1E6Ph4fanLxEUT6ouw1rXGyQmixX4sO+Fk7AmrV8C/lXkPgGz/AyF6de1VkmeMbjMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411714; c=relaxed/simple; bh=+9NmTuQ2Dj3WIbfFxJHgYytJ4NdDwy3IaKM1zDQNvDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X6oQSKUu1pf5fCVXIZlIyW14Az6YUEDcojXXq9jva8D/4rV6n/9RDu9DZ2AvIX7BKiL9ZsKtetkQ05T168R9N90a+TgGuXsDmxMsAiWm6xMLMRSr7qplL1hKOLcgd8oxh7PUqtonm/P9tcnLdAfk/TyQUDGaxmd/NMsi4MQTVdQ= 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=QyrFdxMF; arc=none smtp.client-ip=192.198.163.15 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="QyrFdxMF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411712; x=1791947712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+9NmTuQ2Dj3WIbfFxJHgYytJ4NdDwy3IaKM1zDQNvDI=; b=QyrFdxMFDQkEtSKBEkWAiEd16EajkNJXnI0LIGt2TElCiZxwC2cvnJlr WOwFzvHNUF4s5BanQ86Ez5/EtRQTmIcN8nPmRboqDfPESJjfgPy9fHN3O H6zKzYk0qFmzx16lJdGf344pURW3pBJ+XA4SgI1mb2ckRvlvD4iGyAtJT 3aJiDc7JR7v2uKHaROy2DqGOaRJGvUf42nWn9Abh4HtuiV0nbMaFT1Jzd kBXkES4/IpIf8OGstjfF1Mils367QXllLV/i1rHGKMVTVnov5kyPtF47d EWnaRh9PXGsVKpFdwBfQZgcpMQq38Z8ebzrBQi3Sg4p+TM3ujXA4KX5XQ w==; X-CSE-ConnectionGUID: RzF4hcZFTPOTQjpBdue/Qg== X-CSE-MsgGUID: 2galyq2qTHSUA6RDlQ6F6A== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662087" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662087" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:12 -0700 X-CSE-ConnectionGUID: p3rrwpYpQICeHRR/oyUCHQ== X-CSE-MsgGUID: YU14E1dRSVGgmO4ucQExag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198583" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:10 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment Date: Tue, 14 Oct 2025 11:14:48 +0800 Message-ID: <20251014031450.3781789-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 --- 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 1327f1cad0bc..11df4cf1e33e 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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 72097309F09; Tue, 14 Oct 2025 03:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411717; cv=none; b=mZdOQRvvMiL3+Th14uA0fGICpoavI054ShwmOMZi9QgovqyrSDbjFpjORdMCAEnDNhUv/tDag66s/d5vXqARYedSN37HNoM9H9q4yre6tY+IRpCaVQU4NTLsm0/6AFgi9hxXcAmrI4YubLK7eQAJjOZA9n7mgSjDOAHm4I1taB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411717; c=relaxed/simple; bh=bST5A1RZ2UDNZ/IHVgdVziruZsuAPXLZmxs9N0Kmacw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jEikJLjOmu/aIM8TCJw2HnoFlprOL83TvgPhnA7BNHpvuORTQpBBn0k5XATaQY9DDMNF2v7+CGT6Jpa2SV/mTVweISBD4tQA+Mqfv7ML/+yRJnwl5OvKQpKpy2+KP9sS2NAPogsQ59+0EJH9KKV4TxtahHVghUCJEGJs4Y9FOTk= 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=hNNofO7L; arc=none smtp.client-ip=192.198.163.15 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="hNNofO7L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411714; x=1791947714; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bST5A1RZ2UDNZ/IHVgdVziruZsuAPXLZmxs9N0Kmacw=; b=hNNofO7LwdO027j8ksmeNMWZ1pztIx63ZWj6DAvUQYwDwfk40VXvcNil n5+DZA8rLo7IWludEt0WEzc2JoClymD56lS/hEILIeo2oLNg7k9iVssY5 lNA4wAwXhU88pt2ysE6YhOlP7RguKVNw+Dfcdja04INRrURQu+luSvP5S rd/vW9LcKy+PoGNqKt7vF3zBXuDJAhyxXLJXK3bQuA0w8tqCDHDFLR0wf +3BEjQLo/7Cxcqn+P/T1YfbsIIMNhFvJ75AYuQrbcwTATiZX182nwAq8q 6Wv/mWQISx302egu93nwL2sLMChL3M+OYN6BSVVl1JqiUNW+YevTIdx77 A==; X-CSE-ConnectionGUID: fLqyf95uQt6iFlo7tJiXWg== X-CSE-MsgGUID: S7yXRpEtQwScQckT3I24ww== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662092" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662092" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:13 -0700 X-CSE-ConnectionGUID: aur5r7AjTiG9gc9Elt48tQ== X-CSE-MsgGUID: 3QzdLynVST2fMJ+qBvflyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198591" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:12 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 6/7] soundwire: cadence_master: add fake_size parameter to sdw_cdns_prepare_read_dma_buffer Date: Tue, 14 Oct 2025 11:14:49 +0800 Message-ID: <20251014031450.3781789-7-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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 Fri Dec 19 17:18:47 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 4C0C730AD00; Tue, 14 Oct 2025 03:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411718; cv=none; b=FCnf+VN79YBRyg/rhPSmlO1oupPltLPX1aSR6WgMED5J5PspINicWdSu86RrHMN/0T4sBO54kQ7AM4lRXHmpzAovGI2JL36MktmakhAm50fdwOipwGu92seO+mOus+5JG6kfgpcdIcdAI4wA/OzJ99H+PpnhSWjdtha2sB5wF98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760411718; c=relaxed/simple; bh=v+WcglJ6UXH86GdyEUHRefAusu8oSl3s/X5EonJZUY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QslQ2j/UFt9WsYn6TpSPatbR9FTHL9tJvuTQAU1KBl90m1nM+39EWFJa1SO+Rgrp9+AJYuZYFqjIVRZ06Zaf1TbiE9QDfCM3XPeXqgBUdDafxZapiEhvDIIz1HG4w4rkHg9THlITIHf4mlTaYQBRcQLy2DxLnEjgC/Q8pK8ytzs= 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=Xb4bPGxX; arc=none smtp.client-ip=192.198.163.15 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="Xb4bPGxX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760411716; x=1791947716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v+WcglJ6UXH86GdyEUHRefAusu8oSl3s/X5EonJZUY0=; b=Xb4bPGxXvyNe3bLGhrF26noiOsDO5S5vQX9C6vNqMfTX30W4Zo6Ir5io TILi5B3z8AMnTM0erstWchV1B6tPyOyyokUtHfZ2dAvcxm2k6rGNbDRCT Ecweq0KEEwXtpRo/Nd3MYem8fvCeNEBNXUyWMw1bO9klPGCdD9mUc62vN l6QiNYWls8iAMHzVlqnCI6iPT2ekFYLI7x3zBdau7zjE/m5oiZXHzNpB9 jWd/arqsEdNCiPJfzRmJdp0yKRMMY2AL1M5PdihrsLB220JBjcCYLtz6M NiRLh1NHWjYzbMiMHInakoIbP0AoNGoVP0alehxO0xBejky2RNoVBtjZH w==; X-CSE-ConnectionGUID: JvwPL/Z8T/CIq3+QngZodg== X-CSE-MsgGUID: 5AaEe/q1T0y/BjFdnoYo8g== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62662099" X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="62662099" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:15 -0700 X-CSE-ConnectionGUID: fQdOqS2xS62qsJmh5X6wVQ== X-CSE-MsgGUID: bBs0A5wRTA+rxS7p/IJXUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,227,1754982000"; d="scan'208";a="182198601" Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 20:15:14 -0700 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 7/7] soundwire: intel_ace2x: add fake frame to BRA read command Date: Tue, 14 Oct 2025 11:14:50 +0800 Message-ID: <20251014031450.3781789-8-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251014031450.3781789-1-yung-chuan.liao@linux.intel.com> References: <20251014031450.3781789-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