[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251211-siva_mhi_dp2-v1-9-d2895c4ec73a@oss.qualcomm.com>
Date: Thu, 11 Dec 2025 13:37:41 +0530
From: Sivareddy Surasani <sivareddy.surasani@....qualcomm.com>
To: Manivannan Sadhasivam <mani@...nel.org>, Jonathan Corbet <corbet@....net>,
Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: mhi@...ts.linux.dev, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Upal Kumar Saha <upal.saha@....qualcomm.com>,
Himanshu Shukla <quic_himashuk@...cinc.com>,
Sivareddy Surasani <sivareddy.surasani@....qualcomm.com>,
Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
Subject: [PATCH 09/11] bus: mhi: host: Get total descriptor count
From: Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
Introduce a new API to retrieve the length of a transfer ring.
This API allows clients to query the ring length.
Signed-off-by: Vivek Pernamitta <vivek.pernamitta@....qualcomm.com>
Signed-off-by: Sivareddy Surasani <sivareddy.surasani@....qualcomm.com>
---
drivers/bus/mhi/host/main.c | 11 +++++++++++
include/linux/mhi.h | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index 9772fb13400c..6be15297829d 100644
--- a/drivers/bus/mhi/host/main.c
+++ b/drivers/bus/mhi/host/main.c
@@ -345,6 +345,17 @@ int mhi_get_free_desc_count(struct mhi_device *mhi_dev,
}
EXPORT_SYMBOL_GPL(mhi_get_free_desc_count);
+int mhi_get_total_descriptors(struct mhi_device *mhi_dev,
+ enum dma_data_direction dir)
+{
+ struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ?
+ mhi_dev->ul_chan : mhi_dev->dl_chan;
+ struct mhi_ring *tre_ring = &mhi_chan->tre_ring;
+
+ return tre_ring->elements;
+}
+EXPORT_SYMBOL(mhi_get_total_descriptors);
+
void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason)
{
struct mhi_driver *mhi_drv;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 66fd83bed306..013bc2d82196 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -620,6 +620,15 @@ void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason);
int mhi_get_free_desc_count(struct mhi_device *mhi_dev,
enum dma_data_direction dir);
+/**
+ * mhi_get_total_descriptors - Get total transfer ring length
+ * Get # of TD available to queue buffers
+ * @mhi_dev: Device associated with the channels
+ * @dir: Direction of the channel
+ */
+int mhi_get_total_descriptors(struct mhi_device *mhi_dev,
+ enum dma_data_direction dir);
+
/**
* mhi_prepare_for_power_up - Do pre-initialization before power up.
* This is optional, call this before power up if
--
2.34.1
Powered by blists - more mailing lists