Skip to content

Commit 747a598

Browse files
committed
drm/mode: introduce wrapper to read framebuffer refcount.
Avoids drivers knowing where the kref is stored. [airlied: add kerneldoc] Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 19ab3f8 commit 747a598

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
612612
* in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot
613613
* in this manner.
614614
*/
615-
if (atomic_read(&fb->refcount.refcount) > 1) {
615+
if (drm_framebuffer_read_refcount(fb) > 1) {
616616
drm_modeset_lock_all(dev);
617617
/* remove from any CRTC */
618618
drm_for_each_crtc(crtc, dev) {

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
19171917
fbdev_fb->base.depth,
19181918
fbdev_fb->base.bits_per_pixel,
19191919
fbdev_fb->base.modifier[0],
1920-
atomic_read(&fbdev_fb->base.refcount.refcount));
1920+
drm_framebuffer_read_refcount(&fbdev_fb->base));
19211921
describe_obj(m, fbdev_fb->obj);
19221922
seq_putc(m, '\n');
19231923
}
@@ -1935,7 +1935,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
19351935
fb->base.depth,
19361936
fb->base.bits_per_pixel,
19371937
fb->base.modifier[0],
1938-
atomic_read(&fb->base.refcount.refcount));
1938+
drm_framebuffer_read_refcount(&fb->base));
19391939
describe_obj(m, fb->obj);
19401940
seq_putc(m, '\n');
19411941
}

drivers/gpu/drm/msm/msm_fb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
7777

7878
seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
7979
fb->width, fb->height, (char *)&fb->pixel_format,
80-
fb->refcount.refcount.counter, fb->base.id);
80+
drm_framebuffer_read_refcount(fb), fb->base.id);
8181

8282
for (i = 0; i < n; i++) {
8383
seq_printf(m, " %d: offset=%d pitch=%d, obj: ",

drivers/gpu/drm/tegra/drm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ static int tegra_debugfs_framebuffers(struct seq_file *s, void *data)
878878
seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n",
879879
fb->base.id, fb->width, fb->height, fb->depth,
880880
fb->bits_per_pixel,
881-
atomic_read(&fb->refcount.refcount));
881+
drm_framebuffer_read_refcount(fb));
882882
}
883883

884884
mutex_unlock(&drm->mode_config.fb_lock);

include/drm/drm_crtc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,17 @@ static inline uint32_t drm_color_lut_extract(uint32_t user_input,
26052605
return clamp_val(val, 0, max);
26062606
}
26072607

2608+
/**
2609+
* drm_framebuffer_read_refcount - read the framebuffer reference count.
2610+
* @fb: framebuffer
2611+
*
2612+
* This functions returns the framebuffer's reference count.
2613+
*/
2614+
static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
2615+
{
2616+
return atomic_read(&fb->refcount.refcount);
2617+
}
2618+
26082619
/* Plane list iterator for legacy (overlay only) planes. */
26092620
#define drm_for_each_legacy_plane(plane, dev) \
26102621
list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \

0 commit comments

Comments
 (0)