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

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

diag: Replace wait_event with wait_event_interruptible



Diag driver puts the process that waits for data from peripherals
to an uninterruptible sleep. Make changes in the diag driver to
use the alternative wait that can be interruptible by signals.

Change-Id: I428475b7a14aa4d559fcf08ccc459c49d21974f5
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent 0597b5d5
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static void diag_state_close_smd(void *ctxt)
	atomic_set(&smd_info->diag_state, 0);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		 "%s setting diag state to 0", smd_info->name);
	wake_up(&smd_info->read_wait_q);
	wake_up_interruptible(&smd_info->read_wait_q);
	flush_workqueue(smd_info->wq);
}

@@ -385,7 +385,7 @@ static void smd_close_work_fn(struct work_struct *work)
		return;

	diagfwd_channel_close(smd_info->fwd_ctxt);
	wake_up(&smd_info->read_wait_q);
	wake_up_interruptible(&smd_info->read_wait_q);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s exiting\n",
		 smd_info->name);
}
@@ -413,7 +413,7 @@ static void diag_smd_queue_read(void *ctxt)
	smd_info = (struct diag_smd_info *)ctxt;
	if (smd_info->inited && atomic_read(&smd_info->opened) &&
	    smd_info->hdl) {
		wake_up(&smd_info->read_wait_q);
		wake_up_interruptible(&smd_info->read_wait_q);
		queue_work(smd_info->wq, &(smd_info->read_work));
	}
}
@@ -718,10 +718,13 @@ static int diag_smd_read(void *ctxt, unsigned char *buf, int buf_len)
	    !atomic_read(&smd_info->opened))
		return -EIO;

	wait_event(smd_info->read_wait_q, (smd_info->hdl == NULL) ||
	err = wait_event_interruptible(smd_info->read_wait_q,
				       (smd_info->hdl == NULL) ||
				       (atomic_read(&smd_info->opened) == 0) ||
				       (smd_cur_packet_size(smd_info->hdl)) ||
				(atomic_read(&smd_info->diag_state) == 0));
				       (!atomic_read(&smd_info->diag_state)));
	if (err)
		return -ERESTARTSYS;

	/*
	 * In this case don't reset the buffers as there is no need to further
@@ -828,6 +831,6 @@ static void smd_notify(void *ctxt, unsigned event)
		break;
	}

	wake_up(&smd_info->read_wait_q);
	wake_up_interruptible(&smd_info->read_wait_q);
}
+13 −8
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ static void diag_state_close_socket(void *ctxt)
	atomic_set(&info->diag_state, 0);
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
		 "%s setting diag state to 0", info->name);
	wake_up(&info->read_wait_q);
	wake_up_interruptible(&info->read_wait_q);
	flush_workqueue(info->wq);
}

@@ -242,7 +242,7 @@ static void socket_data_ready(struct sock *sk_ptr)
		diagfwd_buffers_init(info->fwd_ctxt);

	queue_work(info->wq, &(info->read_work));
	wake_up(&info->read_wait_q);
	wake_up_interruptible(&info->read_wait_q);
	return;
}

@@ -255,7 +255,7 @@ static void cntl_socket_data_ready(struct sock *sk_ptr)
	}

	atomic_inc(&cntl_socket->data_ready);
	wake_up(&cntl_socket->read_wait_q);
	wake_up_interruptible(&cntl_socket->read_wait_q);
	queue_work(cntl_socket->wq, &(cntl_socket->read_work));
}

@@ -459,7 +459,7 @@ static void __socket_close_channel(struct diag_socket_info *info)
		write_unlock_bh(&info->hdl->sk->sk_callback_lock);
		sock_release(info->hdl);
		info->hdl = NULL;
		wake_up(&info->read_wait_q);
		wake_up_interruptible(&info->read_wait_q);
	}
	DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s exiting\n", info->name);

@@ -584,8 +584,10 @@ static void cntl_socket_read_work_fn(struct work_struct *work)
	if (!cntl_socket)
		return;

	wait_event(cntl_socket->read_wait_q,
	ret = wait_event_interruptible(cntl_socket->read_wait_q,
				(atomic_read(&cntl_socket->data_ready) > 0));
	if (ret)
		return;

	do {
		iov.iov_base = &msg;
@@ -912,8 +914,11 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len)
	temp = buf;
	bytes_remaining = buf_len;

	wait_event(info->read_wait_q, (info->data_ready > 0) || (!info->hdl) ||
	err = wait_event_interruptible(info->read_wait_q,
				      (info->data_ready > 0) || (!info->hdl) ||
				      (atomic_read(&info->diag_state) == 0));
	if (err)
		return -ERESTARTSYS;

	/*
	 * There is no need to continue reading over peripheral in this case.