public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: hemantk@codeaurora.org
To: bbhatt@codeaurora.org
Cc: manivannan.sadhasivam@linaro.org, bqiang@codeaurora.org,
	linux-arm-msm@vger.kernel.org, clew@codeaurora.org,
	linux-kernel@vger.kernel.org,
	bbhatt=codeaurora.org@codeaurora.org,
	hemantk=codeaurora.org@codeaurora.org
Subject: Re: [PATCH] net: qrtr: mhi: synchronize qrtr and mhi preparation
Date: Thu, 22 Jul 2021 19:45:52 -0700	[thread overview]
Message-ID: <64bbb3db0e1bb33c03e31a6e467c9e42@codeaurora.org> (raw)
In-Reply-To: <62daad3e0074400ee7011f55a6f255ac@codeaurora.org>

On 2021-07-22 12:50, Bhaumik Bhatt wrote:
> On 2021-07-22 12:04 PM, Bhaumik Bhatt wrote:
>> On 2021-07-21 03:27 PM, hemantk@codeaurora.org wrote:
>>> On 2021-07-21 11:07, Bhaumik Bhatt wrote:
>>>> On 2021-07-21 10:52 AM, hemantk@codeaurora.org wrote:
>>>>> On 2021-07-20 18:42, Bhaumik Bhatt wrote:
>>>>>> 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")
>>>>>> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>>>>>> ---
>>>>>>  net/qrtr/mhi.c | 20 +++++++++++++++-----
>>>>>>  1 file changed, 15 insertions(+), 5 deletions(-)
>>>>>> 
>>>>>> diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c
>>>>>> index 29b4fa3..22b0395 100644
>>>>>> --- a/net/qrtr/mhi.c
>>>>>> +++ b/net/qrtr/mhi.c
>>>>>> @@ -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;
>>>>> 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.
>>> 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; ?
>>>> 
>> 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.

Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2021-07-23  2:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  1:42 [PATCH] net: qrtr: mhi: synchronize qrtr and mhi preparation Bhaumik Bhatt
2021-07-21 17:52 ` hemantk
2021-07-21 18:07   ` Bhaumik Bhatt
2021-07-21 22:27     ` hemantk
2021-07-22 19:04       ` Bhaumik Bhatt
2021-07-22 19:50         ` Bhaumik Bhatt
2021-07-23  2:45           ` hemantk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-11-05  1:29 Chris Lew
2024-11-06  9:14 ` Maxim Kochetkov
2024-11-07 11:27 ` Manivannan Sadhasivam
2024-11-07 19:58   ` Chris Lew
2024-11-08 10:32 ` Johan Hovold
2024-11-22  0:28   ` Chris Lew
2024-11-24 15:04     ` Manivannan Sadhasivam
2024-11-25 19:05       ` Chris Lew
2025-03-18  8:03     ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64bbb3db0e1bb33c03e31a6e467c9e42@codeaurora.org \
    --to=hemantk@codeaurora.org \
    --cc=bbhatt=codeaurora.org@codeaurora.org \
    --cc=bbhatt@codeaurora.org \
    --cc=bqiang@codeaurora.org \
    --cc=clew@codeaurora.org \
    --cc=hemantk=codeaurora.org@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox