Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1507449ybk; Thu, 21 May 2020 08:29:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6jygbtnzqiogDwZmCBC59mv8iCYJgQUjaSKzFL66Rmg0xa5o344qzeTFWy4UF8I4fTOZ+ X-Received: by 2002:a17:906:cecb:: with SMTP id si11mr4000557ejb.122.1590074975278; Thu, 21 May 2020 08:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590074975; cv=none; d=google.com; s=arc-20160816; b=BCOG94q+HUtiyIUGyKTCPEYjSU3PjLU1v8JtCEarOHH+PISZxP+gxDPd0bLuMDmeFe PAHxLlSR5wa5JCwIXcKRZ9XFdZEKtHZDJiIxTG3c2U8kmXvFMbyXCul2VcQJr/WOQy1G YGHOvE2o6YVwo43V/su5c8s/rcqKQ0pJYr7vN+zPtq3C+qZ4esdl0JimNA1Hxq8YqjDK wS5QIbqDQc68HVZquwwfxIw4b8j/+swWTHXMClozZ1s519yVI2fPlvEc3tLI86taLsN0 rQ0eHurLCYWvBhyzVdy1+UCAnJAjAzzFfQGMnIMF+hQX+gWo+4Fbg5wvAX4/9biiU8iT o/Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=105G/5dyQRZx0JxSSgvxUFoCIltzPHFUf+fYvScr39g=; b=bSiiiPEteVan+XGjO+eirnyvVs4H+ap0QI9+E8TcyAnyUuTqmlnlRaTDMv5TRb0i72 h1xnh2fZt17KyZpjVXEc2J2dE0AVeaAFy5xrtRDQh4y0zczFtqE8qVvHC1L4L8PXZWhb tfUW9r4NAhWsyNwvzp2vt+GZoMNmGGf0wmeyQ1dzwM8GWx+/gE9ux/D/GMsagPUKrPgk Wp2G48O5l7m0otpj1WdoUhn3HGgvxUwvBgMkgFR8T4ptlwvOFftjTR9uijXd4eFQLd6l USk6n9zaxgC9x/ajcPvn+uYTbPGzhBFMIPO6EBXRKwIFL9SJUO+Z6jbC0dx1dYkrcxTy ougw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tfI73kdy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nx23si3512513ejb.321.2020.05.21.08.29.12; Thu, 21 May 2020 08:29:35 -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=@kernel.org header.s=default header.b=tfI73kdy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730534AbgEUP05 (ORCPT + 99 others); Thu, 21 May 2020 11:26:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:34938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbgEUP0z (ORCPT ); Thu, 21 May 2020 11:26:55 -0400 Received: from localhost.localdomain (unknown [157.51.235.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB3B8204EA; Thu, 21 May 2020 15:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590074815; bh=dvLttKvJJ7BKe09U0t/JMfDNzj7Lp4Uczo90kVKoK48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfI73kdyKuHG+IJXgrnsgleaBqKY+0Hjlnd4C9EUB2zn/refyE9gmwtkgSVOWJgqG heB8xI2rykLSFh0wi6tzjx2iVALLJDuEKy/N14YFQ0MSEoX8P+nodfvBngcuciha9m 7R5BO6uxWvu+0o4MtvrcN6/V5svPzaKCCX7mmV14= From: mani@kernel.org To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 14/14] bus: mhi: core: Handle syserr during power_up Date: Thu, 21 May 2020 20:55:40 +0530 Message-Id: <20200521152540.17335-15-mani@kernel.org> X-Mailer: git-send-email 2.26.GIT In-Reply-To: <20200521152540.17335-1-mani@kernel.org> References: <20200521152540.17335-1-mani@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeffrey Hugo The MHI device may be in the syserr state when we attempt to init it in power_up(). Since we have no local state, the handling is simple - reset the device and wait for it to transition out of the reset state. Signed-off-by: Jeffrey Hugo Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index e6236a3ca39d..1bd61a64d7bb 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -763,6 +763,7 @@ static void mhi_deassert_dev_wake(struct mhi_controller *mhi_cntrl, int mhi_async_power_up(struct mhi_controller *mhi_cntrl) { + enum mhi_state state; enum mhi_ee_type current_ee; enum dev_st_transition next_state; struct device *dev = &mhi_cntrl->mhi_dev->dev; @@ -832,6 +833,32 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl) goto error_bhi_offset; } + state = mhi_get_mhi_state(mhi_cntrl); + if (state == MHI_STATE_SYS_ERR) { + mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); + ret = wait_event_timeout(mhi_cntrl->state_event, + MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state) || + mhi_read_reg_field(mhi_cntrl, + mhi_cntrl->regs, + MHICTRL, + MHICTRL_RESET_MASK, + MHICTRL_RESET_SHIFT, + &val) || + !val, + msecs_to_jiffies(mhi_cntrl->timeout_ms)); + if (ret) { + ret = -EIO; + dev_info(dev, "Failed to reset MHI due to syserr state\n"); + goto error_bhi_offset; + } + + /* + * device cleares INTVEC as part of RESET processing, + * re-program it + */ + mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); + } + /* Transition to next state */ next_state = MHI_IN_PBL(current_ee) ? DEV_ST_TRANSITION_PBL : DEV_ST_TRANSITION_READY; -- 2.26.GIT