lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1617311778-1254-6-git-send-email-bbhatt@codeaurora.org>
Date:   Thu,  1 Apr 2021 14:16:14 -0700
From:   Bhaumik Bhatt <bbhatt@...eaurora.org>
To:     manivannan.sadhasivam@...aro.org
Cc:     linux-arm-msm@...r.kernel.org, hemantk@...eaurora.org,
        jhugo@...eaurora.org, linux-kernel@...r.kernel.org,
        carl.yin@...ctel.com, naveen.kumar@...ctel.com,
        loic.poulain@...aro.org, Bhaumik Bhatt <bbhatt@...eaurora.org>
Subject: [PATCH v8 5/9] bus: mhi: core: Hold device wake for channel update commands

MHI host can fail early if device is in a bad state by attempting
to assert device wake and holding the runtime PM vote before
sending a channel update command instead of performing a wake
toggle and waiting for a timeout if the send were to fail. This
can help improve the design and enable shorter wait periods for
device to respond as votes are already held.

Signed-off-by: Bhaumik Bhatt <bbhatt@...eaurora.org>
---
 drivers/bus/mhi/core/main.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 94fdbf7..989a2a8 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -1278,16 +1278,18 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
 		return -EINVAL;
 	}
 
-	mhi_cntrl->wake_toggle(mhi_cntrl);
+	/* bring host and device out of suspended states */
+	ret = mhi_device_get_sync(mhi_cntrl->mhi_dev);
+	if (ret)
+		return ret;
 	mhi_cntrl->runtime_get(mhi_cntrl);
-	mhi_cntrl->runtime_put(mhi_cntrl);
 
 	reinit_completion(&mhi_chan->completion);
 	ret = mhi_send_cmd(mhi_cntrl, mhi_chan, cmd);
 	if (ret) {
 		dev_err(dev, "%d: Failed to send %s channel command\n",
 			mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
-		return ret;
+		goto exit_channel_update;
 	}
 
 	ret = wait_for_completion_timeout(&mhi_chan->completion,
@@ -1296,9 +1298,12 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
 		dev_err(dev,
 			"%d: Failed to receive %s channel command completion\n",
 			mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
-		return -EIO;
+		ret = -EIO;
+		goto exit_channel_update;
 	}
 
+	ret = 0;
+
 	if (to_state != MHI_CH_STATE_TYPE_RESET) {
 		write_lock_irq(&mhi_chan->lock);
 		mhi_chan->ch_state = (to_state == MHI_CH_STATE_TYPE_START) ?
@@ -1309,7 +1314,11 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
 	dev_dbg(dev, "%d: Channel state change to %s successful\n",
 		mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
 
-	return 0;
+exit_channel_update:
+	mhi_cntrl->runtime_put(mhi_cntrl);
+	mhi_device_put(mhi_cntrl->mhi_dev);
+
+	return ret;
 }
 
 static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ