Skip to content

Commit 0f00a3f

Browse files
committed
ASoC: SOF: misc updates for 6.5
Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>: Couple of improvements on virtual_widget support, firmware trace free, IPC payload dump, duplicated code in suspend and MeteorLake primary code support.
2 parents 60e07fa + fd4e9e9 commit 0f00a3f

7 files changed

Lines changed: 116 additions & 52 deletions

File tree

sound/soc/sof/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,10 @@ int snd_sof_device_shutdown(struct device *dev)
504504
if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
505505
cancel_work_sync(&sdev->probe_work);
506506

507-
if (sdev->fw_state == SOF_FW_BOOT_COMPLETE)
507+
if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) {
508+
sof_fw_trace_free(sdev);
508509
return snd_sof_shutdown(sdev);
510+
}
509511

510512
return 0;
511513
}

sound/soc/sof/intel/mtl.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,17 @@ static int mtl_dsp_core_power_up(struct snd_sof_dev *sdev, int core)
361361
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl,
362362
(dspcxctl & cpa) == cpa, HDA_DSP_REG_POLL_INTERVAL_US,
363363
HDA_DSP_RESET_TIMEOUT_US);
364-
if (ret < 0)
364+
if (ret < 0) {
365365
dev_err(sdev->dev, "%s: timeout on MTL_DSP2CXCTL_PRIMARY_CORE read\n",
366366
__func__);
367+
return ret;
368+
}
367369

368-
return ret;
370+
/* set primary core mask and refcount to 1 */
371+
sdev->enabled_cores_mask = BIT(SOF_DSP_PRIMARY_CORE);
372+
sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 1;
373+
374+
return 0;
369375
}
370376

371377
static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core)
@@ -388,10 +394,15 @@ static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core)
388394
!(dspcxctl & MTL_DSP2CXCTL_PRIMARY_CORE_CPA_MASK),
389395
HDA_DSP_REG_POLL_INTERVAL_US,
390396
HDA_DSP_PD_TIMEOUT * USEC_PER_MSEC);
391-
if (ret < 0)
397+
if (ret < 0) {
392398
dev_err(sdev->dev, "failed to power down primary core\n");
399+
return ret;
400+
}
393401

394-
return ret;
402+
sdev->enabled_cores_mask = 0;
403+
sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 0;
404+
405+
return 0;
395406
}
396407

397408
int mtl_power_down_dsp(struct snd_sof_dev *sdev)

sound/soc/sof/ipc3.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ static inline void ipc3_log_header(struct device *dev, u8 *text, u32 cmd)
223223
}
224224
#endif
225225

226+
static void sof_ipc3_dump_payload(struct snd_sof_dev *sdev,
227+
void *ipc_data, size_t size)
228+
{
229+
printk(KERN_DEBUG "Size of payload following the header: %zu\n", size);
230+
print_hex_dump_debug("Message payload: ", DUMP_PREFIX_OFFSET,
231+
16, 4, ipc_data, size, false);
232+
}
233+
226234
static int sof_ipc3_get_reply(struct snd_sof_dev *sdev)
227235
{
228236
struct snd_sof_ipc_msg *msg = sdev->msg;
@@ -374,6 +382,29 @@ static int sof_ipc3_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_
374382

375383
ret = ipc3_tx_msg_unlocked(ipc, msg_data, msg_bytes, reply_data, reply_bytes);
376384

385+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
386+
size_t payload_bytes, header_bytes;
387+
char *payload = NULL;
388+
389+
/* payload is indicated by non zero msg/reply_bytes */
390+
if (msg_bytes > sizeof(struct sof_ipc_cmd_hdr)) {
391+
payload = msg_data;
392+
393+
header_bytes = sizeof(struct sof_ipc_cmd_hdr);
394+
payload_bytes = msg_bytes - header_bytes;
395+
} else if (reply_bytes > sizeof(struct sof_ipc_reply)) {
396+
payload = reply_data;
397+
398+
header_bytes = sizeof(struct sof_ipc_reply);
399+
payload_bytes = reply_bytes - header_bytes;
400+
}
401+
402+
if (payload) {
403+
payload += header_bytes;
404+
sof_ipc3_dump_payload(sdev, payload, payload_bytes);
405+
}
406+
}
407+
377408
mutex_unlock(&ipc->tx_mutex);
378409

379410
return ret;
@@ -472,6 +503,14 @@ static int sof_ipc3_set_get_data(struct snd_sof_dev *sdev, void *data, size_t da
472503
offset += payload_size;
473504
}
474505

506+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
507+
size_t header_bytes = sizeof(struct sof_ipc_reply);
508+
char *payload = (char *)cdata;
509+
510+
payload += header_bytes;
511+
sof_ipc3_dump_payload(sdev, payload, data_bytes - header_bytes);
512+
}
513+
475514
mutex_unlock(&sdev->ipc->tx_mutex);
476515

477516
kfree(cdata_chunk);

sound/soc/sof/ipc4.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
#include "ipc4-priv.h"
1818
#include "ops.h"
1919

20-
#ifdef DEBUG_VERBOSE
21-
#define sof_ipc4_dump_payload(sdev, ipc_data, size) \
22-
print_hex_dump_debug("Message payload: ", \
23-
DUMP_PREFIX_OFFSET, \
24-
16, 4, ipc_data, size, false)
25-
#else
26-
#define sof_ipc4_dump_payload(sdev, ipc_data, size) do { } while (0)
27-
#endif
28-
2920
static const struct sof_ipc4_fw_status {
3021
int status;
3122
char *msg;
@@ -256,6 +247,13 @@ static void sof_ipc4_log_header(struct device *dev, u8 *text, struct sof_ipc4_ms
256247
}
257248
#endif
258249

250+
static void sof_ipc4_dump_payload(struct snd_sof_dev *sdev,
251+
void *ipc_data, size_t size)
252+
{
253+
print_hex_dump_debug("Message payload: ", DUMP_PREFIX_OFFSET,
254+
16, 4, ipc_data, size, false);
255+
}
256+
259257
static int sof_ipc4_get_reply(struct snd_sof_dev *sdev)
260258
{
261259
struct snd_sof_ipc_msg *msg = sdev->msg;
@@ -362,9 +360,6 @@ static int sof_ipc4_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_
362360
void *reply_data, size_t reply_bytes, bool no_pm)
363361
{
364362
struct snd_sof_ipc *ipc = sdev->ipc;
365-
#ifdef DEBUG_VERBOSE
366-
struct sof_ipc4_msg *msg = NULL;
367-
#endif
368363
int ret;
369364

370365
if (!msg_data)
@@ -386,18 +381,20 @@ static int sof_ipc4_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_
386381

387382
ret = ipc4_tx_msg_unlocked(ipc, msg_data, msg_bytes, reply_data, reply_bytes);
388383

389-
mutex_unlock(&ipc->tx_mutex);
384+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
385+
struct sof_ipc4_msg *msg = NULL;
390386

391-
#ifdef DEBUG_VERBOSE
392-
/* payload is indicated by non zero msg/reply_bytes */
393-
if (msg_bytes)
394-
msg = msg_data;
395-
else if (reply_bytes)
396-
msg = reply_data;
387+
/* payload is indicated by non zero msg/reply_bytes */
388+
if (msg_bytes)
389+
msg = msg_data;
390+
else if (reply_bytes)
391+
msg = reply_data;
397392

398-
if (msg)
399-
sof_ipc4_dump_payload(sdev, msg->data_ptr, msg->data_size);
400-
#endif
393+
if (msg)
394+
sof_ipc4_dump_payload(sdev, msg->data_ptr, msg->data_size);
395+
}
396+
397+
mutex_unlock(&ipc->tx_mutex);
401398

402399
return ret;
403400
}
@@ -516,7 +513,8 @@ static int sof_ipc4_set_get_data(struct snd_sof_dev *sdev, void *data,
516513
if (!set && payload_bytes != offset)
517514
ipc4_msg->data_size = offset;
518515

519-
sof_ipc4_dump_payload(sdev, ipc4_msg->data_ptr, ipc4_msg->data_size);
516+
if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD))
517+
sof_ipc4_dump_payload(sdev, ipc4_msg->data_ptr, ipc4_msg->data_size);
520518

521519
out:
522520
mutex_unlock(&sdev->ipc->tx_mutex);

sound/soc/sof/pm.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,16 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
234234

235235
pm_state.event = target_state;
236236

237-
/* Skip to platform-specific suspend if DSP is entering D0 */
238-
if (target_state == SOF_DSP_PM_D0) {
239-
sof_fw_trace_suspend(sdev, pm_state);
240-
/* Notify clients not managed by pm framework about core suspend */
241-
sof_suspend_clients(sdev, pm_state);
242-
goto suspend;
243-
}
244-
245237
/* suspend DMA trace */
246238
sof_fw_trace_suspend(sdev, pm_state);
247239

248240
/* Notify clients not managed by pm framework about core suspend */
249241
sof_suspend_clients(sdev, pm_state);
250242

243+
/* Skip to platform-specific suspend if DSP is entering D0 */
244+
if (target_state == SOF_DSP_PM_D0)
245+
goto suspend;
246+
251247
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
252248
/* cache debugfs contents during runtime suspend */
253249
if (runtime_suspend)

sound/soc/sof/sof-audio.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
#include "sof-of-dev.h"
1515
#include "ops.h"
1616

17+
static bool is_virtual_widget(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
18+
const char *func)
19+
{
20+
switch (widget->id) {
21+
case snd_soc_dapm_out_drv:
22+
case snd_soc_dapm_output:
23+
case snd_soc_dapm_input:
24+
dev_dbg(sdev->dev, "%s: %s is a virtual widget\n", func, widget->name);
25+
return true;
26+
default:
27+
return false;
28+
}
29+
}
30+
1731
static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct snd_sof_widget *widget)
1832
{
1933
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
@@ -231,23 +245,9 @@ int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsourc
231245
bool route_found = false;
232246

233247
/* ignore routes involving virtual widgets in topology */
234-
switch (src_widget->id) {
235-
case snd_soc_dapm_out_drv:
236-
case snd_soc_dapm_output:
237-
case snd_soc_dapm_input:
248+
if (is_virtual_widget(sdev, src_widget->widget, __func__) ||
249+
is_virtual_widget(sdev, sink_widget->widget, __func__))
238250
return 0;
239-
default:
240-
break;
241-
}
242-
243-
switch (sink_widget->id) {
244-
case snd_soc_dapm_out_drv:
245-
case snd_soc_dapm_output:
246-
case snd_soc_dapm_input:
247-
return 0;
248-
default:
249-
break;
250-
}
251251

252252
/* find route matching source and sink widgets */
253253
list_for_each_entry(sroute, &sdev->route_list, list)
@@ -396,6 +396,9 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
396396
const struct sof_ipc_tplg_widget_ops *widget_ops;
397397
struct snd_soc_dapm_path *p;
398398

399+
if (is_virtual_widget(sdev, widget, __func__))
400+
return;
401+
399402
/* skip if the widget is in use or if it is already unprepared */
400403
if (!swidget || !swidget->prepared || swidget->use_count > 0)
401404
goto sink_unprepare;
@@ -433,6 +436,9 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
433436
struct snd_soc_dapm_path *p;
434437
int ret;
435438

439+
if (is_virtual_widget(sdev, widget, __func__))
440+
return 0;
441+
436442
widget_ops = tplg_ops ? tplg_ops->widget : NULL;
437443
if (!widget_ops)
438444
return 0;
@@ -488,6 +494,9 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap
488494
int err;
489495
int ret = 0;
490496

497+
if (is_virtual_widget(sdev, widget, __func__))
498+
return 0;
499+
491500
if (widget->dobj.private) {
492501
err = sof_widget_free(sdev, widget->dobj.private);
493502
if (err < 0)
@@ -527,6 +536,9 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
527536
struct snd_soc_dapm_path *p;
528537
int ret;
529538

539+
if (is_virtual_widget(sdev, widget, __func__))
540+
return 0;
541+
530542
if (swidget) {
531543
int i;
532544

@@ -592,6 +604,9 @@ sof_walk_widgets_in_order(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm,
592604
return 0;
593605

594606
for_each_dapm_widgets(list, i, widget) {
607+
if (is_virtual_widget(sdev, widget, __func__))
608+
continue;
609+
595610
/* starting widget for playback is AIF type */
596611
if (dir == SNDRV_PCM_STREAM_PLAYBACK && widget->id != snd_soc_dapm_aif_in)
597612
continue;

sound/soc/sof/sof-priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct snd_sof_pcm_stream;
4848
#define SOF_DBG_FORCE_NOCODEC BIT(10) /* ignore all codec-related
4949
* configurations
5050
*/
51+
#define SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD BIT(11) /* On top of the IPC message header
52+
* dump the message payload also
53+
*/
5154
#define SOF_DBG_DSPLESS_MODE BIT(15) /* Do not initialize and use the DSP */
5255

5356
/* Flag definitions used for controlling the DSP dump behavior */

0 commit comments

Comments
 (0)