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

Commit 76984b8c authored by Katish Paran's avatar Katish Paran
Browse files

diag: Read data over peripherals in case of memory device mode



In case of usb disconnect, the logging mode needs to be checked
accordingly to decide whether the data needs to be read over
peripherals or not. In case of memory device mode the data needs
to be read continuoulsy over smd channel even if the usb is
disconnected.

Change-Id: I963740bc3b66a77c2ef68a2c58b48a5c7ed0ab0b
Signed-off-by: default avatarKatish Paran <kparan@codeaurora.org>
parent 2f0184f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ int diag_mux_register(int proc, int ctx, struct diag_mux_ops *ops)
	md_logger.ops[proc] = ops;
	err = diag_md_register(proc, ctx, ops);
	if (err) {
		pr_err("diag: MUX: unable to register usb operations for proc: %d, err: %d\n",
		pr_err("diag: MUX: unable to register md operations for proc: %d, err: %d\n",
		       proc, err);
		return err;
	}
+0 −8
Original line number Diff line number Diff line
@@ -326,16 +326,12 @@ int diag_usb_write(int id, unsigned char *buf, int len, int ctxt)
void diag_usb_connect_all(void)
{
	int i = 0;
	unsigned long flags;
	struct diag_usb_info *usb_info = NULL;

	for (i = 0; i < NUM_DIAG_USB_DEV; i++) {
		usb_info = &diag_usb[i];
		if (!usb_info->enabled)
			continue;
		spin_lock_irqsave(&usb_info->lock, flags);
		usb_info->connected = 1;
		spin_unlock_irqrestore(&usb_info->lock, flags);
		usb_connect(usb_info);
	}
}
@@ -348,16 +344,12 @@ void diag_usb_connect_all(void)
void diag_usb_disconnect_all(void)
{
	int i = 0;
	unsigned long flags;
	struct diag_usb_info *usb_info = NULL;

	for (i = 0; i < NUM_DIAG_USB_DEV; i++) {
		usb_info = &diag_usb[i];
		if (!usb_info->enabled)
			continue;
		spin_lock_irqsave(&usb_info->lock, flags);
		usb_info->connected = 0;
		spin_unlock_irqrestore(&usb_info->lock, flags);
		usb_disconnect(usb_info);
	}
}
+19 −1
Original line number Diff line number Diff line
@@ -873,6 +873,7 @@ static int diag_switch_logging(int requested_mode)
	int success = -EINVAL;
	int temp = 0, status = 0;
	int new_mode = DIAG_USB_MODE; /* set the mode from diag_mux.h */
	int old_logging_id;

	switch (requested_mode) {
	case USB_MODE:
@@ -911,6 +912,7 @@ static int diag_switch_logging(int requested_mode)
	mutex_lock(&driver->diagchar_mutex);
	temp = driver->logging_mode;
	driver->logging_mode = requested_mode;
	old_logging_id = driver->logging_process_id;

	if (driver->logging_mode == MEMORY_DEVICE_MODE) {
		driver->mask_check = 1;
@@ -946,8 +948,24 @@ static int diag_switch_logging(int requested_mode)
	}

	driver->logging_process_id = current->tgid;
	mutex_unlock(&driver->diagchar_mutex);
	status = diag_mux_switch_logging(new_mode);
	if (status) {
		if (requested_mode == MEMORY_DEVICE_MODE)
			driver->mask_check = 0;
		else if (requested_mode == SOCKET_MODE)
			driver->socket_process = NULL;
		else if (requested_mode == CALLBACK_MODE)
			driver->callback_process = NULL;

		driver->logging_process_id = old_logging_id;
		driver->logging_mode = temp;
		pr_err("diag: Error switching logging mode, current logging mode: %d\n",
						driver->logging_mode);
		mutex_unlock(&driver->diagchar_mutex);
		success = status ? success : 1;
		return success;
	}
	mutex_unlock(&driver->diagchar_mutex);
	success = status ? success : 1;
	return success;
}
+26 −12
Original line number Diff line number Diff line
@@ -1423,7 +1423,17 @@ static int diagfwd_mux_open(int id, int mode)
		return -EINVAL;
	}

	if ((mode == DIAG_USB_MODE &&
			driver->logging_mode == MEMORY_DEVICE_MODE) ||
			(mode == DIAG_MEMORY_DEVICE_MODE &&
				driver->logging_mode == USB_MODE)) {
		/* In this case Diag shouldn't not reset the smd in_busy data.
		 * If the reset of smd in_busy values happens then this will
		 * lead to loss of data read over peripherals.
		*/
	} else {
		diag_reset_smd_data(RESET_AND_QUEUE);
	}
	for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++) {
		/* Poll SMD CNTL channels to check for data */
		diag_smd_notify(&(driver->smd_cntl[i]), SMD_EVENT_DATA);
@@ -1448,6 +1458,7 @@ static int diagfwd_mux_close(int id, int mode)
		return -EINVAL;
	}

	if (driver->logging_mode == USB_MODE) {
		for (i = 0; i < NUM_SMD_DATA_CHANNELS; i++) {
			smd_info = &driver->smd_data[i];
			spin_lock_irqsave(&smd_info->in_busy_lock, flags);
@@ -1459,10 +1470,13 @@ static int diagfwd_mux_close(int id, int mode)
		if (driver->supports_separate_cmdrsp) {
			for (i = 0; i < NUM_SMD_CMD_CHANNELS; i++) {
				smd_info = &driver->smd_cmd[i];
			spin_lock_irqsave(&smd_info->in_busy_lock, flags);
				spin_lock_irqsave(&smd_info->in_busy_lock,
						flags);
				smd_info->in_busy_1 = 1;
				smd_info->in_busy_2 = 1;
			spin_unlock_irqrestore(&smd_info->in_busy_lock, flags);
				spin_unlock_irqrestore(&smd_info->in_busy_lock,
						flags);
			}
		}
	}
	queue_work(driver->diag_real_time_wq,