From: Michael Riesch <michael.riesch@collabora.com>
To: Mehdi Djait <mehdi.djait@linux.intel.com>
Cc: "Maxime Chevallier" <maxime.chevallier@bootlin.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Gerald Loacker" <gerald.loacker@wolfvision.net>,
"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
"Markus Elfring" <Markus.Elfring@web.de>,
"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Kever Yang" <kever.yang@rock-chips.com>,
"Nicolas Dufresne" <nicolas.dufresne@collabora.com>,
"Sebastian Reichel" <sebastian.reichel@collabora.com>,
"Collabora Kernel Team" <kernel@collabora.com>,
"Paul Kocialkowski" <paulk@sys-base.io>,
"Alexander Shiyan" <eagle.alexander923@gmail.com>,
"Val Packett" <val@packett.cool>, "Rob Herring" <robh@kernel.org>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v10 08/13] media: rockchip: rkcif: add support for mipi csi-2 capture
Date: Wed, 8 Oct 2025 17:15:10 +0200 [thread overview]
Message-ID: <1c064a20-15bc-4e7d-ab76-bdbcc2a2465c@collabora.com> (raw)
In-Reply-To: <rpaa2jspgmw3do5y367kq4pvvtpboeu7gjd4chmh6pgztmj6ar@ckh7jxvfuhlg>
Hi Mehdi,
On 8/19/25 18:46, Mehdi Djait wrote:
> Hi Michael,
>
> I am seeing IOMMU page faults: See below.
Sorry for the late reply. I had to get a similar setup first. Now I have
a Radxa ROCK 3A and a Radxa Camera 8M (with the Sony IMX219 sensor,
should be 100% compatible to the RasPi Cam v2.1) on my table.
> On Tue, Aug 19, 2025 at 01:26:00AM +0200, Michael Riesch via B4 Relay wrote:
>> From: Michael Riesch <michael.riesch@collabora.com>
>>
>> The RK3568 Video Capture (VICAP) unit features a MIPI CSI-2 capture
>> interface that can receive video data and write it into system memory
>> using the ping-pong scheme. Add support for it.
>>
>> Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
>> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>> Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
>
> [..]
>
>> irqreturn_t rkcif_mipi_isr(int irq, void *ctx)
>> {
>> + struct device *dev = ctx;
>> + struct rkcif_device *rkcif = dev_get_drvdata(dev);
>> irqreturn_t ret = IRQ_NONE;
>> + u32 intstat;
>> +
>> + for (unsigned int i = 0; i < rkcif->match_data->mipi->mipi_num; i++) {
>> + enum rkcif_interface_index index = RKCIF_MIPI_BASE + i;
>> + struct rkcif_interface *interface = &rkcif->interfaces[index];
>> +
>> + intstat = rkcif_mipi_read(interface, RKCIF_MIPI_INTSTAT);
>> + rkcif_mipi_write(interface, RKCIF_MIPI_INTSTAT, intstat);
>> +
>> + for (unsigned int j = 0; j < interface->streams_num; j++) {
>> + struct rkcif_stream *stream = &interface->streams[j];
>
> In the TRM you can see in the MIPI_INTSTAT interrupts to detect
> overflows: why not activate them ?
>
> something like this:
>
> #define RKCIF_MIPI_INT_Y_OVERFLOW(id) BIT(16)
> #define RKCIF_MIPI_INT_UV_OVERFLOW(id) BIT(17)
> #define RKCIF_MIPI_INT_FIFO_OVERFLOW(id) BIT(18)
> #define RKCIF_MIPI_INT_CSI2RX_FIFO_OVERFLOW(id) BIT(20)
>
> and then OR them with the int_mask in rkcif_mipi_start_streaming()
>
> and then you can log the err if something happened ?
I have not needed these interrupts yet. They can be added any time
whenever they are required. (Patches welcome :-))
>> +
>> + if (intstat & RKCIF_MIPI_INT_FRAME0_END(stream->id) ||
>> + intstat & RKCIF_MIPI_INT_FRAME1_END(stream->id)) {
>> + ret = IRQ_HANDLED;
>> +
>> + if (stream->stopping) {
>> + rkcif_mipi_stop_streaming(stream);
>> + wake_up(&stream->wq_stopped);
>> + continue;
>> + }
>> +
>> + rkcif_stream_pingpong(stream);
>> + }
>> + }
>> + }
>>
>> return ret;
>> }
>
> Now to the IOMMU page faults:
>
> Camera Sensor: IMX219
> Frame Size: 1920x1080
> Format: SRGGB10P
>
> Packed SRGGB10
> --> Every four consecutive samples are packed into 5 bytes
> --> Stride = 2400 bytes (1920 * 5/4)
>
> So the imagesize = 1080 * 2400 = 2 592 000
>
> in __vb2_buf_mem_alloc() the size of the buf will be PAGE_ALIGNED in:
> PAGE_ALIGN(vb->planes[plane].length);
>
> So we allocate a buffer with the size: 2 592 768 -> hex = 0x297000
>
> In rkcif_mipi_queue_buffer():
> We will queue a total of two buffers to the HW (2 because of pingpong)
> The first buffer will have the address: 0x00000000ffc00000
>
> We start to capture and then this happens:
>
> rk_iommu fdfe0800.iommu: Page fault at 0x00000000ffe79000 of type write
> rk_iommu fdfe0800.iommu: iova = 0x00000000ffe79000: dte_index: 0x3ff pte_index: 0x279 page_offset: 0x0
> rk_iommu fdfe0800.iommu: mmu_dte_addr: 0x0000000012cc8000 dte@0x0000000012cc8ffc: 0x11a0d001 valid: 1 pte@0x0000000011a0d9e4: 0x31b79006 valid: 0 page@0x0000000000000000 flags: 0x0
>
> With:
> 0xffe79000 = 0xffc00000 (buffer address) + 0x297000 (buffersize)
>
> --> So the VICAP is overflowing the buffer even though everything was
> correctly configured ?! (If I understood everything correctly ofc.)
I could reproduce this behavior and found that the (hardcoded) virtual
line width needs to be adjusted accordingly. It was set to width * 2,
and it needs to be set to width * 10 / 8.
> I also see the same problem with the SRGGB8 format. It also happens in
> the downstream Radxa/Rockchip Kernel.
Strange that the downstream kernel has issues with that. Anyway, this
shouldn't be the issue here...
> Do you see the same problem ?
... but I could reproduce this behavior as well and trace it back to the
same root cause. Here, we need width * 1, of course.
I'll integrate the fix in v12, please stay tuned!
Best regards,
Michael
next prev parent reply other threads:[~2025-10-08 15:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 23:25 [PATCH v10 00/13] media: rockchip: add a driver for the rockchip camera interface Michael Riesch via B4 Relay
2025-08-18 23:25 ` [PATCH v10 01/13] Documentation: admin-guide: media: add " Michael Riesch via B4 Relay
2025-08-18 23:25 ` [PATCH v10 02/13] media: dt-bindings: video-interfaces: add defines for sampling modes Michael Riesch via B4 Relay
2025-08-18 23:25 ` [PATCH v10 03/13] media: dt-bindings: add rockchip px30 vip Michael Riesch via B4 Relay
2025-08-28 13:22 ` Bryan O'Donoghue
2025-08-18 23:25 ` [PATCH v10 04/13] media: dt-bindings: add rockchip rk3568 vicap Michael Riesch via B4 Relay
2025-08-18 23:25 ` [PATCH v10 05/13] media: dt-bindings: add rockchip rk3568 mipi csi-2 receiver Michael Riesch via B4 Relay
2025-08-25 15:28 ` Bryan O'Donoghue
2025-08-18 23:25 ` [PATCH v10 06/13] media: rockchip: add a driver for the rockchip camera interface Michael Riesch via B4 Relay
2025-08-26 6:21 ` Bryan O'Donoghue
2025-08-28 10:03 ` Michael Riesch
2025-08-28 14:08 ` Bryan O'Donoghue
2025-09-16 19:19 ` Michael Riesch
2025-08-18 23:25 ` [PATCH v10 07/13] media: rockchip: add driver for mipi csi-2 receiver Michael Riesch via B4 Relay
2025-08-25 10:37 ` Philipp Zabel
2025-09-17 14:25 ` Michael Riesch
2025-08-18 23:26 ` [PATCH v10 08/13] media: rockchip: rkcif: add support for mipi csi-2 capture Michael Riesch via B4 Relay
2025-08-19 16:46 ` Mehdi Djait
2025-10-08 15:15 ` Michael Riesch [this message]
2025-08-18 23:26 ` [PATCH v10 09/13] arm64: defconfig: enable rockchip camera interface and mipi csi-2 receiver Michael Riesch via B4 Relay
2025-08-28 13:18 ` Bryan O'Donoghue
2025-08-18 23:26 ` [PATCH v10 10/13] arm64: dts: rockchip: add the vip node to px30 Michael Riesch via B4 Relay
2025-08-28 13:25 ` Bryan O'Donoghue
2025-08-18 23:26 ` [PATCH v10 11/13] arm64: dts: rockchip: add vicap node to rk356x Michael Riesch via B4 Relay
2025-08-18 23:26 ` [PATCH v10 12/13] arm64: dts: rockchip: add mipi csi-2 receiver " Michael Riesch via B4 Relay
2025-08-18 23:26 ` [PATCH v10 13/13] arm64: dts: rockchip: enable vicap dvp on wolfvision pf5 io expander Michael Riesch via B4 Relay
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=1c064a20-15bc-4e7d-ab76-bdbcc2a2465c@collabora.com \
--to=michael.riesch@collabora.com \
--cc=Markus.Elfring@web.de \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eagle.alexander923@gmail.com \
--cc=gerald.loacker@wolfvision.net \
--cc=heiko@sntech.de \
--cc=kernel@collabora.com \
--cc=kever.yang@rock-chips.com \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mchehab@kernel.org \
--cc=mehdi.djait@linux.intel.com \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=paulk@sys-base.io \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sebastian.reichel@collabora.com \
--cc=theo.lebrun@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=val@packett.cool \
/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®