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)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- c, linux
- Domaine
- backend, operating-systems
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- C
- Étoiles
- 13.4k
- Forks
- 5.5k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 37
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de raspberrypi/linux
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
raspberrypi/linux#7822 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
raspberrypi/linux#7415 · 2 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace appOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
raspberrypi/linux#7399 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Documentation update requiredOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
raspberrypi/linux#7357 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
raspberrypi/linux#7054 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de raspberrypi/linux
Issues similaires
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
389ds/389-ds-base#8251 ·
Les mainteneurs répondent en général sous 1 jour
-
ColumnDecimal::Append(Int128) stores a value outside the Decimal(P, S) range with no error: cut to 32/64 bits, or with too many digitsPeut-être pris @RUSHIT305 l’a pris aujourd’hui. Ouvertebug data-types
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ClickHouse/clickhouse-cpp#645 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
ROCm/hrx-system#3628 ·
Les mainteneurs répondent en général sous 1 jour