[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <x7y653maep4keb6e33dbpsjeqdasum2l6dd75o5ykwbsqpq5l6@apnaxk4tlcj4>
Date: Wed, 5 Nov 2025 16:20:54 -0600
From: Bjorn Andersson <andersson@...nel.org>
To: Sumit Kumar <sumit.kumar@....qualcomm.com>
Cc: Manivannan Sadhasivam <mani@...nel.org>,
Krishna Chaitanya Chundru <krishna.chundru@....qualcomm.com>, Akhil Vinod <akhil.vinod@....qualcomm.com>,
Subramanian Ananthanarayanan <subramanian.ananthanarayanan@....qualcomm.com>, linux-kernel@...r.kernel.org, mhi@...ts.linux.dev,
linux-arm-msm@...r.kernel.org, quic_vpernami@...cinc.com
Subject: Re: [PATCH v2 2/3] bus: mhi: ep: Create mhi_ep_queue_buf API for raw
buffer queuing
On Tue, Nov 04, 2025 at 11:09:06AM +0530, Sumit Kumar wrote:
> Create and export a new mhi_ep_queue_buf() API that allows raw buffer
> queuing for client not using skb.
Start with make it clear why this patch is desired. Why would such
clients exist, can't they just allocate some skbs?
>
> Extract core logic for queuing buffers into a new internal mhi_ep_queue()
> function that provides a unified implementation for both mhi_ep_queue_skb()
> and mhi_ep_queue_buf(). This internal function uses a cb_buf parameter to
> handle both socket buffers and raw buffers through the same code path.
No signed-off-by?
> ---
> drivers/bus/mhi/ep/main.c | 23 +++++++++++++++++------
> include/linux/mhi_ep.h | 10 ++++++++++
> 2 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
> index b3eafcf2a2c50d95e3efd3afb27038ecf55552a5..f4b119a8dca2dbfb3ffc24b04c85743fb57088fd 100644
> --- a/drivers/bus/mhi/ep/main.c
> +++ b/drivers/bus/mhi/ep/main.c
> @@ -544,9 +544,9 @@ static void mhi_ep_skb_completion(struct mhi_ep_buf_info *buf_info)
>
> mhi_ep_ring_inc_index(ring);
> }
> -
I'm pretty sure we want that line.
> /* TODO: Handle partially formed TDs */
> -int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> +static int mhi_ep_queue(struct mhi_ep_device *mhi_dev, void *buf, size_t len,
> + void *cb_buf)
> {
> struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl;
> struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan;
> @@ -559,7 +559,7 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> u32 tre_len;
> int ret;
>
> - buf_left = skb->len;
> + buf_left = len;
> ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring;
>
> mutex_lock(&mhi_chan->lock);
> @@ -582,13 +582,13 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> tre_len = MHI_TRE_DATA_GET_LEN(el);
>
> tr_len = min(buf_left, tre_len);
> - read_offset = skb->len - buf_left;
> + read_offset = len - buf_left;
>
> - buf_info.dev_addr = skb->data + read_offset;
> + buf_info.dev_addr = buf + read_offset;
> buf_info.host_addr = MHI_TRE_DATA_GET_PTR(el);
> buf_info.size = tr_len;
> buf_info.cb = mhi_ep_skb_completion;
> - buf_info.cb_buf = skb;
> + buf_info.cb_buf = cb_buf;
> buf_info.mhi_dev = mhi_dev;
>
> /*
> @@ -627,8 +627,19 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
>
> return ret;
> }
> +
> +int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> +{
> + return mhi_ep_queue(mhi_dev, skb->data, skb->len, skb);
> +}
> EXPORT_SYMBOL_GPL(mhi_ep_queue_skb);
>
> +int mhi_ep_queue_buf(struct mhi_ep_device *mhi_dev, void *buf, size_t len)
> +{
> + return mhi_ep_queue(mhi_dev, buf, len, buf);
> +}
> +EXPORT_SYMBOL_GPL(mhi_ep_queue_buf);
> +
> static int mhi_ep_cache_host_cfg(struct mhi_ep_cntrl *mhi_cntrl)
> {
> size_t cmd_ctx_host_size, ch_ctx_host_size, ev_ctx_host_size;
> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
> index 7b40fc8cbe77ab8419d167e89264b69a817b9fb1..7186eb667b081009927af48513519084fb0be3a6 100644
> --- a/include/linux/mhi_ep.h
> +++ b/include/linux/mhi_ep.h
> @@ -302,4 +302,14 @@ bool mhi_ep_queue_is_empty(struct mhi_ep_device *mhi_dev, enum dma_data_directio
> */
> int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb);
>
> +/**
> + * mhi_ep_queue_buf - Send buffer to host over MHI Endpoint
> + * @mhi_dev: Device associated with the DL channel
> + * @buf: Buffer to be queued
> + * @len: Size of the buffer
> + *
> + * Return: 0 if the buffer has been sent successfully, a negative error code otherwise.
Sent or queued?
Regards,
Bjorn
> + */
> +int mhi_ep_queue_buf(struct mhi_ep_device *mhi_dev, void *buf, size_t len);
> +
> #endif
>
> --
> 2.34.1
>
>
Powered by blists - more mailing lists