Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp786729pxv; Thu, 22 Jul 2021 12:07:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVZef4odga1bCN2sGZxkoIYFjIcAGXWCMsasMk4isodJCHS5dM/qr2EQ5EXfGfnvHXLXo7 X-Received: by 2002:a17:906:9bf0:: with SMTP id de48mr1244052ejc.260.1626980831961; Thu, 22 Jul 2021 12:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626980831; cv=none; d=google.com; s=arc-20160816; b=Yc9l9c5VL4reyiC+hvwFwWCr1KM/bg7c2Cb31QdmgpJehxTe57AXfcrspx27LT8yGz vxOlVFHUAII4RPBdApBXYGH26xS6IIjN35IrOVY6/5RaxxQmsTg5lpCUJSFLR6b0KT1a fFiYeB2qRLhSkzl4PEo94/4MZt8wgqqv9IQnwvcWDBPwEpMfDmkw/1AOaShFwVlpT5WF pRTQMxlmDaVuc6fdtNq6u7N/A8S4o3gyvEzjEOFN0n6MYz2wTktZ/ZyjLAgv6x1MuUyJ UbEEIBDPt/QQzu2rrfeGVD/tozDEpP5mgYvvi3dgucgUmBBvzwJgD/HlrpMIIPpPRFDw oeZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :mail-reply-to:reply-to:organization:subject:cc:to:from:date :content-transfer-encoding:mime-version:sender:dkim-signature; bh=WduP3o7gBFrmEiLJhLfBl2y3nG4pbHLqEz9PeWRtcrs=; b=h6N352D29ISQWZoA53d9J98KmQf29HKJh0vGR37vXLBtGDb0wMu687wXI/N42GkXfS ZFlr7TLo+oYstnQLkqzuNk4v/wk852sh5OpHmfW3JnQmmEMbmArtfD0NK/nhMzQhr0R2 6njfP4JZuBEOGfY/9mm7IoZQv6s38Yh0n32+xYpy71ADzqIEnMSy6fUuhW53UxiPiImw JTlMw50/Udvjw2KxWOG4Yl2bJ4GHeFRWduYon4MvZdMoAQys5IuM41elBySpmLvuSQHq 1lackyeThmn0B5s95JpfvBQ1KEg1Z2w3KnA2JjNDlrTkz+Apyl2JuBS47IgCBzKp33LJ RIiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=qvbkEVGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si9389595ejn.647.2021.07.22.12.06.48; Thu, 22 Jul 2021 12:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=qvbkEVGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbhGVSYb (ORCPT + 99 others); Thu, 22 Jul 2021 14:24:31 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:40584 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbhGVSYa (ORCPT ); Thu, 22 Jul 2021 14:24:30 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1626980705; h=Message-ID: References: In-Reply-To: Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=WduP3o7gBFrmEiLJhLfBl2y3nG4pbHLqEz9PeWRtcrs=; b=qvbkEVGvQiUtzIOxHAi7FP96+OMl0/ZbV2MEVfC8w901ZpPmGzcODoZntAQU5tKRNSW+z/JU icH1sWfpCNnxCW/SahYzrWULMS8Ik+tFWOOE9k1OzBhMU+iX5Q+VK83qZQuPiXxx1iJceoiP kQRyqlmSfI56TjDei5S8yaxxMpM= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-east-1.postgun.com with SMTP id 60f9c1424815712f3ae551f2 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 22 Jul 2021 19:04:34 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 16AFEC433F1; Thu, 22 Jul 2021 19:04:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: bbhatt) by smtp.codeaurora.org (Postfix) with ESMTPSA id 91A72C433D3; Thu, 22 Jul 2021 19:04:33 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 22 Jul 2021 12:04:33 -0700 From: Bhaumik Bhatt To: hemantk@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 Organization: Qualcomm Innovation Center, Inc. Reply-To: bbhatt@codeaurora.org Mail-Reply-To: bbhatt@codeaurora.org In-Reply-To: References: <1626831778-31796-1-git-send-email-bbhatt@codeaurora.org> <4214f00fa8cbcced4f389125b392f3b3@codeaurora.org> <0da23f32f4313c0b701bafc078942a4e@codeaurora.org> Message-ID: <0e06bf8a7132cc9539e4d9b1e41b8863@codeaurora.org> X-Sender: bbhatt@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >>>> --- >>>> 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. >>>> @@ -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 > > 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