Skip to contentSkip to conversation

bus: mhi: Remove auto-start option

PATCH Superseded Loic Poulain 3 participants 4 messages Sep 18, 2020 – Sep 21, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: mhi: Remove auto-start option

There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used.

This is really up to the MHI device(channel) driver to manage the state of its channels.

---
 drivers/bus/mhi/core/init.c     | 9 ---------
 drivers/bus/mhi/core/internal.h | 1 -
 include/linux/mhi.h             | 2 --
 net/qrtr/mhi.c                  | 5 +++++
 4 files changed, 5 insertions(+), 12 deletions(-)
drivers/bus/mhi/core/init.c +0 -9
index ac19067..7aef6b7 100644
@@ -727,7 +727,6 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl,
 		mhi_chan->offload_ch = ch_cfg->offload_channel;
 		mhi_chan->db_cfg.reset_req = ch_cfg->doorbell_mode_switch;
 		mhi_chan->pre_alloc = ch_cfg->auto_queue;
-		mhi_chan->auto_start = ch_cfg->auto_start;
 
 		/*
 		 * If MHI host allocates buffers, then the channel direction
@@ -1125,11 +1124,6 @@ static int mhi_driver_probe(struct device *dev)
 			goto exit_probe;
 
 		ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
-		if (ul_chan->auto_start) {
-			ret = mhi_prepare_channel(mhi_cntrl, ul_chan);
-			if (ret)
-				goto exit_probe;
-		}
 	}
 
 	ret = -EINVAL;
@@ -1163,9 +1157,6 @@ static int mhi_driver_probe(struct device *dev)
 	if (ret)
 		goto exit_probe;
 
-	if (dl_chan && dl_chan->auto_start)
-		mhi_prepare_channel(mhi_cntrl, dl_chan);
-
 	mhi_device_put(mhi_dev);
 
 	return ret;
drivers/bus/mhi/core/internal.h +0 -1
index 5a81a42..73b52a0 100644
@@ -563,7 +563,6 @@ struct mhi_chan {
 	bool configured;
 	bool offload_ch;
 	bool pre_alloc;
-	bool auto_start;
 	bool wake_capable;
 };
 
include/linux/mhi.h +0 -2
index 008b8f6..742dabe 100644
@@ -214,7 +214,6 @@ enum mhi_db_brst_mode {
  * @offload_channel: The client manages the channel completely
  * @doorbell_mode_switch: Channel switches to doorbell mode on M0 transition
  * @auto_queue: Framework will automatically queue buffers for DL traffic
- * @auto_start: Automatically start (open) this channel
  * @wake-capable: Channel capable of waking up the system
  */
 struct mhi_channel_config {
@@ -232,7 +231,6 @@ struct mhi_channel_config {
 	bool offload_channel;
 	bool doorbell_mode_switch;
 	bool auto_queue;
-	bool auto_start;
 	bool wake_capable;
 };
 
net/qrtr/mhi.c +5 -0
index ff0c414..7100f0b 100644
@@ -76,6 +76,11 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
+	/* start channels */
+	rc = mhi_prepare_for_transfer(mhi_dev);
+	if (rc)
+		return rc;
+
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)
 		return -ENOMEM;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 101 lines · Loic Poulain

There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used.

This is really up to the MHI device(channel) driver to manage the state of its channels.

---
 drivers/bus/mhi/core/init.c     | 9 ---------
 drivers/bus/mhi/core/internal.h | 1 -
 include/linux/mhi.h             | 2 --
 net/qrtr/mhi.c                  | 5 +++++
 4 files changed, 5 insertions(+), 12 deletions(-)
drivers/bus/mhi/core/init.c +0 -1
index ac19067..7aef6b7 100644
@@ -727,7 +727,6 @@ static int parse_ch_cfg(struct mhi_controller 
 *mhi_cntrl,
 		mhi_chan->offload_ch = ch_cfg->offload_channel;
 		mhi_chan->db_cfg.reset_req = ch_cfg->doorbell_mode_switch;
 		mhi_chan->pre_alloc = ch_cfg->auto_queue;
-		mhi_chan->auto_start = ch_cfg->auto_start;
 
 		/*
drivers/bus/mhi/core/init.c +0 -8
 		 * If MHI host allocates buffers, then the channel direction
@@ -1125,11 +1124,6 @@ static int mhi_driver_probe(struct device *dev)
 			goto exit_probe;
 
 		ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
-		if (ul_chan->auto_start) {
-			ret = mhi_prepare_channel(mhi_cntrl, ul_chan);
-			if (ret)
-				goto exit_probe;
-		}
 	}
 
 	ret = -EINVAL;
@@ -1163,9 +1157,6 @@ static int mhi_driver_probe(struct device *dev)
 	if (ret)
 		goto exit_probe;
 
-	if (dl_chan && dl_chan->auto_start)
-		mhi_prepare_channel(mhi_cntrl, dl_chan);
-
 	mhi_device_put(mhi_dev);
 
 	return ret;
drivers/bus/mhi/core/internal.h +0 -1
index 5a81a42..73b52a0 100644
@@ -563,7 +563,6 @@ struct mhi_chan {
 	bool configured;
 	bool offload_ch;
 	bool pre_alloc;
-	bool auto_start;
 	bool wake_capable;
 };
 
include/linux/mhi.h +0 -0
index 008b8f6..742dabe 100644
@@ -214,7 +214,6 @@ enum mhi_db_brst_mode {
  * @offload_channel: The client manages the channel completely
  * @doorbell_mode_switch: Channel switches to doorbell mode on M0 

transition
* @auto_queue: Framework will automatically queue buffers for DL
traffic
- * @auto_start: Automatically start (open) this channel
* @wake-capable: Channel capable of waking up the system */
struct mhi_channel_config {

include/linux/mhi.h +0 -1
@@ -232,7 +231,6 @@ struct mhi_channel_config {
 	bool offload_channel;
 	bool doorbell_mode_switch;
 	bool auto_queue;
-	bool auto_start;
 	bool wake_capable;
 };
 
net/qrtr/mhi.c +5 -0
index ff0c414..7100f0b 100644
@@ -76,6 +76,11 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
+	/* start channels */
+	rc = mhi_prepare_for_transfer(mhi_dev);
+	if (rc)
+		return rc;
+
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)
Quoted 1 line

return -ENOMEM;

Hi Loic,

Thank you for your patch. Hemant and I discussed and we are OK with this patch.

Adding Chris to ensure that QRTR changes are acceptable.

Thanks,
Bhaumik

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

#2 lore raw
In reply to Loic Poulain

Hi Loic,

Quoted 9 lines · Loic Poulain

There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used.

This is really up to the MHI device(channel) driver to manage the state of its channels.

The patch content looks good but you should split the qrtr change to a separate patch. I can't queue the networking change through mhi tree.

Thanks,
Mani

Quoted 94 lines

---

drivers/bus/mhi/core/init.c     | 9 ---------
drivers/bus/mhi/core/internal.h | 1 -
include/linux/mhi.h             | 2 --
net/qrtr/mhi.c                  | 5 +++++
4 files changed, 5 insertions(+), 12 deletions(-)
drivers/bus/mhi/core/init.c +0 -1
index ac19067..7aef6b7 100644
@@ -727,7 +727,6 @@ static int parse_ch_cfg(struct mhi_controller
 *mhi_cntrl,
 		mhi_chan->offload_ch = ch_cfg->offload_channel;
 		mhi_chan->db_cfg.reset_req = ch_cfg->doorbell_mode_switch;
 		mhi_chan->pre_alloc = ch_cfg->auto_queue;
-		mhi_chan->auto_start = ch_cfg->auto_start;
 
 		/*

* If MHI host allocates buffers, then the channel direction

drivers/bus/mhi/core/init.c +0 -8
@@ -1125,11 +1124,6 @@ static int mhi_driver_probe(struct device *dev)
 			goto exit_probe;
 
 		ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
-		if (ul_chan->auto_start) {
-			ret = mhi_prepare_channel(mhi_cntrl, ul_chan);
-			if (ret)
-				goto exit_probe;
-		}
 	}
 
 	ret = -EINVAL;
@@ -1163,9 +1157,6 @@ static int mhi_driver_probe(struct device *dev)
 	if (ret)
 		goto exit_probe;
 
-	if (dl_chan && dl_chan->auto_start)
-		mhi_prepare_channel(mhi_cntrl, dl_chan);
-
 	mhi_device_put(mhi_dev);
 
 	return ret;
drivers/bus/mhi/core/internal.h +0 -1
index 5a81a42..73b52a0 100644
@@ -563,7 +563,6 @@ struct mhi_chan {
 	bool configured;
 	bool offload_ch;
 	bool pre_alloc;
-	bool auto_start;
 	bool wake_capable;
 };
 
include/linux/mhi.h +0 -0
index 008b8f6..742dabe 100644
@@ -214,7 +214,6 @@ enum mhi_db_brst_mode {
 * @offload_channel: The client manages the channel completely
 * @doorbell_mode_switch: Channel switches to doorbell mode on M0

transition
* @auto_queue: Framework will automatically queue buffers for DL traffic
- * @auto_start: Automatically start (open) this channel
* @wake-capable: Channel capable of waking up the system */
struct mhi_channel_config {

include/linux/mhi.h +0 -1
@@ -232,7 +231,6 @@ struct mhi_channel_config {
 	bool offload_channel;
 	bool doorbell_mode_switch;
 	bool auto_queue;
-	bool auto_start;
 	bool wake_capable;
 };
 
net/qrtr/mhi.c +5 -0
index ff0c414..7100f0b 100644
@@ -76,6 +76,11 @@ static int qcom_mhi_qrtr_probe(struct mhi_device
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
+	/* start channels */
+	rc = mhi_prepare_for_transfer(mhi_dev);
+	if (rc)
+		return rc;
+
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)
		return -ENOMEM;
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#3 lore raw
Quoted 9 lines · Manivannan Sadhasivam

Hi Loic,

Quoted 5 lines · Loic Poulain

There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used.

Quoted 6 lines
Quoted 4 lines

This is really up to the MHI device(channel) driver to manage the state of its channels.

The patch content looks good but you should split the qrtr change to a separate patch. I can't queue the networking change through mhi tree.

Ok going to split that.

Thanks,
Loic