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

Commit 0252e89f authored by Yuanfang Zhang's avatar Yuanfang Zhang Committed by Gerrit - the friendly Code Review server
Browse files

coresight-cti: Fix cpu-cti probe fail



A function whose return value is negative indicates
an error, not a non-zero value. A return value of
1 or 0 means the function executed successfully.
In many cases, the return value is negative, such
as dev->power.disable_depth > 0, dev->power.runtime_error
is set

Add verification to the coresight_cti_ctx_save and
coresight_cti_ctx_restore to ensure that the device
is in active status while reading and writing.

Change-Id: I37fd7618371e2f9ce41850c2004ccd95bf473e2c
Signed-off-by: default avatarYuanfang Zhang <zhangyuanfang@codeaurora.org>
parent e5466df0
Loading
Loading
Loading
Loading
+38 −22
Original line number Diff line number Diff line
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -166,15 +166,20 @@ void coresight_cti_ctx_save(void)
out:
		spin_lock_irqsave(&drvdata->spinlock, flag);
		drvdata->l2_off = true;
		drvdata->state->cticontrol = cti_readl(drvdata, CTICONTROL);
		drvdata->state->ctiappset = cti_readl(drvdata, CTIAPPSET);
		drvdata->state->ctigate = cti_readl(drvdata, CTIGATE);
		if (drvdata->refcnt) {
			drvdata->state->cticontrol =
					cti_readl(drvdata, CTICONTROL);
			drvdata->state->ctiappset =
					cti_readl(drvdata, CTIAPPSET);
			drvdata->state->ctigate =
					cti_readl(drvdata, CTIGATE);
			for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
				drvdata->state->ctiinen[trig] =
					cti_readl(drvdata, CTIINEN(trig));
				drvdata->state->ctiouten[trig] =
					cti_readl(drvdata, CTIOUTEN(trig));
			}
		}
		spin_unlock_irqrestore(&drvdata->spinlock, flag);
	}
}
@@ -209,17 +214,22 @@ void coresight_cti_ctx_restore(void)
		continue;
out:
		spin_lock_irqsave(&drvdata->spinlock, flag);
		if (drvdata->refcnt) {
			CTI_UNLOCK(drvdata);
		cti_writel(drvdata, drvdata->state->ctiappset, CTIAPPSET);
		cti_writel(drvdata, drvdata->state->ctigate, CTIGATE);
			cti_writel(drvdata, drvdata->state->ctiappset,
				CTIAPPSET);
			cti_writel(drvdata, drvdata->state->ctigate,
				CTIGATE);
			for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) {
			cti_writel(drvdata, drvdata->state->ctiinen[trig],
				   CTIINEN(trig));
			cti_writel(drvdata, drvdata->state->ctiouten[trig],
				   CTIOUTEN(trig));
				cti_writel(drvdata,
				drvdata->state->ctiinen[trig], CTIINEN(trig));
				cti_writel(drvdata,
				drvdata->state->ctiouten[trig], CTIOUTEN(trig));
			}
		cti_writel(drvdata, drvdata->state->cticontrol, CTICONTROL);
			cti_writel(drvdata, drvdata->state->cticontrol,
				CTICONTROL);
			CTI_LOCK(drvdata);
		}
		drvdata->l2_off = false;
		spin_unlock_irqrestore(&drvdata->spinlock, flag);
	}
@@ -380,9 +390,11 @@ int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch)
	 */
	if (drvdata->refcnt == 0) {
		ret = pm_runtime_get_sync(drvdata->dev);
		if (ret)
		if (ret < 0) {
			pm_runtime_put(drvdata->dev);
			goto err1;
		}
	}

	spin_lock_irqsave(&drvdata->spinlock, flag);
	ret = cti_cpu_verify_access(drvdata);
@@ -464,9 +476,11 @@ int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch)
	 */
	if (drvdata->refcnt == 0) {
		ret = pm_runtime_get_sync(drvdata->dev);
		if (ret)
		if (ret < 0) {
			pm_runtime_put(drvdata->dev);
			goto err1;
		}
	}

	spin_lock_irqsave(&drvdata->spinlock, flag);
	ret = cti_cpu_verify_access(drvdata);
@@ -1472,9 +1486,11 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id)
	}
	if (drvdata->cti_save && !drvdata->cti_hwclk) {
		ret = pm_runtime_get_sync(drvdata->dev);
		if (ret)
		if (ret < 0) {
			pm_runtime_put(drvdata->dev);
			return ret;
		}
	}

	mutex_lock(&cti_lock);
	drvdata->cti.name = ((struct coresight_platform_data *)