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

Commit f5f2de41 authored by Ravi Aravamudhan's avatar Ravi Aravamudhan
Browse files

diag: Forward pkts to peripherals only after receiving feature mask



Diag feature masks are exhanged between the Apps processor and the
peripherals during boot up that contains the information about the
channel used for transmitting/receiving command responses. Do not
process any command until we receive the feature masks from the
peripherals. Also continue to process the ctrl pkt even if the
registration table count is 0 to process the feature mask at the end
of the ctrl pkt.

Change-Id: Iabd6e7dfe803e3f6ae08b287d68a023cef40f6cc
CRs-Fixed: 550023
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent b16fa45c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -105,6 +105,9 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
		"RIVA CNTL in_buf_1_size: %d\n"
		"Modem DCI in_buf_1_size: %d\n"
		"Modem DCI CMD in_buf_1_size: %d\n"
		"Received Feature mask from Modem: %d\n"
		"Received Feature mask from LPASS: %d\n"
		"Received Feature mask from WCNSS: %d\n"
		"logging_mode: %d\n"
		"real_time_mode: %d\n",
		(unsigned int)driver->smd_data[MODEM_DATA].ch,
@@ -171,6 +174,9 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
		(unsigned int)driver->smd_cntl[WCNSS_DATA].buf_in_1_size,
		(unsigned int)driver->smd_dci[MODEM_DATA].buf_in_1_size,
		(unsigned int)driver->smd_dci_cmd[MODEM_DATA].buf_in_1_size,
		driver->rcvd_feature_mask[MODEM_DATA],
		driver->rcvd_feature_mask[LPASS_DATA],
		driver->rcvd_feature_mask[WCNSS_DATA],
		driver->logging_mode,
		driver->real_time_mode);

+1 −0
Original line number Diff line number Diff line
@@ -347,6 +347,7 @@ struct diagchar_dev {
	struct diag_smd_info smd_dci[NUM_SMD_DCI_CHANNELS];
	struct diag_smd_info smd_cmd[NUM_SMD_CMD_CHANNELS];
	struct diag_smd_info smd_dci_cmd[NUM_SMD_DCI_CMD_CHANNELS];
	int rcvd_feature_mask[NUM_SMD_CONTROL_CHANNELS];
	int separate_cmdrsp[NUM_SMD_CONTROL_CHANNELS];
	unsigned char *usb_buf_out;
	unsigned char *apps_rsp_buf;
+26 −12
Original line number Diff line number Diff line
@@ -207,11 +207,12 @@ int chk_polling_response(void)
		 * has registered to respond for polling
		 */
		return 1;
	else if (!(driver->smd_data[MODEM_DATA].ch) &&
					!(chk_apps_master()))
	else if (!((driver->smd_data[MODEM_DATA].ch) &&
		 (driver->rcvd_feature_mask[MODEM_DATA])) &&
		 (chk_apps_master()))
		/*
		 * If the apps processor is not the master and the modem
		 * is not up
		 * is not up or we did not receive the feature masks from Modem
		 */
		return 1;
	else
@@ -1186,6 +1187,18 @@ int diag_process_stm_cmd(unsigned char *buf)
	return 0;
}

int diag_apps_responds()
{
	if (chk_apps_only()) {
		if (driver->smd_data[MODEM_DATA].ch &&
				driver->rcvd_feature_mask[MODEM_DATA]) {
			return 0;
		}
		return 1;
	}
	return 0;
}

int diag_process_apps_pkt(unsigned char *buf, int len)
{
	uint16_t subsys_cmd_code;
@@ -1220,7 +1233,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len)
	pr_debug("diag: %d %d %d", cmd_code, subsys_id, subsys_cmd_code);
	for (i = 0; i < diag_max_reg; i++) {
		entry = driver->table[i];
		if (entry.process_id != NO_PROCESS) {
		if (entry.process_id != NO_PROCESS &&
				driver->rcvd_feature_mask[entry.client_id]) {
			if (entry.cmd_code == cmd_code && entry.subsys_id ==
				 subsys_id && entry.cmd_code_lo <=
							 subsys_cmd_code &&
@@ -1266,8 +1280,7 @@ int diag_process_apps_pkt(unsigned char *buf, int len)
		return diag_process_stm_cmd(buf);
	}
	/* Check for Apps Only & get event mask request */
	else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only() &&
								*buf == 0x81) {
	else if (diag_apps_responds() && *buf == 0x81) {
		driver->apps_rsp_buf[0] = 0x81;
		driver->apps_rsp_buf[1] = 0x0;
		*(uint16_t *)(driver->apps_rsp_buf + 2) = 0x0;
@@ -1278,8 +1291,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len)
		return 0;
	}
	/* Get log ID range & Check for Apps Only */
	else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only()
			  && (*buf == 0x73) && *(int *)(buf+4) == 1) {
	else if (diag_apps_responds() && (*buf == 0x73) &&
							*(int *)(buf+4) == 1) {
		driver->apps_rsp_buf[0] = 0x73;
		*(int *)(driver->apps_rsp_buf + 4) = 0x1; /* operation ID */
		*(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success code */
@@ -1303,8 +1316,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len)
		return 0;
	}
	/* Respond to Get SSID Range request message */
	else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only()
			 && (*buf == 0x7d) && (*(buf+1) == 0x1)) {
	else if (diag_apps_responds() && (*buf == 0x7d) &&
							(*(buf+1) == 0x1)) {
		driver->apps_rsp_buf[0] = 0x7d;
		driver->apps_rsp_buf[1] = 0x1;
		driver->apps_rsp_buf[2] = 0x1;
@@ -1361,8 +1374,8 @@ int diag_process_apps_pkt(unsigned char *buf, int len)
		return 0;
	}
	/* Check for Apps Only Respond to Get Subsys Build mask */
	else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only()
			 && (*buf == 0x7d) && (*(buf+1) == 0x2)) {
	else if (diag_apps_responds() && (*buf == 0x7d) &&
							(*(buf+1) == 0x2)) {
		ssid_first = *(uint16_t *)(buf + 2);
		ssid_last = *(uint16_t *)(buf + 4);
		ssid_range = 4 * (ssid_last - ssid_first + 1);
@@ -2460,6 +2473,7 @@ void diagfwd_init(void)
	for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++) {
		driver->separate_cmdrsp[i] = 0;
		driver->peripheral_supports_stm[i] = DISABLE_STM;
		driver->rcvd_feature_mask[i] = 0;
	}

	for (i = 0; i < NUM_STM_PROCESSORS; i++) {
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ void diag_cmp_logging_modes_sdio_pipe(int old_mode, int new_mode);
void diag_cmp_logging_modes_diagfwd_bridge(int old_mode, int new_mode);
int diag_process_apps_pkt(unsigned char *buf, int len);
void diag_reset_smd_data(int queue);
int diag_apps_responds(void);
/* State for diag forwarding */
#ifdef CONFIG_DIAG_OVER_USB
int diagfwd_connect(void);
+17 −5
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ void diag_clean_reg_fn(struct work_struct *work)
	diag_clear_reg(smd_info->peripheral);
	reg_dirty ^= smd_info->peripheral_mask;

	/* Reset the feature mask flag */
	driver->rcvd_feature_mask[smd_info->peripheral] = 0;

	smd_info->notify_context = 0;
}

@@ -158,14 +161,21 @@ int diag_process_smd_cntl_read_data(struct diag_smd_info *smd_info, void *buf,
			msg = buf+HDR_SIZ;
			range = buf+HDR_SIZ+
					sizeof(struct diag_ctrl_msg);
			if (msg->count_entries == 0) {
				pr_debug("diag: In %s, received reg tbl with no entries\n",
								__func__);
				buf = buf + HDR_SIZ + data_len;
				continue;
			}
			pkt_params->count = msg->count_entries;
			pkt_params->params = kzalloc(pkt_params->count *
				sizeof(struct bindpkt_params), GFP_KERNEL);
			if (ZERO_OR_NULL_PTR(pkt_params->params)) {
				pr_alert("diag: In %s, Memory alloc fail\n",
					__func__);
				kfree(pkt_params);
				return flag;
			if (!pkt_params->params) {
				pr_alert("diag: In %s, Memory alloc fail for cmd_code: %d, subsys: %d\n",
						__func__, msg->cmd_code,
						msg->subsysid);
				buf = buf + HDR_SIZ + data_len;
				continue;
			}
			temp = pkt_params->params;
			for (j = 0; j < pkt_params->count; j++) {
@@ -195,6 +205,8 @@ int diag_process_smd_cntl_read_data(struct diag_smd_info *smd_info, void *buf,
			int feature_mask_len = *(int *)(buf+8);
			if (feature_mask_len > 0) {
				int periph = smd_info->peripheral;
				driver->rcvd_feature_mask[smd_info->peripheral]
									= 1;
				feature_mask = *(uint8_t *)(buf+12);
				if (periph == MODEM_DATA)
					driver->log_on_demand_support =