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

Commit 5bb16305 authored by Tharun Kumar Merugu's avatar Tharun Kumar Merugu
Browse files

msm: adsprpc: log all rpmsg transactions of fastrpc



Log all rpmsg transcations in the fastrpc driver using separate
contexts for each remote subsystem, if Kconfig debug flag is
enabled.

Change-Id: Ida5088ae5e3985898d7e72a7b967d6fb2e3d1e4e
Acked-by: default avatarThyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
parent 30351587
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ config MSM_FASTCVPD
	  subsystems crash.

config MSM_ADSPRPC
        tristate "QTI ADSP RPC driver"
	tristate "QTI FastRPC driver"
	depends on QCOM_GLINK
	help
		Provides a communication mechanism that allows clients to
@@ -559,6 +559,14 @@ config MSM_ADSPRPC
		applications/compute DSP processor.
		Say M if you want to enable this module.

config ADSPRPC_DEBUG
	bool "Debug logs in FastRPC driver"
	help
		Enable debug logs in the fastrpc driver. Flag will be
		disabled by default to maximize RPC performance as debug
		logging will impact RPC overhead.
		Say Y here if you want to enable the logs.

config MSM_RDBG
	tristate "QTI Remote debug driver"
	help
+59 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/msm_ion.h>
#include <soc/qcom/secure_buffer.h>
#include <linux/rpmsg.h>
#include <linux/ipc_logging.h>
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/subsystem_restart.h>
#include <soc/qcom/service-notifier.h>
@@ -129,6 +130,15 @@
			(int64_t *)(perf_ptr + offset)\
				: (int64_t *)NULL) : (int64_t *)NULL)

#define FASTRPC_GLINK_LOG_PAGES 8
#define LOG_FASTRPC_GLINK_MSG(ctx, x, ...)	\
	do {				\
		if (ctx)		\
			ipc_log_string(ctx, "%s (%d, %d): "x,	\
				current->comm, current->tgid, current->pid, \
				##__VA_ARGS__); \
	} while (0)

static int fastrpc_pdr_notifier_cb(struct notifier_block *nb,
					unsigned long code,
					void *data);
@@ -295,6 +305,7 @@ struct fastrpc_channel_ctx {
	/* Indicates, if channel is restricted to secure node only */
	int secure;
	struct fastrpc_dsp_capabilities dsp_cap_kernel;
	void *ipc_log_ctx;
};

struct fastrpc_apps {
@@ -1858,6 +1869,10 @@ static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
		goto bail;
	}
	err = rpmsg_send(channel_ctx->rpdev->ept, (void *)msg, sizeof(*msg));
	LOG_FASTRPC_GLINK_MSG(channel_ctx->ipc_log_ctx,
		"sent pkt %pK (sz %d): ctx 0x%llx, handle 0x%x, sc 0x%x (rpmsg err %d)",
		(void *)msg, sizeof(*msg),
		msg->invoke.header.ctx, handle, ctx->sc, err);
	mutex_unlock(&channel_ctx->rpmsg_mutex);
 bail:
	return err;
@@ -2950,10 +2965,9 @@ static int fastrpc_session_alloc_locked(struct fastrpc_channel_ctx *chan,
	return err;
}

static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
static inline int get_cid_from_rpdev(struct rpmsg_device *rpdev)
{
	int err = 0;
	int cid = -1;
	int err = 0, cid = -1;

	VERIFY(err, !IS_ERR_OR_NULL(rpdev));
	if (err)
@@ -2968,6 +2982,19 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
	else if (!strcmp(rpdev->dev.parent->of_node->name, "mdsp"))
		cid = MDSP_DOMAIN_ID;

	return cid;
}

static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
{
	int err = 0;
	int cid = -1;

	VERIFY(err, !IS_ERR_OR_NULL(rpdev));
	if (err)
		return -EINVAL;

	cid = get_cid_from_rpdev(rpdev);
	VERIFY(err, cid >= 0 && cid < NUM_CHANNELS);
	if (err)
		goto bail;
@@ -2976,6 +3003,19 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
	mutex_unlock(&gcinfo[cid].rpmsg_mutex);
	pr_info("adsprpc: %s: opened rpmsg channel for %s\n",
		__func__, gcinfo[cid].subsys);

#if IS_ENABLED(CONFIG_ADSPRPC_DEBUG)
	if (!gcinfo[cid].ipc_log_ctx)
		gcinfo[cid].ipc_log_ctx =
			ipc_log_context_create(FASTRPC_GLINK_LOG_PAGES,
				gcinfo[cid].name, 0);
	if (!gcinfo[cid].ipc_log_ctx)
		pr_warn("adsprpc: %s: failed to create IPC log context for %s\n",
			__func__, gcinfo[cid].subsys);
	else
		pr_info("adsprpc: %s: enabled IPC logging for %s\n",
			__func__, gcinfo[cid].subsys);
#endif
bail:
	if (err)
		pr_err("adsprpc: rpmsg probe of %s cid %d failed\n",
@@ -2993,15 +3033,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
	if (err)
		return;

	if (!strcmp(rpdev->dev.parent->of_node->name, "cdsp"))
		cid = CDSP_DOMAIN_ID;
	else if (!strcmp(rpdev->dev.parent->of_node->name, "adsp"))
		cid = ADSP_DOMAIN_ID;
	else if (!strcmp(rpdev->dev.parent->of_node->name, "dsps"))
		cid = SDSP_DOMAIN_ID;
	else if (!strcmp(rpdev->dev.parent->of_node->name, "mdsp"))
		cid = MDSP_DOMAIN_ID;

	cid = get_cid_from_rpdev(rpdev);
	VERIFY(err, cid >= 0 && cid < NUM_CHANNELS);
	if (err)
		goto bail;
@@ -3029,6 +3061,17 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
	if (err)
		goto bail;

#if IS_ENABLED(CONFIG_ADSPRPC_DEBUG)
	int cid = -1;

	cid = get_cid_from_rpdev(rpdev);
	if (cid >= 0 && cid < NUM_CHANNELS) {
		LOG_FASTRPC_GLINK_MSG(gcinfo[cid].ipc_log_ctx,
			"recvd pkt %pK (sz %d): ctx 0x%llx, retVal %d",
			data, len, rsp->ctx, rsp->retval);
	}
#endif

	index = (uint32_t)((rsp->ctx & FASTRPC_CTXID_MASK) >> 4);
	VERIFY(err, index < FASTRPC_CTX_MAX);
	if (err)
@@ -3046,7 +3089,8 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
	context_notify_user(me->ctxtable[index], rsp->retval);
bail:
	if (err)
		pr_err("adsprpc: invalid response or context (err %d)\n", err);
		pr_err("adsprpc: ERROR: %s: invalid response (data %pK, len %d) from remote subsystem (err %d)\n",
				__func__, data, len, err);
	return err;
}

@@ -4505,6 +4549,8 @@ static void __exit fastrpc_device_exit(void)
	for (i = 0; i < NUM_CHANNELS; i++) {
		if (!gcinfo[i].name)
			continue;
		if (me->channel[i].ipc_log_ctx)
			ipc_log_context_destroy(me->channel[i].ipc_log_ctx);
		subsys_notif_unregister_notifier(me->channel[i].handle,
						&me->channel[i].nb);
	}