vc4: swiotlb bounce-buffer import check bypassed since "drm/vc4: Set DRM DMA device directly from HVS and V3D" (Pi 4 scans out frozen frames)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c, linux
调研方向
Start with vc4_prime_import_sg_table() and the dma_to_phys()/swiotlb_find_pool() check described in the issue; compare its device argument with the device used to map the imported scatter-gather table. The issue proposes checking with attach->dev or drm_dev_dma_dev(dev), but notes this is untested on hardware. Confirm that bounce-buffer imports are rejected on Raspberry Pi 4 full KMS and that the compositor falls back to GPU composition without frozen frames.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
On a Raspberry Pi 4 with full KMS, the check that rejects swiotlb bounce buffers on dma-buf import (356662cda96f, "drm: vc4: Block swiotlb bounce buffers being imported as dmabuf", #5734) no longer works since the stable backport of upstream b0a6b769cc17 ("drm/vc4: Set DRM DMA device directly from HVS and V3D") was merged into rpi-6.18.y with 6.18.65 (008dd935c79d).
After that change, imports are attached and mapped for the HVS device (drm_dev_dma_dev()), but vc4_prime_import_sg_table() still checks against dev->dev:
phys_addr_t phys = dma_to_phys(dev->dev, sg_dma_address(sgt->sgl));
if (swiotlb_find_pool(dev->dev, phys))
return ERR_PTR(-EINVAL);
dev->dev is the /gpu platform device. In full KMS mode vc4_drm_bind() no longer calls of_dma_configure() for it, and /gpu is a child of the DT root, which has no dma-ranges, so the device has no dma_range_map. dma_to_phys() then returns the bus address unchanged (for example 0xc6660000 instead of 0x06660000), swiotlb_find_pool() does not recognise it as a swiotlb address, and the bounce-buffered import is accepted.
The result is the problem the original check was written to prevent. When the compositor does direct scanout of a client buffer that lies outside the HVS's 1 GB DMA window, the HVS scans out the swiotlb bounce buffer. That buffer holds a copy of the client buffer from the moment of import and is never synced again, so the screen shows a frozen image. In our case some client buffers are imported this way (the bounce happened to be contiguous) and the others are rejected and composited by the GPU, so the display alternates many times per second between stale still images and the live video.
With 6.18.53, the same imports are rejected and the compositor falls back to GPU composition, as intended. Going by the source, 6.18.64-3 does not contain the backport either, but we have not run it.
A possible fix (not tested on hardware) is to check against the device the sg_table was actually mapped for:
struct device *dma_dev = attach->dev; /* or drm_dev_dma_dev(dev) */
phys_addr_t phys = dma_to_phys(dma_dev, sg_dma_address(sgt->sgl));
if (swiotlb_find_pool(dma_dev, phys))
return ERR_PTR(-EINVAL);
Steps to reproduce the behaviour
- Raspberry Pi 4,
dtoverlay=vc4-kms-v3d, kernel from rpi-6.18.y at 6.18.65 or later. - Run a wlroots-based compositor that does direct scanout (we use sway 1.12 with wlroots 0.20.2).
- Run a fullscreen EGL client at the output resolution. Ours is a GStreamer 1.28 video player; its buffers are ARGB2101010, LINEAR, 1920x1080, allocated by v3d through Mesa 26.x.
- The compositor tries direct scanout. Some client buffers are imported into vc4 through swiotlb, and the frames using them show a frozen image.
To check whether it happened:
/sys/kernel/debug/dma_buf/bufinfolistsfe400000.hvsas an attached device of the client buffers./sys/kernel/debug/dri/1/framebuffershows framebuffers whosedma_addrminus 0xc0000000 falls inside the swiotlb pool reported in dmesg.
Device (s)
Raspberry Pi 4 Mod. B
System
- Raspberry Pi 4 Model B Rev 1.5
- OS: Arch Linux ARM (aarch64)
- Kernel: Arch Linux ARM linux-rpi 6.18.65-3 (raspberrypi/linux 16ae2649dcfa)
Linux 6.18.65-3-rpi #1 SMP PREEMPT Mon Nov 30 21:20:51 UTC 2026 aarch64 GNU/Linux vc4_drv.candvc4_hvs.care unchanged in linux-rpi 6.18.66-1 (342dfe848204). We have not run that version on hardware.- Works as intended: linux-rpi 6.18.53-1 (d9e1735f5339). 6.18.64-3 (a40f73532539) does not contain the backport.
- Firmware:
Nov 25 2026 18:52:17,version a23b4fbc8895a3a09818ac5dea47ad8680630f55 (clean) (release) (start) CONFIG_SWIOTLB=y,CONFIG_SWIOTLB_DYNAMICnot set
Logs
software IO TLB: area num 4.
software IO TLB: mapped [mem 0x0000000003000000-0x0000000007000000] (64MB)
On the affected 6.18.65 system:
/sys/kernel/debug/dri/1/framebuffershows two AR30 framebuffers allocated by the compositor withdma_addr=0x00000000c6660000anddma_addr=0x00000000c5496000. These are physical 0x06660000 and 0x05496000, inside the swiotlb pool./sys/kernel/debug/dma_buf/bufinfoshows those two client buffers attached tofe400000.hvs. The third client buffer has no attachment, and the compositor composites it./sys/kernel/debug/swiotlb/io_tlb_usedis 12156, which is 3 x 4052 slabs, i.e. three mappings of the 8298496-byte buffers (one buffer is attached twice).- Reading RAM at
dma_addr - 0xc0000000through/dev/memgives an image that stays the same over several seconds (identical md5) and differs from the dma-buf contents read through an mmap of the PRIME fd. For the compositor's own vc4-allocated framebuffer, the two reads are identical. - Sampling
hvs_dlists300 times showed the two bounce-buffer framebuffers being scanned out about 75% of the time.
On three Raspberry Pi 4s running the same software stack with 6.18.53:
- The client buffers have no attachments.
io_tlb_usedis 0 andio_tlb_used_hiwateris 4308 to 4566 slabs, which is consistent with one 8 MB mapping being created and then rejected.
Additional context
A Raspberry Pi 5 running the same software is not affected, because the HVS there is behind the IOMMU and no bounce buffer is involved.
The fkms path in vc4_drm_bind() still calls of_dma_configure() on /gpu for gen < 6, so the check may still work there. We have only looked at full KMS.
- 主要语言
- C
- 星标
- 13.4k
- 派生
- 5.5k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 37
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
raspberrypi/linux 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
raspberrypi/linux#7822 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
raspberrypi/linux#7415 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace app未关闭
难度 2/5 1-3 小时 新手友好度 72/100
raspberrypi/linux#7399 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
raspberrypi/linux#7357 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
raspberrypi/linux#7054 · 2 条评论 ·
维护者通常 1 天内回复
查看 raspberrypi/linux 的全部 Issue
相似的 Issue
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBuffer未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
needs triage
难度 2/5 1-3 小时 新手友好度 72/100
389ds/389-ds-base#8251 ·
维护者通常 1 天内回复
-
ColumnDecimal::Append(Int128) stores a value outside the Decimal(P, S) range with no error: cut to 32/64 bits, or with too many digits可能已有人在做 @RUSHIT305 今天认领。 未关闭bug data-types
难度 2/5 1-3 小时 新手友好度 76/100
ClickHouse/clickhouse-cpp#645 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
ROCm/hrx-system#3628 ·
维护者通常 1 天内回复