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

Commit 70001cd2 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Remove struct_mutex for destroying framebuffers



We do not need to hold struct_mutex for destroying drm_i915_gem_objects
any longer, and with a little care taken over tracking
obj->framebuffer_references, we can relinquish BKL locking around the
destroy of intel_framebuffer.

v2: Use atomic check for WARN_ON framebuffer miscounting

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170216094621.3426-1-chris@chris-wilson.co.uk


Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
parent 581ab1fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ struct drm_i915_gem_object {
	struct reservation_object *resv;
	struct reservation_object *resv;


	/** References from framebuffers, locks out tiling changes. */
	/** References from framebuffers, locks out tiling changes. */
	unsigned long framebuffer_references;
	atomic_t framebuffer_references;


	/** Record of address bit 17 of each page at last unbind. */
	/** Record of address bit 17 of each page at last unbind. */
	unsigned long *bit_17;
	unsigned long *bit_17;
+1 −1
Original line number Original line Diff line number Diff line
@@ -207,7 +207,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,


			if (!(flags & I915_SHRINK_ACTIVE) &&
			if (!(flags & I915_SHRINK_ACTIVE) &&
			    (i915_gem_object_is_active(obj) ||
			    (i915_gem_object_is_active(obj) ||
			     obj->framebuffer_references))
			     atomic_read(&obj->framebuffer_references)))
				continue;
				continue;


			if (!can_release_pages(obj))
			if (!can_release_pages(obj))
+1 −1
Original line number Original line Diff line number Diff line
@@ -238,7 +238,7 @@ i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
	if ((tiling | stride) == obj->tiling_and_stride)
	if ((tiling | stride) == obj->tiling_and_stride)
		return 0;
		return 0;


	if (obj->framebuffer_references)
	if (atomic_read(&obj->framebuffer_references))
		return -EBUSY;
		return -EBUSY;


	/* We need to rebind the object if its current allocation
	/* We need to rebind the object if its current allocation
+4 −5
Original line number Original line Diff line number Diff line
@@ -14265,14 +14265,13 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv)


static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
{
{
	struct drm_device *dev = fb->dev;
	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);


	drm_framebuffer_cleanup(fb);
	drm_framebuffer_cleanup(fb);
	mutex_lock(&dev->struct_mutex);

	WARN_ON(!intel_fb->obj->framebuffer_references--);
	WARN_ON(atomic_dec_return(&intel_fb->obj->framebuffer_references) < 0);
	i915_gem_object_put(intel_fb->obj);
	i915_gem_object_put(intel_fb->obj);
	mutex_unlock(&dev->struct_mutex);

	kfree(intel_fb);
	kfree(intel_fb);
}
}


@@ -14509,7 +14508,7 @@ static int intel_framebuffer_init(struct drm_device *dev,
		return ret;
		return ret;
	}
	}


	intel_fb->obj->framebuffer_references++;
	atomic_inc(&intel_fb->obj->framebuffer_references);


	return 0;
	return 0;
}
}