[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1690952359-8625-6-git-send-email-quic_krichai@quicinc.com>
Date: Wed, 2 Aug 2023 10:29:19 +0530
From: Krishna chaitanya chundru <quic_krichai@...cinc.com>
To: manivannan.sadhasivam@...aro.org
Cc: helgaas@...nel.org, linux-pci@...r.kernel.org,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
quic_vbadigan@...cinc.com, quic_nitegupt@...cinc.com,
quic_skananth@...cinc.com, quic_ramkri@...cinc.com,
quic_parass@...cinc.com, krzysztof.kozlowski@...aro.org,
Krishna chaitanya chundru <quic_krichai@...cinc.com>,
Manivannan Sadhasivam <mani@...nel.org>,
Jeffrey Hugo <quic_jhugo@...cinc.com>,
Dan Carpenter <error27@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
mhi@...ts.linux.dev (open list:MHI BUS)
Subject: [PATCH v5 5/5] bus: mhi: ep: wake up host if the MHI state is in M3
If the MHI state is in M3 then most probably the host kept the
device in D3 hot or D3 cold, due to that endpoint transactions will not
be read by the host, endpoint needs to wakes up the host to bring the
host to D0 which eventually bring back the MHI state to M0.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@...cinc.com>
---
drivers/bus/mhi/ep/main.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 6008818..9035e02 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -25,6 +25,26 @@ static DEFINE_IDA(mhi_ep_cntrl_ida);
static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id);
static int mhi_ep_destroy_device(struct device *dev, void *data);
+static int mhi_ep_wake_host(struct mhi_ep_cntrl *mhi_cntrl)
+{
+ enum mhi_state state;
+ bool mhi_reset;
+ u32 count = 0;
+
+ mhi_cntrl->wakeup_host(mhi_cntrl);
+
+ /* Wait for Host to set the M0 state */
+ while (count++ < M0_WAIT_COUNT) {
+ msleep(M0_WAIT_DELAY_MS);
+
+ mhi_ep_mmio_get_mhi_state(mhi_cntrl, &state, &mhi_reset);
+ if (state == MHI_STATE_M0)
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
static int mhi_ep_send_event(struct mhi_ep_cntrl *mhi_cntrl, u32 ring_idx,
struct mhi_ring_element *el, bool bei)
{
@@ -466,6 +486,14 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
mutex_lock(&mhi_chan->lock);
+ if (mhi_cntrl->mhi_state == MHI_STATE_M3) {
+ ret = mhi_ep_wake_host(mhi_cntrl);
+ if (ret) {
+ dev_err(dev, "Failed to wakeup host\n");
+ goto err_exit;
+ }
+ }
+
do {
/* Don't process the transfer ring if the channel is not in RUNNING state */
if (mhi_chan->state != MHI_CH_STATE_RUNNING) {
--
2.7.4
Powered by blists - more mailing lists