From patchwork Mon Jun 21 16:16:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 464521 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp2738085jao; Mon, 21 Jun 2021 09:16:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp7OpDjpz530KNVSxOM9aJB6NzhpPZMmAx6jSeol5YLgxShpzj84ITT3ApS7gGDwrSSeoH X-Received: by 2002:a05:6402:1911:: with SMTP id e17mr22596981edz.62.1624292200702; Mon, 21 Jun 2021 09:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292200; cv=none; d=google.com; s=arc-20160816; b=anz0m7X5Ayhzv4znJRIv5zSy5cQMIZ3utKObFHn9XL41YIneNBfHAQs7y4TMPLhYtD w2io5qnCZTCTFYzeBYGVzOsD/Oj+WbTqGDPbr3GVdhdH9hw1vRQa07woo0SHRdC6TmJQ EA0CtNnhxPsCc8hmS4tgidk474k8Wo+6BeEw0CM4gIIFYqtK7tJma/yM5Rh86oR0SQXZ Xtb+vk2AxG4h2aIymh2oi2eIsaQ9HuKZLJeohovTi6n4xFbDCUSxEY7KAyiEzdvqqd2E 2a5A1Pa17nIuc/mnUoRSSVp02YMd+b/XlL+ewI3/1D5YMPDPKnyPBQmRtFnJDJfXBHko 2+xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N7LBMmECFFSW8LKo0Z6mYB/q0IYHCWA9jmYx2xIVnOU=; b=FAdeBbfqamsDADMK9qQpaBmpefCf/C3laDqDoGkCbW4mEYdwoQ5BnKAQxPX+KcDvmr JIoxEa+9WNPcj4CSgBC5XnzozKf6+JeEhCKTTgv52lJABdskbhH3XXlvUbH6OK0lVuVs I+ERWxdJWf9JbiMvfg1Uo2YiC4lZwomADW2nar+DCLUNkFnb/qSWI4EQmCZpYxGC2+JX rznX4Ka4WrOdxjhxMULbjqqsBlGykQ+hvi4q7wK2LT1V1QuW1zB5v8t2Ixt2siEKkfgh /7xDrm5LFdpxS8fnyJhoJlKtYSEZEXd+XhyAJqWcClBdCpkMRRWBtuOGmN1Xeygu7GAD 6Khw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="icEvD/Xm"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si12616428edb.593.2021.06.21.09.16.40; Mon, 21 Jun 2021 09:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linaro.org header.s=google header.b="icEvD/Xm"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbhFUQSx (ORCPT + 12 others); Mon, 21 Jun 2021 12:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbhFUQSx (ORCPT ); Mon, 21 Jun 2021 12:18:53 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E71CC061766 for ; Mon, 21 Jun 2021 09:16:38 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so335543pji.0 for ; Mon, 21 Jun 2021 09:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N7LBMmECFFSW8LKo0Z6mYB/q0IYHCWA9jmYx2xIVnOU=; b=icEvD/Xm7mIt2f74nwT+ZHu6MKsdzMyLiVsH7dBywgGt8gTcMIft6SRt3H0EWEzaFK 24fdKXB8XJcvHl6pfLkga+21EVBdM253Y6PlVZBDKFk5Ou1y3N8pofFg6Zys5PN3P2bo mFl+03t20ExY5k1jfzwgCZlZgPOPaLv5R5Gl7+Rf/IOZgZhgMidbfvwBhabA/W0ZCz5r uL6AIAmHmrfSe8siqZbzO4iYo3OYgmWY1XNOpRbp94bI4papIVrg2f5J/gZGLNmnavUB HwcSU1sz5Hj+fbb30rmduyqP/fiFrVw73EHS/5qXGzZjFXEMClMLMFTZLAPs9gdVdXwz pv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N7LBMmECFFSW8LKo0Z6mYB/q0IYHCWA9jmYx2xIVnOU=; b=Ooyq+D6p3cIidpEtaSoLoF70REDIh+lwhdS3k8QfYT0tkV0ToUYCdjKI9kPW/bU+70 afzHy8X4QeynrmUywpWBZYBerjxIxm/mVVh25IV2QSSljfSphTcnN+9+jdS42482fxCP 7xEmac2bPF+c0kf/ycfPrRQvt0Ro+kWDrengOA+eH2dAPyT8MK28dganrrsAE/dqsijO ZD6tA/iNbRnInxZl9teh6rdkHgyABfrF4U6obYC0vtArr9hF1YSMZFwHKDtwvEq5eEPj DWHuBkRAG+/SToT1xlPLFI+5LyFVK19bJEw5lmyHi2VRP+mldytoK6BlnS+mWfwViXeK PRyg== X-Gm-Message-State: AOAM530U3e4JwKCGYK1Tu3rV4dwmZWo5GTbAB8xSkSAWHiwe2MVH5k36 MD3zL7WKJW8Mlp38yEy7KHQT X-Received: by 2002:a17:902:a70c:b029:118:7b47:e5bf with SMTP id w12-20020a170902a70cb02901187b47e5bfmr18726450plq.9.1624292197969; Mon, 21 Jun 2021 09:16:37 -0700 (PDT) Received: from localhost.localdomain ([120.138.13.116]) by smtp.gmail.com with ESMTPSA id k88sm10734730pjk.15.2021.06.21.09.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:16:37 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, loic.poulain@linaro.org, stable@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 2/8] bus: mhi: core: Fix power down latency Date: Mon, 21 Jun 2021 21:46:10 +0530 Message-Id: <20210621161616.77524-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621161616.77524-1-manivannan.sadhasivam@linaro.org> References: <20210621161616.77524-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Loic Poulain On graceful power-down/disable transition, when an MHI reset is performed, the MHI device loses its context, including interrupt configuration. However, the current implementation is waiting for event(irq) driven state change to confirm reset has been completed, which never happens, and causes reset timeout, leading to unexpected high latency of the mhi_power_down procedure (up to 45 seconds). Fix that by moving to the recently introduced poll_reg_field method, waiting for the reset bit to be cleared, in the same way as the power_on procedure. Cc: stable@vger.kernel.org Fixes: a6e2e3522f29 ("bus: mhi: core: Add support for PM state transitions") Signed-off-by: Loic Poulain Reviewed-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Reviewed-by: Hemant Kumar Link: https://lore.kernel.org/r/1620029090-8975-1-git-send-email-loic.poulain@linaro.org Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index e2e59a341fef..704a5e225097 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -465,23 +465,15 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl) /* Trigger MHI RESET so that the device will not access host memory */ if (!MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state)) { - u32 in_reset = -1; - unsigned long timeout = msecs_to_jiffies(mhi_cntrl->timeout_ms); - dev_dbg(dev, "Triggering MHI Reset in device\n"); mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); /* Wait for the reset bit to be cleared by the device */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_read_reg_field(mhi_cntrl, - mhi_cntrl->regs, - MHICTRL, - MHICTRL_RESET_MASK, - MHICTRL_RESET_SHIFT, - &in_reset) || - !in_reset, timeout); - if (!ret || in_reset) - dev_err(dev, "Device failed to exit MHI Reset state\n"); + ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, + MHICTRL_RESET_MASK, MHICTRL_RESET_SHIFT, 0, + 25000); + if (ret) + dev_err(dev, "Device failed to clear MHI Reset\n"); /* * Device will clear BHI_INTVEC as a part of RESET processing,