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

Commit 14ff0836 authored by Shashank Mittal's avatar Shashank Mittal
Browse files

soc: qcom: jtagv8-etm: fix race condition during probe



There can be a race condition when one core tries to read its etm data
while coming online, while other core is still writing etm data for same
cpu in jtag_mm_etm_probe.

Protect etm data with hotplug lock to avoid this race condition.

CRs-Fixed: 948917

Change-Id: Ie10a0f09520bf9388860ae2095b3af02c048d7ae
Signed-off-by: default avatarShashank Mittal <mittals@codeaurora.org>
parent 9f7af2ec
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -1556,7 +1556,6 @@ static int jtag_mm_etm_probe(struct platform_device *pdev, uint32_t cpu)
	if (!etmdata)
		return -ENOMEM;

	etm[cpu] = etmdata;

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "etm-base");
	if (!res)
@@ -1585,12 +1584,18 @@ static int jtag_mm_etm_probe(struct platform_device *pdev, uint32_t cpu)
	if (cnt++ == 0)
		register_hotcpu_notifier(&jtag_mm_etm_notifier);

	get_online_cpus();

	if (!smp_call_function_single(cpu, etm_init_arch_data, etmdata,
				      1))
		etmdata->init = true;

	if (etmdata->init) {
	etm[cpu] = etmdata;

	put_online_cpus();

	mutex_lock(&etmdata->mutex);
	if (etmdata->init && !etmdata->enable) {
		if (etm_arch_supported(etmdata->arch)) {
			if (scm_get_feat_version(TZ_DBG_ETM_FEAT_ID) <
			    TZ_DBG_ETM_VER)
@@ -1600,8 +1605,8 @@ static int jtag_mm_etm_probe(struct platform_device *pdev, uint32_t cpu)
		} else
			pr_info("etm arch %u not supported\n", etmdata->arch);
		etmdata->enable = true;
		mutex_unlock(&etmdata->mutex);
	}
	mutex_unlock(&etmdata->mutex);
	return 0;
}