diff options
author | Dave Airlie <airlied@redhat.com> | 2016-04-15 01:10:36 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-04-21 20:34:28 -0400 |
commit | d0f37cf62979e65558c1b7bd4d4c221c5281bae1 (patch) | |
tree | f2dc3655e89c07c096d5a4fd36efcff04109c3bf /include/drm | |
parent | 747a598ffa7dff499ee93d414b74a08af6ec657e (diff) |
drm/mode: move framebuffer reference into object.
This is the initial code to add references to some mode objects.
In the future we need to start reference counting connectors so
firstly I want to reorganise the code so the framebuffer ref counting
uses the same paths.
This patch shouldn't change any functionality, just moves the kref.
[airlied: move kerneldoc as well]
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drm_crtc.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 1c99ee09c9a0..43c31496a5a7 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -49,6 +49,8 @@ struct drm_mode_object { | |||
49 | uint32_t id; | 49 | uint32_t id; |
50 | uint32_t type; | 50 | uint32_t type; |
51 | struct drm_object_properties *properties; | 51 | struct drm_object_properties *properties; |
52 | struct kref refcount; | ||
53 | void (*free_cb)(struct kref *kref); | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | #define DRM_OBJECT_MAX_PROPERTY 24 | 56 | #define DRM_OBJECT_MAX_PROPERTY 24 |
@@ -223,8 +225,8 @@ struct drm_framebuffer { | |||
223 | * should be deferred. In cases like this, the driver would like to | 225 | * should be deferred. In cases like this, the driver would like to |
224 | * hold a ref to the fb even though it has already been removed from | 226 | * hold a ref to the fb even though it has already been removed from |
225 | * userspace perspective. | 227 | * userspace perspective. |
228 | * The refcount is stored inside the mode object. | ||
226 | */ | 229 | */ |
227 | struct kref refcount; | ||
228 | /* | 230 | /* |
229 | * Place on the dev->mode_config.fb_list, access protected by | 231 | * Place on the dev->mode_config.fb_list, access protected by |
230 | * dev->mode_config.fb_lock. | 232 | * dev->mode_config.fb_lock. |
@@ -2377,8 +2379,6 @@ extern int drm_framebuffer_init(struct drm_device *dev, | |||
2377 | const struct drm_framebuffer_funcs *funcs); | 2379 | const struct drm_framebuffer_funcs *funcs); |
2378 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, | 2380 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
2379 | uint32_t id); | 2381 | uint32_t id); |
2380 | extern void drm_framebuffer_unreference(struct drm_framebuffer *fb); | ||
2381 | extern void drm_framebuffer_reference(struct drm_framebuffer *fb); | ||
2382 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); | 2382 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); |
2383 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); | 2383 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
2384 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); | 2384 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); |
@@ -2436,6 +2436,8 @@ extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, | |||
2436 | int gamma_size); | 2436 | int gamma_size); |
2437 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, | 2437 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
2438 | uint32_t id, uint32_t type); | 2438 | uint32_t id, uint32_t type); |
2439 | void drm_mode_object_reference(struct drm_mode_object *obj); | ||
2440 | void drm_mode_object_unreference(struct drm_mode_object *obj); | ||
2439 | 2441 | ||
2440 | /* IOCTLs */ | 2442 | /* IOCTLs */ |
2441 | extern int drm_mode_getresources(struct drm_device *dev, | 2443 | extern int drm_mode_getresources(struct drm_device *dev, |
@@ -2605,6 +2607,28 @@ static inline uint32_t drm_color_lut_extract(uint32_t user_input, | |||
2605 | return clamp_val(val, 0, max); | 2607 | return clamp_val(val, 0, max); |
2606 | } | 2608 | } |
2607 | 2609 | ||
2610 | /* | ||
2611 | * drm_framebuffer_reference - incr the fb refcnt | ||
2612 | * @fb: framebuffer | ||
2613 | * | ||
2614 | * This functions increments the fb's refcount. | ||
2615 | */ | ||
2616 | static inline void drm_framebuffer_reference(struct drm_framebuffer *fb) | ||
2617 | { | ||
2618 | drm_mode_object_reference(&fb->base); | ||
2619 | } | ||
2620 | |||
2621 | /** | ||
2622 | * drm_framebuffer_unreference - unref a framebuffer | ||
2623 | * @fb: framebuffer to unref | ||
2624 | * | ||
2625 | * This functions decrements the fb's refcount and frees it if it drops to zero. | ||
2626 | */ | ||
2627 | static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb) | ||
2628 | { | ||
2629 | drm_mode_object_unreference(&fb->base); | ||
2630 | } | ||
2631 | |||
2608 | /** | 2632 | /** |
2609 | * drm_framebuffer_read_refcount - read the framebuffer reference count. | 2633 | * drm_framebuffer_read_refcount - read the framebuffer reference count. |
2610 | * @fb: framebuffer | 2634 | * @fb: framebuffer |
@@ -2613,7 +2637,7 @@ static inline uint32_t drm_color_lut_extract(uint32_t user_input, | |||
2613 | */ | 2637 | */ |
2614 | static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) | 2638 | static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) |
2615 | { | 2639 | { |
2616 | return atomic_read(&fb->refcount.refcount); | 2640 | return atomic_read(&fb->base.refcount.refcount); |
2617 | } | 2641 | } |
2618 | 2642 | ||
2619 | /* Plane list iterator for legacy (overlay only) planes. */ | 2643 | /* Plane list iterator for legacy (overlay only) planes. */ |