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

Commit 2f1e2239 authored by Xiaogang Cui's avatar Xiaogang Cui Committed by Gerrit - the friendly Code Review server
Browse files

coresight: add delayed bootup enabling support for remote etm



Remote process ETM driver uses QMI message to enable remote
ETMs, which depends on QMI service. Add boot enable support to
enable remote ETMs once QMI service is ready.

Change-Id: I910e5da329cd46c4412803eefe473a3591f934ad
Signed-off-by: default avatarXiaogang Cui <xiaogang@codeaurora.org>
parent 9d17b246
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -241,6 +241,14 @@ config CORESIGHT_REMOTE_ETM
	  tracing on remote processor via sysfs by configuring the required
	  CoreSight components.

config CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE
	int "default enable bits for Remote processor ETM"
	depends on CORESIGHT_REMOTE_ETM
	default 0
	help
	  Support for enabling separated Remote processor ETM tracing. Depends
	  on if instance id bit is set.

endif

config CORESIGHT_QPDI
+33 −8
Original line number Diff line number Diff line
@@ -25,7 +25,12 @@
#include <linux/coresight.h>
#include "coresight-qmi.h"

#ifdef CONFIG_CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE
static int boot_enable = CONFIG_CORESIGHT_REMOTE_ETM_DEFAULT_ENABLE;
#else
static int boot_enable;
#endif

module_param_named(
	boot_enable, boot_enable, int, S_IRUGO
);
@@ -41,6 +46,8 @@ struct remote_etm_drvdata {
	struct work_struct		work_rcv_msg;
	struct notifier_block		nb;
	uint32_t			inst_id;
	struct delayed_work		work_delay_enable;
	bool				enable;
};

static int remote_etm_enable(struct coresight_device *csdev)
@@ -66,9 +73,9 @@ static int remote_etm_enable(struct coresight_device *csdev)
	 */
	if (!drvdata->handle) {
		dev_info(drvdata->dev,
			 "%s: QMI service unavailable. Skipping QMI requests\n",
			 __func__);
		goto out;
			 "%s: QMI service unavailable\n",  __func__);
		ret = -EINVAL;
		goto err;
	}

	req.state = CORESIGHT_ETM_STATE_ENABLED_V01;
@@ -96,7 +103,7 @@ static int remote_etm_enable(struct coresight_device *csdev)
		ret = -EREMOTEIO;
		goto err;
	}
out:
	drvdata->enable = true;
	mutex_unlock(&drvdata->mutex);

	dev_info(drvdata->dev, "Remote ETM tracing enabled\n");
@@ -119,9 +126,8 @@ static void remote_etm_disable(struct coresight_device *csdev)

	if (!drvdata->handle) {
		dev_info(drvdata->dev,
			 "%s: QMI service unavailable. Skipping QMI requests\n",
			 __func__);
		goto out;
			 "%s: QMI service unavailable\n",  __func__);
		goto err;
	}

	req.state = CORESIGHT_ETM_STATE_DISABLED_V01;
@@ -147,7 +153,7 @@ static void remote_etm_disable(struct coresight_device *csdev)
			__func__, resp.resp.result, resp.resp.error);
		goto err;
	}
out:
	drvdata->enable = false;
	mutex_unlock(&drvdata->mutex);

	dev_info(drvdata->dev, "Remote ETM tracing disabled\n");
@@ -190,6 +196,14 @@ static void remote_etm_notify(struct qmi_handle *handle,
	}
}

static void remote_delay_enable_handler(struct work_struct *work)
{
	struct remote_etm_drvdata *drvdata = container_of(work,
						struct remote_etm_drvdata,
						work_delay_enable.work);
	coresight_enable(drvdata->csdev);
}

static void remote_etm_svc_arrive(struct work_struct *work)
{
	struct remote_etm_drvdata *drvdata = container_of(work,
@@ -211,6 +225,15 @@ static void remote_etm_svc_arrive(struct work_struct *work)
		qmi_handle_destroy(drvdata->handle);
		drvdata->handle = NULL;
	}

	mutex_lock(&drvdata->mutex);
	if (drvdata->inst_id < sizeof(int)*BITS_PER_BYTE
	    && (boot_enable & BIT(drvdata->inst_id))) {
		if (!drvdata->enable)
			schedule_delayed_work(&drvdata->work_delay_enable,
					      msecs_to_jiffies(TIMEOUT_MS));
	}
	mutex_unlock(&drvdata->mutex);
}

static void remote_etm_svc_exit(struct work_struct *work)
@@ -283,6 +306,8 @@ static int remote_etm_probe(struct platform_device *pdev)
	INIT_WORK(&drvdata->work_svc_arrive, remote_etm_svc_arrive);
	INIT_WORK(&drvdata->work_svc_exit, remote_etm_svc_exit);
	INIT_WORK(&drvdata->work_rcv_msg, remote_etm_rcv_msg);
	INIT_DELAYED_WORK(&drvdata->work_delay_enable,
			  remote_delay_enable_handler);
	ret = qmi_svc_event_notifier_register(CORESIGHT_QMI_SVC_ID,
					      CORESIGHT_QMI_VERSION,
					      drvdata->inst_id,