From: Sumit Kumar <sumit.kumar@oss.qualcomm.com>
To: "Krishna Chaitanya Chundru" <krishna.chundru@oss.qualcomm.com>,
"Veerabhadrarao Badiganti"
<veerabhadrarao.badiganti@oss.qualcomm.com>,
"Subramanian Ananthanarayanan"
<subramanian.ananthanarayanan@oss.qualcomm.com>,
"Akhil Vinod" <akhil.vinod@oss.qualcomm.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Vinod Koul" <vkoul@kernel.org>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux.dev, linux-pci@vger.kernel.org,
mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
Sumit Kumar <sumit.kumar@oss.qualcomm.com>
Subject: [PATCH 3/3] bus: mhi: ep: Use batched read for ring caching
Date: Fri, 13 Mar 2026 12:19:27 +0530 [thread overview]
Message-ID: <20260313-dma_multi_sg-v1-3-8fabb0d1a759@oss.qualcomm.com> (raw)
In-Reply-To: <20260313-dma_multi_sg-v1-0-8fabb0d1a759@oss.qualcomm.com>
Simplify ring caching logic by using the new read_batch() callback
for all ring read operations, replacing the previous approach that
used separate read_sync() calls.
Signed-off-by: Sumit Kumar <sumit.kumar@oss.qualcomm.com>
---
drivers/bus/mhi/ep/ring.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/drivers/bus/mhi/ep/ring.c b/drivers/bus/mhi/ep/ring.c
index 26357ee68dee984d70ae5bf39f8f09f2cbcafe30..03c60c579e12c3bad100c7e1b6a75ae0e5646281 100644
--- a/drivers/bus/mhi/ep/ring.c
+++ b/drivers/bus/mhi/ep/ring.c
@@ -30,7 +30,7 @@ static int __mhi_ep_cache_ring(struct mhi_ep_ring *ring, size_t end)
{
struct mhi_ep_cntrl *mhi_cntrl = ring->mhi_cntrl;
struct device *dev = &mhi_cntrl->mhi_dev->dev;
- struct mhi_ep_buf_info buf_info = {};
+ struct mhi_ep_buf_info buf_info[2] = {};
size_t start;
int ret;
@@ -44,35 +44,38 @@ static int __mhi_ep_cache_ring(struct mhi_ep_ring *ring, size_t end)
start = ring->wr_offset;
if (start < end) {
- buf_info.size = (end - start) * sizeof(struct mhi_ring_element);
- buf_info.host_addr = ring->rbase + (start * sizeof(struct mhi_ring_element));
- buf_info.dev_addr = &ring->ring_cache[start];
+ /* No wraparound */
+ buf_info[0].size = (end - start) * sizeof(struct mhi_ring_element);
+ buf_info[0].host_addr = ring->rbase + (start * sizeof(struct mhi_ring_element));
+ buf_info[0].dev_addr = &ring->ring_cache[start];
- ret = mhi_cntrl->read_sync(mhi_cntrl, &buf_info);
+ ret = mhi_cntrl->read_batch(mhi_cntrl, buf_info, 1);
if (ret < 0)
return ret;
+
+ dev_dbg(dev, "Cached ring: start %zu end %zu size %zu\n", start, end,
+ buf_info[0].size);
} else {
- buf_info.size = (ring->ring_size - start) * sizeof(struct mhi_ring_element);
- buf_info.host_addr = ring->rbase + (start * sizeof(struct mhi_ring_element));
- buf_info.dev_addr = &ring->ring_cache[start];
+ /* Wraparound */
+
+ /* Buffer 0: Tail portion (start → ring_size) */
+ buf_info[0].size = (ring->ring_size - start) * sizeof(struct mhi_ring_element);
+ buf_info[0].host_addr = ring->rbase + (start * sizeof(struct mhi_ring_element));
+ buf_info[0].dev_addr = &ring->ring_cache[start];
- ret = mhi_cntrl->read_sync(mhi_cntrl, &buf_info);
+ /* Buffer 1: Head portion (0 → end) */
+ buf_info[1].size = end * sizeof(struct mhi_ring_element);
+ buf_info[1].host_addr = ring->rbase;
+ buf_info[1].dev_addr = &ring->ring_cache[0];
+
+ ret = mhi_cntrl->read_batch(mhi_cntrl, buf_info, 2);
if (ret < 0)
return ret;
- if (end) {
- buf_info.host_addr = ring->rbase;
- buf_info.dev_addr = &ring->ring_cache[0];
- buf_info.size = end * sizeof(struct mhi_ring_element);
-
- ret = mhi_cntrl->read_sync(mhi_cntrl, &buf_info);
- if (ret < 0)
- return ret;
- }
+ dev_dbg(dev, "Cached ring (batched): start %zu end %zu tail_size %zu head_size %zu\n",
+ start, end, buf_info[0].size, buf_info[1].size);
}
- dev_dbg(dev, "Cached ring: start %zu end %zu size %zu\n", start, end, buf_info.size);
-
return 0;
}
--
2.34.1
prev parent reply other threads:[~2026-03-13 6:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 6:49 [PATCH 0/3] dmaengine: Add batched scatter-gather DMA support Sumit Kumar
2026-03-13 6:49 ` [PATCH 1/3] dmaengine: Add multi-buffer support in single DMA transfer Sumit Kumar
2026-03-13 15:16 ` Robin Murphy
2026-03-16 17:05 ` Niklas Cassel
2026-03-17 10:54 ` Vinod Koul
2026-03-30 5:28 ` Sumit Kumar
2026-03-13 6:49 ` [PATCH 2/3] PCI: epf-mhi: Add batched DMA read support Sumit Kumar
2026-03-13 6:49 ` Sumit Kumar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313-dma_multi_sg-v1-3-8fabb0d1a759@oss.qualcomm.com \
--to=sumit.kumar@oss.qualcomm.com \
--cc=akhil.vinod@oss.qualcomm.com \
--cc=bhelgaas@google.com \
--cc=dmaengine@vger.kernel.org \
--cc=iommu@lists.linux.dev \
--cc=kishon@kernel.org \
--cc=krishna.chundru@oss.qualcomm.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mani@kernel.org \
--cc=mhi@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=subramanian.ananthanarayanan@oss.qualcomm.com \
--cc=veerabhadrarao.badiganti@oss.qualcomm.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®