Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp810566pxf; Thu, 1 Apr 2021 14:19:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEiyOhx5a95zrv5NB5HzylP6g4VgPPvqNgCQNRO/bf+lWwQ4+qaX+NgPddiYRNi4hvxd41 X-Received: by 2002:a6b:8b57:: with SMTP id n84mr8484044iod.12.1617311945082; Thu, 01 Apr 2021 14:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617311945; cv=none; d=google.com; s=arc-20160816; b=PmHviQgH+DbqXtD55FWWJzeTLCywfqLBeGyl0QSZAA/ew1XXT0ZNz7+WpXxJwgH0F1 OMQOKiMLD3xTW5vwMUgQEc7MH4Rni4T6cLKPAIlGjO5/f9vXTV53IO70DVzm8tWPBomd Hvb1TeYVgbAkajy5LNKhFgncL+6wZvFBi+oCfQbx1CbuzkhBvaO+eFFMbQB2Nb5nSapA ScFMY6h+SV/W8wA1qQZBrxM7WyqZozseZuv0U/1rtsAztGZf24iTCYdlvuu/WmBn+ENv 2EUBmDZLRw/I5Nf4KqDZ6xqrjPiY5SzfTiLmF40jIfYEWclY8ujhLcH7/Z+Vv/Elqwaq pYiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=et2I62tqrNz3gbVn9fFmVi93j54gVD5RzHMWTdSyYsY=; b=i1/tclvJHdQ8WF0Xkq+8sVN+cwy7FFwZJZqlcHz4Ledt0QyXqHDbYsNdRO7DouH8tc DeEPlonq5jydSLj7bx2+ltKZwvqdWO6ZM7wkS7T6ohn0xm78u4e6oIwX0b4i2LdBzlIO l1jXRo1abrE5qmMNasNNtfxHEKcfZZQ7hJdfnRq56AMZrZRdTysPghSZxF7kmJkqqCiI T139+wxcTOR0PWJjC409xdKuBnkD1PYwunBYj+sj9PIgolD1iuB6c4hFt210LiTHOID/ UNeYTkiqVMbs4kFwLVuYAUb3dWT8NIFqlqQDkExCCTyxLhlZlsf12EYJoZm0K28qE2uN BKHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=IxsrJrFh; 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 x13si6258668ilg.92.2021.04.01.14.18.51; Thu, 01 Apr 2021 14:19:05 -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=IxsrJrFh; 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 S234884AbhDAVQv (ORCPT + 99 others); Thu, 1 Apr 2021 17:16:51 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:28360 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234845AbhDAVQr (ORCPT ); Thu, 1 Apr 2021 17:16:47 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1617311807; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=et2I62tqrNz3gbVn9fFmVi93j54gVD5RzHMWTdSyYsY=; b=IxsrJrFhEQfZ7nv4tE6/AGvT9FSltn8JD2mefi4EoJDbvzzRdovqIgjzdtxisNgslpJyaYlG B7ZXgi9Co4bs7VmxA3Rb9mtFpaM7fRg9pywkUXjtnTv1IvzIsYu28baEDYh4uQ17+Ttbj4fK XJrbBSa4P1gUqePMmapR/rXGfKo= X-Mailgun-Sending-Ip: 198.61.254.9 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-n02.prod.us-west-2.postgun.com with SMTP id 6066382f8807bcde1d099200 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 01 Apr 2021 21:16:31 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id F3E92C43462; Thu, 1 Apr 2021 21:16:30 +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,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from malabar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bbhatt) by smtp.codeaurora.org (Postfix) with ESMTPSA id C1782C43462; Thu, 1 Apr 2021 21:16:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C1782C43462 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: manivannan.sadhasivam@linaro.org Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, carl.yin@quectel.com, naveen.kumar@quectel.com, loic.poulain@linaro.org, Bhaumik Bhatt Subject: [PATCH v8 7/9] bus: mhi: core: Check channel execution environment before issuing reset Date: Thu, 1 Apr 2021 14:16:16 -0700 Message-Id: <1617311778-1254-8-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617311778-1254-1-git-send-email-bbhatt@codeaurora.org> References: <1617311778-1254-1-git-send-email-bbhatt@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A client can attempt to unprepare certain channels for transfer even after the execution environment they are supposed to run in has changed. In the event that happens, the device need not be notified of the reset and the host can proceed with clean up for the channel context and memory allocated for it on the host as the device will no longer be able to respond to such a request. Signed-off-by: Bhaumik Bhatt Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 989a2a8..04480fd 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -1329,6 +1329,12 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, mutex_lock(&mhi_chan->mutex); + if (!(BIT(mhi_cntrl->ee) & mhi_chan->ee_mask)) { + dev_dbg(dev, "Current EE: %s Required EE Mask: 0x%x\n", + TO_MHI_EXEC_STR(mhi_cntrl->ee), mhi_chan->ee_mask); + goto exit_unprepare_channel; + } + /* no more processing events for this channel */ ret = mhi_update_channel_state(mhi_cntrl, mhi_chan, MHI_CH_STATE_TYPE_RESET); @@ -1336,6 +1342,11 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, dev_err(dev, "%d: Failed to reset channel, still resetting\n", mhi_chan->chan); +exit_unprepare_channel: + write_lock_irq(&mhi_chan->lock); + mhi_chan->ch_state = MHI_CH_STATE_DISABLED; + write_unlock_irq(&mhi_chan->lock); + if (!mhi_chan->offload_ch) { mhi_reset_chan(mhi_cntrl, mhi_chan); mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project