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

Commit d65c14b3 authored by Ionut Nicu's avatar Ionut Nicu Committed by Omar Ramirez Luna
Browse files

staging: tidspbridge: core code cleanup



Reorganized some code in the core module to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: default avatarIonut Nicu <ionut.nicu@mindbit.ro>
Signed-off-by: default avatarOmar Ramirez Luna <omar.ramirez@ti.com>
parent edbeef96
Loading
Loading
Loading
Loading
+206 −243
Original line number Original line Diff line number Diff line
@@ -105,11 +105,12 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
	is_eos = (byte_size == 0);
	is_eos = (byte_size == 0);


	/* Validate args */
	/* Validate args */
	if (!host_buf || !pchnl) {
	if (!host_buf || !pchnl)
		status = -EFAULT;
		return -EFAULT;
	} else if (is_eos && CHNL_IS_INPUT(pchnl->chnl_mode)) {

		status = -EPERM;
	if (is_eos && CHNL_IS_INPUT(pchnl->chnl_mode))
	} else {
		return -EPERM;

	/*
	/*
	 * Check the channel state: only queue chirp if channel state
	 * Check the channel state: only queue chirp if channel state
	 * allows it.
	 * allows it.
@@ -117,23 +118,18 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
	dw_state = pchnl->dw_state;
	dw_state = pchnl->dw_state;
	if (dw_state != CHNL_STATEREADY) {
	if (dw_state != CHNL_STATEREADY) {
		if (dw_state & CHNL_STATECANCEL)
		if (dw_state & CHNL_STATECANCEL)
				status = -ECANCELED;
			return -ECANCELED;
			else if ((dw_state & CHNL_STATEEOS) &&
		if ((dw_state & CHNL_STATEEOS) &&
				CHNL_IS_OUTPUT(pchnl->chnl_mode))
				CHNL_IS_OUTPUT(pchnl->chnl_mode))
				status = -EPIPE;
			return -EPIPE;
			else
		/* No other possible states left */
		/* No other possible states left */
		DBC_ASSERT(0);
		DBC_ASSERT(0);
	}
	}
	}


	dev_obj = dev_get_first();
	dev_obj = dev_get_first();
	dev_get_bridge_context(dev_obj, &dev_ctxt);
	dev_get_bridge_context(dev_obj, &dev_ctxt);
	if (!dev_ctxt)
	if (!dev_ctxt)
		status = -EFAULT;
		return -EFAULT;

	if (status)
		goto func_end;


	if (pchnl->chnl_type == CHNL_PCPY && pchnl->chnl_id > 1 && host_buf) {
	if (pchnl->chnl_type == CHNL_PCPY && pchnl->chnl_id > 1 && host_buf) {
		if (!(host_buf < (void *)USERMODE_ADDR)) {
		if (!(host_buf < (void *)USERMODE_ADDR)) {
@@ -142,18 +138,16 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
		}
		}
		/* if addr in user mode, then copy to kernel space */
		/* if addr in user mode, then copy to kernel space */
		host_sys_buf = kmalloc(buf_size, GFP_KERNEL);
		host_sys_buf = kmalloc(buf_size, GFP_KERNEL);
		if (host_sys_buf == NULL) {
		if (host_sys_buf == NULL)
			status = -ENOMEM;
			return -ENOMEM;
			goto func_end;

		}
		if (CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
		if (CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
			status = copy_from_user(host_sys_buf, host_buf,
			status = copy_from_user(host_sys_buf, host_buf,
					buf_size);
					buf_size);
			if (status) {
			if (status) {
				kfree(host_sys_buf);
				kfree(host_sys_buf);
				host_sys_buf = NULL;
				host_sys_buf = NULL;
				status = -EFAULT;
				return -EFAULT;
				goto func_end;
			}
			}
		}
		}
	}
	}
@@ -167,27 +161,25 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
	omap_mbox_disable_irq(dev_ctxt->mbox, IRQ_RX);
	omap_mbox_disable_irq(dev_ctxt->mbox, IRQ_RX);
	if (pchnl->chnl_type == CHNL_PCPY) {
	if (pchnl->chnl_type == CHNL_PCPY) {
		/* This is a processor-copy channel. */
		/* This is a processor-copy channel. */
		if (!status && CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
		if (CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
			/* Check buffer size on output channels for fit. */
			/* Check buffer size on output channels for fit. */
			if (byte_size >
			if (byte_size > io_buf_size(
			    io_buf_size(pchnl->chnl_mgr_obj->hio_mgr))
						pchnl->chnl_mgr_obj->hio_mgr)) {
				status = -EINVAL;
				status = -EINVAL;

				goto out;
			}
			}
		}
		}
	if (!status) {
	}

	/* Get a free chirp: */
	/* Get a free chirp: */
		if (!list_empty(&pchnl->free_packets_list)) {
	if (list_empty(&pchnl->free_packets_list)) {
			chnl_packet_obj = list_first_entry(
					&pchnl->free_packets_list,
					struct chnl_irp, link);
			list_del(&chnl_packet_obj->link);
		} else {
		status = -EIO;
		status = -EIO;
		goto out;
	}
	}
	chnl_packet_obj = list_first_entry(&pchnl->free_packets_list,
			struct chnl_irp, link);
	list_del(&chnl_packet_obj->link);


	}
	if (!status) {
	/* Enqueue the chirp on the chnl's IORequest queue: */
	/* Enqueue the chirp on the chnl's IORequest queue: */
	chnl_packet_obj->host_user_buf = chnl_packet_obj->host_sys_buf =
	chnl_packet_obj->host_user_buf = chnl_packet_obj->host_sys_buf =
		host_buf;
		host_buf;
@@ -200,8 +192,7 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
	 */
	 */
	DBC_ASSERT(chnl_mgr_obj->word_size != 0);
	DBC_ASSERT(chnl_mgr_obj->word_size != 0);
	/* DSP address */
	/* DSP address */
		chnl_packet_obj->dsp_tx_addr =
	chnl_packet_obj->dsp_tx_addr = dw_dsp_addr / chnl_mgr_obj->word_size;
		    dw_dsp_addr / chnl_mgr_obj->word_size;
	chnl_packet_obj->byte_size = byte_size;
	chnl_packet_obj->byte_size = byte_size;
	chnl_packet_obj->buf_size = buf_size;
	chnl_packet_obj->buf_size = buf_size;
	/* Only valid for output channel */
	/* Only valid for output channel */
@@ -225,8 +216,7 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
			(CHNL_IS_INPUT(pchnl->chnl_mode) ? IO_INPUT :
			(CHNL_IS_INPUT(pchnl->chnl_mode) ? IO_INPUT :
			 IO_OUTPUT), &mb_val);
			 IO_OUTPUT), &mb_val);
	sched_dpc = true;
	sched_dpc = true;

out:
	}
	omap_mbox_enable_irq(dev_ctxt->mbox, IRQ_RX);
	omap_mbox_enable_irq(dev_ctxt->mbox, IRQ_RX);
	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	if (mb_val != 0)
	if (mb_val != 0)
@@ -236,7 +226,6 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
	if (sched_dpc)
	if (sched_dpc)
		iosm_schedule(chnl_mgr_obj->hio_mgr);
		iosm_schedule(chnl_mgr_obj->hio_mgr);


func_end:
	return status;
	return status;
}
}


@@ -251,7 +240,6 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
 */
 */
int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
{
{
	int status = 0;
	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
	u32 chnl_id = -1;
	u32 chnl_id = -1;
	s8 chnl_mode;
	s8 chnl_mode;
@@ -259,22 +247,23 @@ int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
	struct chnl_mgr *chnl_mgr_obj = NULL;
	struct chnl_mgr *chnl_mgr_obj = NULL;


	/* Check args: */
	/* Check args: */
	if (pchnl && pchnl->chnl_mgr_obj) {
	if (!pchnl || !pchnl->chnl_mgr_obj)
		return -EFAULT;

	chnl_id = pchnl->chnl_id;
	chnl_id = pchnl->chnl_id;
	chnl_mode = pchnl->chnl_mode;
	chnl_mode = pchnl->chnl_mode;
	chnl_mgr_obj = pchnl->chnl_mgr_obj;
	chnl_mgr_obj = pchnl->chnl_mgr_obj;
	} else {
		status = -EFAULT;
	}
	if (status)
		goto func_end;


	/*  Mark this channel as cancelled, to prevent further IORequests or
	/*  Mark this channel as cancelled, to prevent further IORequests or
	 *  IORequests or dispatching. */
	 *  IORequests or dispatching. */
	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);

	pchnl->dw_state |= CHNL_STATECANCEL;
	pchnl->dw_state |= CHNL_STATECANCEL;
	if (list_empty(&pchnl->pio_requests))

		goto func_cont;
	if (list_empty(&pchnl->pio_requests)) {
		spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
		return 0;
	}


	if (pchnl->chnl_type == CHNL_PCPY) {
	if (pchnl->chnl_type == CHNL_PCPY) {
		/* Indicate we have no more buffers available for transfer: */
		/* Indicate we have no more buffers available for transfer: */
@@ -296,10 +285,10 @@ int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
		pchnl->cio_reqs--;
		pchnl->cio_reqs--;
		DBC_ASSERT(pchnl->cio_reqs >= 0);
		DBC_ASSERT(pchnl->cio_reqs >= 0);
	}
	}
func_cont:

	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
func_end:

	return status;
	return 0;
}
}


/*
/*
@@ -316,22 +305,15 @@ int bridge_chnl_close(struct chnl_object *chnl_obj)
	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;


	/* Check args: */
	/* Check args: */
	if (!pchnl) {
	if (!pchnl)
		status = -EFAULT;
		return -EFAULT;
		goto func_cont;
	/* Cancel IO: this ensures no further IO requests or notifications */
	}
	{
		/* Cancel IO: this ensures no further IO requests or
		 * notifications. */
	status = bridge_chnl_cancel_io(chnl_obj);
	status = bridge_chnl_cancel_io(chnl_obj);
	}
	if (status)
func_cont:
		return status;
	if (!status) {
	/* Assert I/O on this channel is now cancelled: Protects from io_dpc */
		/* Assert I/O on this channel is now cancelled: Protects
		 * from io_dpc. */
	DBC_ASSERT((pchnl->dw_state & CHNL_STATECANCEL));
	DBC_ASSERT((pchnl->dw_state & CHNL_STATECANCEL));
		/* Invalidate channel object: Protects from
	/* Invalidate channel object: Protects from CHNL_GetIOCompletion() */
		 * CHNL_GetIOCompletion(). */
	/* Free the slot in the channel manager: */
	/* Free the slot in the channel manager: */
	pchnl->chnl_mgr_obj->ap_channel[pchnl->chnl_id] = NULL;
	pchnl->chnl_mgr_obj->ap_channel[pchnl->chnl_id] = NULL;
	spin_lock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
	spin_lock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
@@ -342,8 +324,7 @@ int bridge_chnl_close(struct chnl_object *chnl_obj)
		kfree(pchnl->ntfy_obj);
		kfree(pchnl->ntfy_obj);
		pchnl->ntfy_obj = NULL;
		pchnl->ntfy_obj = NULL;
	}
	}
		/* Reset channel event: (NOTE: user_event freed in user
	/* Reset channel event: (NOTE: user_event freed in user context) */
		 * context.). */
	if (pchnl->sync_event) {
	if (pchnl->sync_event) {
		sync_reset_event(pchnl->sync_event);
		sync_reset_event(pchnl->sync_event);
		kfree(pchnl->sync_event);
		kfree(pchnl->sync_event);
@@ -360,9 +341,7 @@ int bridge_chnl_close(struct chnl_object *chnl_obj)


	/* Release channel object. */
	/* Release channel object. */
	kfree(pchnl);
	kfree(pchnl);
		pchnl = NULL;

	}
	DBC_ENSURE(status || !pchnl);
	return status;
	return status;
}
}


@@ -697,32 +676,22 @@ int bridge_chnl_get_ioc(struct chnl_object *chnl_obj, u32 timeout,
int bridge_chnl_get_mgr_info(struct chnl_mgr *hchnl_mgr, u32 ch_id,
int bridge_chnl_get_mgr_info(struct chnl_mgr *hchnl_mgr, u32 ch_id,
				 struct chnl_mgrinfo *mgr_info)
				 struct chnl_mgrinfo *mgr_info)
{
{
	int status = 0;
	struct chnl_mgr *chnl_mgr_obj = (struct chnl_mgr *)hchnl_mgr;
	struct chnl_mgr *chnl_mgr_obj = (struct chnl_mgr *)hchnl_mgr;


	if (mgr_info != NULL) {
	if (!mgr_info || !hchnl_mgr)
		if (ch_id <= CHNL_MAXCHANNELS) {
		return -EFAULT;
			if (hchnl_mgr) {

	if (ch_id > CHNL_MAXCHANNELS)
		return -ECHRNG;

	/* Return the requested information: */
	/* Return the requested information: */
				mgr_info->chnl_obj =
	mgr_info->chnl_obj = chnl_mgr_obj->ap_channel[ch_id];
				    chnl_mgr_obj->ap_channel[ch_id];
	mgr_info->open_channels = chnl_mgr_obj->open_channels;
				mgr_info->open_channels =
				    chnl_mgr_obj->open_channels;
	mgr_info->dw_type = chnl_mgr_obj->dw_type;
	mgr_info->dw_type = chnl_mgr_obj->dw_type;
	/* total # of chnls */
	/* total # of chnls */
				mgr_info->max_channels =
	mgr_info->max_channels = chnl_mgr_obj->max_channels;
				    chnl_mgr_obj->max_channels;
			} else {
				status = -EFAULT;
			}
		} else {
			status = -ECHRNG;
		}
	} else {
		status = -EFAULT;
	}


	return status;
	return 0;
}
}


/*
/*
@@ -772,45 +741,41 @@ int bridge_chnl_open(struct chnl_object **chnl,
	DBC_REQUIRE(pattrs != NULL);
	DBC_REQUIRE(pattrs != NULL);
	DBC_REQUIRE(hchnl_mgr != NULL);
	DBC_REQUIRE(hchnl_mgr != NULL);
	*chnl = NULL;
	*chnl = NULL;

	/* Validate Args: */
	/* Validate Args: */
	if (pattrs->uio_reqs == 0) {
	if (!pattrs->uio_reqs)
		status = -EINVAL;
		return -EINVAL;
	} else {

		if (!hchnl_mgr) {
	if (!hchnl_mgr)
			status = -EFAULT;
		return -EFAULT;
		} else {

	if (ch_id != CHNL_PICKFREE) {
	if (ch_id != CHNL_PICKFREE) {
		if (ch_id >= chnl_mgr_obj->max_channels)
		if (ch_id >= chnl_mgr_obj->max_channels)
					status = -ECHRNG;
			return -ECHRNG;
				else if (chnl_mgr_obj->ap_channel[ch_id] !=
		if (chnl_mgr_obj->ap_channel[ch_id] != NULL)
					 NULL)
			return -EALREADY;
					status = -EALREADY;
	} else {
	} else {
		/* Check for free channel */
		/* Check for free channel */
				status =
		status = search_free_channel(chnl_mgr_obj, &ch_id);
				    search_free_channel(chnl_mgr_obj, &ch_id);
			}
		}
	}
		if (status)
		if (status)
		goto func_end;
			return status;
	}


	DBC_ASSERT(ch_id < chnl_mgr_obj->max_channels);
	DBC_ASSERT(ch_id < chnl_mgr_obj->max_channels);

	/* Create channel object: */
	/* Create channel object: */
	pchnl = kzalloc(sizeof(struct chnl_object), GFP_KERNEL);
	pchnl = kzalloc(sizeof(struct chnl_object), GFP_KERNEL);
	if (!pchnl) {
	if (!pchnl)
		status = -ENOMEM;
		return -ENOMEM;
		goto func_end;

	}
	/* Protect queues from io_dpc: */
	/* Protect queues from io_dpc: */
	pchnl->dw_state = CHNL_STATECANCEL;
	pchnl->dw_state = CHNL_STATECANCEL;

	/* Allocate initial IOR and IOC queues: */
	/* Allocate initial IOR and IOC queues: */
	status = create_chirp_list(&pchnl->free_packets_list,
	status = create_chirp_list(&pchnl->free_packets_list,
			pattrs->uio_reqs);
			pattrs->uio_reqs);
	if (status) {
	if (status)
		kfree(pchnl);
		goto out_err;
		goto func_end;
	}


	INIT_LIST_HEAD(&pchnl->pio_requests);
	INIT_LIST_HEAD(&pchnl->pio_requests);
	INIT_LIST_HEAD(&pchnl->pio_completions);
	INIT_LIST_HEAD(&pchnl->pio_completions);
@@ -818,22 +783,21 @@ int bridge_chnl_open(struct chnl_object **chnl,
	pchnl->chnl_packets = pattrs->uio_reqs;
	pchnl->chnl_packets = pattrs->uio_reqs;
	pchnl->cio_cs = 0;
	pchnl->cio_cs = 0;
	pchnl->cio_reqs = 0;
	pchnl->cio_reqs = 0;

	sync_event = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
	sync_event = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
	if (sync_event)
	if (!sync_event) {
		sync_init_event(sync_event);
	else
		status = -ENOMEM;
		status = -ENOMEM;
		goto out_err;
	}
	sync_init_event(sync_event);


	if (!status) {
	pchnl->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL);
		pchnl->ntfy_obj = kmalloc(sizeof(struct ntfy_object),
	if (!pchnl->ntfy_obj) {
							GFP_KERNEL);
		if (pchnl->ntfy_obj)
			ntfy_init(pchnl->ntfy_obj);
		else
		status = -ENOMEM;
		status = -ENOMEM;
		goto out_err;
	}
	}
	ntfy_init(pchnl->ntfy_obj);


	if (!status) {
	/* Initialize CHNL object fields: */
	/* Initialize CHNL object fields: */
	pchnl->chnl_mgr_obj = chnl_mgr_obj;
	pchnl->chnl_mgr_obj = chnl_mgr_obj;
	pchnl->chnl_id = ch_id;
	pchnl->chnl_id = ch_id;
@@ -846,16 +810,26 @@ int bridge_chnl_open(struct chnl_object **chnl,
	pchnl->bytes_moved = 0;
	pchnl->bytes_moved = 0;
	/* Default to proc-copy */
	/* Default to proc-copy */
	pchnl->chnl_type = CHNL_PCPY;
	pchnl->chnl_type = CHNL_PCPY;
	}


	if (status) {
	/* Insert channel object in channel manager: */
	chnl_mgr_obj->ap_channel[pchnl->chnl_id] = pchnl;
	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	chnl_mgr_obj->open_channels++;
	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
	/* Return result... */
	pchnl->dw_state = CHNL_STATEREADY;
	*chnl = pchnl;

	return status;

out_err:
	/* Free memory */
	/* Free memory */
	free_chirp_list(&pchnl->pio_completions);
	free_chirp_list(&pchnl->pio_completions);
		pchnl->cio_cs = 0;
	free_chirp_list(&pchnl->pio_requests);
	free_chirp_list(&pchnl->pio_requests);
	free_chirp_list(&pchnl->free_packets_list);
	free_chirp_list(&pchnl->free_packets_list);

	if (sync_event)
		kfree(sync_event);
		kfree(sync_event);
		sync_event = NULL;


	if (pchnl->ntfy_obj) {
	if (pchnl->ntfy_obj) {
		ntfy_delete(pchnl->ntfy_obj);
		ntfy_delete(pchnl->ntfy_obj);
@@ -863,18 +837,7 @@ int bridge_chnl_open(struct chnl_object **chnl,
		pchnl->ntfy_obj = NULL;
		pchnl->ntfy_obj = NULL;
	}
	}
	kfree(pchnl);
	kfree(pchnl);
	} else {

		/* Insert channel object in channel manager: */
		chnl_mgr_obj->ap_channel[pchnl->chnl_id] = pchnl;
		spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
		chnl_mgr_obj->open_channels++;
		spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
		/* Return result... */
		pchnl->dw_state = CHNL_STATEREADY;
		*chnl = pchnl;
	}
func_end:
	DBC_ENSURE((!status && pchnl) || (*chnl == NULL));
	return status;
	return status;
}
}


+90 −102
Original line number Original line Diff line number Diff line
@@ -1195,7 +1195,7 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
	input_empty = msg_ctr_obj->buf_empty;
	input_empty = msg_ctr_obj->buf_empty;
	num_msgs = msg_ctr_obj->size;
	num_msgs = msg_ctr_obj->size;
	if (input_empty)
	if (input_empty)
		goto func_end;
		return;


	msg_input = pio_mgr->msg_input;
	msg_input = pio_mgr->msg_input;
	for (i = 0; i < num_msgs; i++) {
	for (i = 0; i < num_msgs; i++) {
@@ -1225,7 +1225,8 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
		 */
		 */
		list_for_each_entry(msg_queue_obj, &hmsg_mgr->queue_list,
		list_for_each_entry(msg_queue_obj, &hmsg_mgr->queue_list,
				list_elem) {
				list_elem) {
			if (msg.msgq_id == msg_queue_obj->msgq_id) {
			if (msg.msgq_id != msg_queue_obj->msgq_id)
				continue;
			/* Found it */
			/* Found it */
			if (msg.msg.dw_cmd == RMS_EXITACK) {
			if (msg.msg.dw_cmd == RMS_EXITACK) {
				/*
				/*
@@ -1233,8 +1234,7 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
				 * The exit message does not get
				 * The exit message does not get
				 * queued.
				 * queued.
				 */
				 */
					(*hmsg_mgr->on_exit) ((void *)
				(*hmsg_mgr->on_exit)(msg_queue_obj->arg,
							msg_queue_obj->arg,
						msg.msg.dw_arg1);
						msg.msg.dw_arg1);
				break;
				break;
			}
			}
@@ -1242,21 +1242,7 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
			 * Not an exit acknowledgement, queue
			 * Not an exit acknowledgement, queue
			 * the message.
			 * the message.
			 */
			 */
				if (!list_empty(&msg_queue_obj->
			if (list_empty(&msg_queue_obj->msg_free_list)) {
							msg_free_list)) {
					pmsg = list_first_entry(
						&msg_queue_obj->msg_free_list,
						struct msg_frame, list_elem);
					list_del(&pmsg->list_elem);
					pmsg->msg_data = msg;
					list_add_tail(&pmsg->list_elem,
						&msg_queue_obj->msg_used_list);
					ntfy_notify
						(msg_queue_obj->ntfy_obj,
						 DSP_NODEMESSAGEREADY);
					sync_set_event
						(msg_queue_obj->sync_event);
				} else {
				/*
				/*
				 * No free frame to copy the
				 * No free frame to copy the
				 * message into.
				 * message into.
@@ -1264,9 +1250,18 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
				pr_err("%s: no free msg frames,"
				pr_err("%s: no free msg frames,"
						" discarding msg\n",
						" discarding msg\n",
						__func__);
						__func__);
				}
				break;
				break;
			}
			}

			pmsg = list_first_entry(&msg_queue_obj->msg_free_list,
					struct msg_frame, list_elem);
			list_del(&pmsg->list_elem);
			pmsg->msg_data = msg;
			list_add_tail(&pmsg->list_elem,
					&msg_queue_obj->msg_used_list);
			ntfy_notify(msg_queue_obj->ntfy_obj,
					DSP_NODEMESSAGEREADY);
			sync_set_event(msg_queue_obj->sync_event);
		}
		}
	}
	}
	/* Set the post SWI flag */
	/* Set the post SWI flag */
@@ -1276,8 +1271,6 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
		msg_ctr_obj->post_swi = true;
		msg_ctr_obj->post_swi = true;
		sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
		sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
	}
	}
func_end:
	return;
}
}


/*
/*
@@ -1408,54 +1401,51 @@ static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
{
{
	u32 num_msgs = 0;
	u32 num_msgs = 0;
	u32 i;
	u32 i;
	u8 *msg_output;
	struct msg_dspmsg *msg_output;
	struct msg_frame *pmsg;
	struct msg_frame *pmsg;
	struct msg_ctrl *msg_ctr_obj;
	struct msg_ctrl *msg_ctr_obj;
	u32 output_empty;
	u32 val;
	u32 val;
	u32 addr;
	u32 addr;


	msg_ctr_obj = pio_mgr->msg_output_ctrl;
	msg_ctr_obj = pio_mgr->msg_output_ctrl;


	/* Check if output has been cleared */
	/* Check if output has been cleared */
	output_empty = msg_ctr_obj->buf_empty;
	if (!msg_ctr_obj->buf_empty)
	if (output_empty) {
		return;

	num_msgs = (hmsg_mgr->msgs_pending > hmsg_mgr->max_msgs) ?
	num_msgs = (hmsg_mgr->msgs_pending > hmsg_mgr->max_msgs) ?
		hmsg_mgr->max_msgs : hmsg_mgr->msgs_pending;
		hmsg_mgr->max_msgs : hmsg_mgr->msgs_pending;
		msg_output = pio_mgr->msg_output;
	msg_output = (struct msg_dspmsg *) pio_mgr->msg_output;

	/* Copy num_msgs messages into shared memory */
	/* Copy num_msgs messages into shared memory */
	for (i = 0; i < num_msgs; i++) {
	for (i = 0; i < num_msgs; i++) {
			if (!list_empty(&hmsg_mgr->msg_used_list)) {
		if (list_empty(&hmsg_mgr->msg_used_list))
				pmsg = list_first_entry(
			continue;
						&hmsg_mgr->msg_used_list,

		pmsg = list_first_entry(&hmsg_mgr->msg_used_list,
				struct msg_frame, list_elem);
				struct msg_frame, list_elem);
		list_del(&pmsg->list_elem);
		list_del(&pmsg->list_elem);

		val = (pmsg->msg_data).msgq_id;
		val = (pmsg->msg_data).msgq_id;
				addr = (u32) &(((struct msg_dspmsg *)
		addr = (u32) &msg_output->msgq_id;
						 msg_output)->msgq_id);
		write_ext32_bit_dsp_data(pio_mgr->hbridge_context, addr, val);
				write_ext32_bit_dsp_data(

					pio_mgr->hbridge_context, addr, val);
		val = (pmsg->msg_data).msg.dw_cmd;
		val = (pmsg->msg_data).msg.dw_cmd;
				addr = (u32) &((((struct msg_dspmsg *)
		addr = (u32) &msg_output->msg.dw_cmd;
						  msg_output)->msg).dw_cmd);
		write_ext32_bit_dsp_data(pio_mgr->hbridge_context, addr, val);
				write_ext32_bit_dsp_data(

					pio_mgr->hbridge_context, addr, val);
		val = (pmsg->msg_data).msg.dw_arg1;
		val = (pmsg->msg_data).msg.dw_arg1;
				addr = (u32) &((((struct msg_dspmsg *)
		addr = (u32) &msg_output->msg.dw_arg1;
						  msg_output)->msg).dw_arg1);
		write_ext32_bit_dsp_data(pio_mgr->hbridge_context, addr, val);
				write_ext32_bit_dsp_data(

					pio_mgr->hbridge_context, addr, val);
		val = (pmsg->msg_data).msg.dw_arg2;
		val = (pmsg->msg_data).msg.dw_arg2;
				addr = (u32) &((((struct msg_dspmsg *)
		addr = (u32) &msg_output->msg.dw_arg2;
						  msg_output)->msg).dw_arg2);
		write_ext32_bit_dsp_data(pio_mgr->hbridge_context, addr, val);
				write_ext32_bit_dsp_data(

					pio_mgr->hbridge_context, addr, val);
		msg_output++;
				msg_output += sizeof(struct msg_dspmsg);
		list_add_tail(&pmsg->list_elem, &hmsg_mgr->msg_free_list);
				list_add_tail(&pmsg->list_elem,
						&hmsg_mgr->msg_free_list);
		sync_set_event(hmsg_mgr->sync_event);
		sync_set_event(hmsg_mgr->sync_event);
	}
	}
		}


	if (num_msgs > 0) {
	if (num_msgs > 0) {
		hmsg_mgr->msgs_pending -= num_msgs;
		hmsg_mgr->msgs_pending -= num_msgs;
@@ -1472,9 +1462,7 @@ static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
		/* Set the post SWI flag */
		/* Set the post SWI flag */
		msg_ctr_obj->post_swi = true;
		msg_ctr_obj->post_swi = true;
		/* Tell the DSP we have written the output. */
		/* Tell the DSP we have written the output. */
			sm_interrupt_dsp(pio_mgr->hbridge_context,
		sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
						MBX_PCPY_CLASS);
		}
	}
	}
}
}


+205 −248

File changed.

Preview size limit exceeded, changes collapsed.