Replace the stack-allocated dma_resv in the lockdep annotation code with a dynamically allocated one using dma_resv_alloc(). This aligns with the move away from embedded dma_resv structures and towards reference-counted dynamic allocation.
The lockdep annotation block in drmm_mode_config_init() is used to establish lock ordering dependencies between modeset locks and dma_resv locks. Since this only runs when CONFIG_LOCKDEP is enabled and the resv is immediately freed after use, the change is straightforward. If allocation fails, return -ENOMEM early. The existing dma_resv_put() at the end of the block properly handles the cleanup. Signed-off-by: Christian König <[email protected]> Assisted-by: Claude:Sonnet 4 --- drivers/gpu/drm/drm_mode_config.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 312d5e9675f0..de424b755c62 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -658,10 +658,12 @@ int drmm_mode_config_init(struct drm_device *dev) if (IS_ENABLED(CONFIG_LOCKDEP)) { struct drm_modeset_acquire_ctx modeset_ctx; struct ww_acquire_ctx resv_ctx; - struct dma_resv resv; + struct dma_resv *resv; int ret; - dma_resv_init(&resv); + resv = dma_resv_alloc(); + if (!resv) + return -ENOMEM; drm_modeset_acquire_init(&modeset_ctx, 0); ret = drm_modeset_lock(&dev->mode_config.connection_mutex, @@ -672,16 +674,16 @@ int drmm_mode_config_init(struct drm_device *dev) might_fault(); ww_acquire_init(&resv_ctx, &reservation_ww_class); - ret = dma_resv_lock(&resv, &resv_ctx); + ret = dma_resv_lock(resv, &resv_ctx); if (ret == -EDEADLK) - dma_resv_lock_slow(&resv, &resv_ctx); + dma_resv_lock_slow(resv, &resv_ctx); - dma_resv_unlock(&resv); + dma_resv_unlock(resv); ww_acquire_fini(&resv_ctx); drm_modeset_drop_locks(&modeset_ctx); drm_modeset_acquire_fini(&modeset_ctx); - dma_resv_put(&resv); + dma_resv_put(resv); } return drmm_add_action_or_reset(dev, drm_mode_config_init_release, -- 2.43.0
