lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250715132509.2643305-4-usama.anjum@collabora.com>
Date: Tue, 15 Jul 2025 18:25:09 +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 3/3] bus: mhi: keep device context through suspend cycles

Don't deinitialize the device context while going into suspend or
hibernation cycles. Otherwise the resume may fail if at resume time, the
memory pressure is high and no dma memory is available. At resume, only
reset the read/write ring pointers as rings may have stale data.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03926.13-QCAHSPSWPL_V2_SILICONZ_CE-2.52297.6

Fixes: 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")
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:
- Cc stable and fix tested on tag
- Add logic to reset rings at resume
---
 drivers/bus/mhi/host/init.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
index 46ed0ae2ac285..6513012311ce3 100644
--- a/drivers/bus/mhi/host/init.c
+++ b/drivers/bus/mhi/host/init.c
@@ -474,6 +474,24 @@ static int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl)
 	return ret;
 }
 
+static void mhi_reset_dev_rings(struct mhi_controller *mhi_cntrl)
+{
+	struct mhi_event *mhi_event = mhi_cntrl->mhi_event;
+	struct mhi_cmd *mhi_cmd = mhi_cntrl->mhi_cmd;
+	struct mhi_ring *ring;
+	int i;
+
+	for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
+		ring = &mhi_event->ring;
+		ring->rp = ring->wp = ring->base;
+	}
+
+	for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++) {
+		ring = &mhi_cmd->ring;
+		ring->rp = ring->wp = ring->base;
+	}
+}
+
 int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
 {
 	u32 val;
@@ -1133,9 +1151,13 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
 
 	mutex_lock(&mhi_cntrl->pm_mutex);
 
-	ret = mhi_init_dev_ctxt(mhi_cntrl);
-	if (ret)
-		goto error_dev_ctxt;
+	if (!mhi_cntrl->mhi_ctxt) {
+		ret = mhi_init_dev_ctxt(mhi_cntrl);
+		if (ret)
+			goto error_dev_ctxt;
+	} else {
+		mhi_reset_dev_rings(mhi_cntrl);
+	}
 
 	ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIOFF, &bhi_off);
 	if (ret) {
@@ -1212,8 +1234,6 @@ void mhi_deinit_dev_ctxt(struct mhi_controller *mhi_cntrl)
 {
 	mhi_cntrl->bhi = NULL;
 	mhi_cntrl->bhie = NULL;
-
-	__mhi_deinit_dev_ctxt(mhi_cntrl);
 }
 
 void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl)
@@ -1239,6 +1259,7 @@ void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl)
 	}
 
 	mhi_deinit_dev_ctxt(mhi_cntrl);
+	__mhi_deinit_dev_ctxt(mhi_cntrl);
 }
 EXPORT_SYMBOL_GPL(mhi_unprepare_after_power_down);
 
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ