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

Commit cead7623 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare
Browse files

ASoC: wcd_cpe_services: Make sure CPE is inactive before access



CPE (codec processing engine) memory space is shared with CPE and
slimbus register access. Due to simiulatneous access, it is possible
that CPE can crash. Add fix to make sure that CPE is done accessing the
memory space before accessing the same through codec registers.

Change-Id: Idcc7c0620cf82bb0ca7ee9fb041d4c535287a275
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent 37bc52a5
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/sched.h>
#include <linux/completion.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/mfd/wcd9xxx/core.h>
#include <sound/cpe_cmi.h>
#include <sound/soc.h>
@@ -30,6 +31,7 @@
#define CMI_DRIVER_SUPPORTED_VERSION 0
#define CMI_API_SUCCESS 0
#define CMI_MSG_TRANSPORT (0x0002)
#define CPE_SVC_INACTIVE_STATE_RETRIES_MAX 10

#define TOMTOM_A_SVASS_SPE_DRAM_OFFSET				0x50000
#define TOMTOM_A_SVASS_SPE_DRAM_SIZE				0x30000
@@ -1239,6 +1241,7 @@ static enum cpe_process_result cpe_mt_process_cmd(
	struct cpe_send_msg *m;
	struct cmi_hdr *hdr;
	u8 service = 0;
	u8 retries = 0;

	if (!t_info || !command_node) {
		pr_err("%s: Invalid handle/command node\n",
@@ -1273,6 +1276,20 @@ static enum cpe_process_result cpe_mt_process_cmd(

	case CPE_CMD_SEND_TRANS_MSG:
		m = (struct cpe_send_msg *)command_node->data;

		while (retries < CPE_SVC_INACTIVE_STATE_RETRIES_MAX) {
			if (t_info->tgt->tgt_is_active()) {
				++retries;
				/* Wait for CPE to be inactive */
				usleep_range(5000, 5100);
			} else {
				break;
			}
		}

		pr_debug("%s: cpe inactive after %d attempts\n",
			 __func__, retries);

		cpe_change_state(t_info, CPE_STATE_SENDING_MSG,
				CPE_SS_MSG_SEND_INBOX);
		rc = cpe_send_msg_to_inbox(t_info, 0, m);