Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1506982ybk; Thu, 21 May 2020 08:28:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOEBZUyQPwq+sLHGArejgKSacAYDDY4pj4MDjFuLocQqL91OkRz4lTkAfYTnq0Svi/+lAB X-Received: by 2002:a17:906:d043:: with SMTP id bo3mr3873059ejb.409.1590074934009; Thu, 21 May 2020 08:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590074934; cv=none; d=google.com; s=arc-20160816; b=0sdP20ttiJAbUuqhgVwyu+kH2zeaZ3bL7DvC/GO89axQRxXF5Z11HITh4TVvlrDrPs djUFAuL2YLI/fE0c/00yKhhGpoZjN+OwpgbRhYEeTFUV7W5PqPlUb3zVIxGv7PqqavW+ Tp5WycjGL09TXG1GxzAwpULmM0iXL421IlXMwYa7RHraJBuKydoOV9VxzEzfzHJt3FeR 6pT5XZwZZTCTrBsLBKlp8RqmAvEPbeAcDbRq/fvMCF3gpqTHjxQ7e3Bg70HG0ioxYrfM BH5BSgHXoS0YEXR5qanBEXHl81Z1ACyHTG9GOFUbWhh1O6i3atTefyHsv16MPSn3GZxW drIA== 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=ttvaKYCdkxHatKYETh4ZbUevmkfS/BsoNs46EeJbvME=; b=CG4ZGmaK0HZ8TU0ztVOZNyUAVVAWcZXWjdQujNCl6jmE7UMFtZiOP6FG2wzsP/gV/l 2FTR9RJEla+ePYhGPqsZBazGttLNYmDpMkDMNS5o4kcJEZfYPoOsj4h6KMCUT9/h3iT0 EIQjysQo6qzZIKwZkieWrX6dhHanu/ZIClYQdLc86505RX23orHq0AW4wHw0wTlDZ85V hL48qWsnE6NtET13P9+1/zLBPwF0wjJCrHvM9p5ad0wJeD43H4JYf1GywMUQh2+xSB5y K1Yn9sliMPXWvtf1OOAqtTUHprI6akKeKn2jjPOcujxt/X/86rP7px/aRa+7IRRBtx+K fjsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yDO93MN2; 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 f20si2994266edy.274.2020.05.21.08.28.31; Thu, 21 May 2020 08:28:53 -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=yDO93MN2; 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 S1730486AbgEUP0W (ORCPT + 99 others); Thu, 21 May 2020 11:26:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730456AbgEUP0U (ORCPT ); Thu, 21 May 2020 11:26:20 -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 76AC4207D8; Thu, 21 May 2020 15:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590074779; bh=AJmYW9HuU9yryKkC/CR9tmkLTg2Hr/aoAaHtA7zSaaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yDO93MN2kaSoVyK8ITtY2+hh4jBgyCAcJaFngTQje9A3eWr/WOu6P3dKjVBCouCIN VJPDQKIW7d9B02kwVoXK6jjaRuTnb5GXYlYRmjneBVbj2PZvxm7+bZQpA9izwQPIQd Bksb6FtB1hxL7vC0Y1nEH2eh/QX9D1W3vFxuyqHk= 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, Bhaumik Bhatt , Manivannan Sadhasivam Subject: [PATCH 06/14] bus: mhi: core: Return appropriate error codes for AMSS load failure Date: Thu, 21 May 2020 20:55:32 +0530 Message-Id: <20200521152540.17335-7-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: Bhaumik Bhatt When loading AMSS firmware using BHIe protocol, return -ETIMEDOUT if no response is received within the timeout or return -EIO in case of a protocol returned failure or an MHI error state. Signed-off-by: Bhaumik Bhatt Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/boot.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c index 17c636b4bc6e..cf6dc5a2361c 100644 --- a/drivers/bus/mhi/core/boot.c +++ b/drivers/bus/mhi/core/boot.c @@ -176,6 +176,7 @@ static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl, void __iomem *base = mhi_cntrl->bhie; rwlock_t *pm_lock = &mhi_cntrl->pm_lock; u32 tx_status, sequence_id; + int ret; read_lock_bh(pm_lock); if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { @@ -198,19 +199,19 @@ static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl, read_unlock_bh(pm_lock); /* Wait for the image download to complete */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, - BHIE_TXVECSTATUS_OFFS, - BHIE_TXVECSTATUS_STATUS_BMSK, - BHIE_TXVECSTATUS_STATUS_SHFT, - &tx_status) || tx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) + ret = wait_event_timeout(mhi_cntrl->state_event, + MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || + mhi_read_reg_field(mhi_cntrl, base, + BHIE_TXVECSTATUS_OFFS, + BHIE_TXVECSTATUS_STATUS_BMSK, + BHIE_TXVECSTATUS_STATUS_SHFT, + &tx_status) || tx_status, + msecs_to_jiffies(mhi_cntrl->timeout_ms)); + if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || + tx_status != BHIE_TXVECSTATUS_STATUS_XFER_COMPL) return -EIO; - return (tx_status == BHIE_TXVECSTATUS_STATUS_XFER_COMPL) ? 0 : -EIO; + return (!ret) ? -ETIMEDOUT : 0; } static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl, -- 2.26.GIT