Commit fa78ceab authored by Dave Airlie's avatar Dave Airlie

Merge tag 'topic/drm-misc-2015-07-23' of git://anongit.freedesktop.org/drm-intel into drm-next

Update drm-misc pull request since the first one didn't go in yet. Few
atomic helper patches, rejecting some old dri1 crap for modern drivers and
a few trivial things on top.

* tag 'topic/drm-misc-2015-07-23' of git://anongit.freedesktop.org/drm-intel:
  drm/mgag200: remove unneeded variable
  drm/mgag200: remove unused variables
  drm/atomic: Only update crtc->x/y if it's part of the state, v2.
  drm/fb: drop panic handling
  drm: Fix warning with make xmldocs caused by drm_irq.c
  drm/gem: rip out drm vma accounting for gem mmaps
  drm/fourcc: Add formats R8, RG88, GR88
  drm/atomic: Cleanup on error properly in the atomic ioctl.
  drm: Update plane->fb also for page_flip
  drm: remove redundant code form drm_ioc32.c
  drm: reset empty state in transitional helpers
  drm/crtc-helper: Fixup error handling in drm_helper_crtc_mode_set
  drm/atomic: Update old_fb after setting a property.
  drm: Remove useless blank line
  drm: Reject DRI1 hw lock ioctl functions for kms drivers
  drm: Convert drm_legacy_ctxbitmap_init to void return type
  drm: Turn off Legacy Context Functions
parents 5da612fa f9fe4b9b
...@@ -1463,24 +1463,18 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1463,24 +1463,18 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
if (get_user(obj_id, objs_ptr + copied_objs)) { if (get_user(obj_id, objs_ptr + copied_objs)) {
ret = -EFAULT; ret = -EFAULT;
goto fail; goto out;
} }
obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY); obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
if (!obj || !obj->properties) { if (!obj || !obj->properties) {
ret = -ENOENT; ret = -ENOENT;
goto fail; goto out;
}
if (obj->type == DRM_MODE_OBJECT_PLANE) {
plane = obj_to_plane(obj);
plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb;
} }
if (get_user(count_props, count_props_ptr + copied_objs)) { if (get_user(count_props, count_props_ptr + copied_objs)) {
ret = -EFAULT; ret = -EFAULT;
goto fail; goto out;
} }
copied_objs++; copied_objs++;
...@@ -1492,28 +1486,34 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1492,28 +1486,34 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
if (get_user(prop_id, props_ptr + copied_props)) { if (get_user(prop_id, props_ptr + copied_props)) {
ret = -EFAULT; ret = -EFAULT;
goto fail; goto out;
} }
prop = drm_property_find(dev, prop_id); prop = drm_property_find(dev, prop_id);
if (!prop) { if (!prop) {
ret = -ENOENT; ret = -ENOENT;
goto fail; goto out;
} }
if (copy_from_user(&prop_value, if (copy_from_user(&prop_value,
prop_values_ptr + copied_props, prop_values_ptr + copied_props,
sizeof(prop_value))) { sizeof(prop_value))) {
ret = -EFAULT; ret = -EFAULT;
goto fail; goto out;
} }
ret = atomic_set_prop(state, obj, prop, prop_value); ret = atomic_set_prop(state, obj, prop, prop_value);
if (ret) if (ret)
goto fail; goto out;
copied_props++; copied_props++;
} }
if (obj->type == DRM_MODE_OBJECT_PLANE && count_props) {
plane = obj_to_plane(obj);
plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb;
}
} }
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
...@@ -1523,7 +1523,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1523,7 +1523,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
e = create_vblank_event(dev, file_priv, arg->user_data); e = create_vblank_event(dev, file_priv, arg->user_data);
if (!e) { if (!e) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto out;
} }
crtc_state->event = e; crtc_state->event = e;
...@@ -1533,13 +1533,15 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1533,13 +1533,15 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) { if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) {
ret = drm_atomic_check_only(state); ret = drm_atomic_check_only(state);
/* _check_only() does not free state, unlike _commit() */ /* _check_only() does not free state, unlike _commit() */
drm_atomic_state_free(state); if (!ret)
drm_atomic_state_free(state);
} else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
ret = drm_atomic_async_commit(state); ret = drm_atomic_async_commit(state);
} else { } else {
ret = drm_atomic_commit(state); ret = drm_atomic_commit(state);
} }
out:
/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping /* if succeeded, fixup legacy plane crtc/fb ptrs before dropping
* locks (ie. while it is still safe to deref plane->state). We * locks (ie. while it is still safe to deref plane->state). We
* need to do this here because the driver entry points cannot * need to do this here because the driver entry points cannot
...@@ -1552,41 +1554,35 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1552,41 +1554,35 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
drm_framebuffer_reference(new_fb); drm_framebuffer_reference(new_fb);
plane->fb = new_fb; plane->fb = new_fb;
plane->crtc = plane->state->crtc; plane->crtc = plane->state->crtc;
} else {
plane->old_fb = NULL; if (plane->old_fb)
} drm_framebuffer_unreference(plane->old_fb);
if (plane->old_fb) {
drm_framebuffer_unreference(plane->old_fb);
plane->old_fb = NULL;
} }
plane->old_fb = NULL;
} }
drm_modeset_drop_locks(&ctx); if (ret == -EDEADLK) {
drm_modeset_acquire_fini(&ctx); drm_atomic_state_clear(state);
drm_modeset_backoff(&ctx);
return ret; goto retry;
}
fail: if (ret) {
if (ret == -EDEADLK) if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
goto backoff; for_each_crtc_in_state(state, crtc, crtc_state, i) {
if (!crtc_state->event)
continue;
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { destroy_vblank_event(dev, file_priv,
for_each_crtc_in_state(state, crtc, crtc_state, i) { crtc_state->event);
destroy_vblank_event(dev, file_priv, crtc_state->event); }
crtc_state->event = NULL;
} }
}
drm_atomic_state_free(state); drm_atomic_state_free(state);
}
drm_modeset_drop_locks(&ctx); drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx); drm_modeset_acquire_fini(&ctx);
return ret; return ret;
backoff:
drm_atomic_state_clear(state);
drm_modeset_backoff(&ctx);
goto retry;
} }
...@@ -665,10 +665,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, ...@@ -665,10 +665,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
/* set legacy state in the crtc structure */ /* set legacy state in the crtc structure */
for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) { for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
struct drm_plane *primary = crtc->primary;
crtc->mode = crtc->state->mode; crtc->mode = crtc->state->mode;
crtc->enabled = crtc->state->enable; crtc->enabled = crtc->state->enable;
crtc->x = crtc->primary->state->src_x >> 16;
crtc->y = crtc->primary->state->src_y >> 16; if (drm_atomic_get_existing_plane_state(old_state, primary) &&
primary->state->crtc == crtc) {
crtc->x = primary->state->src_x >> 16;
crtc->y = primary->state->src_y >> 16;
}
if (crtc->state->enable) if (crtc->state->enable)
drm_calc_timestamping_constants(crtc, drm_calc_timestamping_constants(crtc,
...@@ -1915,10 +1921,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, ...@@ -1915,10 +1921,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
if (ret != 0) if (ret != 0)
goto fail; goto fail;
/* TODO: ->page_flip is the only driver callback where the core
* doesn't update plane->fb. For now patch it up here. */
plane->fb = plane->state->fb;
/* Driver takes ownership of state on successful async commit. */ /* Driver takes ownership of state on successful async commit. */
return 0; return 0;
fail: fail:
......
...@@ -53,6 +53,10 @@ struct drm_ctx_list { ...@@ -53,6 +53,10 @@ struct drm_ctx_list {
*/ */
void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle) void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
idr_remove(&dev->ctx_idr, ctx_handle); idr_remove(&dev->ctx_idr, ctx_handle);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
...@@ -85,10 +89,13 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev) ...@@ -85,10 +89,13 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
* *
* Initialise the drm_device::ctx_idr * Initialise the drm_device::ctx_idr
*/ */
int drm_legacy_ctxbitmap_init(struct drm_device * dev) void drm_legacy_ctxbitmap_init(struct drm_device * dev)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return;
idr_init(&dev->ctx_idr); idr_init(&dev->ctx_idr);
return 0;
} }
/** /**
...@@ -101,6 +108,10 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev) ...@@ -101,6 +108,10 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
*/ */
void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
idr_destroy(&dev->ctx_idr); idr_destroy(&dev->ctx_idr);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
...@@ -119,6 +130,10 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) ...@@ -119,6 +130,10 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
{ {
struct drm_ctx_list *pos, *tmp; struct drm_ctx_list *pos, *tmp;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return;
mutex_lock(&dev->ctxlist_mutex); mutex_lock(&dev->ctxlist_mutex);
list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) { list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
...@@ -161,6 +176,10 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data, ...@@ -161,6 +176,10 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
struct drm_local_map *map; struct drm_local_map *map;
struct drm_map_list *_entry; struct drm_map_list *_entry;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
map = idr_find(&dev->ctx_idr, request->ctx_id); map = idr_find(&dev->ctx_idr, request->ctx_id);
...@@ -205,6 +224,10 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data, ...@@ -205,6 +224,10 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
struct drm_local_map *map = NULL; struct drm_local_map *map = NULL;
struct drm_map_list *r_list = NULL; struct drm_map_list *r_list = NULL;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
list_for_each_entry(r_list, &dev->maplist, head) { list_for_each_entry(r_list, &dev->maplist, head) {
if (r_list->map if (r_list->map
...@@ -305,6 +328,10 @@ int drm_legacy_resctx(struct drm_device *dev, void *data, ...@@ -305,6 +328,10 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
struct drm_ctx ctx; struct drm_ctx ctx;
int i; int i;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
if (res->count >= DRM_RESERVED_CONTEXTS) { if (res->count >= DRM_RESERVED_CONTEXTS) {
memset(&ctx, 0, sizeof(ctx)); memset(&ctx, 0, sizeof(ctx));
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
...@@ -335,6 +362,10 @@ int drm_legacy_addctx(struct drm_device *dev, void *data, ...@@ -335,6 +362,10 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
struct drm_ctx_list *ctx_entry; struct drm_ctx_list *ctx_entry;
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
ctx->handle = drm_legacy_ctxbitmap_next(dev); ctx->handle = drm_legacy_ctxbitmap_next(dev);
if (ctx->handle == DRM_KERNEL_CONTEXT) { if (ctx->handle == DRM_KERNEL_CONTEXT) {
/* Skip kernel's context and get a new one. */ /* Skip kernel's context and get a new one. */
...@@ -378,6 +409,10 @@ int drm_legacy_getctx(struct drm_device *dev, void *data, ...@@ -378,6 +409,10 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
{ {
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
/* This is 0, because we don't handle any context flags */ /* This is 0, because we don't handle any context flags */
ctx->flags = 0; ctx->flags = 0;
...@@ -400,6 +435,10 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data, ...@@ -400,6 +435,10 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
{ {
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);
return drm_context_switch(dev, dev->last_context, ctx->handle); return drm_context_switch(dev, dev->last_context, ctx->handle);
} }
...@@ -420,6 +459,10 @@ int drm_legacy_newctx(struct drm_device *dev, void *data, ...@@ -420,6 +459,10 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
{ {
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);
drm_context_switch_complete(dev, file_priv, ctx->handle); drm_context_switch_complete(dev, file_priv, ctx->handle);
...@@ -442,6 +485,10 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data, ...@@ -442,6 +485,10 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
{ {
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);
if (ctx->handle != DRM_KERNEL_CONTEXT) { if (ctx->handle != DRM_KERNEL_CONTEXT) {
if (dev->driver->context_dtor) if (dev->driver->context_dtor)
......
...@@ -4301,7 +4301,6 @@ void drm_property_unreference_blob(struct drm_property_blob *blob) ...@@ -4301,7 +4301,6 @@ void drm_property_unreference_blob(struct drm_property_blob *blob)
mutex_unlock(&dev->mode_config.blob_lock); mutex_unlock(&dev->mode_config.blob_lock);
else else
might_lock(&dev->mode_config.blob_lock); might_lock(&dev->mode_config.blob_lock);
} }
EXPORT_SYMBOL(drm_property_unreference_blob); EXPORT_SYMBOL(drm_property_unreference_blob);
...@@ -5349,13 +5348,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5349,13 +5348,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
/* Keep the old fb, don't unref it. */ /* Keep the old fb, don't unref it. */
crtc->primary->old_fb = NULL; crtc->primary->old_fb = NULL;
} else { } else {
/* crtc->primary->fb = fb;
* Warn if the driver hasn't properly updated the crtc->fb
* field to reflect that the new framebuffer is now used.
* Failing to do so will screw with the reference counting
* on framebuffers.
*/
WARN_ON(crtc->primary->fb != fb);
/* Unref only the old framebuffer. */ /* Unref only the old framebuffer. */
fb = NULL; fb = NULL;
} }
......
...@@ -928,15 +928,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ...@@ -928,15 +928,15 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
if (crtc->funcs->atomic_duplicate_state) if (crtc->funcs->atomic_duplicate_state)
crtc_state = crtc->funcs->atomic_duplicate_state(crtc); crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
else { else {
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); if (!crtc->state)
if (!crtc_state) drm_atomic_helper_crtc_reset(crtc);
return -ENOMEM;
if (crtc->state) crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
__drm_atomic_helper_crtc_duplicate_state(crtc, crtc_state);
else
crtc_state->crtc = crtc;
} }
if (!crtc_state)
return -ENOMEM;
crtc_state->planes_changed = true; crtc_state->planes_changed = true;
crtc_state->mode_changed = true; crtc_state->mode_changed = true;
ret = drm_atomic_set_mode_for_crtc(crtc_state, mode); ret = drm_atomic_set_mode_for_crtc(crtc_state, mode);
...@@ -957,11 +957,11 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ...@@ -957,11 +957,11 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
ret = drm_helper_crtc_mode_set_base(crtc, x, y, old_fb); ret = drm_helper_crtc_mode_set_base(crtc, x, y, old_fb);
out: out:
if (crtc->funcs->atomic_destroy_state) if (crtc_state) {
crtc->funcs->atomic_destroy_state(crtc, crtc_state); if (crtc->funcs->atomic_destroy_state)
else { crtc->funcs->atomic_destroy_state(crtc, crtc_state);
__drm_atomic_helper_crtc_destroy_state(crtc, crtc_state); else
kfree(crtc_state); drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
} }
return ret; return ret;
......
...@@ -582,11 +582,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, ...@@ -582,11 +582,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
if (drm_ht_create(&dev->map_hash, 12)) if (drm_ht_create(&dev->map_hash, 12))
goto err_minors; goto err_minors;
ret = drm_legacy_ctxbitmap_init(dev); drm_legacy_ctxbitmap_init(dev);
if (ret) {
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
goto err_ht;
}
if (drm_core_check_feature(dev, DRIVER_GEM)) { if (drm_core_check_feature(dev, DRIVER_GEM)) {
ret = drm_gem_init(dev); ret = drm_gem_init(dev);
...@@ -600,7 +596,6 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, ...@@ -600,7 +596,6 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
err_ctxbitmap: err_ctxbitmap:
drm_legacy_ctxbitmap_cleanup(dev); drm_legacy_ctxbitmap_cleanup(dev);
err_ht:
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
err_minors: err_minors:
drm_minor_free(dev, DRM_MINOR_LEGACY); drm_minor_free(dev, DRM_MINOR_LEGACY);
......
...@@ -429,24 +429,6 @@ static bool drm_fb_helper_force_kernel_mode(void) ...@@ -429,24 +429,6 @@ static bool drm_fb_helper_force_kernel_mode(void)
return error; return error;
} }
static int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed,
void *panic_str)
{
/*
* It's a waste of time and effort to switch back to text console
* if the kernel should reboot before panic messages can be seen.
*/
if (panic_timeout < 0)
return 0;
pr_err("panic occurred, switching back to text console\n");
return drm_fb_helper_force_kernel_mode();
}
static struct notifier_block paniced = {
.notifier_call = drm_fb_helper_panic,
};
static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper) static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper)
{ {
struct drm_device *dev = fb_helper->dev; struct drm_device *dev = fb_helper->dev;
...@@ -672,9 +654,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) ...@@ -672,9 +654,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
if (!list_empty(&fb_helper->kernel_fb_list)) { if (!list_empty(&fb_helper->kernel_fb_list)) {
list_del(&fb_helper->kernel_fb_list); list_del(&fb_helper->kernel_fb_list);
if (list_empty(&kernel_fb_helper_list)) { if (list_empty(&kernel_fb_helper_list)) {
pr_info("drm: unregistered panic notifier\n");
atomic_notifier_chain_unregister(&panic_notifier_list,
&paniced);
unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op);
} }
} }
...@@ -1109,12 +1088,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, ...@@ -1109,12 +1088,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
dev_info(fb_helper->dev->dev, "fb%d: %s frame buffer device\n", dev_info(fb_helper->dev->dev, "fb%d: %s frame buffer device\n",
info->node, info->fix.id); info->node, info->fix.id);
/* Switch back to kernel console on panic */
/* multi card linked list maybe */
if (list_empty(&kernel_fb_helper_list)) { if (list_empty(&kernel_fb_helper_list)) {
dev_info(fb_helper->dev->dev, "registered panic notifier\n");
atomic_notifier_chain_register(&panic_notifier_list,
&paniced);
register_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); register_sysrq_key('v', &sysrq_drm_fb_helper_restore_op);
} }
......
...@@ -778,22 +778,14 @@ void drm_gem_vm_open(struct vm_area_struct *vma) ...@@ -778,22 +778,14 @@ void drm_gem_vm_open(struct vm_area_struct *vma)
struct drm_gem_object *obj = vma->vm_private_data; struct drm_gem_object *obj = vma->vm_private_data;
drm_gem_object_reference(obj); drm_gem_object_reference(obj);
mutex_lock(&obj->dev->struct_mutex);
drm_vm_open_locked(obj->dev, vma);
mutex_unlock(&obj->dev->struct_mutex);
} }
EXPORT_SYMBOL(drm_gem_vm_open); EXPORT_SYMBOL(drm_gem_vm_open);
void drm_gem_vm_close(struct vm_area_struct *vma) void drm_gem_vm_close(struct vm_area_struct *vma)
{ {
struct drm_gem_object *obj = vma->vm_private_data; struct drm_gem_object *obj = vma->vm_private_data;
struct drm_device *dev = obj->dev;
mutex_lock(&dev->struct_mutex); drm_gem_object_unreference_unlocked(obj);
drm_vm_close_locked(obj->dev, vma);
drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
} }
EXPORT_SYMBOL(drm_gem_vm_close); EXPORT_SYMBOL(drm_gem_vm_close);
...@@ -850,7 +842,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, ...@@ -850,7 +842,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
*/ */
drm_gem_object_reference(obj); drm_gem_object_reference(obj);
drm_vm_open_locked(dev, vma);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_gem_mmap_obj); EXPORT_SYMBOL(drm_gem_mmap_obj);
......
...@@ -95,7 +95,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd, ...@@ -95,7 +95,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
version = compat_alloc_user_space(sizeof(*version)); version = compat_alloc_user_space(sizeof(*version));
if (!access_ok(VERIFY_WRITE, version, sizeof(*version))) if (!version)
return -EFAULT; return -EFAULT;
if (__put_user(v32.name_len, &version->name_len) if (__put_user(v32.name_len, &version->name_len)
|| __put_user((void __user *)(unsigned long)v32.name, || __put_user((void __user *)(unsigned long)v32.name,
...@@ -142,7 +142,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd, ...@@ -142,7 +142,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
u = compat_alloc_user_space(sizeof(*u)); u = compat_alloc_user_space(sizeof(*u));
if (!access_ok(VERIFY_WRITE, u, sizeof(*u))) if (!u)
return -EFAULT; return -EFAULT;
if (__put_user(uq32.unique_len, &u->unique_len) if (__put_user(uq32.unique_len, &u->unique_len)
|| __put_user((void __user *)(unsigned long)uq32.unique, || __put_user((void __user *)(unsigned long)uq32.unique,
...@@ -170,7 +170,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd, ...@@ -170,7 +170,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
u = compat_alloc_user_space(sizeof(*u)); u = compat_alloc_user_space(sizeof(*u));
if (!access_ok(VERIFY_WRITE, u, sizeof(*u))) if (!u)
return -EFAULT; return -EFAULT;
if (__put_user(uq32.unique_len, &u->unique_len) if (__put_user(uq32.unique_len, &u->unique_len)
|| __put_user((void __user *)(unsigned long)uq32.unique, || __put_user((void __user *)(unsigned long)uq32.unique,
...@@ -202,7 +202,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd, ...@@ -202,7 +202,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
map = compat_alloc_user_space(sizeof(*map)); map = compat_alloc_user_space(sizeof(*map));
if (!access_ok(VERIFY_WRITE, map, sizeof(*map))) if (!map)
return -EFAULT; return -EFAULT;
if (__put_user(idx, &map->offset)) if (__put_user(idx, &map->offset))
return -EFAULT; return -EFAULT;
...@@ -239,7 +239,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd, ...@@ -239,7 +239,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
map = compat_alloc_user_space(sizeof(*map)); map = compat_alloc_user_space(sizeof(*map));
if (!access_ok(VERIFY_WRITE, map, sizeof(*map))) if (!map)
return -EFAULT; return -EFAULT;
if (__put_user(m32.offset, &map->offset) if (__put_user(m32.offset, &map->offset)
|| __put_user(m32.size, &map->size) || __put_user(m32.size, &map->size)
...@@ -279,7 +279,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd, ...@@ -279,7 +279,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
map = compat_alloc_user_space(sizeof(*map)); map = compat_alloc_user_space(sizeof(*map));
if (!access_ok(VERIFY_WRITE, map, sizeof(*map))) if (!map)
return -EFAULT; return -EFAULT;
if (__put_user((void *)(unsigned long)handle, &map->handle)) if (__put_user((void *)(unsigned long)handle, &map->handle))
return -EFAULT; return -EFAULT;
...@@ -308,7 +308,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd, ...@@ -308,7 +308,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
client = compat_alloc_user_space(sizeof(*client)); client = compat_alloc_user_space(sizeof(*client));
if (!access_ok(VERIFY_WRITE, client, sizeof(*client))) if (!client)
return -EFAULT; return -EFAULT;
if (__put_user(idx, &client->idx)) if (__put_user(idx, &client->idx))
return -EFAULT; return -EFAULT;
...@@ -347,7 +347,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd, ...@@ -347,7 +347,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
int i, err; int i, err;
stats = compat_alloc_user_space(sizeof(*stats)); stats = compat_alloc_user_space(sizeof(*stats));
if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats))) if (!stats)
return -EFAULT; return -EFAULT;
err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats); err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats);
...@@ -384,8 +384,7 @@ static int compat_drm_addbufs(struct file *file, unsigned int cmd, ...@@ -384,8 +384,7 @@ static int compat_drm_addbufs(struct file *file, unsigned int cmd,
unsigned long agp_start; unsigned long agp_start;
buf = compat_alloc_user_space(sizeof(*buf)); buf = compat_alloc_user_space(sizeof(*buf));
if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)) if (!buf || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
return -EFAULT; return -EFAULT;
if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start)) if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start))
...@@ -416,7 +415,7 @@ static int compat_drm_markbufs(struct file *file, unsigned int cmd, ...@@ -416,7 +415,7 @@ static int compat_drm_markbufs(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
buf = compat_alloc_user_space(sizeof(*buf)); buf = compat_alloc_user_space(sizeof(*buf));
if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf))) if (!buf)
return -EFAULT; return -EFAULT;
if (__put_user(b32.size, &buf->size) if (__put_user(b32.size, &buf->size)
...@@ -457,7 +456,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd, ...@@ -457,7 +456,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc); nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc);
request = compat_alloc_user_space(nbytes); request = compat_alloc_user_space(nbytes);
if (!access_ok(VERIFY_WRITE, request, nbytes)) if (!request)
return -EFAULT; return -EFAULT;
list = (struct drm_buf_desc *) (request + 1); list = (struct drm_buf_desc *) (request + 1);
...@@ -518,7 +517,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd, ...@@ -518,7 +517,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
return -EINVAL; return -EINVAL;
nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub); nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub);
request = compat_alloc_user_space(nbytes); request = compat_alloc_user_space(nbytes);
if (!access_ok(VERIFY_WRITE, request, nbytes)) if (!request)
return -EFAULT; return -EFAULT;
list = (struct drm_buf_pub *) (request + 1); list = (struct drm_buf_pub *) (request + 1);
...@@ -565,7 +564,7 @@ static int compat_drm_freebufs(struct file *file, unsigned int cmd, ...@@ -565,7 +564,7 @@ static int compat_drm_freebufs(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) if (!request)
return -EFAULT; return -EFAULT;
if (__put_user(req32.count, &request->count) if (__put_user(req32.count, &request->count)
|| __put_user((int __user *)(unsigned long)req32.list, || __put_user((int __user *)(unsigned long)req32.list,
...@@ -591,7 +590,7 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd, ...@@ -591,7 +590,7 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) if (!request)
return -EFAULT; return -EFAULT;
if (__put_user(req32.ctx_id, &request->ctx_id) if (__put_user(req32.ctx_id, &request->ctx_id)
|| __put_user((void *)(unsigned long)req32.handle, || __put_user((void *)(unsigned long)req32.handle,
...@@ -615,7 +614,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd, ...@@ -615,7 +614,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) if (!request)
return -EFAULT; return -EFAULT;
if (__put_user(ctx_id, &request->ctx_id)) if (__put_user(ctx_id, &request->ctx_id))
return -EFAULT; return -EFAULT;
...@@ -648,7 +647,7 @@ static int compat_drm_resctx(struct file *file, unsigned int cmd, ...@@ -648,7 +647,7 @@ static int compat_drm_resctx(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
res = compat_alloc_user_space(sizeof(*res)); res = compat_alloc_user_space(sizeof(*res));
if (!access_ok(VERIFY_WRITE, res, sizeof(*res))) if (!res)
return -EFAULT; return -EFAULT;
if (__put_user(res32.count, &res->count) if (__put_user(res32.count, &res->count)
|| __put_user((struct drm_ctx __user *) (unsigned long)res32.contexts, || __put_user((struct drm_ctx __user *) (unsigned long)res32.contexts,
...@@ -691,7 +690,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd, ...@@ -691,7 +690,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
d = compat_alloc_user_space(sizeof(*d)); d = compat_alloc_user_space(sizeof(*d));
if (!access_ok(VERIFY_WRITE, d, sizeof(*d))) if (!d)
return -EFAULT; return -EFAULT;
if (__put_user(d32.context, &d->context) if (__put_user(d32.context, &d->context)
...@@ -766,7 +765,7 @@ static int compat_drm_agp_info(struct file *file, unsigned int cmd, ...@@ -766,7 +765,7 @@ static int compat_drm_agp_info(struct file *file, unsigned int cmd,
int err; int err;
info = compat_alloc_user_space(sizeof(*info)); info = compat_alloc_user_space(sizeof(*info));
if (!access_ok(VERIFY_WRITE, info, sizeof(*info))) if (!info)
return -EFAULT; return -EFAULT;
err = drm_ioctl(file, DRM_IOCTL_AGP_INFO, (unsigned long)info); err = drm_ioctl(file, DRM_IOCTL_AGP_INFO, (unsigned long)info);
...@@ -809,7 +808,7 @@ static int compat_drm_agp_alloc(struct file *file, unsigned int cmd, ...@@ -809,7 +808,7 @@ static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request
|| __put_user(req32.size, &request->size) || __put_user(req32.size, &request->size)
|| __put_user(req32.type, &request->type)) || __put_user(req32.type, &request->type))
return -EFAULT; return -EFAULT;
...@@ -836,7 +835,7 @@ static int compat_drm_agp_free(struct file *file, unsigned int cmd, ...@@ -836,7 +835,7 @@ static int compat_drm_agp_free(struct file *file, unsigned int cmd,
u32 handle; u32 handle;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request
|| get_user(handle, &argp->handle) || get_user(handle, &argp->handle)
|| __put_user(handle, &request->handle)) || __put_user(handle, &request->handle))
return -EFAULT; return -EFAULT;
...@@ -860,7 +859,7 @@ static int compat_drm_agp_bind(struct file *file, unsigned int cmd, ...@@ -860,7 +859,7 @@ static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request
|| __put_user(req32.handle, &request->handle) || __put_user(req32.handle, &request->handle)
|| __put_user(req32.offset, &request->offset)) || __put_user(req32.offset, &request->offset))
return -EFAULT; return -EFAULT;
...@@ -876,7 +875,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd, ...@@ -876,7 +875,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
u32 handle; u32 handle;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request
|| get_user(handle, &argp->handle) || get_user(handle, &argp->handle)
|| __put_user(handle, &request->handle)) || __put_user(handle, &request->handle))
return -EFAULT; return -EFAULT;
...@@ -899,8 +898,7 @@ static int compat_drm_sg_alloc(struct file *file, unsigned int cmd, ...@@ -899,8 +898,7 @@ static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
unsigned long x; unsigned long x;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|| __get_user(x, &argp->size) || __get_user(x, &argp->size)
|| __put_user(x, &request->size)) || __put_user(x, &request->size))
return -EFAULT; return -EFAULT;
...@@ -925,8 +923,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd, ...@@ -925,8 +923,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
unsigned long x; unsigned long x;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|| __get_user(x, &argp->handle) || __get_user(x, &argp->handle)
|| __put_user(x << PAGE_SHIFT, &request->handle)) || __put_user(x << PAGE_SHIFT, &request->handle))
return -EFAULT; return -EFAULT;
...@@ -954,7 +951,7 @@ static int compat_drm_update_draw(struct file *file, unsigned int cmd, ...@@ -954,7 +951,7 @@ static int compat_drm_update_draw(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) || if (!request ||
__put_user(update32.handle, &request->handle) || __put_user(update32.handle, &request->handle) ||
__put_user(update32.type, &request->type) || __put_user(update32.type, &request->type) ||
__put_user(update32.num, &request->num) || __put_user(update32.num, &request->num) ||
...@@ -996,7 +993,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, ...@@ -996,7 +993,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
request = compat_alloc_user_space(sizeof(*request)); request = compat_alloc_user_space(sizeof(*request));
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) if (!request
|| __put_user(req32.request.type, &request->request.type) || __put_user(req32.request.type, &request->request.type)
|| __put_user(req32.request.sequence, &request->request.sequence) || __put_user(req32.request.sequence, &request->request.sequence)
|| __put_user(req32.request.signal, &request->request.signal)) || __put_user(req32.request.signal, &request->request.signal))
......
...@@ -1267,7 +1267,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off); ...@@ -1267,7 +1267,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
/** /**
* drm_crtc_vblank_reset - reset vblank state to off on a CRTC * drm_crtc_vblank_reset - reset vblank state to off on a CRTC
* @crtc: CRTC in question * @drm_crtc: CRTC in question
* *
* Drivers can use this function to reset the vblank state to off at load time. * Drivers can use this function to reset the vblank state to off at load time.
* Drivers should use this together with the drm_crtc_vblank_off() and * Drivers should use this together with the drm_crtc_vblank_off() and
......
...@@ -42,7 +42,7 @@ struct drm_file; ...@@ -42,7 +42,7 @@ struct drm_file;
#define DRM_KERNEL_CONTEXT 0 #define DRM_KERNEL_CONTEXT 0
#define DRM_RESERVED_CONTEXTS 1 #define DRM_RESERVED_CONTEXTS 1
int drm_legacy_ctxbitmap_init(struct drm_device *dev); void drm_legacy_ctxbitmap_init(struct drm_device *dev);
void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev); void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle); void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file); void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
......
...@@ -61,6 +61,9 @@ int drm_legacy_lock(struct drm_device *dev, void *data, ...@@ -61,6 +61,9 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
struct drm_master *master = file_priv->master; struct drm_master *master = file_priv->master;
int ret = 0; int ret = 0;
if (drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
++file_priv->lock_count; ++file_priv->lock_count;
if (lock->context == DRM_KERNEL_CONTEXT) { if (lock->context == DRM_KERNEL_CONTEXT) {
...@@ -153,6 +156,9 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -153,6 +156,9 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
struct drm_lock *lock = data; struct drm_lock *lock = data;
struct drm_master *master = file_priv->master; struct drm_master *master = file_priv->master;
if (drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
if (lock->context == DRM_KERNEL_CONTEXT) { if (lock->context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n", DRM_ERROR("Process %d using kernel context %d\n",
task_pid_nr(current), lock->context); task_pid_nr(current), lock->context);
......
...@@ -525,10 +525,12 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -525,10 +525,12 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
if (plane->funcs->atomic_duplicate_state) if (plane->funcs->atomic_duplicate_state)
plane_state = plane->funcs->atomic_duplicate_state(plane); plane_state = plane->funcs->atomic_duplicate_state(plane);
else if (plane->state) else {
if (!plane->state)
drm_atomic_helper_plane_reset(plane);
plane_state = drm_atomic_helper_plane_duplicate_state(plane); plane_state = drm_atomic_helper_plane_duplicate_state(plane);
else }
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
if (!plane_state) if (!plane_state)
return -ENOMEM; return -ENOMEM;
plane_state->plane = plane; plane_state->plane = plane;
...@@ -572,10 +574,12 @@ int drm_plane_helper_disable(struct drm_plane *plane) ...@@ -572,10 +574,12 @@ int drm_plane_helper_disable(struct drm_plane *plane)
if (plane->funcs->atomic_duplicate_state) if (plane->funcs->atomic_duplicate_state)
plane_state = plane->funcs->atomic_duplicate_state(plane); plane_state = plane->funcs->atomic_duplicate_state(plane);
else if (plane->state) else {
if (!plane->state)
drm_atomic_helper_plane_reset(plane);
plane_state = drm_atomic_helper_plane_duplicate_state(plane); plane_state = drm_atomic_helper_plane_duplicate_state(plane);
else }
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
if (!plane_state) if (!plane_state)
return -ENOMEM; return -ENOMEM;
plane_state->plane = plane; plane_state->plane = plane;
......
...@@ -167,7 +167,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -167,7 +167,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *gobj = NULL;
struct device *device = &dev->pdev->dev; struct device *device = &dev->pdev->dev;
struct mgag200_bo *bo;
int ret; int ret;
void *sysram; void *sysram;
int size; int size;
...@@ -185,7 +184,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper, ...@@ -185,7 +184,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
DRM_ERROR("failed to create fbcon backing object %d\n", ret); DRM_ERROR("failed to create fbcon backing object %d\n", ret);
return ret; return ret;
} }
bo = gem_to_mga_bo(gobj);
sysram = vmalloc(size); sysram = vmalloc(size);
if (!sysram) if (!sysram)
......
...@@ -158,7 +158,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock) ...@@ -158,7 +158,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
{ {
unsigned int vcomax, vcomin, pllreffreq; unsigned int vcomax, vcomin, pllreffreq;
unsigned int delta, tmpdelta, permitteddelta; unsigned int delta, tmpdelta;
unsigned int testp, testm, testn; unsigned int testp, testm, testn;
unsigned int p, m, n; unsigned int p, m, n;
unsigned int computed; unsigned int computed;
...@@ -172,7 +172,6 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) ...@@ -172,7 +172,6 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
pllreffreq = 48000; pllreffreq = 48000;
delta = 0xffffffff; delta = 0xffffffff;
permitteddelta = clock * 5 / 1000;
for (testp = 1; testp < 9; testp++) { for (testp = 1; testp < 9; testp++) {
if (clock * testp > vcomax) if (clock * testp > vcomax)
...@@ -298,7 +297,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) ...@@ -298,7 +297,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
{ {
unsigned int vcomax, vcomin, pllreffreq; unsigned int vcomax, vcomin, pllreffreq;
unsigned int delta, tmpdelta, permitteddelta; unsigned int delta, tmpdelta;
unsigned int testp, testm, testn; unsigned int testp, testm, testn;
unsigned int p, m, n; unsigned int p, m, n;
unsigned int computed; unsigned int computed;
...@@ -310,7 +309,6 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) ...@@ -310,7 +309,6 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
pllreffreq = 50000; pllreffreq = 50000;
delta = 0xffffffff; delta = 0xffffffff;
permitteddelta = clock * 5 / 1000;
for (testp = 16; testp > 0; testp--) { for (testp = 16; testp > 0; testp--) {
if (clock * testp > vcomax) if (clock * testp > vcomax)
...@@ -392,7 +390,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) ...@@ -392,7 +390,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
static int mga_g200eh_set_plls(struct mga_device *mdev, long clock) static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
{ {
unsigned int vcomax, vcomin, pllreffreq; unsigned int vcomax, vcomin, pllreffreq;
unsigned int delta, tmpdelta, permitteddelta; unsigned int delta, tmpdelta;
unsigned int testp, testm, testn; unsigned int testp, testm, testn;
unsigned int p, m, n; unsigned int p, m, n;
unsigned int computed; unsigned int computed;
...@@ -406,7 +404,6 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock) ...@@ -406,7 +404,6 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
pllreffreq = 33333; pllreffreq = 33333;
delta = 0xffffffff; delta = 0xffffffff;
permitteddelta = clock * 5 / 1000;
for (testp = 16; testp > 0; testp >>= 1) { for (testp = 16; testp > 0; testp >>= 1) {
if (clock * testp > vcomax) if (clock * testp > vcomax)
......
...@@ -378,7 +378,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr) ...@@ -378,7 +378,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
int mgag200_bo_unpin(struct mgag200_bo *bo) int mgag200_bo_unpin(struct mgag200_bo *bo)
{ {
int i, ret; int i;
if (!bo->pin_count) { if (!bo->pin_count) {
DRM_ERROR("unpin bad %p\n", bo); DRM_ERROR("unpin bad %p\n", bo);
return 0; return 0;
...@@ -389,11 +389,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo) ...@@ -389,11 +389,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo)
for (i = 0; i < bo->placement.num_placement ; i++) for (i = 0; i < bo->placement.num_placement ; i++)
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT; bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false); return ttm_bo_validate(&bo->bo, &bo->placement, false, false);
if (ret)
return ret;
return 0;
} }
int mgag200_bo_push_sysram(struct mgag200_bo *bo) int mgag200_bo_push_sysram(struct mgag200_bo *bo)
......
...@@ -943,7 +943,8 @@ static struct drm_driver ...@@ -943,7 +943,8 @@ static struct drm_driver
driver_stub = { driver_stub = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_USE_AGP |
DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER, DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
DRIVER_KMS_LEGACY_CONTEXT,
.load = nouveau_drm_load, .load = nouveau_drm_load,
.unload = nouveau_drm_unload, .unload = nouveau_drm_unload,
......
...@@ -137,17 +137,18 @@ void drm_err(const char *format, ...); ...@@ -137,17 +137,18 @@ void drm_err(const char *format, ...);
/*@{*/ /*@{*/
/* driver capabilities and requirements mask */ /* driver capabilities and requirements mask */
#define DRIVER_USE_AGP 0x1 #define DRIVER_USE_AGP 0x1
#define DRIVER_PCI_DMA 0x8 #define DRIVER_PCI_DMA 0x8
#define DRIVER_SG 0x10 #define DRIVER_SG 0x10
#define DRIVER_HAVE_DMA 0x20 #define DRIVER_HAVE_DMA 0x20
#define DRIVER_HAVE_IRQ 0x40 #define DRIVER_HAVE_IRQ 0x40
#define DRIVER_IRQ_SHARED 0x80 #define DRIVER_IRQ_SHARED 0x80
#define DRIVER_GEM 0x1000 #define DRIVER_GEM 0x1000
#define DRIVER_MODESET 0x2000 #define DRIVER_MODESET 0x2000
#define DRIVER_PRIME 0x4000 #define DRIVER_PRIME 0x4000
#define DRIVER_RENDER 0x8000 #define DRIVER_RENDER 0x8000
#define DRIVER_ATOMIC 0x10000 #define DRIVER_ATOMIC 0x10000
#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
/***********************************************************************/ /***********************************************************************/
/** \name Macros to make printk easier */ /** \name Macros to make printk easier */
......
...@@ -34,6 +34,13 @@ ...@@ -34,6 +34,13 @@
/* color index */ /* color index */
#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
/* 8 bpp Red */
#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
/* 16 bpp RG */
#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */
#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */
/* 8 bpp RGB */ /* 8 bpp RGB */
#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ #define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ #define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
......
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