Skip to content

Commit af6887e

Browse files
icklesashalevin
authored andcommitted
drm: Don't assign fbs for universal cursor support to files
[ Upstream commit 9a6f513 ] 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 161d0dc 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: Matt 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> Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 2c7f037 commit af6887e

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

‎drivers/gpu/drm/drm_crtc.c‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@
4242
#include "drm_crtc_internal.h"
4343
#include "drm_internal.h"
4444

45-
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
46-
struct drm_mode_fb_cmd2 *r,
47-
struct drm_file *file_priv);
45+
static struct drm_framebuffer *
46+
internal_framebuffer_create(struct drm_device *dev,
47+
struct drm_mode_fb_cmd2 *r,
48+
struct drm_file *file_priv);
4849

4950
/* Avoid boilerplate. I'm tired of typing. */
5051
#define DRM_ENUM_NAME_FN(fnname, list) \
@@ -2739,13 +2740,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
27392740
*/
27402741
if (req->flags & DRM_MODE_CURSOR_BO) {
27412742
if (req->handle) {
2742-
fb = add_framebuffer_internal(dev, &fbreq, file_priv);
2743+
fb = internal_framebuffer_create(dev, &fbreq, file_priv);
27432744
if (IS_ERR(fb)) {
27442745
DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n");
27452746
return PTR_ERR(fb);
27462747
}
2747-
2748-
drm_framebuffer_reference(fb);
27492748
} else {
27502749
fb = NULL;
27512750
}
@@ -3114,9 +3113,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
31143113
return 0;
31153114
}
31163115

3117-
static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
3118-
struct drm_mode_fb_cmd2 *r,
3119-
struct drm_file *file_priv)
3116+
static struct drm_framebuffer *
3117+
internal_framebuffer_create(struct drm_device *dev,
3118+
struct drm_mode_fb_cmd2 *r,
3119+
struct drm_file *file_priv)
31203120
{
31213121
struct drm_mode_config *config = &dev->mode_config;
31223122
struct drm_framebuffer *fb;
@@ -3148,12 +3148,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
31483148
return fb;
31493149
}
31503150

3151-
mutex_lock(&file_priv->fbs_lock);
3152-
r->fb_id = fb->base.id;
3153-
list_add(&fb->filp_head, &file_priv->fbs);
3154-
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
3155-
mutex_unlock(&file_priv->fbs_lock);
3156-
31573151
return fb;
31583152
}
31593153

@@ -3175,15 +3169,24 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
31753169
int drm_mode_addfb2(struct drm_device *dev,
31763170
void *data, struct drm_file *file_priv)
31773171
{
3172+
struct drm_mode_fb_cmd2 *r = data;
31783173
struct drm_framebuffer *fb;
31793174

31803175
if (!drm_core_check_feature(dev, DRIVER_MODESET))
31813176
return -EINVAL;
31823177

3183-
fb = add_framebuffer_internal(dev, data, file_priv);
3178+
fb = internal_framebuffer_create(dev, r, file_priv);
31843179
if (IS_ERR(fb))
31853180
return PTR_ERR(fb);
31863181

3182+
/* Transfer ownership to the filp for reaping on close */
3183+
3184+
DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
3185+
mutex_lock(&file_priv->fbs_lock);
3186+
r->fb_id = fb->base.id;
3187+
list_add(&fb->filp_head, &file_priv->fbs);
3188+
mutex_unlock(&file_priv->fbs_lock);
3189+
31873190
return 0;
31883191
}
31893192

0 commit comments

Comments
 (0)