Commit 2ddea3fd authored by Dave Airlie's avatar Dave Airlie

drm/modes: reduce fb_lock to just protecting lists

This reduces the fb_lock to just protecting the num_fb/fb_list.

"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: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 72fe90b8
...@@ -433,9 +433,7 @@ static void drm_framebuffer_free(struct kref *kref) ...@@ -433,9 +433,7 @@ static void drm_framebuffer_free(struct kref *kref)
* The lookup idr holds a weak reference, which has not necessarily been * The lookup idr holds a weak reference, which has not necessarily been
* removed at this point. Check for that. * removed at this point. Check for that.
*/ */
mutex_lock(&dev->mode_config.fb_lock);
drm_mode_object_unregister(dev, &fb->base); drm_mode_object_unregister(dev, &fb->base);
mutex_unlock(&dev->mode_config.fb_lock);
fb->funcs->destroy(fb); fb->funcs->destroy(fb);
} }
...@@ -475,9 +473,9 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, ...@@ -475,9 +473,9 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
mutex_lock(&dev->mode_config.fb_lock); mutex_lock(&dev->mode_config.fb_lock);
dev->mode_config.num_fb++; dev->mode_config.num_fb++;
list_add(&fb->head, &dev->mode_config.fb_list); list_add(&fb->head, &dev->mode_config.fb_list);
mutex_unlock(&dev->mode_config.fb_lock);
drm_mode_object_register(dev, &fb->base); drm_mode_object_register(dev, &fb->base);
mutex_unlock(&dev->mode_config.fb_lock);
out: out:
return ret; return ret;
} }
...@@ -498,12 +496,9 @@ struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, ...@@ -498,12 +496,9 @@ struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
struct drm_mode_object *obj; struct drm_mode_object *obj;
struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fb = NULL;
mutex_lock(&dev->mode_config.fb_lock);
obj = _object_find(dev, id, DRM_MODE_OBJECT_FB); obj = _object_find(dev, id, DRM_MODE_OBJECT_FB);
if (obj) if (obj)
fb = obj_to_fb(obj); fb = obj_to_fb(obj);
mutex_unlock(&dev->mode_config.fb_lock);
return fb; return fb;
} }
EXPORT_SYMBOL(drm_framebuffer_lookup); EXPORT_SYMBOL(drm_framebuffer_lookup);
...@@ -526,10 +521,8 @@ void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) ...@@ -526,10 +521,8 @@ void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
dev = fb->dev; dev = fb->dev;
mutex_lock(&dev->mode_config.fb_lock);
/* Mark fb as reaped and drop idr ref. */ /* Mark fb as reaped and drop idr ref. */
drm_mode_object_unregister(dev, &fb->base); drm_mode_object_unregister(dev, &fb->base);
mutex_unlock(&dev->mode_config.fb_lock);
} }
EXPORT_SYMBOL(drm_framebuffer_unregister_private); EXPORT_SYMBOL(drm_framebuffer_unregister_private);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment