From patchwork Wed Apr 22 04:19:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhaumik Bhatt X-Patchwork-Id: 189477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957B7C38A30 for ; Wed, 22 Apr 2020 04:31:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70BFA2064C for ; Wed, 22 Apr 2020 04:31:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="XpQyJrcp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725808AbgDVEby (ORCPT ); Wed, 22 Apr 2020 00:31:54 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:24835 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgDVEbx (ORCPT ); Wed, 22 Apr 2020 00:31:53 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587529913; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=9ajINjyxVnZz0xrqD52l756TPDsznJMo9dg0aqFR6yM=; b=XpQyJrcpjotvDvVgGnLg+0FBcjm3pmb2moUcb5XrZUxjfTCbxgaVPXOsYPNESfYG3icWnUyh 7cw0N/CU2TNsYAGR/pBTS+vISYU+TiXhiRB5TyH1yiJMNuek0JonrYVujo/JN2JraUE3/qcb Ad6ZvgM4JzfKBfk//Mt9q08SNjc= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e9fc5e6.7fc3729ee8f0-smtp-out-n03; Wed, 22 Apr 2020 04:19:50 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 548A7C433F2; Wed, 22 Apr 2020 04:19:50 +0000 (UTC) Received: from bbhatt-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 B9DE9C433D2; Wed, 22 Apr 2020 04:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B9DE9C433D2 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=none smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Hemant Kumar Subject: [PATCH v1 1/8] bus: mhi: core: Cache intmod from mhi event to mhi channel Date: Tue, 21 Apr 2020 21:19:28 -0700 Message-Id: <1587529175-27778-2-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> References: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hemant Kumar Driver is using zero initialized intmod value from mhi channel when configuring TRE for bei field. This prevents interrupt moderation to take effect in case it is supported by an event ring. Fix this by copying intmod value from associated event ring to mhi channel upon registering mhi controller. Signed-off-by: Hemant Kumar --- drivers/bus/mhi/core/init.c | 4 ++++ drivers/bus/mhi/core/main.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index b38359c..4dc7f22 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -864,6 +864,10 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mutex_init(&mhi_chan->mutex); init_completion(&mhi_chan->completion); rwlock_init(&mhi_chan->lock); + + /* used in setting bei field of TRE */ + mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; + mhi_chan->intmod = mhi_event->intmod; } if (mhi_cntrl->bounce_buf) { diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index eb4256b..23154f1 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -929,7 +929,7 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir, struct mhi_ring *buf_ring = &mhi_chan->buf_ring; struct mhi_buf_info *buf_info; struct mhi_tre *mhi_tre; - int ret; + int ret, bei; /* If MHI host pre-allocates buffers then client drivers cannot queue */ if (mhi_chan->pre_alloc) @@ -966,10 +966,11 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir, goto map_error; mhi_tre = tre_ring->wp; + bei = !!(mhi_chan->intmod); mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_info->len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(1, 1, 0, 0); + mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(bei, 1, 0, 0); /* increment WP */ mhi_add_ring_element(mhi_cntrl, tre_ring); @@ -1006,6 +1007,7 @@ int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir, struct mhi_ring *buf_ring = &mhi_chan->buf_ring; struct mhi_buf_info *buf_info; struct mhi_tre *mhi_tre; + int bei; /* If MHI host pre-allocates buffers then client drivers cannot queue */ if (mhi_chan->pre_alloc) @@ -1043,10 +1045,11 @@ int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir, buf_info->len = len; mhi_tre = tre_ring->wp; + bei = !!(mhi_chan->intmod); mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_info->len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(1, 1, 0, 0); + mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(bei, 1, 0, 0); /* increment WP */ mhi_add_ring_element(mhi_cntrl, tre_ring); From patchwork Wed Apr 22 04:19:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhaumik Bhatt X-Patchwork-Id: 189480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E37A8C55189 for ; Wed, 22 Apr 2020 04:19:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE85120706 for ; Wed, 22 Apr 2020 04:19:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="KibRwLCv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgDVET5 (ORCPT ); Wed, 22 Apr 2020 00:19:57 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:38387 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbgDVET4 (ORCPT ); Wed, 22 Apr 2020 00:19:56 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587529196; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=kvpym/R0LUwgL8lADSrB9TScxJz6XxGUYe6UV96jMZQ=; b=KibRwLCvsPQpK5REEZhU1HIDrAYStoD/1c+vLNhN1EhfysMLkH7Na3HrPqDi9X/GBEmARRYi tu8c1qJIUa8Dd7/pMUYIuVMCUiY4nWMp3tQgFPonu+ALFtfoE1ZEF97rFG2j47yNWBO3sx7p G9yu5SVL1M7zZQnXnk7YT7Ejn2w= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e9fc5e6.7fe203ca6538-smtp-out-n02; Wed, 22 Apr 2020 04:19:50 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 84D90C43637; Wed, 22 Apr 2020 04:19:50 +0000 (UTC) Received: from bbhatt-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 1B40DC433BA; Wed, 22 Apr 2020 04:19:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1B40DC433BA 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=none smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Hemant Kumar Subject: [PATCH v1 2/8] bus: mhi: core: Add range check for channel id received in event ring Date: Tue, 21 Apr 2020 21:19:29 -0700 Message-Id: <1587529175-27778-3-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> References: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hemant Kumar MHI data completion handler function reads channel id from event ring element. Value is under the control of MHI devices and can be any value between 0 and 255. In order to prevent out of bound access add a bound check against the max channel supported by controller and skip processing of that event ring element. Signed-off-by: Hemant Kumar --- drivers/bus/mhi/core/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 23154f1..ba8afa7 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -827,6 +827,9 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl, enum mhi_pkt_type type = MHI_TRE_GET_EV_TYPE(local_rp); chan = MHI_TRE_GET_EV_CHID(local_rp); + if (WARN_ON(chan >= mhi_cntrl->max_chan)) + continue; + mhi_chan = &mhi_cntrl->mhi_chan[chan]; if (likely(type == MHI_PKT_TYPE_TX_EVENT)) { From patchwork Wed Apr 22 04:19:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhaumik Bhatt X-Patchwork-Id: 189481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CDC1C38A30 for ; Wed, 22 Apr 2020 04:19:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A5C120747 for ; Wed, 22 Apr 2020 04:19:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="iZNDqx6O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725899AbgDVETy (ORCPT ); Wed, 22 Apr 2020 00:19:54 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:26751 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbgDVETy (ORCPT ); Wed, 22 Apr 2020 00:19:54 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587529194; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=jNSPiheV+d47ns/l8Ch/Ze/Q8LvlI/1DRVaErfIZ8Mw=; b=iZNDqx6OP14UZrMF+hkbobQ4+78VxmXCCYTvp8B3XuLwm5FOGuL96xGWMkTNV/oP6KaNIiK0 W4ODZaMRMd3M4JPxeKc/BBD9xmCOvB7//Q+dwayLJQimePxMRfb6rRELsiIj5JwpyuFrMgok bdngwvEfXdEPDfKJZWVH/5bWnoI= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e9fc5e8.7f90cac94260-smtp-out-n04; Wed, 22 Apr 2020 04:19:52 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 47531C432C2; Wed, 22 Apr 2020 04:19:52 +0000 (UTC) Received: from bbhatt-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 0F6BAC433CB; Wed, 22 Apr 2020 04:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0F6BAC433CB 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=none smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bhaumik Bhatt Subject: [PATCH v1 5/8] bus: mhi: core: WARN_ON for malformed vector table Date: Tue, 21 Apr 2020 21:19:32 -0700 Message-Id: <1587529175-27778-6-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> References: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add a bounds check in the firmware copy routine to exit if a malformed vector table is found while attempting to load the firmware in to the BHIe vector table. Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/boot.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c index 17c636b..bc70edc 100644 --- a/drivers/bus/mhi/core/boot.c +++ b/drivers/bus/mhi/core/boot.c @@ -362,8 +362,14 @@ static void mhi_firmware_copy(struct mhi_controller *mhi_cntrl, int i = 0; struct mhi_buf *mhi_buf = img_info->mhi_buf; struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; + struct device *dev = &mhi_cntrl->mhi_dev->dev; while (remainder) { + if (WARN_ON(i >= img_info->entries)) { + dev_err(dev, "Malformed vector table\n"); + return; + } + to_cpy = min(remainder, mhi_buf->len); memcpy(mhi_buf->buf, buf, to_cpy); bhi_vec->dma_addr = mhi_buf->dma_addr; From patchwork Wed Apr 22 04:19:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhaumik Bhatt X-Patchwork-Id: 189478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04A8AC54FCB for ; Wed, 22 Apr 2020 04:20:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5EBE2076E for ; Wed, 22 Apr 2020 04:20:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="SGUHgy50" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbgDVEUW (ORCPT ); Wed, 22 Apr 2020 00:20:22 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:64155 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbgDVEUC (ORCPT ); Wed, 22 Apr 2020 00:20:02 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587529201; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=WIo04m5DvvXhO1a8uko76GWkE9AMVf53ZeZpDgYxOKs=; b=SGUHgy50eb6KIxEqiGIsvhwNU9chjbfpzD45sJmherBuGQBHiWrVXv8EiJ5XoD4pvEOosEwg Xi9W1vLTN2Vxv3/0Xg56C86nIfy9fJ7foNAhZMTq0r0DGAj8XKiwoNGhmFJxTJajF7V3Ne66 ETzk2zJZad3+xagUM98haAa90u4= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e9fc5e7.7fe344cf5768-smtp-out-n02; Wed, 22 Apr 2020 04:19:51 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CFD39C43637; Wed, 22 Apr 2020 04:19:51 +0000 (UTC) Received: from bbhatt-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 61A18C433BA; Wed, 22 Apr 2020 04:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 61A18C433BA 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=none smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bhaumik Bhatt Subject: [PATCH v1 6/8] bus: mhi: core: Return appropriate error codes for AMSS load failure Date: Tue, 21 Apr 2020 21:19:33 -0700 Message-Id: <1587529175-27778-7-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> References: <1587529175-27778-1-git-send-email-bbhatt@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- 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 bc70edc..4e49a0e 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,