Commit c5939a73 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'topic/core-stuff-2014-09-29' of git://anongit.freedesktop.org/drm-intel into drm-next

Ok, here's the update core-stuff pull request with the locking fixup patch
fixed up with another patch.

* tag 'topic/core-stuff-2014-09-29' of git://anongit.freedesktop.org/drm-intel:
  drm: Drop grab fpriv->fbs_lock in drm_fb_release
  drm/udl: use container_of to resolve udl_fbdev from drm_fb_helper
  drm/ast: use container_of to resolve ast_fbdev from drm_fb_helper
  drm/gma500: use container_of to resolve psb_fbdev from drm_fb_helper
  drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper
  drm/nouveau: use container_of to resolve nouveau_plane from drm_plane
  drm/nouveau: use container_of to resolve nouveau_fbdev from drm_fb_helper
  drm/radeon: use container_of to resolve radeon_fbdev from drm_fb_helper
  drm/mgag200: use container_of to resolve mga_fbdev from drm_fb_helper
  drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper
  drm: Improve debug output for drm_wait_one_vblank
  drm: Fixup locking for universal cursor planes
  drm: Don't update vblank timestamp when the counter didn't change
parents 1dadba87 1b116297
...@@ -186,7 +186,8 @@ static int astfb_create_object(struct ast_fbdev *afbdev, ...@@ -186,7 +186,8 @@ static int astfb_create_object(struct ast_fbdev *afbdev,
static int astfb_create(struct drm_fb_helper *helper, static int astfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct ast_fbdev *afbdev = (struct ast_fbdev *)helper; struct ast_fbdev *afbdev =
container_of(helper, struct ast_fbdev, helper);
struct drm_device *dev = afbdev->helper.dev; struct drm_device *dev = afbdev->helper.dev;
struct drm_mode_fb_cmd2 mode_cmd; struct drm_mode_fb_cmd2 mode_cmd;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
......
...@@ -160,7 +160,8 @@ static int cirrusfb_create_object(struct cirrus_fbdev *afbdev, ...@@ -160,7 +160,8 @@ static int cirrusfb_create_object(struct cirrus_fbdev *afbdev,
static int cirrusfb_create(struct drm_fb_helper *helper, static int cirrusfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct cirrus_fbdev *gfbdev = (struct cirrus_fbdev *)helper; struct cirrus_fbdev *gfbdev =
container_of(helper, struct cirrus_fbdev, helper);
struct drm_device *dev = gfbdev->helper.dev; struct drm_device *dev = gfbdev->helper.dev;
struct cirrus_device *cdev = gfbdev->helper.dev->dev_private; struct cirrus_device *cdev = gfbdev->helper.dev->dev_private;
struct fb_info *info; struct fb_info *info;
......
...@@ -2263,7 +2263,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data, ...@@ -2263,7 +2263,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
* *
* src_{x,y,w,h} are provided in 16.16 fixed point format * src_{x,y,w,h} are provided in 16.16 fixed point format
*/ */
static int setplane_internal(struct drm_plane *plane, static int __setplane_internal(struct drm_plane *plane,
struct drm_crtc *crtc, struct drm_crtc *crtc,
struct drm_framebuffer *fb, struct drm_framebuffer *fb,
int32_t crtc_x, int32_t crtc_y, int32_t crtc_x, int32_t crtc_y,
...@@ -2272,12 +2272,10 @@ static int setplane_internal(struct drm_plane *plane, ...@@ -2272,12 +2272,10 @@ static int setplane_internal(struct drm_plane *plane,
uint32_t src_x, uint32_t src_y, uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct drm_device *dev = plane->dev;
int ret = 0; int ret = 0;
unsigned int fb_width, fb_height; unsigned int fb_width, fb_height;
int i; int i;
drm_modeset_lock_all(dev);
/* No fb means shut it down */ /* No fb means shut it down */
if (!fb) { if (!fb) {
plane->old_fb = plane->fb; plane->old_fb = plane->fb;
...@@ -2345,10 +2343,28 @@ static int setplane_internal(struct drm_plane *plane, ...@@ -2345,10 +2343,28 @@ static int setplane_internal(struct drm_plane *plane,
if (plane->old_fb) if (plane->old_fb)
drm_framebuffer_unreference(plane->old_fb); drm_framebuffer_unreference(plane->old_fb);
plane->old_fb = NULL; plane->old_fb = NULL;
drm_modeset_unlock_all(dev);
return ret; return ret;
}
static int setplane_internal(struct drm_plane *plane,
struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int32_t crtc_x, int32_t crtc_y,
uint32_t crtc_w, uint32_t crtc_h,
/* src_{x,y,w,h} values are 16.16 fixed point */
uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h)
{
int ret;
drm_modeset_lock_all(plane->dev);
ret = __setplane_internal(plane, crtc, fb,
crtc_x, crtc_y, crtc_w, crtc_h,
src_x, src_y, src_w, src_h);
drm_modeset_unlock_all(plane->dev);
return ret;
} }
/** /**
...@@ -2714,6 +2730,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, ...@@ -2714,6 +2730,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
int ret = 0; int ret = 0;
BUG_ON(!crtc->cursor); BUG_ON(!crtc->cursor);
WARN_ON(crtc->cursor->crtc != crtc && crtc->cursor->crtc != NULL);
/* /*
* Obtain fb we'll be using (either new or existing) and take an extra * Obtain fb we'll be using (either new or existing) and take an extra
...@@ -2733,11 +2750,9 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, ...@@ -2733,11 +2750,9 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
fb = NULL; fb = NULL;
} }
} else { } else {
mutex_lock(&dev->mode_config.mutex);
fb = crtc->cursor->fb; fb = crtc->cursor->fb;
if (fb) if (fb)
drm_framebuffer_reference(fb); drm_framebuffer_reference(fb);
mutex_unlock(&dev->mode_config.mutex);
} }
if (req->flags & DRM_MODE_CURSOR_MOVE) { if (req->flags & DRM_MODE_CURSOR_MOVE) {
...@@ -2759,7 +2774,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, ...@@ -2759,7 +2774,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
* setplane_internal will take care of deref'ing either the old or new * setplane_internal will take care of deref'ing either the old or new
* framebuffer depending on success. * framebuffer depending on success.
*/ */
ret = setplane_internal(crtc->cursor, crtc, fb, ret = __setplane_internal(crtc->cursor, crtc, fb,
crtc_x, crtc_y, crtc_w, crtc_h, crtc_x, crtc_y, crtc_w, crtc_h,
0, 0, src_w, src_h); 0, 0, src_w, src_h);
...@@ -2795,10 +2810,12 @@ static int drm_mode_cursor_common(struct drm_device *dev, ...@@ -2795,10 +2810,12 @@ static int drm_mode_cursor_common(struct drm_device *dev,
* If this crtc has a universal cursor plane, call that plane's update * If this crtc has a universal cursor plane, call that plane's update
* handler rather than using legacy cursor handlers. * handler rather than using legacy cursor handlers.
*/ */
if (crtc->cursor)
return drm_mode_cursor_universal(crtc, req, file_priv);
drm_modeset_lock_crtc(crtc); drm_modeset_lock_crtc(crtc);
if (crtc->cursor) {
ret = drm_mode_cursor_universal(crtc, req, file_priv);
goto out;
}
if (req->flags & DRM_MODE_CURSOR_BO) { if (req->flags & DRM_MODE_CURSOR_BO) {
if (!crtc->funcs->cursor_set && !crtc->funcs->cursor_set2) { if (!crtc->funcs->cursor_set && !crtc->funcs->cursor_set2) {
ret = -ENXIO; ret = -ENXIO;
...@@ -3383,7 +3400,16 @@ void drm_fb_release(struct drm_file *priv) ...@@ -3383,7 +3400,16 @@ void drm_fb_release(struct drm_file *priv)
struct drm_device *dev = priv->minor->dev; struct drm_device *dev = priv->minor->dev;
struct drm_framebuffer *fb, *tfb; struct drm_framebuffer *fb, *tfb;
mutex_lock(&priv->fbs_lock); /*
* When the file gets released that means no one else can access the fb
* list any more, so no need to grab fpriv->fbs_lock. And we need to to
* avoid upsetting lockdep since the universal cursor code adds a
* framebuffer while holding mutex locks.
*
* Note that a real deadlock between fpriv->fbs_lock and the modeset
* locks is impossible here since no one else but this function can get
* at it any more.
*/
list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) {
mutex_lock(&dev->mode_config.fb_lock); mutex_lock(&dev->mode_config.fb_lock);
...@@ -3396,7 +3422,6 @@ void drm_fb_release(struct drm_file *priv) ...@@ -3396,7 +3422,6 @@ void drm_fb_release(struct drm_file *priv)
/* This will also drop the fpriv->fbs reference. */ /* This will also drop the fpriv->fbs reference. */
drm_framebuffer_remove(fb); drm_framebuffer_remove(fb);
} }
mutex_unlock(&priv->fbs_lock);
} }
/** /**
......
...@@ -126,6 +126,9 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc) ...@@ -126,6 +126,9 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc)
DRM_DEBUG("updating vblank count on crtc %d, missed %d\n", DRM_DEBUG("updating vblank count on crtc %d, missed %d\n",
crtc, diff); crtc, diff);
if (diff == 0)
return;
/* Reinitialize corresponding vblank timestamp if high-precision query /* Reinitialize corresponding vblank timestamp if high-precision query
* available. Skip this step if query unsupported or failed. Will * available. Skip this step if query unsupported or failed. Will
* reinitialize delayed at next vblank interrupt in that case. * reinitialize delayed at next vblank interrupt in that case.
...@@ -1074,7 +1077,7 @@ void drm_wait_one_vblank(struct drm_device *dev, int crtc) ...@@ -1074,7 +1077,7 @@ void drm_wait_one_vblank(struct drm_device *dev, int crtc)
u32 last; u32 last;
ret = drm_vblank_get(dev, crtc); ret = drm_vblank_get(dev, crtc);
if (WARN_ON(ret)) if (WARN(ret, "vblank not available on crtc %i, ret=%i\n", crtc, ret))
return; return;
last = drm_vblank_count(dev, crtc); last = drm_vblank_count(dev, crtc);
...@@ -1083,7 +1086,7 @@ void drm_wait_one_vblank(struct drm_device *dev, int crtc) ...@@ -1083,7 +1086,7 @@ void drm_wait_one_vblank(struct drm_device *dev, int crtc)
last != drm_vblank_count(dev, crtc), last != drm_vblank_count(dev, crtc),
msecs_to_jiffies(100)); msecs_to_jiffies(100));
WARN_ON(ret == 0); WARN(ret == 0, "vblank wait timed out on crtc %i\n", crtc);
drm_vblank_put(dev, crtc); drm_vblank_put(dev, crtc);
} }
......
...@@ -540,7 +540,8 @@ static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red, ...@@ -540,7 +540,8 @@ static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
static int psbfb_probe(struct drm_fb_helper *helper, static int psbfb_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct psb_fbdev *psb_fbdev = (struct psb_fbdev *)helper; struct psb_fbdev *psb_fbdev =
container_of(helper, struct psb_fbdev, psb_fb_helper);
struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;
struct drm_psb_private *dev_priv = dev->dev_private; struct drm_psb_private *dev_priv = dev->dev_private;
int bytespp; int bytespp;
......
...@@ -158,7 +158,8 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, ...@@ -158,7 +158,8 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev,
static int mgag200fb_create(struct drm_fb_helper *helper, static int mgag200fb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct mga_fbdev *mfbdev = (struct mga_fbdev *)helper; struct mga_fbdev *mfbdev =
container_of(helper, struct mga_fbdev, helper);
struct drm_device *dev = mfbdev->helper.dev; struct drm_device *dev = mfbdev->helper.dev;
struct drm_mode_fb_cmd2 mode_cmd; struct drm_mode_fb_cmd2 mode_cmd;
struct mga_device *mdev = dev->dev_private; struct mga_device *mdev = dev->dev_private;
......
...@@ -97,7 +97,8 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -97,7 +97,8 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct nvif_device *dev = &nouveau_drm(plane->dev)->device; struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base);
struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct nouveau_bo *cur = nv_plane->cur; struct nouveau_bo *cur = nv_plane->cur;
...@@ -173,7 +174,8 @@ static int ...@@ -173,7 +174,8 @@ static int
nv10_disable_plane(struct drm_plane *plane) nv10_disable_plane(struct drm_plane *plane)
{ {
struct nvif_device *dev = &nouveau_drm(plane->dev)->device; struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base);
nvif_wr32(dev, NV_PVIDEO_STOP, 1); nvif_wr32(dev, NV_PVIDEO_STOP, 1);
if (nv_plane->cur) { if (nv_plane->cur) {
...@@ -224,7 +226,8 @@ nv_set_property(struct drm_plane *plane, ...@@ -224,7 +226,8 @@ nv_set_property(struct drm_plane *plane,
struct drm_property *property, struct drm_property *property,
uint64_t value) uint64_t value)
{ {
struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base);
if (property == nv_plane->props.colorkey) if (property == nv_plane->props.colorkey)
nv_plane->colorkey = value; nv_plane->colorkey = value;
...@@ -344,7 +347,8 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -344,7 +347,8 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct nvif_device *dev = &nouveau_drm(plane->dev)->device; struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base);
struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
struct nouveau_bo *cur = nv_plane->cur; struct nouveau_bo *cur = nv_plane->cur;
uint32_t overlay = 1; uint32_t overlay = 1;
...@@ -423,7 +427,8 @@ static int ...@@ -423,7 +427,8 @@ static int
nv04_disable_plane(struct drm_plane *plane) nv04_disable_plane(struct drm_plane *plane)
{ {
struct nvif_device *dev = &nouveau_drm(plane->dev)->device; struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base);
nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0); nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0); nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
......
...@@ -308,7 +308,8 @@ static int ...@@ -308,7 +308,8 @@ static int
nouveau_fbcon_create(struct drm_fb_helper *helper, nouveau_fbcon_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct nouveau_fbdev *fbcon = (struct nouveau_fbdev *)helper; struct nouveau_fbdev *fbcon =
container_of(helper, struct nouveau_fbdev, helper);
struct drm_device *dev = fbcon->dev; struct drm_device *dev = fbcon->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->device;
......
...@@ -625,7 +625,8 @@ static int qxl_fb_find_or_create_single( ...@@ -625,7 +625,8 @@ static int qxl_fb_find_or_create_single(
struct drm_fb_helper *helper, struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct qxl_fbdev *qfbdev = (struct qxl_fbdev *)helper; struct qxl_fbdev *qfbdev =
container_of(helper, struct qxl_fbdev, helper);
int new_fb = 0; int new_fb = 0;
int ret; int ret;
......
...@@ -189,7 +189,8 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev, ...@@ -189,7 +189,8 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
static int radeonfb_create(struct drm_fb_helper *helper, static int radeonfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct radeon_fbdev *rfbdev = (struct radeon_fbdev *)helper; struct radeon_fbdev *rfbdev =
container_of(helper, struct radeon_fbdev, helper);
struct radeon_device *rdev = rfbdev->rdev; struct radeon_device *rdev = rfbdev->rdev;
struct fb_info *info; struct fb_info *info;
struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fb = NULL;
......
...@@ -472,7 +472,8 @@ udl_framebuffer_init(struct drm_device *dev, ...@@ -472,7 +472,8 @@ udl_framebuffer_init(struct drm_device *dev,
static int udlfb_create(struct drm_fb_helper *helper, static int udlfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct udl_fbdev *ufbdev = (struct udl_fbdev *)helper; struct udl_fbdev *ufbdev =
container_of(helper, struct udl_fbdev, helper);
struct drm_device *dev = ufbdev->helper.dev; struct drm_device *dev = ufbdev->helper.dev;
struct fb_info *info; struct fb_info *info;
struct device *device = dev->dev; struct device *device = dev->dev;
......
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