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)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c, linux
- Área
- backend, operating-systems
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 13.4k
- Forks
- 5.5k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 37
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de raspberrypi/linux
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
raspberrypi/linux#7822 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
raspberrypi/linux#7415 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace appAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
raspberrypi/linux#7399 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Documentation update requiredAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
raspberrypi/linux#7357 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
raspberrypi/linux#7054 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de raspberrypi/linux
Issues similares
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
389ds/389-ds-base#8251 ·
Los mantenedores suelen responder en 1 día
-
ColumnDecimal::Append(Int128) stores a value outside the Decimal(P, S) range with no error: cut to 32/64 bits, or with too many digitsPosiblemente ocupada @RUSHIT305 la tomó hoy. Abiertobug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ClickHouse/clickhouse-cpp#645 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ROCm/hrx-system#3628 ·
Los mantenedores suelen responder en 1 día