freenode
Desktop & Graphics

DRM series moves dma_resv to refcounted dynamic allocs

Christian König proposes dropping embedded reservation objects across GEM, TTM, and drivers, with Claude-assisted patches and automated review already flagging serious leaks.

Christian König has posted a DRM patch series that makes dma_resv a reference-counted, dynamically allocated object instead of an embedded structure sprinkled through GEM, TTM, and related drivers.

The change is meant to end awkward sharing when several GEM objects point at one reservation, let TTM handle delayed buffer teardown without zombie-object hacks, and give DMA-buf room for cleaner map and pin contention later. König had shelved the idea before as too invasive for such a widely used lock object. After trying the conversion with Claude Sonnet 4, he concluded the result is a cleanup the subsystem should pursue, then smoke-tested the series on amdgpu, selftests, and kmemleak.

The work stages the migration behind a temporary allocated flag so callers can switch one by one, removes embedded _resv fields from core GEM and driver structures, and finally drops dma_resv_init() once every user goes through dma_resv_alloc(). Drivers touched include amdgpu, i915, Xe, Nouveau, and TTM tests, plus lockdep priming paths that previously kept stack-allocated reservations.

Automated review from the Sashiko bot immediately reported high-severity problems in the posted diffs: permanent leaks of reservation objects on i915 GEM teardown and Nouveau internal BOs, double allocation that overwrites the first pointer in i915 address-space setup, callers that ignore new -ENOMEM returns, missing puts on TTM ghost objects, and several test paths that abandon fences or reservations on assert failure. Those findings underscore both the reach of the refactor and how much careful human review the series still needs before it is safe to land.