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

Commit 65033f75 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Add diag support for NPU"

parents be1ecaca 636eed4d
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@
#define DIAG_CON_SENSORS	(0x0010)	/* Bit mask for Sensors */
#define DIAG_CON_WDSP		(0x0020)	/* Bit mask for WDSP */
#define DIAG_CON_CDSP		(0x0040)	/* Bit mask for CDSP */
#define DIAG_CON_NPU		(0x0080)	/* Bit mask for NPU */

#define DIAG_CON_UPD_WLAN		(0x1000) /*Bit mask for WLAN PD*/
#define DIAG_CON_UPD_AUDIO		(0x2000) /*Bit mask for AUDIO PD*/
@@ -74,7 +75,7 @@
#define DIAG_CON_ALL		(DIAG_CON_APSS | DIAG_CON_MPSS \
				| DIAG_CON_LPASS | DIAG_CON_WCNSS \
				| DIAG_CON_SENSORS | DIAG_CON_WDSP \
				| DIAG_CON_CDSP)
				| DIAG_CON_CDSP | DIAG_CON_NPU)
#define DIAG_CON_UPD_ALL	(DIAG_CON_UPD_WLAN \
				| DIAG_CON_UPD_AUDIO \
				| DIAG_CON_UPD_SENSORS)
@@ -85,6 +86,7 @@
#define DIAG_STM_APPS	0x08
#define DIAG_STM_SENSORS 0x10
#define DIAG_STM_CDSP 0x20
#define DIAG_STM_NPU 0x40

#define INVALID_PID		-1
#define DIAG_CMD_FOUND		1
@@ -212,12 +214,13 @@
#define PERIPHERAL_SENSORS	3
#define PERIPHERAL_WDSP		4
#define PERIPHERAL_CDSP		5
#define NUM_PERIPHERALS		6
#define PERIPHERAL_NPU		6
#define NUM_PERIPHERALS		7
#define APPS_DATA		(NUM_PERIPHERALS)

#define UPD_WLAN		7
#define UPD_AUDIO		8
#define UPD_SENSORS		9
#define UPD_WLAN		8
#define UPD_AUDIO		9
#define UPD_SENSORS		10
#define NUM_UPD			3

#define MAX_PERIPHERAL_UPD			2
@@ -489,6 +492,7 @@ struct diag_query_pid_t {
struct diag_con_all_param_t {
	uint32_t diag_con_all;
	uint32_t num_peripherals;
	uint32_t upd_map_supported;
};

struct diag_md_session_t {
+7 −0
Original line number Diff line number Diff line
@@ -381,6 +381,8 @@ static uint32_t diag_translate_kernel_to_user_mask(uint32_t peripheral_mask)
		ret |= DIAG_CON_WDSP;
	if (peripheral_mask & MD_PERIPHERAL_MASK(PERIPHERAL_CDSP))
		ret |= DIAG_CON_CDSP;
	if (peripheral_mask & MD_PERIPHERAL_MASK(PERIPHERAL_NPU))
		ret |= DIAG_CON_NPU;
	if (peripheral_mask & MD_PERIPHERAL_MASK(UPD_WLAN))
		ret |= DIAG_CON_UPD_WLAN;
	if (peripheral_mask & MD_PERIPHERAL_MASK(UPD_AUDIO))
@@ -1655,6 +1657,8 @@ static uint32_t diag_translate_mask(uint32_t peripheral_mask)
		ret |= (1 << PERIPHERAL_WDSP);
	if (peripheral_mask & DIAG_CON_CDSP)
		ret |= (1 << PERIPHERAL_CDSP);
	if (peripheral_mask & DIAG_CON_NPU)
		ret |= (1 << PERIPHERAL_NPU);
	if (peripheral_mask & DIAG_CON_UPD_WLAN)
		ret |= (1 << UPD_WLAN);
	if (peripheral_mask & DIAG_CON_UPD_AUDIO)
@@ -2278,6 +2282,8 @@ int diag_query_pd(char *process_name)
		return PERIPHERAL_SENSORS;
	if (diag_query_pd_name(process_name, "cdsp/root_pd"))
		return PERIPHERAL_CDSP;
	if (diag_query_pd_name(process_name, "npu/root_pd"))
		return PERIPHERAL_NPU;
	if (diag_query_pd_name(process_name, "wlan_pd"))
		return UPD_WLAN;
	if (diag_query_pd_name(process_name, "audio_pd"))
@@ -2683,6 +2689,7 @@ long diagchar_compat_ioctl(struct file *filp,
	case DIAG_IOCTL_QUERY_CON_ALL:
		con_param.diag_con_all = DIAG_CON_ALL;
		con_param.num_peripherals = NUM_PERIPHERALS;
		con_param.upd_map_supported = 1;
		if (copy_to_user((void __user *)ioarg, &con_param,
				sizeof(struct diag_con_all_param_t)))
			result = -EFAULT;
+86 −55
Original line number Diff line number Diff line
@@ -554,63 +554,10 @@ void diag_process_stm_mask(uint8_t cmd, uint8_t data_mask, int data_type)
	}
}

int diag_process_stm_cmd(unsigned char *buf, unsigned char *dest_buf)
static uint8_t diag_get_stm_peripheral_mask(void)
{
	uint8_t version, mask, cmd;
	uint8_t rsp_supported = 0;
	uint8_t rsp_status = 0;
	int i;

	if (!buf || !dest_buf) {
		pr_err("diag: Invalid pointers buf: %pK, dest_buf %pK in %s\n",
		       buf, dest_buf, __func__);
		return -EIO;
	}

	version = *(buf + STM_CMD_VERSION_OFFSET);
	mask = *(buf + STM_CMD_MASK_OFFSET);
	cmd = *(buf + STM_CMD_DATA_OFFSET);

	/*
	 * Check if command is valid. If the command is asking for
	 * status, then the processor mask field is to be ignored.
	 */
	if ((version != 2) || (cmd > STM_AUTO_QUERY) ||
		((cmd != STATUS_STM && cmd != STM_AUTO_QUERY) &&
		((mask == 0) || (0 != (mask >> (NUM_PERIPHERALS + 1)))))) {
		/* Command is invalid. Send bad param message response */
		dest_buf[0] = BAD_PARAM_RESPONSE_MESSAGE;
		for (i = 0; i < STM_CMD_NUM_BYTES; i++)
			dest_buf[i+1] = *(buf + i);
		return STM_CMD_NUM_BYTES+1;
	} else if (cmd != STATUS_STM && cmd != STM_AUTO_QUERY) {
		if (mask & DIAG_STM_MODEM)
			diag_process_stm_mask(cmd, DIAG_STM_MODEM,
					      PERIPHERAL_MODEM);

		if (mask & DIAG_STM_LPASS)
			diag_process_stm_mask(cmd, DIAG_STM_LPASS,
					      PERIPHERAL_LPASS);

		if (mask & DIAG_STM_WCNSS)
			diag_process_stm_mask(cmd, DIAG_STM_WCNSS,
					      PERIPHERAL_WCNSS);

		if (mask & DIAG_STM_SENSORS)
			diag_process_stm_mask(cmd, DIAG_STM_SENSORS,
						PERIPHERAL_SENSORS);
		if (mask & DIAG_STM_CDSP)
			diag_process_stm_mask(cmd, DIAG_STM_CDSP,
						PERIPHERAL_CDSP);

		if (mask & DIAG_STM_APPS)
			diag_process_stm_mask(cmd, DIAG_STM_APPS, APPS_DATA);
	}

	for (i = 0; i < STM_CMD_NUM_BYTES; i++)
		dest_buf[i] = *(buf + i);

	/* Set mask denoting which peripherals support STM */
	if (driver->feature[PERIPHERAL_MODEM].stm_support)
		rsp_supported |= DIAG_STM_MODEM;

@@ -626,9 +573,18 @@ int diag_process_stm_cmd(unsigned char *buf, unsigned char *dest_buf)
	if (driver->feature[PERIPHERAL_CDSP].stm_support)
		rsp_supported |= DIAG_STM_CDSP;

	if (driver->feature[PERIPHERAL_NPU].stm_support)
		rsp_supported |= DIAG_STM_NPU;

	rsp_supported |= DIAG_STM_APPS;

	/* Set mask denoting STM state/status for each peripheral/APSS */
	return rsp_supported;
}

static uint8_t diag_get_stm_state_for_peripherals(void)
{
	uint8_t rsp_status = 0;

	if (driver->stm_state[PERIPHERAL_MODEM])
		rsp_status |= DIAG_STM_MODEM;

@@ -644,9 +600,84 @@ int diag_process_stm_cmd(unsigned char *buf, unsigned char *dest_buf)
	if (driver->stm_state[PERIPHERAL_CDSP])
		rsp_status |= DIAG_STM_CDSP;

	if (driver->stm_state[PERIPHERAL_NPU])
		rsp_status |= DIAG_STM_NPU;

	if (driver->stm_state[APPS_DATA])
		rsp_status |= DIAG_STM_APPS;

	return rsp_status;
}

static void diag_process_stm_mask_for_peripherals(uint8_t cmd, uint8_t mask)
{
	if (mask & DIAG_STM_MODEM)
		diag_process_stm_mask(cmd, DIAG_STM_MODEM,
					      PERIPHERAL_MODEM);

	if (mask & DIAG_STM_LPASS)
		diag_process_stm_mask(cmd, DIAG_STM_LPASS,
					      PERIPHERAL_LPASS);

	if (mask & DIAG_STM_WCNSS)
		diag_process_stm_mask(cmd, DIAG_STM_WCNSS,
					      PERIPHERAL_WCNSS);

	if (mask & DIAG_STM_SENSORS)
		diag_process_stm_mask(cmd, DIAG_STM_SENSORS,
						PERIPHERAL_SENSORS);
	if (mask & DIAG_STM_CDSP)
		diag_process_stm_mask(cmd, DIAG_STM_CDSP,
						PERIPHERAL_CDSP);
	if (mask & DIAG_STM_NPU)
		diag_process_stm_mask(cmd, DIAG_STM_NPU,
						PERIPHERAL_NPU);

	if (mask & DIAG_STM_APPS)
		diag_process_stm_mask(cmd, DIAG_STM_APPS, APPS_DATA);
}

int diag_process_stm_cmd(unsigned char *buf, unsigned char *dest_buf)
{
	uint8_t version, mask, cmd;
	uint8_t rsp_supported = 0;
	uint8_t rsp_status = 0;
	int i;

	if (!buf || !dest_buf) {
		pr_err("diag: Invalid pointers buf: %pK, dest_buf %pK in %s\n",
		       buf, dest_buf, __func__);
		return -EIO;
	}

	version = *(buf + STM_CMD_VERSION_OFFSET);
	mask = *(buf + STM_CMD_MASK_OFFSET);
	cmd = *(buf + STM_CMD_DATA_OFFSET);

	/*
	 * Check if command is valid. If the command is asking for
	 * status, then the processor mask field is to be ignored.
	 */
	if ((version != 2) || (cmd > STM_AUTO_QUERY) ||
		((cmd != STATUS_STM && cmd != STM_AUTO_QUERY) &&
		((mask == 0) || (0 != (mask >> (NUM_PERIPHERALS + 1)))))) {
		/* Command is invalid. Send bad param message response */
		dest_buf[0] = BAD_PARAM_RESPONSE_MESSAGE;
		for (i = 0; i < STM_CMD_NUM_BYTES; i++)
			dest_buf[i+1] = *(buf + i);
		return STM_CMD_NUM_BYTES+1;
	} else if (cmd != STATUS_STM && cmd != STM_AUTO_QUERY)
		diag_process_stm_mask_for_peripherals(cmd, mask);

	for (i = 0; i < STM_CMD_NUM_BYTES; i++)
		dest_buf[i] = *(buf + i);

	/* Set mask denoting which peripherals support STM */
	rsp_supported = diag_get_stm_peripheral_mask();

	/* Set mask denoting STM state/status for each peripheral/APSS */
	rsp_status = diag_get_stm_state_for_peripherals();

	dest_buf[STM_RSP_SUPPORTED_INDEX] = rsp_supported;
	dest_buf[STM_RSP_STATUS_INDEX] = rsp_status;

+4 −2
Original line number Diff line number Diff line
@@ -20,7 +20,8 @@
	((x == PERIPHERAL_WCNSS) ? DIAG_CON_WCNSS :		\
	((x == PERIPHERAL_SENSORS) ? DIAG_CON_SENSORS : \
	((x == PERIPHERAL_WDSP) ? DIAG_CON_WDSP : \
	((x == PERIPHERAL_CDSP) ? DIAG_CON_CDSP : 0))))))	\
	((x == PERIPHERAL_CDSP) ? DIAG_CON_CDSP :	\
	((x == PERIPHERAL_NPU) ? DIAG_CON_NPU : 0)))))))	\

#define PERIPHERAL_STRING(x)					\
	((x == PERIPHERAL_MODEM) ? "MODEM" :			\
@@ -28,7 +29,8 @@
	((x == PERIPHERAL_WCNSS) ? "WCNSS" :			\
	((x == PERIPHERAL_SENSORS) ? "SENSORS" :		\
	((x == PERIPHERAL_WDSP) ? "WDSP" :			\
	((x == PERIPHERAL_CDSP) ? "CDSP" : "UNKNOWN"))))))	\
	((x == PERIPHERAL_CDSP) ? "CDSP" :			\
	((x == PERIPHERAL_NPU) ? "NPU" : "UNKNOWN")))))))	\

struct diagfwd_buf_t {
	unsigned char *data;
+45 −0
Original line number Diff line number Diff line
@@ -83,6 +83,15 @@ struct diag_rpmsg_info rpmsg_data[NUM_PERIPHERALS] = {
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	},
	{
		.peripheral = PERIPHERAL_NPU,
		.type = TYPE_DATA,
		.edge = "npu",
		.name = "DIAG_DATA",
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	}
};

@@ -140,6 +149,15 @@ struct diag_rpmsg_info rpmsg_cntl[NUM_PERIPHERALS] = {
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	},
	{
		.peripheral = PERIPHERAL_NPU,
		.type = TYPE_CNTL,
		.edge = "npu",
		.name = "DIAG_CTRL",
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	}
};

@@ -197,6 +215,15 @@ struct diag_rpmsg_info rpmsg_dci[NUM_PERIPHERALS] = {
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	},
	{
		.peripheral = PERIPHERAL_NPU,
		.type = TYPE_DCI,
		.edge = "npu",
		.name = "DIAG_DCI_DATA",
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	}
};

@@ -254,6 +281,15 @@ struct diag_rpmsg_info rpmsg_cmd[NUM_PERIPHERALS] = {
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	},
	{
		.peripheral = PERIPHERAL_NPU,
		.type = TYPE_CMD,
		.edge = "npu",
		.name = "DIAG_CMD",
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	}
};

@@ -311,6 +347,15 @@ struct diag_rpmsg_info rpmsg_dci_cmd[NUM_PERIPHERALS] = {
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	},
	{
		.peripheral = PERIPHERAL_NPU,
		.type = TYPE_DCI_CMD,
		.edge = "npu",
		.name = "DIAG_DCI_CMD",
		.buf1 = NULL,
		.buf2 = NULL,
		.hdl = NULL
	}
};

Loading