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

Commit 199252c3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: glink_smem_native_xport: Add ipc logs for smem transport"

parents 88789f3d 4a052816
Loading
Loading
Loading
Loading
+77 −2
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@
#define RPM_FIFO_ADDR_ALIGN_BYTES 3
#define TRACER_PKT_FEATURE BIT(2)
#define DEFERRED_CMDS_THRESHOLD 25
#define NUM_LOG_PAGES	4

/**
 * enum command_types - definition of the types of commands sent/received
 * @VERSION_CMD:		Version and feature set supported
@@ -169,6 +171,7 @@ struct mailbox_config_info {
 * @tx_blocked_signal_sent:	Flag to indicate the flush signal has already
 *				been sent, and a response is pending from the
 *				remote side.  Protected by @write_lock.
 * @debug_mask			mask to set debugging level.
 * @kwork:			Work to be executed when an irq is received.
 * @kworker:			Handle to the entity processing of
				deferred commands.
@@ -189,6 +192,7 @@ struct mailbox_config_info {
 * @ramp_time_us:		Array of ramp times in microseconds where array
 *				index position represents a power state.
 * @mailbox:			Mailbox transport channel description reference.
 * @log_ctx:			Pointer to log context.
 */
struct edge_info {
	struct glink_transport_if xprt_if;
@@ -214,6 +218,7 @@ struct edge_info {
	wait_queue_head_t tx_blocked_queue;
	bool tx_resume_needed;
	bool tx_blocked_signal_sent;
	unsigned int debug_mask;
	struct kthread_work kwork;
	struct kthread_worker kworker;
	struct task_struct *task;
@@ -229,6 +234,7 @@ struct edge_info {
	uint32_t readback;
	unsigned long *ramp_time_us;
	struct mailbox_config_info *mailbox;
	void *log_ctx;
};

/**
@@ -261,6 +267,27 @@ static struct glink_core_version versions[] = {
	{1, TRACER_PKT_FEATURE, negotiate_features_v1},
};

#define SMEM_IPC_LOG(einfo, str, id, param1, param2) do { \
	if ((glink_xprt_debug_mask & QCOM_GLINK_DEBUG_ENABLE) \
		&& (einfo->debug_mask & QCOM_GLINK_DEBUG_ENABLE)) \
		ipc_log_string(einfo->log_ctx, \
				"%s: Rx:%x:%x Tx:%x:%x Cmd:%x P1:%x P2:%x\n", \
				str, einfo->rx_ch_desc->read_index, \
				einfo->rx_ch_desc->write_index, \
				einfo->tx_ch_desc->read_index, \
				einfo->tx_ch_desc->write_index, \
				id, param1, param2); \
} while (0) \

enum {
	QCOM_GLINK_DEBUG_ENABLE = 1U << 0,
	QCOM_GLINK_DEBUG_DISABLE = 1U << 1,
};

static unsigned int glink_xprt_debug_mask = QCOM_GLINK_DEBUG_ENABLE;
module_param_named(debug_mask, glink_xprt_debug_mask,
		   uint, 0664);

/**
 * send_irq() - send an irq to a remote entity as an event signal
 * @einfo:	Which remote entity that should receive the irq.
@@ -640,6 +667,7 @@ static void send_tx_blocked_signal(struct edge_info *einfo)
	read_notif_req.reserved = 0;
	read_notif_req.reserved2 = 0;

	SMEM_IPC_LOG(einfo, __func__, READ_NOTIF_CMD, 0, 0);
	if (!einfo->tx_blocked_signal_sent) {
		einfo->tx_blocked_signal_sent = true;
		fifo_write(einfo, &read_notif_req, sizeof(read_notif_req));
@@ -968,8 +996,12 @@ static void __rx_worker(struct edge_info *einfo, bool atomic_ctx)
			cmd.param2 = d_cmd->param2;
			cmd_data = d_cmd->data;
			kfree(d_cmd);
			SMEM_IPC_LOG(einfo, "kthread", cmd.id, cmd.param1,
								cmd.param2);
		} else {
			fifo_read(einfo, &cmd, sizeof(cmd));
			SMEM_IPC_LOG(einfo, "IRQ", cmd.id, cmd.param1,
								cmd.param2);
			cmd_data = NULL;
		}

@@ -1297,6 +1329,7 @@ static void tx_cmd_version(struct glink_transport_if *if_ptr, uint32_t version,
	cmd.version = version;
	cmd.features = features;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.version, cmd.features);
	fifo_tx(einfo, &cmd, sizeof(cmd));
	srcu_read_unlock(&einfo->use_ref, rcu_id);
}
@@ -1332,6 +1365,7 @@ static void tx_cmd_version_ack(struct glink_transport_if *if_ptr,
	cmd.version = version;
	cmd.features = features;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.version, cmd.features);
	fifo_tx(einfo, &cmd, sizeof(cmd));
	srcu_read_unlock(&einfo->use_ref, rcu_id);
}
@@ -1417,6 +1451,7 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
	memcpy(buf, &cmd, sizeof(cmd));
	memcpy(buf + sizeof(cmd), name, cmd.length);

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.length);
	fifo_tx(einfo, buf, buf_size);

	kfree(buf);
@@ -1455,6 +1490,7 @@ static int tx_cmd_ch_close(struct glink_transport_if *if_ptr, uint32_t lcid)
	cmd.lcid = lcid;
	cmd.reserved = 0;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.reserved);
	fifo_tx(einfo, &cmd, sizeof(cmd));

	srcu_read_unlock(&einfo->use_ref, rcu_id);
@@ -1492,6 +1528,7 @@ static void tx_cmd_ch_remote_open_ack(struct glink_transport_if *if_ptr,
	cmd.rcid = rcid;
	cmd.reserved = 0;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.rcid, cmd.reserved);
	fifo_tx(einfo, &cmd, sizeof(cmd));
	srcu_read_unlock(&einfo->use_ref, rcu_id);
}
@@ -1526,6 +1563,7 @@ static void tx_cmd_ch_remote_close_ack(struct glink_transport_if *if_ptr,
	cmd.rcid = rcid;
	cmd.reserved = 0;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.rcid, cmd.reserved);
	fifo_tx(einfo, &cmd, sizeof(cmd));
	srcu_read_unlock(&einfo->use_ref, rcu_id);
}
@@ -1686,6 +1724,7 @@ static int tx_cmd_local_rx_intent(struct glink_transport_if *if_ptr,
	cmd.size = size;
	cmd.liid = liid;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.count);
	fifo_tx(einfo, &cmd, sizeof(cmd));

	srcu_read_unlock(&einfo->use_ref, rcu_id);
@@ -1726,6 +1765,7 @@ static void tx_cmd_local_rx_done(struct glink_transport_if *if_ptr,
	cmd.lcid = lcid;
	cmd.liid = liid;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.liid);
	fifo_tx(einfo, &cmd, sizeof(cmd));
	srcu_read_unlock(&einfo->use_ref, rcu_id);
}
@@ -1771,6 +1811,7 @@ static int tx_cmd_rx_intent_req(struct glink_transport_if *if_ptr,
	cmd.lcid = lcid;
	cmd.size = size;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.size);
	fifo_tx(einfo, &cmd, sizeof(cmd));

	srcu_read_unlock(&einfo->use_ref, rcu_id);
@@ -1816,6 +1857,7 @@ static int tx_cmd_remote_rx_intent_req_ack(struct glink_transport_if *if_ptr,
	else
		cmd.response = 0;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.response);
	fifo_tx(einfo, &cmd, sizeof(cmd));

	srcu_read_unlock(&einfo->use_ref, rcu_id);
@@ -1854,6 +1896,7 @@ static int tx_cmd_set_sigs(struct glink_transport_if *if_ptr, uint32_t lcid,
	cmd.lcid = lcid;
	cmd.sigs = sigs;

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.sigs);
	fifo_tx(einfo, &cmd, sizeof(cmd));

	srcu_read_unlock(&einfo->use_ref, rcu_id);
@@ -2051,6 +2094,7 @@ static int tx_data(struct glink_transport_if *if_ptr, uint16_t cmd_id,
		return ret;
	}

	SMEM_IPC_LOG(einfo, __func__, cmd.id, cmd.lcid, cmd.riid);
	GLINK_DBG("%s %s: lcid[%u] riid[%u] cmd[%d], size[%d], size_left[%d]\n",
		"<SMEM>", __func__, cmd.lcid, cmd.riid, cmd.id, cmd.size,
		cmd.size_left);
@@ -2370,6 +2414,7 @@ static int glink_smem_native_probe(struct platform_device *pdev)
	uint32_t irq_mask;
	struct resource *r;
	u32 *cpu_array;
	char log_name[GLINK_NAME_SIZE*2+7] = {0};

	node = pdev->dev.of_node;

@@ -2529,6 +2574,16 @@ static int glink_smem_native_probe(struct platform_device *pdev)
		kfree(cpu_array);
	}

	einfo->debug_mask = QCOM_GLINK_DEBUG_ENABLE;
	snprintf(log_name, sizeof(log_name), "%s_%s_xprt",
			einfo->xprt_cfg.edge, einfo->xprt_cfg.name);
	if (einfo->debug_mask & QCOM_GLINK_DEBUG_ENABLE)
		einfo->log_ctx =
			ipc_log_context_create(NUM_LOG_PAGES, log_name, 0);
	if (!einfo->log_ctx)
		GLINK_ERR("%s: unable to create log context for [%s:%s]\n",
			__func__, einfo->xprt_cfg.edge,
			einfo->xprt_cfg.name);
	register_debugfs_info(einfo);
	/* fake an interrupt on this edge to see if the remote side is up */
	irq_handler(0, einfo);
@@ -2570,6 +2625,7 @@ static int glink_rpm_native_probe(struct platform_device *pdev)
	char toc[RPM_TOC_SIZE];
	uint32_t *tocp;
	uint32_t num_toc_entries;
	char log_name[GLINK_NAME_SIZE*2+7] = {0};

	node = pdev->dev.of_node;

@@ -2776,7 +2832,16 @@ static int glink_rpm_native_probe(struct platform_device *pdev)
	if (rc < 0)
		pr_err("%s: enable_irq_wake() failed on %d\n", __func__,
								irq_line);

	einfo->debug_mask = QCOM_GLINK_DEBUG_DISABLE;
	snprintf(log_name, sizeof(log_name), "%s_%s_xprt",
			einfo->xprt_cfg.edge, einfo->xprt_cfg.name);
	if (einfo->debug_mask & QCOM_GLINK_DEBUG_ENABLE)
		einfo->log_ctx =
			ipc_log_context_create(NUM_LOG_PAGES, log_name, 0);
	if (!einfo->log_ctx)
		GLINK_ERR("%s: unable to create log context for [%s:%s]\n",
			__func__, einfo->xprt_cfg.edge,
			einfo->xprt_cfg.name);
	register_debugfs_info(einfo);
	einfo->xprt_if.glink_core_if_ptr->link_up(&einfo->xprt_if);
	return 0;
@@ -2822,6 +2887,7 @@ static int glink_mailbox_probe(struct platform_device *pdev)
	struct mailbox_config_info *mbox_cfg;
	uint32_t mbox_cfg_size;
	phys_addr_t cfg_p_addr;
	char log_name[GLINK_NAME_SIZE*2+7] = {0};

	node = pdev->dev.of_node;

@@ -3020,7 +3086,16 @@ static int glink_mailbox_probe(struct platform_device *pdev)
	if (rc < 0)
		pr_err("%s: enable_irq_wake() failed on %d\n", __func__,
								irq_line);

	einfo->debug_mask = QCOM_GLINK_DEBUG_DISABLE;
	snprintf(log_name, sizeof(log_name), "%s_%s_xprt",
			einfo->xprt_cfg.edge, einfo->xprt_cfg.name);
	if (einfo->debug_mask & QCOM_GLINK_DEBUG_ENABLE)
		einfo->log_ctx =
			ipc_log_context_create(NUM_LOG_PAGES, log_name, 0);
	if (!einfo->log_ctx)
		GLINK_ERR("%s: unable to create log context for [%s:%s]\n",
			__func__, einfo->xprt_cfg.edge,
			einfo->xprt_cfg.name);
	register_debugfs_info(einfo);

	writel_relaxed(mbox_cfg_size, mbox_size);