From 99ba40a4dce22b726f94c010262f7a1af93afe33 Mon Sep 17 00:00:00 2001 From: Andrei Danaila Date: Wed, 18 Feb 2015 18:29:23 -0800 Subject: [PATCH] mhi: core: Assert on incorrect device events Assert when an event is received for a channel which is empty. This is a fatal transport error. Change-Id: I0249f97480ebc3ca8d3e98c10e35a0eb040215a4 Signed-off-by: Andrei Danaila --- drivers/platform/msm/mhi/mhi.h | 3 +-- drivers/platform/msm/mhi/mhi_main.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/platform/msm/mhi/mhi.h b/drivers/platform/msm/mhi/mhi.h index 907eb5413e55..eb719041324b 100644 --- a/drivers/platform/msm/mhi/mhi.h +++ b/drivers/platform/msm/mhi/mhi.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2015, 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 @@ -361,7 +361,6 @@ struct mhi_control_seg { }; struct mhi_chan_counters { - u32 empty_ring_removal; u32 pkts_xferd; u32 ev_processed; }; diff --git a/drivers/platform/msm/mhi/mhi_main.c b/drivers/platform/msm/mhi/mhi_main.c index f9459125e1ee..c6c30eaa292d 100644 --- a/drivers/platform/msm/mhi/mhi_main.c +++ b/drivers/platform/msm/mhi/mhi_main.c @@ -731,14 +731,8 @@ static enum MHI_STATUS parse_outbound(struct mhi_device_ctxt *mhi_dev_ctxt, client_handle = mhi_dev_ctxt->client_handle_list[chan]; /* If ring is empty */ - if (mhi_dev_ctxt->mhi_local_chan_ctxt[chan].rp == - mhi_dev_ctxt->mhi_local_chan_ctxt[chan].wp) { - mhi_dev_ctxt->mhi_chan_cntr[chan].empty_ring_removal++; - mhi_wait_for_mdm(mhi_dev_ctxt); - return mhi_send_cmd(mhi_dev_ctxt, - MHI_COMMAND_RESET_CHAN, - chan); - } + MHI_ASSERT(!unlikely(mhi_dev_ctxt->mhi_local_chan_ctxt[chan].rp == + mhi_dev_ctxt->mhi_local_chan_ctxt[chan].wp), "Empty Event Ring\n"); if (NULL != client_handle) { result = &mhi_dev_ctxt->client_handle_list[chan]->result; @@ -771,14 +765,8 @@ static enum MHI_STATUS parse_inbound(struct mhi_device_ctxt *mhi_dev_ctxt, client_handle = mhi_dev_ctxt->client_handle_list[chan]; local_chan_ctxt = &mhi_dev_ctxt->mhi_local_chan_ctxt[chan]; - if (unlikely(mhi_dev_ctxt->mhi_local_chan_ctxt[chan].rp == - mhi_dev_ctxt->mhi_local_chan_ctxt[chan].wp)) { - mhi_dev_ctxt->mhi_chan_cntr[chan].empty_ring_removal++; - mhi_wait_for_mdm(mhi_dev_ctxt); - return mhi_send_cmd(mhi_dev_ctxt, - MHI_COMMAND_RESET_CHAN, - chan); - } + MHI_ASSERT(!unlikely(mhi_dev_ctxt->mhi_local_chan_ctxt[chan].rp == + mhi_dev_ctxt->mhi_local_chan_ctxt[chan].wp), "Empty Event Ring\n"); if (NULL != mhi_dev_ctxt->client_handle_list[chan]) result = &mhi_dev_ctxt->client_handle_list[chan]->result;