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

Commit 6bf118c8 authored by Sai Chaitanya Kaveti's avatar Sai Chaitanya Kaveti
Browse files

msm: mhi_dev: Avoiding ereq memory allocation in start



Start channel commands from MHI Host are given for all the set of valid
channels during the initialization itself. Previously we are allocating
ereq memory as part of start channel command. But, many of these channels
may not be opened by the clients and the ereq memory allocated is not
useful here.

Here avoiding ereq memory allocation during start channel command and
allocating memory only as part of open channel call by the clients. This
will reduce the overall memory usage and avoid the memory allocation
failures.

Change-Id: I60eccd1d17c60e1108820e1532f2ae385455f336
Signed-off-by: default avatarSai Chaitanya Kaveti <quic_skaveti@quicinc.com>
parent bb300e0c
Loading
Loading
Loading
Loading
+8 −17
Original line number Diff line number Diff line
@@ -1873,10 +1873,12 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id)
	 * event in the next flush operation.
	 */
	spin_lock_irqsave(&mhi_ctx->lock, flags);
	if (!list_empty(&ch->flush_event_req_buffers)) {
		list_for_each_entry_safe(itr, tmp, &ch->flush_event_req_buffers, list) {
			list_del(&itr->list);
			kfree(itr);
		}
	}
	spin_unlock_irqrestore(&mhi_ctx->lock, flags);

	/* hard stop and set the channel to stop */
@@ -1991,16 +1993,6 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
					goto send_undef_completion_event;
				}
			}
			mutex_lock(&mhi->ch[ch_id].ch_lock);
			rc = mhi_dev_alloc_evt_buf_evt_req(mhi, &mhi->ch[ch_id],
					evt_ring);
			mutex_unlock(&mhi->ch[ch_id].ch_lock);
			if (rc) {
				mhi_log(MHI_MSG_ERROR,
					"Failed to alloc ereqs for er %d\n",
					mhi->ch_ctx_cache[ch_id].err_indx);
				goto send_undef_completion_event;
			}
		}

		if (MHI_USE_DMA(mhi))
@@ -3080,9 +3072,6 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi,
	int rc;
	uint32_t size, i;

	if (evt_ring)
		size = evt_ring->ring_size;
	else
	size = mhi_dev_get_evt_ring_size(mhi, ch->ch_id);

	if (!size) {
@@ -4122,6 +4111,8 @@ static int mhi_init(struct mhi_dev *mhi)
		for (i = 0; i < mhi->cfg.channels; i++) {
			mhi->ch[i].ch_id = i;
			mutex_init(&mhi->ch[i].ch_lock);
			INIT_LIST_HEAD(&mhi->ch[i].event_req_buffers);
			INIT_LIST_HEAD(&mhi->ch[i].flush_event_req_buffers);
			}
	}