Skip to content

Commit 9cd4742

Browse files
committed
drm/mode: reduce scope of fb_lock in framebuffer init
We don't need to hold the fb lock around the initialisation, only around the list manipulaton. So do the lock hold only around the register for now. From Daniel: Previously fb refcounting, and especially the weak reference (kref_get_unless_zero) used in fb lookups have been protected by fb_lock. But with the refactoring to share refcounting in the drm_mode_object base class that switched to being protected by idr_mutex, which means fb_lock critical sections can be reduced. Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent cee26ac commit 9cd4742

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,22 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
458458
{
459459
int ret;
460460

461-
mutex_lock(&dev->mode_config.fb_lock);
462461
INIT_LIST_HEAD(&fb->filp_head);
463462
fb->dev = dev;
464463
fb->funcs = funcs;
465464

466465
ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
467-
true, drm_framebuffer_free);
466+
false, drm_framebuffer_free);
468467
if (ret)
469468
goto out;
470469

470+
mutex_lock(&dev->mode_config.fb_lock);
471471
dev->mode_config.num_fb++;
472472
list_add(&fb->head, &dev->mode_config.fb_list);
473-
out:
474-
mutex_unlock(&dev->mode_config.fb_lock);
475473

474+
drm_mode_object_register(dev, &fb->base);
475+
mutex_unlock(&dev->mode_config.fb_lock);
476+
out:
476477
return ret;
477478
}
478479
EXPORT_SYMBOL(drm_framebuffer_init);

0 commit comments

Comments
 (0)