Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d035bea9 authored by Sujeev Dias's avatar Sujeev Dias
Browse files

mhi: core: confirm MHI offset is valid before using it



PCIe link can go down anytime asynchronously without host
knowing. In event of a link-down, MMIO reads will always
return 0xffffffff.  Confirm the read value is valid prior
to executing further.

CRs-Fixed: 1030692
Change-Id: If052a1a31c62a81f380cec3f523b605b38a33847
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 3e44bf17
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -139,6 +139,13 @@ int set_mhi_base_state(struct mhi_device_ctxt *mhi_dev_ctxt)

	mhi_dev_ctxt->bhi_ctxt.bhi_base = mhi_dev_ctxt->core.bar0_base;
	pcie_word_val = mhi_reg_read(mhi_dev_ctxt->bhi_ctxt.bhi_base, BHIOFF);

	/* confirm it's a valid reading */
	if (unlikely(pcie_word_val == U32_MAX)) {
		mhi_log(mhi_dev_ctxt, MHI_MSG_ERROR,
			"Invalid BHI Offset:0x%x\n", pcie_word_val);
		return -EIO;
	}
	mhi_dev_ctxt->bhi_ctxt.bhi_base += pcie_word_val;
	pcie_word_val = mhi_reg_read(mhi_dev_ctxt->bhi_ctxt.bhi_base,
				     BHI_EXECENV);