Skip to content

Commit 5d82e3e

Browse files
ickledanvet
authored andcommitted
drm/i915: Clarify the semantics of tiling_changed
Rename obj->tiling_changed to obj->fence_dirty so that it is clear that it flags when the parameters for an active fence (including the no-fence) register are changed. Also, do not set this flag when the object does not have a fence register allocated currently and the gpu does not depend upon the unfence. This case works exactly like when a tiled object lost its fence and hence does not need additional handling for the tiling change in the code. v2: Use fence_dirty to better express what the flag tracks and add a few more details to the comments to serve as a reminder of how the GPU also uses the unfenced register slot. Signed-off-by: Chris Wilson <[email protected]> [danvet: Add some bikeshed to the commit message about the stricter use of fence_dirty.] Signed-off-by: Daniel Vetter <[email protected]>
1 parent 38de45c commit 5d82e3e

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,14 @@ struct drm_i915_gem_object {
869869
* Current tiling mode for the object.
870870
*/
871871
unsigned int tiling_mode:2;
872-
unsigned int tiling_changed:1;
872+
/**
873+
* Whether the tiling parameters for the currently associated fence
874+
* register have changed. Note that for the purposes of tracking
875+
* tiling changes we also treat the unfenced register, the register
876+
* slot that the object occupies whilst it executes a fenced
877+
* command (such as BLT on gen2/3), as a "fence".
878+
*/
879+
unsigned int fence_dirty:1;
873880

874881
/** How many users have pinned this object in GTT space. The following
875882
* users can each hold at most one reference: pwrite/pread, pin_ioctl

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static inline void i915_gem_object_fence_lost(struct drm_i915_gem_object *obj)
6666
/* As we do not have an associated fence register, we will force
6767
* a tiling change if we ever need to acquire one.
6868
*/
69-
obj->tiling_changed = false;
69+
obj->fence_dirty = false;
7070
obj->fence_reg = I915_FENCE_REG_NONE;
7171
}
7272

@@ -2459,7 +2459,7 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
24592459
/* Have we updated the tiling parameters upon the object and so
24602460
* will need to serialise the write to the associated fence register?
24612461
*/
2462-
if (obj->tiling_changed) {
2462+
if (obj->fence_dirty) {
24632463
ret = i915_gem_object_flush_fence(obj);
24642464
if (ret)
24652465
return ret;
@@ -2468,7 +2468,7 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
24682468
/* Just update our place in the LRU if our fence is getting reused. */
24692469
if (obj->fence_reg != I915_FENCE_REG_NONE) {
24702470
reg = &dev_priv->fence_regs[obj->fence_reg];
2471-
if (!obj->tiling_changed) {
2471+
if (!obj->fence_dirty) {
24722472
list_move_tail(&reg->lru_list,
24732473
&dev_priv->mm.fence_list);
24742474
return 0;
@@ -2491,7 +2491,7 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
24912491
return 0;
24922492

24932493
i915_gem_object_update_fence(obj, reg, enable);
2494-
obj->tiling_changed = false;
2494+
obj->fence_dirty = false;
24952495

24962496
return 0;
24972497
}

drivers/gpu/drm/i915/i915_gem_tiling.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
355355
* no longer meets the alignment restrictions for its new
356356
* tiling mode. Otherwise we can just leave it alone, but
357357
* need to ensure that any fence register is cleared.
358+
*
359+
* After updating the tiling parameters, we then flag whether
360+
* we need to update an associated fence register. Note this
361+
* has to also include the unfenced register the GPU uses
362+
* whilst executing a fenced command for an untiled object.
358363
*/
359364
i915_gem_release_mmap(obj);
360365

@@ -374,7 +379,10 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
374379
}
375380

376381
if (ret == 0) {
377-
obj->tiling_changed = true;
382+
obj->fence_dirty =
383+
obj->fenced_gpu_access ||
384+
obj->fence_reg != I915_FENCE_REG_NONE;
385+
378386
obj->tiling_mode = args->tiling_mode;
379387
obj->stride = args->stride;
380388
}

0 commit comments

Comments
 (0)