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

Commit 785f45b6 authored by Yong Ding's avatar Yong Ding
Browse files

soc: qcom: hab: add the uninterruptible receive support



In the blocking mode of habmm_socket_recv(), it is an
interruptible wait by default. Here, the uninterruptible
version is added.

Change-Id: Iba9ee10afb3f2529a99a9c90f6fc0cb56fb9cb08
Signed-off-by: default avatarYong Ding <yongding@codeaurora.org>
parent ef00227c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ struct hab_message *hab_vchan_recv(struct uhab_context *ctx,
		physical_channel_rx_dispatch((unsigned long) vchan->pchan);
	}

	message = hab_msg_dequeue(vchan, !nonblocking_flag);
	message = hab_msg_dequeue(vchan, flags);
	if (!message) {
		if (nonblocking_flag)
			ret = -EAGAIN;
+1 −1
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ int habmem_imp_hyp_mmap(struct file *flip, struct vm_area_struct *vma);

void hab_msg_free(struct hab_message *message);
struct hab_message *hab_msg_dequeue(struct virtual_channel *vchan,
		int wait_flag);
		unsigned int flags);

void hab_msg_recv(struct physical_channel *pchan,
		struct hab_header *header);
+17 −9
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -43,16 +43,24 @@ void hab_msg_free(struct hab_message *message)
}

struct hab_message *
hab_msg_dequeue(struct virtual_channel *vchan, int wait_flag)
hab_msg_dequeue(struct virtual_channel *vchan, unsigned int flags)
{
	struct hab_message *message = NULL;
	int ret = 0;
	int wait = !(flags & HABMM_SOCKET_RECV_FLAGS_NON_BLOCKING);
	int interruptible = !(flags & HABMM_SOCKET_RECV_FLAGS_UNINTERRUPTIBLE);

	if (wait_flag) {
		if (hab_rx_queue_empty(vchan))
	if (wait) {
		if (hab_rx_queue_empty(vchan)) {
			if (interruptible)
				ret = wait_event_interruptible(vchan->rx_queue,
					!hab_rx_queue_empty(vchan) ||
					vchan->otherend_closed);
			else
				wait_event(vchan->rx_queue,
					!hab_rx_queue_empty(vchan) ||
					vchan->otherend_closed);
		}
	}

	/* return all the received messages before the remote close */
@@ -74,7 +82,7 @@ static void hab_msg_queue(struct virtual_channel *vchan,
	list_add_tail(&message->node, &vchan->rx_list);
	spin_unlock_bh(&vchan->rx_lock);

	wake_up_interruptible(&vchan->rx_queue);
	wake_up(&vchan->rx_queue);
}

static int hab_export_enqueue(struct virtual_channel *vchan,
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ void hab_vchan_stop(struct virtual_channel *vchan)
{
	if (vchan) {
		vchan->otherend_closed = 1;
		wake_up_interruptible(&vchan->rx_queue);
		wake_up(&vchan->rx_queue);
	}
}

+5 −0
Original line number Diff line number Diff line
@@ -143,6 +143,11 @@ int32_t habmm_socket_send(int32_t handle, void *src_buff, uint32_t size_bytes,
 */
#define HABMM_SOCKET_RECV_FLAGS_NON_BLOCKING 0x00000001

/* In the blocking mode, this flag is used to indicate it is an
 * uninterruptbile blocking call.
 */
#define HABMM_SOCKET_RECV_FLAGS_UNINTERRUPTIBLE 0x00000002

int32_t habmm_socket_recv(int32_t handle, void *dst_buff, uint32_t *size_bytes,
		uint32_t timeout, uint32_t flags);