Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: intel_ace2x: handle multi BPT sections

Calculate required PDI buffer and pass the section number to the cdns
BPT helpers.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Tested-by: Shuming Fan <shumingf@realtek.com>
Link: https://patch.msgid.link/20251021094355.132943-4-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Bard Liao and committed by
Vinod Koul
188d194b fe8a9cf7

+34 -12
+34 -12
drivers/soundwire/intel_ace2x.c
··· 57 57 struct sdw_port_config *pconfig; 58 58 unsigned int pdi0_buf_size_pre_frame; 59 59 unsigned int pdi1_buf_size_pre_frame; 60 + unsigned int pdi0_buffer_size_; 61 + unsigned int pdi1_buffer_size_; 60 62 unsigned int pdi0_buffer_size; 61 63 unsigned int tx_dma_bandwidth; 62 64 unsigned int pdi1_buffer_size; ··· 70 68 struct sdw_cdns_pdi *pdi1; 71 69 unsigned int rx_alignment; 72 70 unsigned int tx_alignment; 71 + unsigned int num_frames_; 73 72 unsigned int num_frames; 74 73 unsigned int fake_size; 75 74 unsigned int tx_pad; ··· 79 76 int ret1; 80 77 int ret; 81 78 int dir; 79 + int len; 82 80 int i; 83 81 84 82 stream = sdw_alloc_stream("BPT", SDW_STREAM_BPT); ··· 159 155 if (ret < 0) 160 156 goto deprepare_stream; 161 157 162 - ret = sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row, cdns->bus.params.col, 163 - msg->sec[0].len, SDW_BPT_MSG_MAX_BYTES, 164 - &data_per_frame, &pdi0_buffer_size, &pdi1_buffer_size, 165 - &num_frames); 166 - if (ret < 0) 167 - goto deprepare_stream; 158 + len = 0; 159 + pdi0_buffer_size = 0; 160 + pdi1_buffer_size = 0; 161 + num_frames = 0; 162 + /* Add up pdi buffer size and frame numbers of each BPT sections */ 163 + for (i = 0; i < msg->sections; i++) { 164 + ret = sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row, 165 + cdns->bus.params.col, 166 + msg->sec[i].len, SDW_BPT_MSG_MAX_BYTES, 167 + &data_per_frame, &pdi0_buffer_size_, 168 + &pdi1_buffer_size_, &num_frames_); 169 + if (ret < 0) 170 + goto deprepare_stream; 171 + 172 + len += msg->sec[i].len; 173 + pdi0_buffer_size += pdi0_buffer_size_; 174 + pdi1_buffer_size += pdi1_buffer_size_; 175 + num_frames += num_frames_; 176 + } 168 177 169 178 sdw->bpt_ctx.pdi0_buffer_size = pdi0_buffer_size; 170 179 sdw->bpt_ctx.pdi1_buffer_size = pdi1_buffer_size; ··· 222 205 } 223 206 224 207 dev_dbg(cdns->dev, "Message len %d transferred in %d frames (%d per frame)\n", 225 - msg->sec[0].len, num_frames, data_per_frame); 208 + len, num_frames, data_per_frame); 226 209 dev_dbg(cdns->dev, "sizes pdi0 %d pdi1 %d tx_bandwidth %d rx_bandwidth %d\n", 227 210 pdi0_buffer_size, pdi1_buffer_size, tx_dma_bandwidth, rx_dma_bandwidth); 228 211 ··· 237 220 } 238 221 239 222 if (!command) { 240 - ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, 1, 223 + ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, msg->sections, 241 224 data_per_frame, 242 225 sdw->bpt_ctx.dmab_tx_bdl.area, 243 226 pdi0_buffer_size, &tx_total_bytes); 244 227 } else { 245 - ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, 1, 228 + ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, msg->sections, 246 229 data_per_frame, 247 230 sdw->bpt_ctx.dmab_tx_bdl.area, 248 231 pdi0_buffer_size, &tx_total_bytes, ··· 321 304 struct sdw_bpt_msg *msg) 322 305 { 323 306 struct sdw_cdns *cdns = &sdw->cdns; 307 + int len = 0; 324 308 int ret; 309 + int i; 325 310 326 - if (msg->sec[0].len < INTEL_BPT_MSG_BYTE_MIN) { 311 + for (i = 0; i < msg->sections; i++) 312 + len += msg->sec[i].len; 313 + 314 + if (len < INTEL_BPT_MSG_BYTE_MIN) { 327 315 dev_err(cdns->dev, "BPT message length %d is less than the minimum bytes %d\n", 328 - msg->sec[0].len, INTEL_BPT_MSG_BYTE_MIN); 316 + len, INTEL_BPT_MSG_BYTE_MIN); 329 317 return -EINVAL; 330 318 } 331 319 ··· 390 368 } else { 391 369 ret = sdw_cdns_check_read_response(cdns->dev, sdw->bpt_ctx.dmab_rx_bdl.area, 392 370 sdw->bpt_ctx.pdi1_buffer_size, 393 - msg->sec, 1, sdw->bpt_ctx.num_frames, 371 + msg->sec, msg->sections, sdw->bpt_ctx.num_frames, 394 372 sdw->bpt_ctx.data_per_frame); 395 373 if (ret < 0) 396 374 dev_err(cdns->dev, "%s: BPT Read failed %d\n", __func__, ret);