Skip to content

Commit

Permalink
drm/fb-helper: Don't clobber the display palette when fbdev isn't bound
Browse files Browse the repository at this point in the history
Perform the drm_fb_helper_is_bound() check to avoid clobbering the
display palette of some other KMS client.

While at it, fix up the locking by grabbing all modeset locks for the
duration of the fb_setcmap operation.

v2: Make a note of the locking changes in the commit message

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
  • Loading branch information
Ville Syrjälä authored and Dave Airlie committed Jun 17, 2013
1 parent 778ad90 commit 8391a3d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/gpu/drm/drm_fb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,19 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
struct drm_crtc_helper_funcs *crtc_funcs;
u16 *red, *green, *blue, *transp;
struct drm_crtc *crtc;
int i, j, rc = 0;
int start;

drm_modeset_lock_all(dev);
if (!drm_fb_helper_is_bound(fb_helper)) {
drm_modeset_unlock_all(dev);
return -EBUSY;
}

for (i = 0; i < fb_helper->crtc_count; i++) {
crtc = fb_helper->crtc_info[i].mode_set.crtc;
crtc_funcs = crtc->helper_private;
Expand All @@ -668,10 +675,12 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)

rc = setcolreg(crtc, hred, hgreen, hblue, start++, info);
if (rc)
return rc;
goto out;
}
crtc_funcs->load_lut(crtc);
}
out:
drm_modeset_unlock_all(dev);
return rc;
}
EXPORT_SYMBOL(drm_fb_helper_setcmap);
Expand Down

0 comments on commit 8391a3d

Please sign in to comment.