Skip to contentSkip to conversation

media: ti: j721e-csi2rx: Allow passing cache hints from user-space

PATCH In review Devarsh Thakkar 3 participants 3 messages Mar 12, 2025 – Jun 25, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: ti: j721e-csi2rx: Allow passing cache hints from user-space

User-space can provide cache hints to enable software managed cache operations or skip certain cache operations using memory flags and buffer flags. This is useful for SoCs such as AM62px which do not support hardware cache coherency.

This is tested on AM62px with yavta capture by passing V4L2_MEMORY_FLAG_NON_COHERENT while using VIDIOC_REQBUFS and V4L2_BUF_FLAG_NO_CACHE_CLEAN while using VIDIOC_QBUF and ~5x reduction in memcpy time is seen for copying captured frame to DDR as shared here [1].

[1]:

---
 drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +1 -0
index 6412a00be8ea..284d33b2a0ec 100644
@@ -895,6 +895,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi)
 	q->dev = dmaengine_get_dma_device(csi->dma.chan);
 	q->lock = &csi->mutex;
 	q->min_queued_buffers = 1;
+	q->allow_cache_hints = 1;
 
 	ret = vb2_queue_init(q);
 	if (ret)
Signature · 1 line
2.39.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Devarsh,

Thanks for the patch.

Quoted 5 lines · Devarsh Thakkar

User-space can provide cache hints to enable software managed cache operations or skip certain cache operations using memory flags and buffer flags. This is useful for SoCs such as AM62px which do not support hardware cache coherency.

Quoted 7 lines

This is tested on AM62px with yavta capture by passing V4L2_MEMORY_FLAG_NON_COHERENT while using VIDIOC_REQBUFS and V4L2_BUF_FLAG_NO_CACHE_CLEAN while using VIDIOC_QBUF and ~5x reduction in memcpy time is seen for copying captured frame to DDR as shared here [1].

[1]:

nit: might be cleaner to drop the "[1]" reference as a single Link tag is pretty unambiguous.

But in any case,

Quoted 20 lines
---
 drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +1 -0
index 6412a00be8ea..284d33b2a0ec 100644
@@ -895,6 +895,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi)
 	q->dev = dmaengine_get_dma_device(csi->dma.chan);
 	q->lock = &csi->mutex;
 	q->min_queued_buffers = 1;
+	q->allow_cache_hints = 1;
 
 	ret = vb2_queue_init(q);
 	if (ret)
Signature · 1 line
2.39.1
#2 lore raw
In reply to Devarsh Thakkar

Hi Devarsh,

Thanks for the patch.

Quoted 10 lines · Devarsh Thakkar

User-space can provide cache hints to enable software managed cache operations or skip certain cache operations using memory flags and buffer flags. This is useful for SoCs such as AM62px which do not support hardware cache coherency.

This is tested on AM62px with yavta capture by passing V4L2_MEMORY_FLAG_NON_COHERENT while using VIDIOC_REQBUFS and V4L2_BUF_FLAG_NO_CACHE_CLEAN while using VIDIOC_QBUF and ~5x reduction in memcpy time is seen for copying captured frame to DDR as shared here [1].

The lines may be up to 75 characters long here. Most editors can handle the wrapping for you, I've rewrapped the text in this case and edited it a little, as Jai suggested.

Quoted 20 lines

[1]:

---
 drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +1 -0
index 6412a00be8ea..284d33b2a0ec 100644
@@ -895,6 +895,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi)
 	q->dev = dmaengine_get_dma_device(csi->dma.chan);
 	q->lock = &csi->mutex;
 	q->min_queued_buffers = 1;
+	q->allow_cache_hints = 1;
 
 	ret = vb2_queue_init(q);
 	if (ret)
Signature · 3 lines
Regards,

Sakari Ailus