Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa78ceab authored by Dave Airlie's avatar Dave Airlie
Browse files

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
Loading
Loading
Loading
Loading
+36 −40
Original line number Diff line number Diff line
@@ -1463,24 +1463,18 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,

		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 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,

			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 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
			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 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
	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 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
		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 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
				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;
		}
		plane->old_fb = NULL;
	}

	drm_modeset_drop_locks(&ctx);
	drm_modeset_acquire_fini(&ctx);

	return ret;

fail:
	if (ret == -EDEADLK)
		goto backoff;
	if (ret == -EDEADLK) {
		drm_atomic_state_clear(state);
		drm_modeset_backoff(&ctx);
		goto retry;
	}

	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;
}
+8 −6
Original line number Diff line number Diff line
@@ -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 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
	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:
+49 −2
Original line number Diff line number Diff line
@@ -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)
+1 −8
Original line number Diff line number Diff line
@@ -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;
	}
+12 −12
Original line number Diff line number Diff line
@@ -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;
Loading