archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] bus: mhi: host: Add session ID to MHI controller
@ 2022-11-02  9:41 Qiang Yu
  0 siblings, 0 replies; only message in thread
From: Qiang Yu @ 2022-11-02  9:41 UTC (permalink / raw)
  To: mani, loic.poulain
  Cc: mhi, linux-arm-msm, linux-kernel, quic_cang, mrana, Qiang Yu

Session ID to be used during BHI transfers to recognize a
particular session are currently not being stored in the MHI
controller structure. Store them to allow for debug enhancement
described below.

Sometimes, we may find some error logs and want to see what
happens on device side when host is printing these error logs.
Session id can help us find the logs we want on device side
quickly, especially when we are faced with a huge amount of logs.

Signed-off-by: Qiang Yu <>
v1->v2: modify commit message.

 drivers/bus/mhi/host/boot.c | 8 ++++----
 include/linux/mhi.h         | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c
index 1c69fee..79a0eec 100644
--- a/drivers/bus/mhi/host/boot.c
+++ b/drivers/bus/mhi/host/boot.c
@@ -229,7 +229,7 @@ static int mhi_fw_load_bhi(struct mhi_controller *mhi_cntrl,
 			   dma_addr_t dma_addr,
 			   size_t size)
-	u32 tx_status, val, session_id;
+	u32 tx_status, val;
 	int i, ret;
 	void __iomem *base = mhi_cntrl->bhi;
 	rwlock_t *pm_lock = &mhi_cntrl->pm_lock;
@@ -251,16 +251,16 @@ static int mhi_fw_load_bhi(struct mhi_controller *mhi_cntrl,
 		goto invalid_pm_state;
+	mhi_cntrl->session_id = MHI_RANDOM_U32_NONZERO(BHI_TXDB_SEQNUM_BMSK);
 	dev_dbg(dev, "Starting image download via BHI. Session ID: %u\n",
-		session_id);
+		mhi_cntrl->session_id);
 	mhi_write_reg(mhi_cntrl, base, BHI_STATUS, 0);
 	mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_HIGH,
 	mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_LOW,
 	mhi_write_reg(mhi_cntrl, base, BHI_IMGSIZE, size);
-	mhi_write_reg(mhi_cntrl, base, BHI_IMGTXDB, session_id);
+	mhi_write_reg(mhi_cntrl, base, BHI_IMGTXDB, mhi_cntrl->session_id);
 	/* Wait for the image download to complete */
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index a5441ad..8b3c934 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -405,6 +405,7 @@ struct mhi_controller {
 	u32 minor_version;
 	u32 serial_number;
 	u32 oem_pk_hash[MHI_MAX_OEM_PK_HASH_SEGMENTS];
+	u32 session_id;
 	struct mhi_event *mhi_event;
 	struct mhi_cmd *mhi_cmd;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-02  9:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  9:41 [PATCH v2] bus: mhi: host: Add session ID to MHI controller Qiang Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).