Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c74289c authored by Aviral Gupta's avatar Aviral Gupta
Browse files

ASoC: q6asm: Fix the memory leak during the SSR



If a session is released during the SSR, then the memory unmap
command to DSP fails. This results in not releasing up the memory
block shared among apps and the DSP.
Fix by checking if the session has been invalidated during the SSR
and free up the memory during the close command.

CRs-Fixed: 687190
Change-Id: I66251e624e5cc1abd816c2e4647997482b96c771
Signed-off-by: default avatarAviral Gupta <aviralg@codeaurora.org>
parent 6360b49e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ struct audio_client {
	/* audio cache operations fptr*/
	int (*fptr_cache_ops)(struct audio_buffer *abuff, int cache_op);
	atomic_t               unmap_cb_success;
	atomic_t               reset;
};

void q6asm_audio_client_free(struct audio_client *ac);
+7 −8
Original line number Diff line number Diff line
@@ -751,7 +751,7 @@ int q6asm_audio_client_buf_free(unsigned int dir,

		while (cnt >= 0) {
			if (port->buf[cnt].data) {
				if (!rc)
				if (!rc || atomic_read(&ac->reset))
					msm_audio_ion_free(
						port->buf[cnt].client,
						port->buf[cnt].handle);
@@ -801,7 +801,7 @@ int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
			(void *)&port->buf[0].phys,
			(void *)port->buf[0].client,
			(void *)port->buf[0].handle);
		if (!rc)
		if (!rc || atomic_read(&ac->reset))
			msm_audio_ion_free(port->buf[0].client,
					   port->buf[0].handle);
		port->buf[0].client = NULL;
@@ -962,6 +962,7 @@ struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv)
	init_waitqueue_head(&ac->cmd_wait);
	init_waitqueue_head(&ac->time_wait);
	atomic_set(&ac->time_flag, 1);
	atomic_set(&ac->reset, 0);
	INIT_LIST_HEAD(&ac->port[0].mem_map_handle);
	INIT_LIST_HEAD(&ac->port[1].mem_map_handle);
	pr_debug("%s: mem_map_handle list init'ed\n", __func__);
@@ -1389,6 +1390,7 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
	}

	if (data->opcode == RESET_EVENTS) {
		atomic_set(&ac->reset, 1);
		if (ac->apr == NULL)
			ac->apr = ac->apr2;
		pr_debug("q6asm_callback: Reset event is received: %d %d apr[%p]\n",
@@ -1397,14 +1399,11 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
			ac->cb(data->opcode, data->token,
				(uint32_t *)data->payload, ac->priv);
		apr_reset(ac->apr);
		if (ac->cb)
			ac->cb(data->opcode, data->token,
				data->payload, ac->priv);
		ac->apr = NULL;
		atomic_set(&ac->time_flag, 0);
		atomic_set(&ac->cmd_state, 0);
		wake_up(&ac->time_wait);
		wake_up(&ac->cmd_wait);
		ac->apr = NULL;
		return 0;
	}