From 77221bae90fd186833aa30def073da0d3ea71ba7 Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Mon, 21 Feb 2022 14:32:50 +0530 Subject: [PATCH] msm: mhi_dev: Avoiding freeing of ereq memory in reset With the commit <1528bbe6b570> ("msm: mhi_dev: Keeping event req memory without clearing in close channel"), we are avoiding freeing of ereq memory in close channel API. New memory is not created again as part of start/open channel since it is not released while closing the channel. Idea is to hold the allocated memory and avoid reallocating every time. But during the reset command we are freeing some of the ereqs which we need to hold without releasing. This change avoids freeing of ereq memory as part of reset channel command and adds the ereqs to the event_req_buffers list. This ensures that the lists, event_req_buffers and flush_event_req_buffers are updated with valid ereqs. Change-Id: Ie29962f2bc8ef5a0c193d13a13118ae9b6044c0b Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 23a78b8fcd78..eed0707ac886 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -1868,15 +1868,15 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) mhi_log(MHI_MSG_VERBOSE, "Processing reset cmd for ch%d\n", ch_id); /* * Ensure that the completions that are present in the flush list are - * removed from the list and discarded before stopping the channel. - * Otherwise, those stale events may get flushed along with a valid - * event in the next flush operation. + * removed from the list and added to event req list before channel + * reset. Otherwise, those stale events may get flushed along with a + * valid 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); + list_add_tail(&itr->list, &ch->event_req_buffers); } } spin_unlock_irqrestore(&mhi_ctx->lock, flags);