All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/9] Updates to MHI channel handling
@ 2021-01-08 20:54 Bhaumik Bhatt
  2021-01-08 20:54 ` [PATCH v5 1/9] bus: mhi: core: Allow sending the STOP channel command Bhaumik Bhatt
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Bhaumik Bhatt @ 2021-01-08 20:54 UTC (permalink / raw)
  To: manivannan.sadhasivam
  Cc: linux-arm-msm, hemantk, jhugo, linux-kernel, loic.poulain,
	Bhaumik Bhatt

MHI specification shows a state machine with support for STOP channel command
and the validity of certain state transitions. MHI host currently does not
provide any mechanism to stop a channel and restart it without resetting it.
There are also times when the device moves on to a different execution
environment while client drivers on the host are unaware of it and still
attempt to reset the channels facing unnecessary timeouts.

This series addresses the above areas to provide support for stopping an MHI
channel, resuming it back, improved documentation and improving upon channel
state machine handling in general.

This set of patches was tested on arm64 architecture.

v5:
-Added reviewed-by tags from Hemant I missed earlier
-Added patch to prevent kernel warnings on clearing channel context twice

v4:
-Updated commit text/descriptions and addressed checkpatch checks
-Added context validity check before starting/stopping channels from new API
-Added patch to clear channel context configuration after reset/unprepare

v3:
-Updated documentation for channel transfer APIs to highlight differences
-Create separate patch for "allowing channel to be disabled from stopped state"

v2:
-Renamed the newly introduced APIs to mhi_start_transfer() / mhi_stop_transfer()
-Added improved documentation to avoid confusion with the new APIs
-Removed the __ prefix from mhi_unprepare_channel() API for consistency.

Bhaumik Bhatt (9):
  bus: mhi: core: Allow sending the STOP channel command
  bus: mhi: core: Allow channel to be disabled from stopped state
  bus: mhi: core: Improvements to the channel handling state machine
  bus: mhi: core: Clear configuration from channel context during reset
  bus: mhi: core: Add support to stop or start channel data transfers
  bus: mhi: core: Check channel execution environment before issuing
    reset
  bus: mhi: core: Remove __ prefix for MHI channel unprepare function
  bus: mhi: Improve documentation on channel transfer setup APIs
  bus: mhi: core: Do not clear channel context more than once

 drivers/bus/mhi/core/init.c     |  23 +++-
 drivers/bus/mhi/core/internal.h |  12 ++
 drivers/bus/mhi/core/main.c     | 238 ++++++++++++++++++++++++++++------------
 include/linux/mhi.h             |  45 +++++++-
 4 files changed, 243 insertions(+), 75 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH v5 3/9] bus: mhi: core: Improvements to the channel handling state machine
@ 2021-01-09  7:38 kernel test robot
  0 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2021-01-09  7:38 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 10022 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1610139297-36435-4-git-send-email-bbhatt@codeaurora.org>
References: <1610139297-36435-4-git-send-email-bbhatt@codeaurora.org>
TO: Bhaumik Bhatt <bbhatt@codeaurora.org>
TO: manivannan.sadhasivam(a)linaro.org
CC: linux-arm-msm(a)vger.kernel.org
CC: hemantk(a)codeaurora.org
CC: jhugo(a)codeaurora.org
CC: linux-kernel(a)vger.kernel.org
CC: loic.poulain(a)linaro.org
CC: Bhaumik Bhatt <bbhatt@codeaurora.org>

Hi Bhaumik,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.11-rc2 next-20210108]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bhaumik-Bhatt/Updates-to-MHI-channel-handling/20210109-050206
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f5e6c330254ae691f6d7befe61c786eb5056007e
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
compiler: hppa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/bus/mhi/core/main.c:1276:6: warning: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing? [redundantAssignInSwitch]
    ret = mhi_device_get_sync(mhi_cntrl->mhi_dev);
        ^
   drivers/bus/mhi/core/main.c:1239:0: note: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing?
    int ret = -EIO;
   ^
   drivers/bus/mhi/core/main.c:1276:6: note: Variable 'ret' is reassigned a value before the old one has been used. 'break;' missing?
    ret = mhi_device_get_sync(mhi_cntrl->mhi_dev);
        ^

vim +1276 drivers/bus/mhi/core/main.c

189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1232  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1233  static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl,
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1234  				    struct mhi_chan *mhi_chan,
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1235  				    enum mhi_ch_state_type to_state)
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1236  {
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1237  	struct device *dev = &mhi_cntrl->mhi_dev->dev;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1238  	enum mhi_cmd_type cmd = MHI_CMD_NOP;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1239  	int ret = -EIO;
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1240  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1241  	dev_dbg(dev, "Updating channel %s(%d) state to: %s\n", mhi_chan->name,
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1242  		mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1243  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1244  	switch (to_state) {
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1245  	case MHI_CH_STATE_TYPE_RESET:
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1246  		write_lock_irq(&mhi_chan->lock);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1247  		if (mhi_chan->ch_state != MHI_CH_STATE_STOP &&
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1248  		    mhi_chan->ch_state != MHI_CH_STATE_ENABLED &&
a7f422f2f89e7d4 Loic Poulain          2020-10-09  1249  		    mhi_chan->ch_state != MHI_CH_STATE_SUSPENDED) {
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1250  			write_unlock_irq(&mhi_chan->lock);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1251  			goto exit_invalid_state;
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1252  		}
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1253  		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1254  		write_unlock_irq(&mhi_chan->lock);
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1255  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1256  		cmd = MHI_CMD_RESET_CHAN;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1257  		break;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1258  	case MHI_CH_STATE_TYPE_STOP:
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1259  		if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED)
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1260  			goto exit_invalid_state;
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1261  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1262  		cmd = MHI_CMD_STOP_CHAN;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1263  		break;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1264  	case MHI_CH_STATE_TYPE_START:
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1265  		if (mhi_chan->ch_state != MHI_CH_STATE_STOP &&
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1266  		    mhi_chan->ch_state != MHI_CH_STATE_DISABLED)
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1267  			goto exit_invalid_state;
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1268  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1269  		cmd = MHI_CMD_START_CHAN;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1270  		break;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1271  	default:
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1272  		goto exit_invalid_state;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1273  	}
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1274  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1275  	/* bring host and device out of suspended states */
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08 @1276  	ret = mhi_device_get_sync(mhi_cntrl->mhi_dev);
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1277  	if (ret)
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1278  		return ret;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1279  	mhi_cntrl->runtime_get(mhi_cntrl);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1280  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1281  	reinit_completion(&mhi_chan->completion);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1282  	ret = mhi_send_cmd(mhi_cntrl, mhi_chan, cmd);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1283  	if (ret) {
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1284  		dev_err(dev, "Failed to send %s(%d) %s command\n",
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1285  			mhi_chan->name, mhi_chan->chan,
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1286  			TO_CH_STATE_TYPE_STR(to_state));
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1287  		goto exit_command_failure;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1288  	}
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1289  
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1290  	ret = wait_for_completion_timeout(&mhi_chan->completion,
189ff97cca53e3f Manivannan Sadhasivam 2020-02-20  1291  				       msecs_to_jiffies(mhi_cntrl->timeout_ms));
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1292  	if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) {
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1293  		dev_err(dev, "Failed to receive %s(%d) %s command completion\n",
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1294  			mhi_chan->name, mhi_chan->chan,
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1295  			TO_CH_STATE_TYPE_STR(to_state));
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1296  		ret = -EIO;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1297  		goto exit_command_failure;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1298  	}
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1299  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1300  	ret = 0;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1301  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1302  	if (to_state != MHI_CH_STATE_TYPE_RESET) {
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1303  		write_lock_irq(&mhi_chan->lock);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1304  		mhi_chan->ch_state = (to_state == MHI_CH_STATE_TYPE_START) ?
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1305  				      MHI_CH_STATE_ENABLED : MHI_CH_STATE_STOP;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1306  		write_unlock_irq(&mhi_chan->lock);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1307  	}
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1308  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1309  	dev_dbg(dev, "Channel %s(%d) state change to %s successful\n",
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1310  		mhi_chan->name, mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1311  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1312  exit_command_failure:
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1313  	mhi_cntrl->runtime_put(mhi_cntrl);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1314  	mhi_device_put(mhi_cntrl->mhi_dev);
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1315  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1316  	return ret;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1317  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1318  exit_invalid_state:
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1319  	dev_err(dev, "Channel %s(%d) update to %s not allowed\n",
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1320  		mhi_chan->name, mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state));
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1321  
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1322  	return -EINVAL;
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1323  }
5ba47e684d77e4c Bhaumik Bhatt         2021-01-08  1324  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-02-04 20:26 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-08 20:54 [PATCH v5 0/9] Updates to MHI channel handling Bhaumik Bhatt
2021-01-08 20:54 ` [PATCH v5 1/9] bus: mhi: core: Allow sending the STOP channel command Bhaumik Bhatt
2021-01-21 11:25   ` Manivannan Sadhasivam
2021-01-08 20:54 ` [PATCH v5 2/9] bus: mhi: core: Allow channel to be disabled from stopped state Bhaumik Bhatt
2021-01-21 11:35   ` Manivannan Sadhasivam
2021-01-08 20:54 ` [PATCH v5 3/9] bus: mhi: core: Improvements to the channel handling state machine Bhaumik Bhatt
2021-01-21 14:43   ` Manivannan Sadhasivam
2021-01-08 20:54 ` [PATCH v5 4/9] bus: mhi: core: Clear configuration from channel context during reset Bhaumik Bhatt
2021-01-21 14:47   ` Manivannan Sadhasivam
2021-01-08 20:54 ` [PATCH v5 5/9] bus: mhi: core: Add support to stop or start channel data transfers Bhaumik Bhatt
2021-01-21 14:50   ` Manivannan Sadhasivam
2021-02-04 20:25     ` Bhaumik Bhatt
2021-01-08 20:54 ` [PATCH v5 6/9] bus: mhi: core: Check channel execution environment before issuing reset Bhaumik Bhatt
2021-01-21 15:12   ` Manivannan Sadhasivam
2021-02-04 20:23     ` Bhaumik Bhatt
2021-01-08 20:54 ` [PATCH v5 7/9] bus: mhi: core: Remove __ prefix for MHI channel unprepare function Bhaumik Bhatt
2021-01-08 20:54 ` [PATCH v5 8/9] bus: mhi: Improve documentation on channel transfer setup APIs Bhaumik Bhatt
2021-01-08 20:54 ` [PATCH v5 9/9] bus: mhi: core: Do not clear channel context more than once Bhaumik Bhatt
2021-01-09  4:39   ` Hemant Kumar
2021-01-21 15:15   ` Manivannan Sadhasivam
  -- strict thread matches above, loose matches on Subject: below --
2021-01-09  7:38 [PATCH v5 3/9] bus: mhi: core: Improvements to the channel handling state machine kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.