Commit 77f7ef95 authored by Chris Wilson's avatar Chris Wilson Committed by Greg Kroah-Hartman

drm: Don't assign fbs for universal cursor support to files

commit 9a6f5130 upstream.

The internal framebuffers we create to remap legacy cursor ioctls to
plane operations for the universal plane support shouldn't be linke to
the file like normal userspace framebuffers. This bug goes back to the
original universal cursor plane support introduced in

commit 161d0dc1
Author: Matt Roper <matthew.d.roper@intel.com>
Date:   Tue Jun 10 08:28:10 2014 -0700

    drm: Support legacy cursor ioctls via universal planes when possible (v4)

The isn't too disastrous since fbs are small, we only create one when the
cursor bo gets changed and ultimately they'll be reaped when the window
server restarts.

Conceptually we'd want to just pass NULL for file_priv when creating it,
but the driver needs the file to lookup the underlying buffer object for
cursor id. Instead let's move the file_priv linking out of
add_framebuffer_internal() into the addfb ioctl implementation, which is
the only place it is needed. And also rename the function for a more
accurate since it only creates the fb, but doesn't add it anywhere.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> (fix & commit msg)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> (provider of lipstick)
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b197b203
...@@ -42,9 +42,10 @@ ...@@ -42,9 +42,10 @@
#include "drm_crtc_internal.h" #include "drm_crtc_internal.h"
#include "drm_internal.h" #include "drm_internal.h"
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, static struct drm_framebuffer *
struct drm_mode_fb_cmd2 *r, internal_framebuffer_create(struct drm_device *dev,
struct drm_file *file_priv); struct drm_mode_fb_cmd2 *r,
struct drm_file *file_priv);
/* Avoid boilerplate. I'm tired of typing. */ /* Avoid boilerplate. I'm tired of typing. */
#define DRM_ENUM_NAME_FN(fnname, list) \ #define DRM_ENUM_NAME_FN(fnname, list) \
...@@ -2817,13 +2818,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, ...@@ -2817,13 +2818,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
*/ */
if (req->flags & DRM_MODE_CURSOR_BO) { if (req->flags & DRM_MODE_CURSOR_BO) {
if (req->handle) { if (req->handle) {
fb = add_framebuffer_internal(dev, &fbreq, file_priv); fb = internal_framebuffer_create(dev, &fbreq, file_priv);
if (IS_ERR(fb)) { if (IS_ERR(fb)) {
DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n"); DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n");
return PTR_ERR(fb); return PTR_ERR(fb);
} }
drm_framebuffer_reference(fb);
} else { } else {
fb = NULL; fb = NULL;
} }
...@@ -3175,9 +3174,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) ...@@ -3175,9 +3174,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
return 0; return 0;
} }
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, static struct drm_framebuffer *
struct drm_mode_fb_cmd2 *r, internal_framebuffer_create(struct drm_device *dev,
struct drm_file *file_priv) struct drm_mode_fb_cmd2 *r,
struct drm_file *file_priv)
{ {
struct drm_mode_config *config = &dev->mode_config; struct drm_mode_config *config = &dev->mode_config;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
...@@ -3209,12 +3209,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, ...@@ -3209,12 +3209,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
return fb; return fb;
} }
mutex_lock(&file_priv->fbs_lock);
r->fb_id = fb->base.id;
list_add(&fb->filp_head, &file_priv->fbs);
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
mutex_unlock(&file_priv->fbs_lock);
return fb; return fb;
} }
...@@ -3236,15 +3230,24 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, ...@@ -3236,15 +3230,24 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
int drm_mode_addfb2(struct drm_device *dev, int drm_mode_addfb2(struct drm_device *dev,
void *data, struct drm_file *file_priv) void *data, struct drm_file *file_priv)
{ {
struct drm_mode_fb_cmd2 *r = data;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL; return -EINVAL;
fb = add_framebuffer_internal(dev, data, file_priv); fb = internal_framebuffer_create(dev, r, file_priv);
if (IS_ERR(fb)) if (IS_ERR(fb))
return PTR_ERR(fb); return PTR_ERR(fb);
/* Transfer ownership to the filp for reaping on close */
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
mutex_lock(&file_priv->fbs_lock);
r->fb_id = fb->base.id;
list_add(&fb->filp_head, &file_priv->fbs);
mutex_unlock(&file_priv->fbs_lock);
return 0; return 0;
} }
......
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