Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp599643pxb; Fri, 8 Jan 2021 12:58:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn8a6s+BID+3gQ6DmCkEJB/z6FqEGMEy6t58wCX19DQNj3Cn5+W4c8pKc7lJ2TEH1f3+hB X-Received: by 2002:a05:6402:1c8a:: with SMTP id cy10mr6535422edb.151.1610139503781; Fri, 08 Jan 2021 12:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610139503; cv=none; d=google.com; s=arc-20160816; b=nV9BdkggSIEp/kHisNutc8LoVrnTM9avC94XuyrN0A3UNYo4AwB1lSujTgwDa0fWUe wyduTCm5+KDa6ZtMAlxL9hGYMZx3EYGPLkqOSDaoibcY/dI4C64mXnILNG986SPQDqPU RNkAT2IFgzgTtJmFNY8lkAt786zbQYYxT8FVglP/89xU4TiYhIlclwK0URK/62rcu8Tn rnZjxqhfEMNnX7DOgwmp4b5puct5v/ibLvlgXFJdTPN1A7KIjPMWS3UY3WC/5D/XbjG0 EUITnyiUaJIpTRnHUSt1X6XL8TodsGAEoE6r9Z43JIuWJaC4yjza6rNcVJ38iwWGgv/8 n/sw== 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=wZhhI3WIjbbH4RqH1eCzwajCfWCHwYPEW0BZAnQnUmE=; b=Tm3zS8EcaZSmjBfdoFqKwKmawpGePgZicvKXV3GKlOsdjETFQulAcNqpZ+AMWwurQd L5Ep/Ll8mA9JW0//lT5t2BWZlLNLD4ErdFq5LzgcjSRoOXrr071h2CTGYGzSyPbGl5EU 9vuIYEBhQGNtM3rY2wSTqoYEy2vXyHCTlutNEhmL1EDWhq3b63s3ZoaH2ZJ9g/+lWQDH ONuaMCI0tYKXb2yI/bfHy7iuHDHraYdGkF6smH66MQul0mBZYJcg8y9KxwFTrTAP+HBd OsjRvAvZCZ8B5o3q6AsQhbquwaJNmkwQ9A/nqXHZDi9ru6OUfuY5U11GM3xBqSMT75jj 2wtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DwEMUawr; 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 j26si3956690eds.457.2021.01.08.12.58.00; Fri, 08 Jan 2021 12:58:23 -0800 (PST) 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=DwEMUawr; 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 S1729460AbhAHU4L (ORCPT + 99 others); Fri, 8 Jan 2021 15:56:11 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:61561 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729452AbhAHU4K (ORCPT ); Fri, 8 Jan 2021 15:56:10 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1610139352; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=wZhhI3WIjbbH4RqH1eCzwajCfWCHwYPEW0BZAnQnUmE=; b=DwEMUawr77LrfUnGAqXWTufyr4oxDIGRcHtU2uZGqYtH4bgZazKyhpgtgKVKoTlV4wNbI1Mw fCcgCEJsr9Fis9U/l3ktJPB9QtMTwmZQ0cHq1xjyCFlQrUjZmKc6Aqi0MU5P27Fei1heBsUW md80vO2Fe3RUrKupMmpR+PFd9ts= X-Mailgun-Sending-Ip: 69.72.43.15 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-n09.prod.us-west-2.postgun.com with SMTP id 5ff8c6acd84bad35476d8d81 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 08 Jan 2021 20:55:08 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EED7FC43464; Fri, 8 Jan 2021 20:55:07 +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 4862DC43462; Fri, 8 Jan 2021 20:55:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4862DC43462 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, loic.poulain@linaro.org, Bhaumik Bhatt Subject: [PATCH v5 6/9] bus: mhi: core: Check channel execution environment before issuing reset Date: Fri, 8 Jan 2021 12:54:54 -0800 Message-Id: <1610139297-36435-7-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610139297-36435-1-git-send-email-bbhatt@codeaurora.org> References: <1610139297-36435-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 --- drivers/bus/mhi/core/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index a84e6aa..ec720fe 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -1351,11 +1351,24 @@ static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, /* no more processing events for this channel */ mutex_lock(&mhi_chan->mutex); + if (!(BIT(mhi_cntrl->ee) & mhi_chan->ee_mask)) { + dev_err(dev, + "Current EE: %s Required EE Mask: 0x%x for chan: %s\n", + TO_MHI_EXEC_STR(mhi_cntrl->ee), mhi_chan->ee_mask, + mhi_chan->name); + goto exit_unprepare_channel; + } + ret = mhi_update_channel_state(mhi_cntrl, mhi_chan, MHI_CH_STATE_TYPE_RESET); if (ret) dev_err(dev, "Failed to reset channel, still resetting\n"); +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