From f1ae7429fb1680e5c39e50794fce70ef98bb7166 Mon Sep 17 00:00:00 2001 From: Bhaumik Bhatt Date: Thu, 20 Feb 2020 11:42:55 -0800 Subject: [PATCH] mhi: core: ensure non-zero session or sequence ID values While writing any sequence or session identifiers, it is possible that the host could write a zero value, whereas only non-zero values are supported writes to those registers. Ensure that host does not write a non-zero value for those cases. Change-Id: I33248a0aa43321c85a107e394f953774140dec50 Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/mhi_boot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/mhi_boot.c b/drivers/bus/mhi/core/mhi_boot.c index ad7794772ccc..e90237b19b89 100644 --- a/drivers/bus/mhi/core/mhi_boot.c +++ b/drivers/bus/mhi/core/mhi_boot.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ #include #include @@ -321,6 +321,9 @@ static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl, mhi_buf->len); mhi_cntrl->sequence_id = prandom_u32() & BHIE_TXVECSTATUS_SEQNUM_BMSK; + if (unlikely(!mhi_cntrl->sequence_id)) + mhi_cntrl->sequence_id = 1; + mhi_write_reg_field(mhi_cntrl, base, BHIE_TXVECDB_OFFS, BHIE_TXVECDB_SEQNUM_BMSK, BHIE_TXVECDB_SEQNUM_SHFT, mhi_cntrl->sequence_id); @@ -383,6 +386,9 @@ static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl, lower_32_bits(dma_addr)); mhi_cntrl->write_reg(mhi_cntrl, base, BHI_IMGSIZE, size); mhi_cntrl->session_id = prandom_u32() & BHI_TXDB_SEQNUM_BMSK; + if (unlikely(!mhi_cntrl->session_id)) + mhi_cntrl->session_id = 1; + mhi_cntrl->write_reg(mhi_cntrl, base, BHI_IMGTXDB, mhi_cntrl->session_id); read_unlock_bh(pm_lock);