forked from Minki/linux
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
This commit is contained in:
commit
fa78ceab99
@ -1463,24 +1463,18 @@ retry:
|
||||
|
||||
if (get_user(obj_id, objs_ptr + copied_objs)) {
|
||||
ret = -EFAULT;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
|
||||
if (!obj || !obj->properties) {
|
||||
ret = -ENOENT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (obj->type == DRM_MODE_OBJECT_PLANE) {
|
||||
plane = obj_to_plane(obj);
|
||||
plane_mask |= (1 << drm_plane_index(plane));
|
||||
plane->old_fb = plane->fb;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (get_user(count_props, count_props_ptr + copied_objs)) {
|
||||
ret = -EFAULT;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
copied_objs++;
|
||||
@ -1492,28 +1486,34 @@ retry:
|
||||
|
||||
if (get_user(prop_id, props_ptr + copied_props)) {
|
||||
ret = -EFAULT;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
prop = drm_property_find(dev, prop_id);
|
||||
if (!prop) {
|
||||
ret = -ENOENT;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (copy_from_user(&prop_value,
|
||||
prop_values_ptr + copied_props,
|
||||
sizeof(prop_value))) {
|
||||
ret = -EFAULT;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = atomic_set_prop(state, obj, prop, prop_value);
|
||||
if (ret)
|
||||
goto fail;
|
||||
goto out;
|
||||
|
||||
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) {
|
||||
@ -1523,7 +1523,7 @@ retry:
|
||||
e = create_vblank_event(dev, file_priv, arg->user_data);
|
||||
if (!e) {
|
||||
ret = -ENOMEM;
|
||||
goto fail;
|
||||
goto out;
|
||||
}
|
||||
|
||||
crtc_state->event = e;
|
||||
@ -1533,6 +1533,7 @@ retry:
|
||||
if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) {
|
||||
ret = drm_atomic_check_only(state);
|
||||
/* _check_only() does not free state, unlike _commit() */
|
||||
if (!ret)
|
||||
drm_atomic_state_free(state);
|
||||
} else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
|
||||
ret = drm_atomic_async_commit(state);
|
||||
@ -1540,6 +1541,7 @@ retry:
|
||||
ret = drm_atomic_commit(state);
|
||||
}
|
||||
|
||||
out:
|
||||
/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping
|
||||
* locks (ie. while it is still safe to deref plane->state). We
|
||||
* need to do this here because the driver entry points cannot
|
||||
@ -1552,41 +1554,35 @@ retry:
|
||||
drm_framebuffer_reference(new_fb);
|
||||
plane->fb = new_fb;
|
||||
plane->crtc = plane->state->crtc;
|
||||
} else {
|
||||
plane->old_fb = NULL;
|
||||
}
|
||||
if (plane->old_fb) {
|
||||
|
||||
if (plane->old_fb)
|
||||
drm_framebuffer_unreference(plane->old_fb);
|
||||
}
|
||||
plane->old_fb = NULL;
|
||||
}
|
||||
|
||||
if (ret == -EDEADLK) {
|
||||
drm_atomic_state_clear(state);
|
||||
drm_modeset_backoff(&ctx);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
drm_modeset_drop_locks(&ctx);
|
||||
drm_modeset_acquire_fini(&ctx);
|
||||
|
||||
return ret;
|
||||
|
||||
fail:
|
||||
if (ret == -EDEADLK)
|
||||
goto backoff;
|
||||
|
||||
if (ret) {
|
||||
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
|
||||
for_each_crtc_in_state(state, crtc, crtc_state, i) {
|
||||
destroy_vblank_event(dev, file_priv, crtc_state->event);
|
||||
crtc_state->event = NULL;
|
||||
if (!crtc_state->event)
|
||||
continue;
|
||||
|
||||
destroy_vblank_event(dev, file_priv,
|
||||
crtc_state->event);
|
||||
}
|
||||
}
|
||||
|
||||
drm_atomic_state_free(state);
|
||||
}
|
||||
|
||||
drm_modeset_drop_locks(&ctx);
|
||||
drm_modeset_acquire_fini(&ctx);
|
||||
|
||||
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,
|
||||
|
||||
/* set legacy state in the crtc structure */
|
||||
for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
|
||||
struct drm_plane *primary = crtc->primary;
|
||||
|
||||
crtc->mode = crtc->state->mode;
|
||||
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)
|
||||
drm_calc_timestamping_constants(crtc,
|
||||
@ -1915,10 +1921,6 @@ retry:
|
||||
if (ret != 0)
|
||||
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. */
|
||||
return 0;
|
||||
fail:
|
||||
|
@ -53,6 +53,10 @@ struct drm_ctx_list {
|
||||
*/
|
||||
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);
|
||||
idr_remove(&dev->ctx_idr, ctx_handle);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
@ -85,10 +89,13 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
|
||||
*
|
||||
* 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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,6 +108,10 @@ int drm_legacy_ctxbitmap_init(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);
|
||||
idr_destroy(&dev->ctx_idr);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
@ -119,6 +130,10 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
|
||||
{
|
||||
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);
|
||||
|
||||
list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
|
||||
@ -161,6 +176,10 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
|
||||
struct drm_local_map *map;
|
||||
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);
|
||||
|
||||
map = idr_find(&dev->ctx_idr, request->ctx_id);
|
||||
@ -205,6 +224,10 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
|
||||
struct drm_local_map *map = 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);
|
||||
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||
if (r_list->map
|
||||
@ -305,6 +328,10 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
|
||||
struct drm_ctx ctx;
|
||||
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) {
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
|
||||
@ -335,6 +362,10 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
|
||||
struct drm_ctx_list *ctx_entry;
|
||||
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);
|
||||
if (ctx->handle == DRM_KERNEL_CONTEXT) {
|
||||
/* Skip kernel's context and get a new one. */
|
||||
@ -378,6 +409,10 @@ int drm_legacy_getctx(struct drm_device *dev, void *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 */
|
||||
ctx->flags = 0;
|
||||
|
||||
@ -400,6 +435,10 @@ int drm_legacy_switchctx(struct drm_device *dev, void *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);
|
||||
return drm_context_switch(dev, dev->last_context, ctx->handle);
|
||||
}
|
||||
@ -420,6 +459,10 @@ int drm_legacy_newctx(struct drm_device *dev, void *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_context_switch_complete(dev, file_priv, ctx->handle);
|
||||
|
||||
@ -442,6 +485,10 @@ int drm_legacy_rmctx(struct drm_device *dev, void *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);
|
||||
if (ctx->handle != DRM_KERNEL_CONTEXT) {
|
||||
if (dev->driver->context_dtor)
|
||||
|
@ -4301,7 +4301,6 @@ void drm_property_unreference_blob(struct drm_property_blob *blob)
|
||||
mutex_unlock(&dev->mode_config.blob_lock);
|
||||
else
|
||||
might_lock(&dev->mode_config.blob_lock);
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL(drm_property_unreference_blob);
|
||||
|
||||
@ -5349,13 +5348,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
||||
/* Keep the old fb, don't unref it. */
|
||||
crtc->primary->old_fb = NULL;
|
||||
} else {
|
||||
/*
|
||||
* 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);
|
||||
crtc->primary->fb = fb;
|
||||
/* Unref only the old framebuffer. */
|
||||
fb = NULL;
|
||||
}
|
||||
|
@ -928,14 +928,14 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
|
||||
if (crtc->funcs->atomic_duplicate_state)
|
||||
crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
|
||||
else {
|
||||
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
|
||||
if (!crtc->state)
|
||||
drm_atomic_helper_crtc_reset(crtc);
|
||||
|
||||
crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
|
||||
}
|
||||
|
||||
if (!crtc_state)
|
||||
return -ENOMEM;
|
||||
if (crtc->state)
|
||||
__drm_atomic_helper_crtc_duplicate_state(crtc, crtc_state);
|
||||
else
|
||||
crtc_state->crtc = crtc;
|
||||
}
|
||||
|
||||
crtc_state->planes_changed = true;
|
||||
crtc_state->mode_changed = true;
|
||||
@ -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);
|
||||
|
||||
out:
|
||||
if (crtc_state) {
|
||||
if (crtc->funcs->atomic_destroy_state)
|
||||
crtc->funcs->atomic_destroy_state(crtc, crtc_state);
|
||||
else {
|
||||
__drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
|
||||
kfree(crtc_state);
|
||||
else
|
||||
drm_atomic_helper_crtc_destroy_state(crtc, crtc_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -582,11 +582,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
|
||||
if (drm_ht_create(&dev->map_hash, 12))
|
||||
goto err_minors;
|
||||
|
||||
ret = drm_legacy_ctxbitmap_init(dev);
|
||||
if (ret) {
|
||||
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
|
||||
goto err_ht;
|
||||
}
|
||||
drm_legacy_ctxbitmap_init(dev);
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_GEM)) {
|
||||
ret = drm_gem_init(dev);
|
||||
@ -600,7 +596,6 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
|
||||
|
||||
err_ctxbitmap:
|
||||
drm_legacy_ctxbitmap_cleanup(dev);
|
||||
err_ht:
|
||||
drm_ht_remove(&dev->map_hash);
|
||||
err_minors:
|
||||
drm_minor_free(dev, DRM_MINOR_LEGACY);
|
||||
|
@ -429,24 +429,6 @@ static bool drm_fb_helper_force_kernel_mode(void)
|
||||
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)
|
||||
{
|
||||
struct drm_device *dev = fb_helper->dev;
|
||||
@ -672,9 +654,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
|
||||
if (!list_empty(&fb_helper->kernel_fb_list)) {
|
||||
list_del(&fb_helper->kernel_fb_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);
|
||||
}
|
||||
}
|
||||
@ -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",
|
||||
info->node, info->fix.id);
|
||||
|
||||
/* Switch back to kernel console on panic */
|
||||
/* multi card linked list maybe */
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -778,22 +778,14 @@ void drm_gem_vm_open(struct vm_area_struct *vma)
|
||||
struct drm_gem_object *obj = vma->vm_private_data;
|
||||
|
||||
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);
|
||||
|
||||
void drm_gem_vm_close(struct vm_area_struct *vma)
|
||||
{
|
||||
struct drm_gem_object *obj = vma->vm_private_data;
|
||||
struct drm_device *dev = obj->dev;
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
drm_vm_close_locked(obj->dev, vma);
|
||||
drm_gem_object_unreference(obj);
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
drm_gem_object_unreference_unlocked(obj);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_gem_vm_close);
|
||||
|
||||
@ -850,7 +842,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
|
||||
*/
|
||||
drm_gem_object_reference(obj);
|
||||
|
||||
drm_vm_open_locked(dev, vma);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_gem_mmap_obj);
|
||||
|
@ -95,7 +95,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
version = compat_alloc_user_space(sizeof(*version));
|
||||
if (!access_ok(VERIFY_WRITE, version, sizeof(*version)))
|
||||
if (!version)
|
||||
return -EFAULT;
|
||||
if (__put_user(v32.name_len, &version->name_len)
|
||||
|| __put_user((void __user *)(unsigned long)v32.name,
|
||||
@ -142,7 +142,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
u = compat_alloc_user_space(sizeof(*u));
|
||||
if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
|
||||
if (!u)
|
||||
return -EFAULT;
|
||||
if (__put_user(uq32.unique_len, &u->unique_len)
|
||||
|| __put_user((void __user *)(unsigned long)uq32.unique,
|
||||
@ -170,7 +170,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
u = compat_alloc_user_space(sizeof(*u));
|
||||
if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
|
||||
if (!u)
|
||||
return -EFAULT;
|
||||
if (__put_user(uq32.unique_len, &u->unique_len)
|
||||
|| __put_user((void __user *)(unsigned long)uq32.unique,
|
||||
@ -202,7 +202,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
map = compat_alloc_user_space(sizeof(*map));
|
||||
if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
|
||||
if (!map)
|
||||
return -EFAULT;
|
||||
if (__put_user(idx, &map->offset))
|
||||
return -EFAULT;
|
||||
@ -239,7 +239,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
map = compat_alloc_user_space(sizeof(*map));
|
||||
if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
|
||||
if (!map)
|
||||
return -EFAULT;
|
||||
if (__put_user(m32.offset, &map->offset)
|
||||
|| __put_user(m32.size, &map->size)
|
||||
@ -279,7 +279,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
map = compat_alloc_user_space(sizeof(*map));
|
||||
if (!access_ok(VERIFY_WRITE, map, sizeof(*map)))
|
||||
if (!map)
|
||||
return -EFAULT;
|
||||
if (__put_user((void *)(unsigned long)handle, &map->handle))
|
||||
return -EFAULT;
|
||||
@ -308,7 +308,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
client = compat_alloc_user_space(sizeof(*client));
|
||||
if (!access_ok(VERIFY_WRITE, client, sizeof(*client)))
|
||||
if (!client)
|
||||
return -EFAULT;
|
||||
if (__put_user(idx, &client->idx))
|
||||
return -EFAULT;
|
||||
@ -347,7 +347,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
|
||||
int i, err;
|
||||
|
||||
stats = compat_alloc_user_space(sizeof(*stats));
|
||||
if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats)))
|
||||
if (!stats)
|
||||
return -EFAULT;
|
||||
|
||||
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,
|
||||
unsigned long agp_start;
|
||||
|
||||
buf = compat_alloc_user_space(sizeof(*buf));
|
||||
if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf))
|
||||
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
|
||||
if (!buf || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
|
||||
return -EFAULT;
|
||||
|
||||
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,
|
||||
return -EFAULT;
|
||||
|
||||
buf = compat_alloc_user_space(sizeof(*buf));
|
||||
if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)))
|
||||
if (!buf)
|
||||
return -EFAULT;
|
||||
|
||||
if (__put_user(b32.size, &buf->size)
|
||||
@ -457,7 +456,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
|
||||
|
||||
nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc);
|
||||
request = compat_alloc_user_space(nbytes);
|
||||
if (!access_ok(VERIFY_WRITE, request, nbytes))
|
||||
if (!request)
|
||||
return -EFAULT;
|
||||
list = (struct drm_buf_desc *) (request + 1);
|
||||
|
||||
@ -518,7 +517,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
|
||||
return -EINVAL;
|
||||
nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub);
|
||||
request = compat_alloc_user_space(nbytes);
|
||||
if (!access_ok(VERIFY_WRITE, request, nbytes))
|
||||
if (!request)
|
||||
return -EFAULT;
|
||||
list = (struct drm_buf_pub *) (request + 1);
|
||||
|
||||
@ -565,7 +564,7 @@ static int compat_drm_freebufs(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
|
||||
if (!request)
|
||||
return -EFAULT;
|
||||
if (__put_user(req32.count, &request->count)
|
||||
|| __put_user((int __user *)(unsigned long)req32.list,
|
||||
@ -591,7 +590,7 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
|
||||
if (!request)
|
||||
return -EFAULT;
|
||||
if (__put_user(req32.ctx_id, &request->ctx_id)
|
||||
|| __put_user((void *)(unsigned long)req32.handle,
|
||||
@ -615,7 +614,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)))
|
||||
if (!request)
|
||||
return -EFAULT;
|
||||
if (__put_user(ctx_id, &request->ctx_id))
|
||||
return -EFAULT;
|
||||
@ -648,7 +647,7 @@ static int compat_drm_resctx(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
res = compat_alloc_user_space(sizeof(*res));
|
||||
if (!access_ok(VERIFY_WRITE, res, sizeof(*res)))
|
||||
if (!res)
|
||||
return -EFAULT;
|
||||
if (__put_user(res32.count, &res->count)
|
||||
|| __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,
|
||||
return -EFAULT;
|
||||
|
||||
d = compat_alloc_user_space(sizeof(*d));
|
||||
if (!access_ok(VERIFY_WRITE, d, sizeof(*d)))
|
||||
if (!d)
|
||||
return -EFAULT;
|
||||
|
||||
if (__put_user(d32.context, &d->context)
|
||||
@ -766,7 +765,7 @@ static int compat_drm_agp_info(struct file *file, unsigned int cmd,
|
||||
int err;
|
||||
|
||||
info = compat_alloc_user_space(sizeof(*info));
|
||||
if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
|
||||
if (!info)
|
||||
return -EFAULT;
|
||||
|
||||
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,
|
||||
return -EFAULT;
|
||||
|
||||
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.type, &request->type))
|
||||
return -EFAULT;
|
||||
@ -836,7 +835,7 @@ static int compat_drm_agp_free(struct file *file, unsigned int cmd,
|
||||
u32 handle;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
|
||||
if (!request
|
||||
|| get_user(handle, &argp->handle)
|
||||
|| __put_user(handle, &request->handle))
|
||||
return -EFAULT;
|
||||
@ -860,7 +859,7 @@ static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
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.offset, &request->offset))
|
||||
return -EFAULT;
|
||||
@ -876,7 +875,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
|
||||
u32 handle;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
|
||||
if (!request
|
||||
|| get_user(handle, &argp->handle)
|
||||
|| __put_user(handle, &request->handle))
|
||||
return -EFAULT;
|
||||
@ -899,8 +898,7 @@ static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
|
||||
unsigned long x;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
|
||||
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|
||||
if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|
||||
|| __get_user(x, &argp->size)
|
||||
|| __put_user(x, &request->size))
|
||||
return -EFAULT;
|
||||
@ -925,8 +923,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
|
||||
unsigned long x;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
|
||||
|| !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|
||||
if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
|
||||
|| __get_user(x, &argp->handle)
|
||||
|| __put_user(x << PAGE_SHIFT, &request->handle))
|
||||
return -EFAULT;
|
||||
@ -954,7 +951,7 @@ static int compat_drm_update_draw(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
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.type, &request->type) ||
|
||||
__put_user(update32.num, &request->num) ||
|
||||
@ -996,7 +993,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
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.sequence, &request->request.sequence)
|
||||
|| __put_user(req32.request.signal, &request->request.signal))
|
||||
|
@ -1267,7 +1267,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
|
||||
|
||||
/**
|
||||
* 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 should use this together with the drm_crtc_vblank_off() and
|
||||
|
@ -42,7 +42,7 @@ struct drm_file;
|
||||
#define DRM_KERNEL_CONTEXT 0
|
||||
#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_free(struct drm_device *dev, int ctx_handle);
|
||||
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,
|
||||
struct drm_master *master = file_priv->master;
|
||||
int ret = 0;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return -EINVAL;
|
||||
|
||||
++file_priv->lock_count;
|
||||
|
||||
if (lock->context == DRM_KERNEL_CONTEXT) {
|
||||
@ -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_master *master = file_priv->master;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return -EINVAL;
|
||||
|
||||
if (lock->context == DRM_KERNEL_CONTEXT) {
|
||||
DRM_ERROR("Process %d using kernel context %d\n",
|
||||
task_pid_nr(current), lock->context);
|
||||
|
@ -525,10 +525,12 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
|
||||
|
||||
if (plane->funcs->atomic_duplicate_state)
|
||||
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);
|
||||
else
|
||||
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
|
||||
}
|
||||
if (!plane_state)
|
||||
return -ENOMEM;
|
||||
plane_state->plane = plane;
|
||||
@ -572,10 +574,12 @@ int drm_plane_helper_disable(struct drm_plane *plane)
|
||||
|
||||
if (plane->funcs->atomic_duplicate_state)
|
||||
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);
|
||||
else
|
||||
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
|
||||
}
|
||||
if (!plane_state)
|
||||
return -ENOMEM;
|
||||
plane_state->plane = plane;
|
||||
|
@ -167,7 +167,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
|
||||
struct drm_framebuffer *fb;
|
||||
struct drm_gem_object *gobj = NULL;
|
||||
struct device *device = &dev->pdev->dev;
|
||||
struct mgag200_bo *bo;
|
||||
int ret;
|
||||
void *sysram;
|
||||
int size;
|
||||
@ -185,7 +184,6 @@ static int mgag200fb_create(struct drm_fb_helper *helper,
|
||||
DRM_ERROR("failed to create fbcon backing object %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
bo = gem_to_mga_bo(gobj);
|
||||
|
||||
sysram = vmalloc(size);
|
||||
if (!sysram)
|
||||
|
@ -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)
|
||||
{
|
||||
unsigned int vcomax, vcomin, pllreffreq;
|
||||
unsigned int delta, tmpdelta, permitteddelta;
|
||||
unsigned int delta, tmpdelta;
|
||||
unsigned int testp, testm, testn;
|
||||
unsigned int p, m, n;
|
||||
unsigned int computed;
|
||||
@ -172,7 +172,6 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
|
||||
pllreffreq = 48000;
|
||||
|
||||
delta = 0xffffffff;
|
||||
permitteddelta = clock * 5 / 1000;
|
||||
|
||||
for (testp = 1; testp < 9; testp++) {
|
||||
if (clock * testp > vcomax)
|
||||
@ -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)
|
||||
{
|
||||
unsigned int vcomax, vcomin, pllreffreq;
|
||||
unsigned int delta, tmpdelta, permitteddelta;
|
||||
unsigned int delta, tmpdelta;
|
||||
unsigned int testp, testm, testn;
|
||||
unsigned int p, m, n;
|
||||
unsigned int computed;
|
||||
@ -310,7 +309,6 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
|
||||
pllreffreq = 50000;
|
||||
|
||||
delta = 0xffffffff;
|
||||
permitteddelta = clock * 5 / 1000;
|
||||
|
||||
for (testp = 16; testp > 0; testp--) {
|
||||
if (clock * testp > vcomax)
|
||||
@ -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)
|
||||
{
|
||||
unsigned int vcomax, vcomin, pllreffreq;
|
||||
unsigned int delta, tmpdelta, permitteddelta;
|
||||
unsigned int delta, tmpdelta;
|
||||
unsigned int testp, testm, testn;
|
||||
unsigned int p, m, n;
|
||||
unsigned int computed;
|
||||
@ -406,7 +404,6 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
|
||||
pllreffreq = 33333;
|
||||
|
||||
delta = 0xffffffff;
|
||||
permitteddelta = clock * 5 / 1000;
|
||||
|
||||
for (testp = 16; testp > 0; testp >>= 1) {
|
||||
if (clock * testp > vcomax)
|
||||
|
@ -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 i, ret;
|
||||
int i;
|
||||
if (!bo->pin_count) {
|
||||
DRM_ERROR("unpin bad %p\n", bo);
|
||||
return 0;
|
||||
@ -389,11 +389,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo)
|
||||
|
||||
for (i = 0; i < bo->placement.num_placement ; i++)
|
||||
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
|
||||
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
return ttm_bo_validate(&bo->bo, &bo->placement, false, false);
|
||||
}
|
||||
|
||||
int mgag200_bo_push_sysram(struct mgag200_bo *bo)
|
||||
|
@ -943,7 +943,8 @@ static struct drm_driver
|
||||
driver_stub = {
|
||||
.driver_features =
|
||||
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,
|
||||
.unload = nouveau_drm_unload,
|
||||
|
@ -148,6 +148,7 @@ void drm_err(const char *format, ...);
|
||||
#define DRIVER_PRIME 0x4000
|
||||
#define DRIVER_RENDER 0x8000
|
||||
#define DRIVER_ATOMIC 0x10000
|
||||
#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
|
||||
|
||||
/***********************************************************************/
|
||||
/** \name Macros to make printk easier */
|
||||
|
@ -34,6 +34,13 @@
|
||||
/* color index */
|
||||
#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 */
|
||||
#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 */
|
||||
|
Loading…
Reference in New Issue
Block a user