Unverified Commit 0f00a3fa authored by Mark Brown's avatar Mark Brown
Browse files

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.
parents 60e07fa4 fd4e9e9b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -504,8 +504,10 @@ int snd_sof_device_shutdown(struct device *dev)
	if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
		cancel_work_sync(&sdev->probe_work);

	if (sdev->fw_state == SOF_FW_BOOT_COMPLETE)
	if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) {
		sof_fw_trace_free(sdev);
		return snd_sof_shutdown(sdev);
	}

	return 0;
}
+15 −4
Original line number Diff line number Diff line
@@ -361,13 +361,19 @@ static int mtl_dsp_core_power_up(struct snd_sof_dev *sdev, int core)
	ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl,
					    (dspcxctl & cpa) == cpa, HDA_DSP_REG_POLL_INTERVAL_US,
					    HDA_DSP_RESET_TIMEOUT_US);
	if (ret < 0)
	if (ret < 0) {
		dev_err(sdev->dev, "%s: timeout on MTL_DSP2CXCTL_PRIMARY_CORE read\n",
			__func__);

		return ret;
	}

	/* set primary core mask and refcount to 1 */
	sdev->enabled_cores_mask = BIT(SOF_DSP_PRIMARY_CORE);
	sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 1;

	return 0;
}

static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core)
{
	u32 dspcxctl;
@@ -388,12 +394,17 @@ static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core)
					    !(dspcxctl & MTL_DSP2CXCTL_PRIMARY_CORE_CPA_MASK),
					    HDA_DSP_REG_POLL_INTERVAL_US,
					    HDA_DSP_PD_TIMEOUT * USEC_PER_MSEC);
	if (ret < 0)
	if (ret < 0) {
		dev_err(sdev->dev, "failed to power down primary core\n");

		return ret;
	}

	sdev->enabled_cores_mask = 0;
	sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 0;

	return 0;
}

int mtl_power_down_dsp(struct snd_sof_dev *sdev)
{
	u32 dsphfdsscs, cpa;
+39 −0
Original line number Diff line number Diff line
@@ -223,6 +223,14 @@ static inline void ipc3_log_header(struct device *dev, u8 *text, u32 cmd)
}
#endif

static void sof_ipc3_dump_payload(struct snd_sof_dev *sdev,
				  void *ipc_data, size_t size)
{
	printk(KERN_DEBUG "Size of payload following the header: %zu\n", size);
	print_hex_dump_debug("Message payload: ", DUMP_PREFIX_OFFSET,
			     16, 4, ipc_data, size, false);
}

static int sof_ipc3_get_reply(struct snd_sof_dev *sdev)
{
	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_

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

	if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
		size_t payload_bytes, header_bytes;
		char *payload = NULL;

		/* payload is indicated by non zero msg/reply_bytes */
		if (msg_bytes > sizeof(struct sof_ipc_cmd_hdr)) {
			payload = msg_data;

			header_bytes = sizeof(struct sof_ipc_cmd_hdr);
			payload_bytes = msg_bytes - header_bytes;
		} else if (reply_bytes > sizeof(struct sof_ipc_reply)) {
			payload = reply_data;

			header_bytes = sizeof(struct sof_ipc_reply);
			payload_bytes = reply_bytes - header_bytes;
		}

		if (payload) {
			payload += header_bytes;
			sof_ipc3_dump_payload(sdev, payload, payload_bytes);
		}
	}

	mutex_unlock(&ipc->tx_mutex);

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

	if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
		size_t header_bytes = sizeof(struct sof_ipc_reply);
		char *payload = (char *)cdata;

		payload += header_bytes;
		sof_ipc3_dump_payload(sdev, payload, data_bytes - header_bytes);
	}

	mutex_unlock(&sdev->ipc->tx_mutex);

	kfree(cdata_chunk);
+21 −23
Original line number Diff line number Diff line
@@ -17,15 +17,6 @@
#include "ipc4-priv.h"
#include "ops.h"

#ifdef DEBUG_VERBOSE
#define sof_ipc4_dump_payload(sdev, ipc_data, size)			\
		print_hex_dump_debug("Message payload: ",		\
				     DUMP_PREFIX_OFFSET,		\
				     16, 4, ipc_data, size, false)
#else
#define sof_ipc4_dump_payload(sdev, ipc_data, size)	do { } while (0)
#endif

static const struct sof_ipc4_fw_status {
	int status;
	char *msg;
@@ -256,6 +247,13 @@ static void sof_ipc4_log_header(struct device *dev, u8 *text, struct sof_ipc4_ms
}
#endif

static void sof_ipc4_dump_payload(struct snd_sof_dev *sdev,
				  void *ipc_data, size_t size)
{
	print_hex_dump_debug("Message payload: ", DUMP_PREFIX_OFFSET,
			     16, 4, ipc_data, size, false);
}

static int sof_ipc4_get_reply(struct snd_sof_dev *sdev)
{
	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_
			   void *reply_data, size_t reply_bytes, bool no_pm)
{
	struct snd_sof_ipc *ipc = sdev->ipc;
#ifdef DEBUG_VERBOSE
	struct sof_ipc4_msg *msg = NULL;
#endif
	int ret;

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

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

	mutex_unlock(&ipc->tx_mutex);
	if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD)) {
		struct sof_ipc4_msg *msg = NULL;

#ifdef DEBUG_VERBOSE
		/* payload is indicated by non zero msg/reply_bytes */
		if (msg_bytes)
			msg = msg_data;
@@ -397,7 +392,9 @@ static int sof_ipc4_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_

		if (msg)
			sof_ipc4_dump_payload(sdev, msg->data_ptr, msg->data_size);
#endif
	}

	mutex_unlock(&ipc->tx_mutex);

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

	if (sof_debug_check_flag(SOF_DBG_DUMP_IPC_MESSAGE_PAYLOAD))
		sof_ipc4_dump_payload(sdev, ipc4_msg->data_ptr, ipc4_msg->data_size);

out:
+4 −8
Original line number Diff line number Diff line
@@ -234,20 +234,16 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)

	pm_state.event = target_state;

	/* Skip to platform-specific suspend if DSP is entering D0 */
	if (target_state == SOF_DSP_PM_D0) {
		sof_fw_trace_suspend(sdev, pm_state);
		/* Notify clients not managed by pm framework about core suspend */
		sof_suspend_clients(sdev, pm_state);
		goto suspend;
	}

	/* suspend DMA trace */
	sof_fw_trace_suspend(sdev, pm_state);

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

	/* Skip to platform-specific suspend if DSP is entering D0 */
	if (target_state == SOF_DSP_PM_D0)
		goto suspend;

#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
	/* cache debugfs contents during runtime suspend */
	if (runtime_suspend)
Loading