@@ -153,7 +153,8 @@ int drm_mode_getconnector(struct drm_device *dev,
struct drm_framebuffer *
drm_internal_framebuffer_create(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *r,
- struct drm_file *file_priv);
+ struct drm_file *file_priv,
+ bool internal);
void drm_framebuffer_free(struct kref *kref);
int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h,
@@ -262,7 +262,8 @@ static int framebuffer_check(struct drm_device *dev,
struct drm_framebuffer *
drm_internal_framebuffer_create(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *r,
- struct drm_file *file_priv)
+ struct drm_file *file_priv,
+ bool internal)
{
struct drm_mode_config *config = &dev->mode_config;
struct drm_framebuffer *fb;
@@ -300,6 +301,8 @@ drm_internal_framebuffer_create(struct drm_device *dev,
return fb;
}
+ fb->internal = internal;
+
return fb;
}
@@ -327,7 +330,7 @@ int drm_mode_addfb2(struct drm_device *dev,
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
- fb = drm_internal_framebuffer_create(dev, r, file_priv);
+ fb = drm_internal_framebuffer_create(dev, r, file_priv, false);
if (IS_ERR(fb))
return PTR_ERR(fb);
@@ -757,7 +757,9 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
*/
if (req->flags & DRM_MODE_CURSOR_BO) {
if (req->handle) {
- fb = drm_internal_framebuffer_create(dev, &fbreq, file_priv);
+ fb = drm_internal_framebuffer_create(dev, &fbreq,
+ file_priv,
+ true);
if (IS_ERR(fb)) {
DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n");
return PTR_ERR(fb);
@@ -187,6 +187,11 @@ struct drm_framebuffer {
*/
int hot_y;
/**
+ * @internal: Indicates the framebuffer was created internally and not
+ * as the result of the drm_mode_fb_cmd* ioctl.
+ */
+ bool internal;
+ /**
* @filp_head: Placed on &drm_file.fbs, protected by &drm_file.fbs_lock.
*/
struct list_head filp_head;
We create an internal framebuffer when using the legacy cursor ioctls, but using the legacy API, userspace has no way of freeing this resource. This patch introduces a field in struct drm_framebuffer to keep track of internally owned framebuffers. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> --- drivers/gpu/drm/drm_crtc_internal.h | 3 ++- drivers/gpu/drm/drm_framebuffer.c | 7 +++++-- drivers/gpu/drm/drm_plane.c | 4 +++- include/drm/drm_framebuffer.h | 5 +++++ 4 files changed, 15 insertions(+), 4 deletions(-)