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

Commit 5cec352f authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Prevent switching mode for non mdlog process"

parents 3417d797 3df8bc04
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -289,6 +289,10 @@ do { \
#define DIAG_NUM_PROC	(1 + NUM_REMOTE_DEV)
#define DIAG_NUM_PROC	(1 + NUM_REMOTE_DEV)
#endif
#endif


#define DIAG_MSM_MASK (0x0001)   /* Bit mask for MSM */
#define DIAG_MDM_MASK (0x0002)   /* Bit mask for first mdm device */
#define DIAG_MDM2_MASK (0x0004) /* Bit mask for second mdm device */

#define DIAG_WS_DCI		0
#define DIAG_WS_DCI		0
#define DIAG_WS_MUX		1
#define DIAG_WS_MUX		1


@@ -685,6 +689,7 @@ struct diagchar_dev {
	int usb_connected;
	int usb_connected;
#endif
#endif
	int pcie_connected;
	int pcie_connected;
	int pcie_switch_pid;
	struct workqueue_struct *diag_wq;
	struct workqueue_struct *diag_wq;
	struct work_struct diag_drain_work;
	struct work_struct diag_drain_work;
	struct work_struct update_user_clients;
	struct work_struct update_user_clients;
+27 −8
Original line number Original line Diff line number Diff line
@@ -463,15 +463,20 @@ static void diag_close_logging_process(const int pid)
	session_info = diag_md_session_get_pid(pid);
	session_info = diag_md_session_get_pid(pid);
	if (!session_info) {
	if (!session_info) {
		mutex_unlock(&driver->md_session_lock);
		mutex_unlock(&driver->md_session_lock);
		if (driver->pcie_transport_def == DIAG_ROUTE_TO_PCIE)
		mutex_lock(&driver->diagchar_mutex);
		if (driver->pcie_switch_pid == pid) {
			if (driver->pcie_transport_def ==
				DIAG_ROUTE_TO_PCIE)
				params.req_mode = PCIE_MODE;
				params.req_mode = PCIE_MODE;
			else
			else
				params.req_mode = USB_MODE;
				params.req_mode = USB_MODE;
			params.mode_param = 0;
			params.mode_param = 0;
			params.pd_mask = 0;
			params.pd_mask = 0;
			params.device_mask = DIAG_MSM_MASK;
			params.peripheral_mask = DIAG_CON_ALL;
			params.peripheral_mask = DIAG_CON_ALL;
		mutex_lock(&driver->diagchar_mutex);
			diag_switch_logging(&params);
			diag_switch_logging(&params);
			driver->pcie_switch_pid = 0;
		}
		mutex_unlock(&driver->diagchar_mutex);
		mutex_unlock(&driver->diagchar_mutex);
		return;
		return;
	}
	}
@@ -1935,6 +1940,19 @@ static int diag_switch_logging(struct diag_logging_mode_param_t *param)
			}
			}
			driver->logging_mode[proc] = new_mode;
			driver->logging_mode[proc] = new_mode;
			driver->logging_mask[proc] = peripheral_mask;
			driver->logging_mask[proc] = peripheral_mask;
			if (((curr_mode == DIAG_PCIE_MODE &&
				new_mode == DIAG_USB_MODE) ||
				(curr_mode == DIAG_USB_MODE &&
				new_mode == DIAG_PCIE_MODE)) &&
				!driver->pcie_switch_pid) {
				/*
				 * Store the pid of process affecting switch
				 * from USB to PCIE or vice versa to help
				 * close only this process while closing
				 * logging process.
				 */
				driver->pcie_switch_pid = current->tgid;
			}
			if (new_mode == DIAG_PCIE_MODE) {
			if (new_mode == DIAG_PCIE_MODE) {
				driver->transport_set = DIAG_ROUTE_TO_PCIE;
				driver->transport_set = DIAG_ROUTE_TO_PCIE;
				diagmem_setsize(POOL_TYPE_MUX_APPS,
				diagmem_setsize(POOL_TYPE_MUX_APPS,
@@ -4332,6 +4350,7 @@ static int __init diagchar_init(void)
	driver->mask_check = 0;
	driver->mask_check = 0;
	driver->in_busy_pktdata = 0;
	driver->in_busy_pktdata = 0;
	driver->in_busy_dcipktdata = 0;
	driver->in_busy_dcipktdata = 0;
	driver->pcie_switch_pid = 0;
	driver->rsp_buf_ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_CMD, TYPE_CMD);
	driver->rsp_buf_ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_CMD, TYPE_CMD);
	hdlc_data.ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_DATA, 1);
	hdlc_data.ctxt = SET_BUF_CTXT(APPS_DATA, TYPE_DATA, 1);
	hdlc_data.len = 0;
	hdlc_data.len = 0;