drm/i915: Move obj->active:5 to obj->flags
We are motivated to avoid using a bitfield for obj->active for a couple
of reasons. Firstly, we wish to document our lockless read of obj->active
using READ_ONCE inside i915_gem_busy_ioctl() and that requires an
integral type (i.e. not a bitfield). Secondly, gcc produces abysmal code
when presented with a bitfield and that shows up high on the profiles of
request tracking (mainly due to excess memory traffic as it converts
the bitfield to a register and back and generates frequent AGI in the
process).
v2: BIT, break up a long line in compute the other engines, new paint
for i915_gem_object_is_active (now i915_gem_object_get_active).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1470324762-2545-23-git-send-email-chris@chris-wilson.co.uk
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 03eb094..0e2b00f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1358,7 +1358,7 @@
if (!readonly) {
active = obj->last_read;
- active_mask = obj->active;
+ active_mask = i915_gem_object_get_active(obj);
} else {
active_mask = 1;
active = &obj->last_write;
@@ -1402,7 +1402,7 @@
BUG_ON(!mutex_is_locked(&dev->struct_mutex));
BUG_ON(!dev_priv->mm.interruptible);
- active_mask = obj->active;
+ active_mask = i915_gem_object_get_active(obj);
if (!active_mask)
return 0;
@@ -2365,10 +2365,10 @@
struct drm_i915_gem_object *obj =
container_of(active, struct drm_i915_gem_object, last_read[idx]);
- GEM_BUG_ON((obj->active & (1 << idx)) == 0);
+ GEM_BUG_ON(!i915_gem_object_has_active_engine(obj, idx));
- obj->active &= ~(1 << idx);
- if (obj->active)
+ i915_gem_object_clear_active(obj, idx);
+ if (i915_gem_object_is_active(obj))
return;
/* Bump our place on the bound list to keep it roughly in LRU order
@@ -2672,7 +2672,7 @@
return -ENOENT;
}
- if (!obj->active)
+ if (!i915_gem_object_is_active(obj))
goto out;
for (i = 0; i < I915_NUM_ENGINES; i++) {
@@ -2760,7 +2760,7 @@
lockdep_assert_held(&obj->base.dev->struct_mutex);
- active_mask = obj->active;
+ active_mask = i915_gem_object_get_active(obj);
if (!active_mask)
return 0;
@@ -3811,7 +3811,7 @@
* become non-busy without any further actions.
*/
args->busy = 0;
- if (obj->active) {
+ if (i915_gem_object_is_active(obj)) {
struct drm_i915_gem_request *req;
int i;