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

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

ASoC: wcd-dsp-mgr: set status before broadcasting post events



During image download, the status is set after post download events
are broadcasted. This could possibly lead to race condition if other
drivers requested to boot the dsp before the status was set. Change
makes sure the wdsp status is set prior to broadcasting post download
events to avoid possible race conditions.

CRs-fixed: 1071949
Change-Id: If3ec6202b4729b24ee839c3a8aa4edf2482d6e59
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent d728aa90
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -376,6 +376,7 @@ static int wdsp_download_segments(struct wdsp_mgr_priv *wdsp,
	struct wdsp_cmpnt *ctl;
	struct wdsp_img_segment *seg = NULL;
	enum wdsp_event_type pre, post;
	long status;
	int ret;

	ctl = WDSP_GET_COMPONENT(wdsp, WDSP_CMPNT_CONTROL);
@@ -383,9 +384,11 @@ static int wdsp_download_segments(struct wdsp_mgr_priv *wdsp,
	if (type == WDSP_ELF_FLAG_RE) {
		pre = WDSP_EVENT_PRE_DLOAD_CODE;
		post = WDSP_EVENT_POST_DLOAD_CODE;
		status = WDSP_STATUS_CODE_DLOADED;
	} else if (type == WDSP_ELF_FLAG_WRITE) {
		pre = WDSP_EVENT_PRE_DLOAD_DATA;
		post = WDSP_EVENT_POST_DLOAD_DATA;
		status = WDSP_STATUS_DATA_DLOADED;
	} else {
		WDSP_ERR(wdsp, "Invalid type %u", type);
		return -EINVAL;
@@ -416,6 +419,8 @@ static int wdsp_download_segments(struct wdsp_mgr_priv *wdsp,
		}
	}

	WDSP_SET_STATUS(wdsp, status);

	/* Notify all components that image is downloaded */
	wdsp_broadcast_event_downseq(wdsp, post, NULL);

@@ -448,8 +453,6 @@ static int wdsp_init_and_dload_code_sections(struct wdsp_mgr_priv *wdsp)
		WDSP_ERR(wdsp, "Error %d to download code sections", ret);
		goto done;
	}

	WDSP_SET_STATUS(wdsp, WDSP_STATUS_CODE_DLOADED);
done:
	return ret;
}
@@ -488,8 +491,6 @@ static int wdsp_enable_dsp(struct wdsp_mgr_priv *wdsp)
		goto done;
	}

	WDSP_SET_STATUS(wdsp, WDSP_STATUS_DATA_DLOADED);

	wdsp_broadcast_event_upseq(wdsp, WDSP_EVENT_PRE_BOOTUP, NULL);

	ret = wdsp_unicast_event(wdsp, WDSP_CMPNT_CONTROL,