freedreno/kgsl: opt in to linear dma-buf sharing#85
Merged
Conversation
lfdevs
marked this pull request as ready for review
July 8, 2026 17:26
Add an explicit KGSL screen flag and gate the surfaceless/XWayland dma-buf sharing contract behind a separate opt-in path. When enabled, KGSL advertises PRIME import/export support even if the control fd cannot report it through DRM caps, restricts dma-buf modifiers to LINEAR, forces shared/scanout resources to use linear layouts, rejects non-linear KGSL dma-buf imports, and shadows non-shared resources into shared linear resources before export. Keep native KGSL BOs non-exportable directly: only imported or dma-heap/ION-backed KGSL BOs can provide a dma-buf fd. This avoids duplicating an invalid import fd and removes the noisy failed first export attempt for resources that need to be shadowed. The KGSL dma-buf path is enabled with either: FD_KGSL_ENABLE_DMABUF=1 XWAYLAND_FORCE_KGSL_SURFACELESS=1 It is intentionally not enabled by XWAYLAND_KGSL_SURFACELESS alone, because that variable only allows Xwayland to fall back to surfaceless after GBM setup fails. If the chroot DRM/GBM path succeeds, it should keep the normal DRM behavior instead of applying the surfaceless-oriented sharing rules.
lfdevs
force-pushed
the
test/support-xwayland-surfaceless
branch
from
July 9, 2026 07:27
59fa0b2 to
69aaa92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also see: lfdevs/xwayland#1
Summary
This teaches the freedreno KGSL path to expose a narrow dma-buf import/export contract for surfaceless/XWayland consumers: shared linear buffers only.
The KGSL stack can allocate shareable buffers through dma-heap/ION and import them into KGSL, but native KGSL allocations are not directly exportable as dma-bufs. This change makes that distinction explicit, constrains exported/imported modifiers to LINEAR when the KGSL dma-buf path is enabled, and shadows non-shared resources into shared linear resources before export.
The KGSL dma-buf sharing behavior is intentionally opt-in, so the normal chroot DRM/GBM path keeps its previous behavior.
Changes
FD_FEATURE_KGSLwinsys feature and store it asscreen->is_kgsl.screen->kgsl_dmabufflag for the opt-in dma-buf sharing path.FD_KGSL_ENABLE_DMABUF=1XWAYLAND_FORCE_KGSL_SURFACELESS=1screen->kgsl_dmabufis enabled.DRM_FORMAT_MOD_LINEAR.Why
XWayland/KWin surfaceless paths need a stable dma-buf contract for KGSL-backed rendering. The safe contract currently is:
At the same time, enabling these rules unconditionally can break the chroot DRM/GBM path. In testing, the modified Mesa path made
glmark2render black under DRM/GBM while still producing a score, whereas forcing XWayland's KGSL surfaceless backend restored correct output.For that reason, this keeps the surfaceless-oriented KGSL dma-buf behavior behind an explicit opt-in and leaves existing DRM/GBM behavior unchanged by default.
Testing
Tested with KGSL surfaceless/XWayland flow on Adreno 830 and 730:
glmark2runs through XWayland with hardware renderingAlso tested the chroot DRM/GBM path on Adreno 730:
XWAYLAND_FORCE_KGSL_SURFACELESS=1 EGL_PLATFORM=surfacelessenables the surfaceless flowThe shadow-before-export change also removes the expected-but-noisy first export failure: