netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 1/2] bus: mhi: Add mhi_queue_is_full function
@ 2020-10-16  9:20 Loic Poulain
  2020-10-16  9:20 ` [PATCH v6 2/3] net: Add mhi-net driver Loic Poulain
  2020-10-23  3:06 ` [PATCH v6 1/2] bus: mhi: Add mhi_queue_is_full function Hemant Kumar
  0 siblings, 2 replies; 9+ messages in thread
From: Loic Poulain @ 2020-10-16  9:20 UTC (permalink / raw)
  To: davem, kuba
  Cc: netdev, hemantk, manivannan.sadhasivam, eric.dumazet, Loic Poulain

This function can be used by client driver to determine whether it's
possible to queue new elements in a channel ring.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 v1->v5: This change is not part of the series
 v6: add this patch to the series

 drivers/bus/mhi/core/main.c | 15 +++++++++++++--
 include/linux/mhi.h         |  7 +++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index a588eac..44aa11f 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -943,8 +943,8 @@ void mhi_ctrl_ev_task(unsigned long data)
 	}
 }
 
-static bool mhi_is_ring_full(struct mhi_controller *mhi_cntrl,
-			     struct mhi_ring *ring)
+static inline bool mhi_is_ring_full(struct mhi_controller *mhi_cntrl,
+				    struct mhi_ring *ring)
 {
 	void *tmp = ring->wp + ring->el_size;
 
@@ -1173,6 +1173,17 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
 }
 EXPORT_SYMBOL_GPL(mhi_queue_buf);
 
+bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir)
+{
+	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
+	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 mhi_is_ring_full(mhi_cntrl, tre_ring);
+}
+EXPORT_SYMBOL_GPL(mhi_queue_is_full);
+
 int mhi_send_cmd(struct mhi_controller *mhi_cntrl,
 		 struct mhi_chan *mhi_chan,
 		 enum mhi_cmd_type cmd)
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 9d67e75..f72c3a4 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -745,4 +745,11 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
 int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
 		  struct sk_buff *skb, size_t len, enum mhi_flags mflags);
 
+/**
+ * mhi_queue_is_full - Determine whether queueing new elements is possible
+ * @mhi_dev: Device associated with the channels
+ * @dir: DMA direction for the channel
+ */
+bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir);
+
 #endif /* _MHI_H_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-23 19:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16  9:20 [PATCH v6 1/2] bus: mhi: Add mhi_queue_is_full function Loic Poulain
2020-10-16  9:20 ` [PATCH v6 2/3] net: Add mhi-net driver Loic Poulain
2020-10-16 18:06   ` Jakub Kicinski
2020-10-17  0:52   ` Hemant Kumar
2020-10-17  1:37     ` Jakub Kicinski
2020-10-23  3:06 ` [PATCH v6 1/2] bus: mhi: Add mhi_queue_is_full function Hemant Kumar
2020-10-23 15:44   ` Jakub Kicinski
2020-10-23 16:19     ` Jeffrey Hugo
     [not found]   ` <CAMZdPi_NZ5PaONpePHHFOosiuQ50R0_o3bymwzKfp2DJ37BCig@mail.gmail.com>
2020-10-23 19:24     ` Jeffrey Hugo

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).