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)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- c, linux
- Domínio
- backend, operating-systems
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- C
- Estrelas
- 13.4k
- Forks
- 5.5k
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 37
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de raspberrypi/linux
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
raspberrypi/linux#7822 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
raspberrypi/linux#7415 · 2 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace appAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
raspberrypi/linux#7399 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
raspberrypi/linux#7357 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
raspberrypi/linux#7054 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de raspberrypi/linux
Issues semelhantes
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
389ds/389-ds-base#8251 ·
Mantenedores costumam responder em até 1 dia
-
ColumnDecimal::Append(Int128) stores a value outside the Decimal(P, S) range with no error: cut to 32/64 bits, or with too many digitsTalvez já em andamento @RUSHIT305 assumiu hoje. Abertabug data-types
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
ClickHouse/clickhouse-cpp#645 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
ROCm/hrx-system#3628 ·
Mantenedores costumam responder em até 1 dia