[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250715132509.2643305-3-usama.anjum@collabora.com>
Date: Tue, 15 Jul 2025 18:25:08 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Manivannan Sadhasivam <mani@...nel.org>,
Jeff Hugo <jeff.hugo@....qualcomm.com>,
Muhammad Usama Anjum <usama.anjum@...labora.com>,
Youssef Samir <quic_yabdulra@...cinc.com>,
Matthew Leung <quic_mattleun@...cinc.com>,
Alexander Wilhelm <alexander.wilhelm@...termo.com>,
Kunwu Chan <chentao@...inos.cn>,
Krishna Chaitanya Chundru <krishna.chundru@....qualcomm.com>,
Jacek Lawrynowicz <jacek.lawrynowicz@...ux.intel.com>,
Yan Zhen <yanzhen@...o.com>,
Sujeev Dias <sdias@...eaurora.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Siddartha Mohanadoss <smohanad@...eaurora.org>,
mhi@...ts.linux.dev,
linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: kernel@...labora.com,
stable@...r.kernel.org
Subject: [PATCH v2 2/3] bus: mhi: host: keep bhie buffer through suspend cycle
When there is memory pressure, at resume time dma_alloc_coherent()
returns error which in turn fails the loading of the firmware and hence
the driver crashes.
Fix it by allocating only once and then reuse the same allocated memory.
As we'll allocate this memory only once, this memory will stays
allocated.
Fixes: f88f1d0998ea ("bus: mhi: host: Add a policy to enable image transfer via BHIe in PBL")
Cc: Krishna Chaitanya Chundru <krishna.chundru@....qualcomm.com>
Cc: stable@...r.kernel.org
Signed-off-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
---
Changes since v1:
- Added in v2
---
drivers/bus/mhi/host/boot.c | 19 ++++++++++++-------
drivers/bus/mhi/host/init.c | 5 +++++
include/linux/mhi.h | 1 +
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c
index 9fc983bc12d49..9f35ce9d670e7 100644
--- a/drivers/bus/mhi/host/boot.c
+++ b/drivers/bus/mhi/host/boot.c
@@ -478,17 +478,22 @@ static int mhi_load_image_bhi(struct mhi_controller *mhi_cntrl, const u8 *fw_dat
static int mhi_load_image_bhie(struct mhi_controller *mhi_cntrl, const u8 *fw_data, size_t size)
{
- struct image_info *image;
+ struct image_info **image = &mhi_cntrl->bhie_image;
int ret;
- ret = mhi_alloc_bhie_table(mhi_cntrl, &image, size);
- if (ret)
- return ret;
+ if (!(*image)) {
+ ret = mhi_alloc_bhie_table(mhi_cntrl, image, size);
+ if (ret)
+ return ret;
- mhi_firmware_copy_bhie(mhi_cntrl, fw_data, size, image);
+ mhi_firmware_copy_bhie(mhi_cntrl, fw_data, size, *image);
+ }
- ret = mhi_fw_load_bhie(mhi_cntrl, &image->mhi_buf[image->entries - 1]);
- mhi_free_bhie_table(mhi_cntrl, image);
+ ret = mhi_fw_load_bhie(mhi_cntrl, &(*image)->mhi_buf[(*image)->entries - 1]);
+ if (ret) {
+ mhi_free_bhie_table(mhi_cntrl, *image);
+ *image = NULL;
+ }
return ret;
}
diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
index 2e0f18c939e68..46ed0ae2ac285 100644
--- a/drivers/bus/mhi/host/init.c
+++ b/drivers/bus/mhi/host/init.c
@@ -1228,6 +1228,11 @@ void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl)
mhi_cntrl->rddm_image = NULL;
}
+ if (mhi_cntrl->bhie_image) {
+ mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->bhie_image);
+ mhi_cntrl->bhie_image = NULL;
+ }
+
if (mhi_cntrl->bhi_image) {
mhi_free_bhi_buffer(mhi_cntrl, mhi_cntrl->bhi_image);
mhi_cntrl->bhi_image = NULL;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 593012f779d97..77986cd66fda3 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -391,6 +391,7 @@ struct mhi_controller {
size_t reg_len;
struct image_info *fbc_image;
struct image_info *rddm_image;
+ struct image_info *bhie_image;
struct image_info *bhi_image;
struct mhi_chan *mhi_chan;
struct list_head lpm_chans;
--
2.39.5
Powered by blists - more mailing lists