Skip to content

Fix: add vmap/vunmap callbacks to evdi GEM objects in order to support some multi monitor setups - #604

Open
TigerWolf wants to merge 1 commit into
DisplayLink:mainfrom
TigerWolf:fix/gem-vmap-vunmap-callbacks
Open

TigerWolf wants to merge 1 commit into
DisplayLink:mainfrom
TigerWolf:fix/gem-vmap-vunmap-callbacks

Conversation

@TigerWolf

@TigerWolf TigerWolf commented Nov 10, 2026 •

Copy link
Copy Markdown

The problem

I use an external monitor through a DisplayLink dock. The monitor stayed black, although the mouse pointer still moved on it.

The kernel log showed errors such as:

Failed to map scanout buffer
evdi: dma_buf_vmap_unlocked failed: ret=... owner=...

Why it happened

EVDI shares its graphics buffers with the rest of the display stack using DMA-BUF. Before another driver or compositor can read one of those buffers, it has to map the buffer into memory and later unmap it.

EVDI's buffers did not provide those map/unmap operations, so the mapping failed and the second output could not be displayed.

How this fixes it

This change adds the missing map and unmap operations to EVDI's graphics buffers and registers them with the DRM subsystem. Another driver can now map an EVDI buffer, read it, and unmap it when finished.

The page pinning is balanced:

  • vmap pins the pages, maps the buffer, and returns the address.
  • vunmap unmaps the buffer and releases the page pin.
  • If mapping fails, the page pin is released as well.

The error message now includes the real error code and the name of the driver that owns the buffer, which makes future failures easier to diagnose.

What changed

  • evdi_gem_object_vmap(): new callback that pins the pages and maps the buffer into kernel memory.
  • evdi_gem_object_vunmap(): new callback that unmaps the buffer and releases the page pin.
  • gem_obj_funcs: registers the new callbacks so DRM can use them.
  • evdi_pin_pages() / evdi_unpin_pages(): existing helpers used to keep the pages in place while the buffer is mapped.
  • dma_buf_map / iosys_map: keeps the code building on older (5.11-5.17) and newer (5.18+) kernels.
  • evdi_gem_vmap() error path: logs the actual DMA-BUF error and buffer owner instead of returning a generic -ENOMEM.

Testing

  • Built against Linux 7.0.0-42-generic with make -C module.
  • Installed and tested locally through DKMS on a DisplayLink multi-monitor setup; both outputs work and the mapping errors are gone.
  • git diff --check passes.

I can rebuild and test further changes on this setup.

Refs: #591

DMA-BUF importers such as compositors may require the exporting GEM
object to expose .vmap/.vunmap. EVDI's GEM objects do not, so mapping an
EVDI-exported buffer can fail with -EOPNOTSUPP and leave one of multiple
DisplayLink outputs black.

Implement evdi_gem_object_vmap()/evdi_gem_object_vunmap() using
evdi_pin_pages()/evdi_unpin_pages() and vmap()/vunmap(), and register
them in gem_obj_funcs. Balance the page pin on the vmap failure path and
in vunmap.

Also report the real dma_buf_vmap() error together with the exporter
name instead of collapsing it to -ENOMEM.

See DisplayLink#591
@TigerWolf TigerWolf changed the title module: add vmap/vunmap callbacks to evdi GEM objects Fix: add vmap/vunmap callbacks to evdi GEM objects Nov 10, 2026
@TigerWolf TigerWolf changed the title Fix: add vmap/vunmap callbacks to evdi GEM objects Fix: add vmap/vunmap callbacks to evdi GEM objects in order to support some multi monitor setups Nov 10, 2026
@TigerWolf

Copy link
Copy Markdown
Author

Should I leave the error logging in there or remove it? It was helpful when debugging.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant