Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp809734pxf; Thu, 1 Apr 2021 14:17:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWH0K9mBO2GR+TgsINFoo5rubez3ay6R5ZNAlq3tFAFuJMQzQQNAvxZiImJjAZ+8AjTGzL X-Received: by 2002:a92:c265:: with SMTP id h5mr7721010ild.43.1617311850273; Thu, 01 Apr 2021 14:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617311850; cv=none; d=google.com; s=arc-20160816; b=HolTi7Po676jyhY7iPgn+J5GTJROKwtU8d2KvctAq4gprlokh3ZWnXDut2tywK6uvE txl8oabFlom7c8ZB9fXohYmJIq9ozCVHq3dVKvGIzpv4YOXHGYSGtjdoh5RiiNdTv/FP AZ6fhSQNZXA90znGX29EwIEXW6t9zjQEMQIeOX+AxwVMU1SchISTeI/HsP3mwrOOsnPB Hi+JtqlzMku24sCP0RyyP/yt/5zhQroriZ0LdLp20j5ZQyDpfJHU6maU8e4B5WSRZpBR YZ4UqTEE/oPQUgXOPXa6ENPmD5eT8H6T64xddZunN/IApoeaTMhR+WWGTKiW52MkGX+n JBTw== 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=pdpDO14UwF2Vs0wHRzOUe16xHfmqgtibnCCZkg/pBlo=; b=HAYkhYcax47+qVi7HBALgzFczo8YUpVblaDshwBtHlZrSJBRlQO4KzsCBMH3m3PHs2 SYSpkKRuY8a92pLcuyMOe6A7yJAYTcrdnsvQCP/gWJ6J+AFAP5Jna3ywlkaHMFLP10Z8 TWE/hfQbp79GsM/x4dZDCo0wt+U05iqyJ1/J8gVwh9kC/TbWm2r5cS6FLmTLlbFjhMwF ZFuX//L+0U7hT0ahr6K9upWuzbG+4ek0d+Xg/tMaaPjnnbC9oWDjklQTy6VVtDCFHBu5 dGXOpvUemsYfCrkaknUSfcYMcVfGjCndpLJfjxRESpM4NpNRODn8jQXZooDlpnM7L47Q reKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=TL9FMvqf; 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 a16si5594526iow.42.2021.04.01.14.17.16; Thu, 01 Apr 2021 14:17:30 -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=TL9FMvqf; 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 S234719AbhDAVQh (ORCPT + 99 others); Thu, 1 Apr 2021 17:16:37 -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 S234648AbhDAVQb (ORCPT ); Thu, 1 Apr 2021 17:16:31 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1617311791; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=pdpDO14UwF2Vs0wHRzOUe16xHfmqgtibnCCZkg/pBlo=; b=TL9FMvqfPVPusqtnEHmbDIOZPXX23RGcQ1iUyz3enDxI/iD6O42KIJE/VPE2k3mi3ZBhFiZI G1acNcuIhcBa+7HtRrLiXPkbySm8XT2PUS0GIp96vtruhKKkSI7bPHJ3Uf+FZ6xdHjg43ZAk hwtWCGDPifmc+L6XTFf8ZEE6lVo= 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-east-1.postgun.com with SMTP id 6066382e74f773a66493fbc3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 01 Apr 2021 21:16:30 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 6F22AC43463; Thu, 1 Apr 2021 21:16:29 +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 0E922C43463; Thu, 1 Apr 2021 21:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0E922C43463 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 5/9] bus: mhi: core: Hold device wake for channel update commands Date: Thu, 1 Apr 2021 14:16:14 -0700 Message-Id: <1617311778-1254-6-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 MHI host can fail early if device is in a bad state by attempting to assert device wake and holding the runtime PM vote before sending a channel update command instead of performing a wake toggle and waiting for a timeout if the send were to fail. This can help improve the design and enable shorter wait periods for device to respond as votes are already held. Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/main.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 94fdbf7..989a2a8 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -1278,16 +1278,18 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl, return -EINVAL; } - mhi_cntrl->wake_toggle(mhi_cntrl); + /* bring host and device out of suspended states */ + ret = mhi_device_get_sync(mhi_cntrl->mhi_dev); + if (ret) + return ret; mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); reinit_completion(&mhi_chan->completion); ret = mhi_send_cmd(mhi_cntrl, mhi_chan, cmd); if (ret) { dev_err(dev, "%d: Failed to send %s channel command\n", mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); - return ret; + goto exit_channel_update; } ret = wait_for_completion_timeout(&mhi_chan->completion, @@ -1296,9 +1298,12 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl, dev_err(dev, "%d: Failed to receive %s channel command completion\n", mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); - return -EIO; + ret = -EIO; + goto exit_channel_update; } + ret = 0; + if (to_state != MHI_CH_STATE_TYPE_RESET) { write_lock_irq(&mhi_chan->lock); mhi_chan->ch_state = (to_state == MHI_CH_STATE_TYPE_START) ? @@ -1309,7 +1314,11 @@ static int mhi_update_channel_state(struct mhi_controller *mhi_cntrl, dev_dbg(dev, "%d: Channel state change to %s successful\n", mhi_chan->chan, TO_CH_STATE_TYPE_STR(to_state)); - return 0; +exit_channel_update: + mhi_cntrl->runtime_put(mhi_cntrl); + mhi_device_put(mhi_cntrl->mhi_dev); + + return ret; } static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project