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

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

Merge "diag: Add SMD support"

parents f5b1ce62 d6da1cb3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -34,4 +34,11 @@ config DIAGFWD_BRIDGE_CODE
	  become available, this bridge driver enables DIAG traffic over MHI
	  and SMUX.

config DIAG_USES_SMD
	bool "Enable diag internal interface over SMD"
	depends on DIAG_CHAR && MSM_SMD
	help
	  Diag over SMD enables exchanging diagnostic information between
	  application processor and peripherals over SDM.

endmenu
+1 −0
Original line number Diff line number Diff line
@@ -3,4 +3,5 @@ obj-$(CONFIG_DIAGFWD_BRIDGE_CODE) += diagfwd_bridge.o
obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_hsic.o
obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diagfwd_smux.o
obj-$(CONFIG_MSM_MHI) += diagfwd_mhi.o
obj-$(CONFIG_DIAG_USES_SMD) += diagfwd_smd.o
diagchar-objs := diagchar_core.o diagchar_hdlc.o diagfwd.o diagfwd_glink.o diagfwd_peripheral.o diagfwd_socket.o diag_mux.o diag_memorydevice.o diag_usb.o diagmem.o diagfwd_cntl.o diag_dci.o diag_masks.o diag_debugfs.o
+122 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "diag_dci.h"
#include "diag_usb.h"
#include "diagfwd_peripheral.h"
#include "diagfwd_smd.h"
#include "diagfwd_socket.h"
#include "diagfwd_glink.h"
#include "diag_debugfs.h"
@@ -42,6 +43,7 @@ static struct dentry *diag_dbgfs_dent;
static int diag_dbgfs_table_index;
static int diag_dbgfs_mempool_index;
static int diag_dbgfs_usbinfo_index;
static int diag_dbgfs_smdinfo_index;
static int diag_dbgfs_socketinfo_index;
static int diag_dbgfs_glinkinfo_index;
static int diag_dbgfs_hsicinfo_index;
@@ -479,6 +481,112 @@ static ssize_t diag_dbgfs_read_usbinfo(struct file *file, char __user *ubuf,
	return ret;
}

#ifdef CONFIG_DIAG_USES_SMD
static ssize_t diag_dbgfs_read_smdinfo(struct file *file, char __user *ubuf,
				       size_t count, loff_t *ppos)
{
	char *buf = NULL;
	int ret = 0;
	int i = 0;
	int j = 0;
	unsigned int buf_size;
	unsigned int bytes_remaining = 0;
	unsigned int bytes_written = 0;
	unsigned int bytes_in_buffer = 0;
	struct diag_smd_info *smd_info = NULL;
	struct diagfwd_info *fwd_ctxt = NULL;

	if (diag_dbgfs_smdinfo_index >= NUM_PERIPHERALS) {
		/* Done. Reset to prepare for future requests */
		diag_dbgfs_smdinfo_index = 0;
		return 0;
	}

	buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	buf_size = DEBUG_BUF_SIZE;
	bytes_remaining = buf_size;
	for (i = 0; i < NUM_TYPES; i++) {
		for (j = 0; j < NUM_PERIPHERALS; j++) {
			switch (i) {
			case TYPE_DATA:
				smd_info = &smd_data[j];
				break;
			case TYPE_CNTL:
				smd_info = &smd_cntl[j];
				break;
			case TYPE_DCI:
				smd_info = &smd_dci[j];
				break;
			case TYPE_CMD:
				smd_info = &smd_cmd[j];
				break;
			case TYPE_DCI_CMD:
				smd_info = &smd_dci_cmd[j];
				break;
			default:
				return -EINVAL;
			}

			fwd_ctxt = (struct diagfwd_info *)(smd_info->fwd_ctxt);

			bytes_written = scnprintf(buf+bytes_in_buffer,
				bytes_remaining,
				"name\t\t:\t%s\n"
				"hdl\t\t:\t%pK\n"
				"inited\t\t:\t%d\n"
				"opened\t\t:\t%d\n"
				"diag_state\t:\t%d\n"
				"fifo size\t:\t%d\n"
				"open pending\t:\t%d\n"
				"close pending\t:\t%d\n"
				"read pending\t:\t%d\n"
				"buf_1 busy\t:\t%d\n"
				"buf_2 busy\t:\t%d\n"
				"bytes read\t:\t%lu\n"
				"bytes written\t:\t%lu\n"
				"fwd inited\t:\t%d\n"
				"fwd opened\t:\t%d\n"
				"fwd ch_open\t:\t%d\n\n",
				smd_info->name,
				smd_info->hdl,
				smd_info->inited,
				atomic_read(&smd_info->opened),
				atomic_read(&smd_info->diag_state),
				smd_info->fifo_size,
				work_pending(&smd_info->open_work),
				work_pending(&smd_info->close_work),
				work_pending(&smd_info->read_work),
				(fwd_ctxt && fwd_ctxt->buf_1) ?
				atomic_read(&fwd_ctxt->buf_1->in_busy) : -1,
				(fwd_ctxt && fwd_ctxt->buf_2) ?
				atomic_read(&fwd_ctxt->buf_2->in_busy) : -1,
				(fwd_ctxt) ? fwd_ctxt->read_bytes : 0,
				(fwd_ctxt) ? fwd_ctxt->write_bytes : 0,
				(fwd_ctxt) ? fwd_ctxt->inited : -1,
				(fwd_ctxt) ?
				atomic_read(&fwd_ctxt->opened) : -1,
				(fwd_ctxt) ? fwd_ctxt->ch_open : -1);
			bytes_in_buffer += bytes_written;

			/* Check if there is room to add another table entry */
			bytes_remaining = buf_size - bytes_in_buffer;

			if (bytes_remaining < bytes_written)
				break;
		}
	}
	diag_dbgfs_smdinfo_index = i+1;
	*ppos = 0;
	ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer);

	kfree(buf);
	return ret;
}
#endif

static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
					  size_t count, loff_t *ppos)
{
@@ -944,6 +1052,12 @@ const struct file_operations diag_dbgfs_status_ops = {
	.read = diag_dbgfs_read_status,
};

#ifdef CONFIG_DIAG_USES_SMD
static const struct file_operations diag_dbgfs_smdinfo_ops = {
	.read = diag_dbgfs_read_smdinfo,
};
#endif

const struct file_operations diag_dbgfs_socketinfo_ops = {
	.read = diag_dbgfs_read_socketinfo,
};
@@ -989,6 +1103,13 @@ int diag_debugfs_init(void)
	if (!entry)
		goto err;

#ifdef CONFIG_DIAG_USES_SMD
	entry = debugfs_create_file("smdinfo", 0444, diag_dbgfs_dent, NULL,
				    &diag_dbgfs_smdinfo_ops);
	if (!entry)
		goto err;
#endif

	entry = debugfs_create_file("socketinfo", 0444, diag_dbgfs_dent, 0,
				    &diag_dbgfs_socketinfo_ops);
	if (!entry)
@@ -1050,6 +1171,7 @@ int diag_debugfs_init(void)
	diag_dbgfs_table_index = 0;
	diag_dbgfs_mempool_index = 0;
	diag_dbgfs_usbinfo_index = 0;
	diag_dbgfs_smdinfo_index = 0;
	diag_dbgfs_socketinfo_index = 0;
	diag_dbgfs_hsicinfo_index = 0;
	diag_dbgfs_bridgeinfo_index = 0;
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/workqueue.h>
#include <linux/sched.h>
#include <linux/device.h>
#include <soc/qcom/smd.h>
#include <linux/atomic.h>
#include "diagfwd_bridge.h"

+5 −0
Original line number Diff line number Diff line
@@ -333,8 +333,13 @@ static void diag_close_transport_work_fn(struct work_struct *work)
		if (!(driver->close_transport & PERIPHERAL_MASK(peripheral)))
			continue;
		driver->close_transport ^= PERIPHERAL_MASK(peripheral);
#ifdef CONFIG_DIAG_USES_SMD
		transport = driver->feature[peripheral].sockets_enabled ?
					TRANSPORT_SMD : TRANSPORT_SOCKET;
#else
		transport = driver->feature[peripheral].sockets_enabled ?
					TRANSPORT_GLINK : TRANSPORT_SOCKET;
#endif
		diagfwd_close_transport(transport, peripheral);
	}
	mutex_unlock(&driver->cntl_lock);
Loading