Skip to contentSkip to conversation

net: qrtr: mhi: synchronize qrtr and mhi preparation

PATCH Superseded Bhaumik Bhatt 2 participants 7 messages Jul 21, 2021 – Jul 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: qrtr: mhi: synchronize qrtr and mhi preparation

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +15 -5
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct qrtr_endpoint *ep, struct sk_buff *skb)
 	struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev, ep);
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
 		sock_hold(skb->sk);
 
@@ -78,11 +83,6 @@ 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, MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)
 		return -ENOMEM;
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 	dev_set_drvdata(&mhi_dev->dev, qdev);
 	rc = qrtr_endpoint_register(&qdev->ep, QRTR_EP_NID_AUTO);
 	if (rc)
 		return rc;
 
+	/* start channels */
+	rc = mhi_prepare_for_transfer(mhi_dev, MHI_CH_INBOUND_ALLOC_BUFS);
+	if (rc) {
+		qrtr_endpoint_unregister(&qdev->ep);
+		dev_set_drvdata(&mhi_dev->dev, NULL);
+		return rc;
+	}
+
+	complete_all(&qdev->ready);
 	dev_dbg(qdev->dev, "Qualcomm MHI QRTR driver probed\n");
 
 	return 0;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw
Quoted 52 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +5 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct qrtr_endpoint
 *ep, struct sk_buff *skb)
 	struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev, 
 ep);
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
net/qrtr/mhi.c +0 -5
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ 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, MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)
Quoted 1 line

return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

Quoted 10 lines
net/qrtr/mhi.c +1 -0
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 
 
 	return 0;
#2 lore raw
Quoted 46 lines · On 2021-07-21 10:52 AM, [email protected] wrote:
Quoted 45 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +5 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct qrtr_endpoint
 *ep, struct sk_buff *skb)
 	struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev, 
 ep);
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
net/qrtr/mhi.c +0 -0
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
Quoted 9 lines
Quoted 8 lines
net/qrtr/mhi.c +0 -5
-	/* start channels */
-	rc = mhi_prepare_for_transfer(mhi_dev, MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)

return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

You mean just before setting qdev->mhi_dev? I don't see why that would make a difference mainly because the qcom_mhi_qrtr_send() will only happen after endpoint is registered and DL xfer cb will also only come in after we have prepared the channels and completed ready with dev_data already set.

Quoted 10 lines

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device · line 98

Quoted 10 lines
net/qrtr/mhi.c +1 -0
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 
 
 	return 0;

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

#3 lore raw
Quoted 56 lines · Bhaumik Bhatt
Quoted 46 lines · On 2021-07-21 10:52 AM, [email protected] wrote:
Quoted 45 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +5 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct qrtr_endpoint
 *ep, struct sk_buff *skb)
 	struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev, 
 ep);
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
net/qrtr/mhi.c +0 -0
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
Quoted 9 lines
Quoted 8 lines
net/qrtr/mhi.c +0 -5
-	/* start channels */
-	rc = mhi_prepare_for_transfer(mhi_dev, MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)

return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

Quoted 5 lines

You mean just before setting qdev->mhi_dev? I don't see why that would make a difference
mainly because the qcom_mhi_qrtr_send() will only happen after endpoint is registered and DL xfer cb will also only come in after we have prepared the channels and completed ready with dev_data already set.

looks like qcom_mhi_qrtr_send is not going to get called directly. i was thinking what if this api is called before init_completion() returns. if it is only possible through ep.xmit call back only, can you move it right above qdev->ep.xmit = qcom_mhi_qrtr_send; ?

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
net/qrtr/mhi.c +1 -0
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 
 
Quoted 7 lines
Quoted 1 line

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, · line 111

Quoted 1 line
net/qrtr/mhi.c +0 -0
 	return 0;

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

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

#4 lore raw
Quoted 63 lines · On 2021-07-21 03:27 PM, [email protected] wrote:
Quoted 57 lines · Bhaumik Bhatt
Quoted 47 lines · On 2021-07-21 10:52 AM, [email protected] wrote:
Quoted 46 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +1 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct 

qrtr_endpoint
*ep, struct sk_buff *skb)
struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev,
ep);

net/qrtr/mhi.c +4 -0
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
Quoted 9 lines
Quoted 8 lines
net/qrtr/mhi.c +0 -5
-	/* start channels */
-	rc = mhi_prepare_for_transfer(mhi_dev, MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
 	if (!qdev)

return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

Quoted 5 lines

You mean just before setting qdev->mhi_dev? I don't see why that would make a difference
mainly because the qcom_mhi_qrtr_send() will only happen after endpoint is registered and DL xfer cb will also only come in after we have prepared the channels and completed ready with dev_data already set.

Quoted 7 lines

looks like qcom_mhi_qrtr_send is not going to get called directly. i was thinking
what if this api is called before init_completion() returns. if it is only possible
through ep.xmit call back only, can you move it right above qdev->ep.xmit = qcom_mhi_qrtr_send; ?

Quoted 1 line

Ah. OK. I see your point. I will do that and upload a v2.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
net/qrtr/mhi.c +1 -0
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 
 
Quoted 7 lines
Quoted 1 line

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, · line 111

Quoted 1 line
net/qrtr/mhi.c +0 -0
 	return 0;

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

Quoted 5 lines

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

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

#5 lore raw
Quoted 65 lines · Bhaumik Bhatt
Quoted 64 lines · On 2021-07-21 03:27 PM, [email protected] wrote:
Quoted 63 lines · Bhaumik Bhatt
Quoted 47 lines · On 2021-07-21 10:52 AM, [email protected] wrote:
Quoted 46 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +1 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct 

qrtr_endpoint
*ep, struct sk_buff *skb)
struct qrtr_mhi_dev *qdev = container_of(ep, struct qrtr_mhi_dev,
ep);

net/qrtr/mhi.c +4 -0
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ static int qcom_mhi_qrtr_probe(struct mhi_device 
 *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
Quoted 10 lines

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, · line 88

Quoted 9 lines
net/qrtr/mhi.c +0 -5
-	/* start channels */
-	rc = mhi_prepare_for_transfer(mhi_dev, 
 MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
net/qrtr/mhi.c +0 -0
 	if (!qdev)
 		return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

You mean just before setting qdev->mhi_dev? I don't see why that would make a difference
mainly because the qcom_mhi_qrtr_send() will only happen after endpoint is registered and DL xfer cb will also only come in after we have prepared the channels and completed ready with dev_data already set.

Quoted 9 lines
Quoted 7 lines

looks like qcom_mhi_qrtr_send is not going to get called directly. i was thinking
what if this api is called before init_completion() returns. if it is only possible
through ep.xmit call back only, can you move it right above qdev->ep.xmit = qcom_mhi_qrtr_send; ?

Quoted 1 line

Ah. OK. I see your point. I will do that and upload a v2.

On second thought, this is not required because the ep.xmit() will not be called until the qrtr_endpoint_register() is done.

So this version should be fine IMO.

Quoted 23 lines
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
net/qrtr/mhi.c +1 -0
@@ -90,12 +90,22 @@ static int qcom_mhi_qrtr_probe(struct 
 mhi_device *mhi_dev,
 	qdev->mhi_dev = mhi_dev;
 	qdev->dev = &mhi_dev->dev;
 	qdev->ep.xmit = qcom_mhi_qrtr_send;
+	init_completion(&qdev->ready);
 
 
 
Quoted 7 lines
Quoted 1 line

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, · line 111

Quoted 1 line
net/qrtr/mhi.c +0 -0
 	return 0;

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

Quoted 5 lines

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

Quoted 5 lines

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

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

Reviewed-by
#6 lore raw
Quoted 73 lines · Bhaumik Bhatt
Quoted 72 lines · Bhaumik Bhatt
Quoted 71 lines · On 2021-07-21 03:27 PM, [email protected] wrote:
Quoted 58 lines · Bhaumik Bhatt
Quoted 47 lines · On 2021-07-21 10:52 AM, [email protected] wrote:
Quoted 46 lines · Bhaumik Bhatt

A dl callback can be received anytime after mhi_prepare_for_transfer has been called. There is a window where the callback may happen before the probe initializes the qrtr_mhi_dev state. Move the mhi_prepare_for_transfer call after the registering the endpoint.

Once moved, the reverse can happen where qrtr will try to send a packet before the channels are prepared. Add a wait in the sending path to ensure the channels are prepared before trying to do a ul transfer.

Fixes a2e2cc0dbb11 ("net: qrtr: Start MHI channels during init")
---
 net/qrtr/mhi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
net/qrtr/mhi.c +1 -0
index 29b4fa3..22b0395 100644
@@ -15,6 +15,7 @@ struct qrtr_mhi_dev {
 	struct qrtr_endpoint ep;
 	struct mhi_device *mhi_dev;
 	struct device *dev;
+	struct completion ready;
 };
 
 /* From MHI to QRTR */
@@ -50,6 +51,10 @@ static int qcom_mhi_qrtr_send(struct 

qrtr_endpoint
*ep, struct sk_buff *skb)
struct qrtr_mhi_dev *qdev = container_of(ep, struct
qrtr_mhi_dev, ep);

net/qrtr/mhi.c +4 -0
 	int rc;
 
+	rc = wait_for_completion_interruptible(&qdev->ready);
+	if (rc)
+		goto free_skb;
+
 	if (skb->sk)
 		sock_hold(skb->sk);
@@ -78,11 +83,6 @@ static int qcom_mhi_qrtr_probe(struct 
 mhi_device *mhi_dev,
 	struct qrtr_mhi_dev *qdev;
 	int rc;
 
Quoted 10 lines

net/qrtr/mhi.c static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, · line 88

Quoted 9 lines
net/qrtr/mhi.c +0 -5
-	/* start channels */
-	rc = mhi_prepare_for_transfer(mhi_dev, 
 MHI_CH_INBOUND_ALLOC_BUFS);
-	if (rc)
-		return rc;
-
 	qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL);
net/qrtr/mhi.c +0 -0
 	if (!qdev)
 		return -ENOMEM;

would it be good to init completion variable here (call init_completion) ?

Quoted 5 lines

You mean just before setting qdev->mhi_dev? I don't see why that would make a difference
mainly because the qcom_mhi_qrtr_send() will only happen after endpoint is registered and DL xfer cb will also only come in after we have prepared the channels and completed ready with dev_data already set.

looks like qcom_mhi_qrtr_send is not going to get called directly. i was thinking
what if this api is called before init_completion() returns. if it is only possible
through ep.xmit call back only, can you move it right above qdev->ep.xmit = qcom_mhi_qrtr_send; ?

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

Ah. OK. I see your point. I will do that and upload a v2.

On second thought, this is not required because the ep.xmit() will not be called until the qrtr_endpoint_register() is done.

So this version should be fine IMO.

Thanks for checking that, Bhaumik.

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