Skip to contentSkip to conversation

drm/i915: Skip unbinding large unmappable global buffers

PATCH In review Chris Wilson 4 participants 8 messages Oct 13, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Skip unbinding large unmappable global buffers

If the user requests a mappable binding to the global GTT, we will first unbind an existing mapping if it doesn't match. We will unbind even if there is no possibility that the object can fit in the mappable aperture. This may lead to a ping-pong migration of the object, for example igt/gem_exec_big.

Testcase: igt/gem_exec_big

---
 drivers/gpu/drm/i915/i915_gem.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +18 -1
index 2f939f90984b..f33aa9bb95c0 100644
@@ -3144,6 +3144,9 @@ search_free:
 
 			goto err_unpin;
 		}
+
+		GEM_BUG_ON(vma->node.start < start);
+		GEM_BUG_ON(vma->node.start + vma->node.size > end);
 	}
 	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
 
@@ -3843,7 +3846,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 			 u64 alignment,
 			 u64 flags)
 {
-	struct i915_address_space *vm = &to_i915(obj->base.dev)->ggtt.base;
+	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+	struct i915_address_space *vm = &dev_priv->ggtt.base;
 	struct i915_vma *vma;
 	int ret;
 
@@ -3858,6 +3862,19 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 		    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)))
 			return ERR_PTR(-ENOSPC);
 
+		if (flags & PIN_MAPPABLE) {
+			u32 fence_size;
+
+			fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
+							    i915_gem_object_get_tiling(obj));
+			if (fence_size > dev_priv->ggtt.mappable_end)
+				return ERR_PTR(-E2BIG);
+
+			if (flags & PIN_NONBLOCK &&
+			    fence_size > dev_priv->ggtt.mappable_end / 2)
+				return ERR_PTR(-ENOSPC);
+		}
+
 		WARN(i915_vma_is_pinned(vma),
 		     "bo is already pinned in ggtt with incorrect alignment:"
 		     " offset=%08x, req.alignment=%llx,"
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.BAT: warning for drm/i915: Skip unbinding large unmappable global buffers

== Series Details ==

== Series Details ==

Series: drm/i915: Skip unbinding large unmappable global buffers
URL : https://patchwork.freedesktop.org/series/13702/
State : warning

== Summary ==

Series 13702v1 drm/i915: Skip unbinding large unmappable global buffers
https://patchwork.freedesktop.org/api/1.0/series/13702/revisions/1/mbox/

Test drv_module_reload_basic:

                skip       -> PASS       (fi-skl-6260u)
Test kms_busy:
        Subgroup basic-flip-default-a:
                pass       -> DMESG-WARN (fi-snb-2520m)
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-a-frame-sequence:
                dmesg-warn -> PASS       (fi-skl-6770hq)
        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> PASS       (fi-byt-j1900)
Test vgem_basic:
        Subgroup unload:
                pass       -> SKIP       (fi-skl-6260u)
                pass       -> SKIP       (fi-hsw-4770)
fi-bdw-5557u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:246  pass:204  dwarn:0   dfail:0   fail:0   skip:42 
fi-bxt-t5700     total:246  pass:216  dwarn:0   dfail:0   fail:0   skip:30 
fi-byt-j1900     total:246  pass:214  dwarn:0   dfail:0   fail:1   skip:31 
fi-byt-n2820     total:246  pass:210  dwarn:0   dfail:0   fail:1   skip:35 
fi-hsw-4770      total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23 
fi-hsw-4770r     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-ivb-3520m     total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25 
fi-ivb-3770      total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25 
fi-kbl-7200u     total:246  pass:222  dwarn:0   dfail:0   fail:0   skip:24 
fi-skl-6260u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15 
fi-skl-6700hq    total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23 
fi-skl-6700k     total:246  pass:221  dwarn:1   dfail:0   fail:0   skip:24 
fi-skl-6770hq    total:246  pass:230  dwarn:1   dfail:0   fail:1   skip:14 
fi-snb-2520m     total:246  pass:209  dwarn:1   dfail:0   fail:0   skip:36 
fi-snb-2600      total:246  pass:209  dwarn:0   dfail:0   fail:0   skip:37 

Results at /archive/results/CI_IGT_test/Patchwork_2697/

d8bf31fcdb62e0b0637352e2e08c95a817f0c543 drm-intel-nightly: 2016y-10m-13d-06h-10m-53s UTC integration manifest 825c978 drm/i915: Skip unbinding large unmappable global buffers

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

Re: ✗ Fi.CI.BAT: warning for drm/i915: Skip unbinding large unmappable global buffers

Quoted 8 lines

== Series Details ==

Series: drm/i915: Skip unbinding large unmappable global buffers
URL : https://patchwork.freedesktop.org/series/13702/
State : warning

== Summary ==

Quoted 8 lines

Series 13702v1 drm/i915: Skip unbinding large unmappable global buffers
https://patchwork.freedesktop.org/api/1.0/series/13702/revisions/1/mbox/

Test drv_module_reload_basic:

                skip       -> PASS       (fi-skl-6260u)
Test kms_busy:
        Subgroup basic-flip-default-a:
                pass       -> DMESG-WARN (fi-snb-2520m)

dmesg

[  470.998755] [drm:drm_edid_block_valid] *ERROR* EDID checksum is invalid, remainder is 186
[  470.998762] Raw EDID:
[  470.998765]  	00 ff ff ff ff ff ff 00 04 72 5b 03 63 15 90 34
[  470.998768]  	31 17 01 03 80 35 1e 78 ee a0 a5 a6 56 52 9d 27
[  470.998770]  	0f 50 54 b3 0c 00 71 4f 81 80 81 c0 81 00 95 00
[  470.998772]  	b3 00 d1 c0 01 01 02 3a 80 18 71 38 2d 40 58 2c
[  470.998774]  	45 00 0f 28 21 00 00 1e 00 00 00 fd 00 38 4b 1f
[  470.998776]  	4b 1f ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[  470.998778]  	ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[  470.998779]  	ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Quoted 27 lines

Test kms_pipe_crc_basic:

        Subgroup read-crc-pipe-a-frame-sequence:
                dmesg-warn -> PASS       (fi-skl-6770hq)
        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> PASS       (fi-byt-j1900)
Test vgem_basic:
        Subgroup unload:
                pass       -> SKIP       (fi-skl-6260u)
                pass       -> SKIP       (fi-hsw-4770)
fi-bdw-5557u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15
fi-bsw-n3050     total:246  pass:204  dwarn:0   dfail:0   fail:0   skip:42
fi-bxt-t5700     total:246  pass:216  dwarn:0   dfail:0   fail:0   skip:30
fi-byt-j1900     total:246  pass:214  dwarn:0   dfail:0   fail:1   skip:31
fi-byt-n2820     total:246  pass:210  dwarn:0   dfail:0   fail:1   skip:35
fi-hsw-4770      total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23
fi-hsw-4770r     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22
fi-ivb-3520m     total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25
fi-ivb-3770      total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25
fi-kbl-7200u     total:246  pass:222  dwarn:0   dfail:0   fail:0   skip:24
fi-skl-6260u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15
fi-skl-6700hq    total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23
fi-skl-6700k     total:246  pass:221  dwarn:1   dfail:0   fail:0   skip:24
fi-skl-6770hq    total:246  pass:230  dwarn:1   dfail:0   fail:1   skip:14
fi-snb-2520m     total:246  pass:209  dwarn:1   dfail:0   fail:0   skip:36
fi-snb-2600      total:246  pass:209  dwarn:0   dfail:0   fail:0   skip:37
Quoted 5 lines

Results at /archive/results/CI_IGT_test/Patchwork_2697/

d8bf31fcdb62e0b0637352e2e08c95a817f0c543 drm-intel-nightly: 2016y-10m- 13d-06h-10m-53s UTC integration manifest
825c978 drm/i915: Skip unbinding large unmappable global buffers

Jani Saarinen
Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: ✗ Fi.CI.BAT: warning for drm/i915: Skip unbinding large unmappable global buffers

Quoted 17 lines · Jani
Quoted 8 lines

== Series Details ==

Series: drm/i915: Skip unbinding large unmappable global buffers
URL : https://patchwork.freedesktop.org/series/13702/
State : warning

== Summary ==

Quoted 8 lines

Series 13702v1 drm/i915: Skip unbinding large unmappable global buffers
https://patchwork.freedesktop.org/api/1.0/series/13702/revisions/1/mbox/

Test drv_module_reload_basic:

                 skip       -> PASS       (fi-skl-6260u)
Test kms_busy:
         Subgroup basic-flip-default-a:
                 pass       -> DMESG-WARN (fi-snb-2520m)

dmesg

Quoted 10 lines
[  470.998755] [drm:drm_edid_block_valid] *ERROR* EDID checksum is invalid, remainder is 186
[  470.998762] Raw EDID:
[  470.998765]  	00 ff ff ff ff ff ff 00 04 72 5b 03 63 15 90 34
[  470.998768]  	31 17 01 03 80 35 1e 78 ee a0 a5 a6 56 52 9d 27
[  470.998770]  	0f 50 54 b3 0c 00 71 4f 81 80 81 c0 81 00 95 00
[  470.998772]  	b3 00 d1 c0 01 01 02 3a 80 18 71 38 2d 40 58 2c
[  470.998774]  	45 00 0f 28 21 00 00 1e 00 00 00 fd 00 38 4b 1f
[  470.998776]  	4b 1f ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[  470.998778]  	ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[  470.998779]  	ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

BZ already exists:

https://bugs.freedesktop.org/show_bug.cgi?id=98228

Regards,

Tvrtko

Quoted 38 lines
Quoted 27 lines

Test kms_pipe_crc_basic:

         Subgroup read-crc-pipe-a-frame-sequence:
                 dmesg-warn -> PASS       (fi-skl-6770hq)
         Subgroup suspend-read-crc-pipe-a:
                 dmesg-warn -> PASS       (fi-byt-j1900)
Test vgem_basic:
         Subgroup unload:
                 pass       -> SKIP       (fi-skl-6260u)
                 pass       -> SKIP       (fi-hsw-4770)
fi-bdw-5557u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15
fi-bsw-n3050     total:246  pass:204  dwarn:0   dfail:0   fail:0   skip:42
fi-bxt-t5700     total:246  pass:216  dwarn:0   dfail:0   fail:0   skip:30
fi-byt-j1900     total:246  pass:214  dwarn:0   dfail:0   fail:1   skip:31
fi-byt-n2820     total:246  pass:210  dwarn:0   dfail:0   fail:1   skip:35
fi-hsw-4770      total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23
fi-hsw-4770r     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22
fi-ivb-3520m     total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25
fi-ivb-3770      total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25
fi-kbl-7200u     total:246  pass:222  dwarn:0   dfail:0   fail:0   skip:24
fi-skl-6260u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15
fi-skl-6700hq    total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23
fi-skl-6700k     total:246  pass:221  dwarn:1   dfail:0   fail:0   skip:24
fi-skl-6770hq    total:246  pass:230  dwarn:1   dfail:0   fail:1   skip:14
fi-snb-2520m     total:246  pass:209  dwarn:1   dfail:0   fail:0   skip:36
fi-snb-2600      total:246  pass:209  dwarn:0   dfail:0   fail:0   skip:37
Quoted 5 lines

Results at /archive/results/CI_IGT_test/Patchwork_2697/

d8bf31fcdb62e0b0637352e2e08c95a817f0c543 drm-intel-nightly: 2016y-10m- 13d-06h-10m-53s UTC integration manifest
825c978 drm/i915: Skip unbinding large unmappable global buffers

Jani Saarinen
Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Chris Wilson
Quoted 41 lines · Chris Wilson

If the user requests a mappable binding to the global GTT, we will first unbind an existing mapping if it doesn't match. We will unbind even if there is no possibility that the object can fit in the mappable aperture. This may lead to a ping-pong migration of the object, for example igt/gem_exec_big.

Testcase: igt/gem_exec_big

---
  drivers/gpu/drm/i915/i915_gem.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +6 -1
index 2f939f90984b..f33aa9bb95c0 100644
@@ -3144,6 +3144,9 @@ search_free:
 
  			goto err_unpin;
  		}
+
+		GEM_BUG_ON(vma->node.start < start);
+		GEM_BUG_ON(vma->node.start + vma->node.size > end);
  	}
  	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
 
@@ -3843,7 +3846,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
  			 u64 alignment,
  			 u64 flags)
  {
-	struct i915_address_space *vm = &to_i915(obj->base.dev)->ggtt.base;
+	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+	struct i915_address_space *vm = &dev_priv->ggtt.base;
  	struct i915_vma *vma;
  	int ret;
 
@@ -3858,6 +3862,19 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
  		    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)))
  			return ERR_PTR(-ENOSPC);
 
+		if (flags & PIN_MAPPABLE) {

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · line 3875

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +10 -0
+			u32 fence_size;
+
+			fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
+							    i915_gem_object_get_tiling(obj));
+			if (fence_size > dev_priv->ggtt.mappable_end)
+				return ERR_PTR(-E2BIG);
+
+			if (flags & PIN_NONBLOCK &&
+			    fence_size > dev_priv->ggtt.mappable_end / 2)
+				return ERR_PTR(-ENOSPC);

One half of aperture is a magic number or something else?

Regards,

Tvrtko

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · line 3880

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2 -0
+		}
+
  		WARN(i915_vma_is_pinned(vma),
  		     "bo is already pinned in ggtt with incorrect alignment:"
  		     " offset=%08x, req.alignment=%llx,"

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 43 lines · Tvrtko Ursulin
Quoted 41 lines · Chris Wilson

If the user requests a mappable binding to the global GTT, we will first unbind an existing mapping if it doesn't match. We will unbind even if there is no possibility that the object can fit in the mappable aperture. This may lead to a ping-pong migration of the object, for example igt/gem_exec_big.

Testcase: igt/gem_exec_big

---
 drivers/gpu/drm/i915/i915_gem.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +10 -1
index 2f939f90984b..f33aa9bb95c0 100644
@@ -3144,6 +3144,9 @@ search_free:
 			goto err_unpin;
 		}
+
+		GEM_BUG_ON(vma->node.start < start);
+		GEM_BUG_ON(vma->node.start + vma->node.size > end);
 	}
 	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
@@ -3843,7 +3846,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 			 u64 alignment,
 			 u64 flags)
 {
-	struct i915_address_space *vm = &to_i915(obj->base.dev)->ggtt.base;
+	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+	struct i915_address_space *vm = &dev_priv->ggtt.base;
 	struct i915_vma *vma;
 	int ret;
@@ -3858,6 +3862,19 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 		    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)))
 			return ERR_PTR(-ENOSPC);
+		if (flags & PIN_MAPPABLE) {
+			u32 fence_size;
+
+			fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
+							    i915_gem_object_get_tiling(obj));
Quoted 8 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · line 3875

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +6 -0
+			if (fence_size > dev_priv->ggtt.mappable_end)
+				return ERR_PTR(-E2BIG);
+
+			if (flags & PIN_NONBLOCK &&
+			    fence_size > dev_priv->ggtt.mappable_end / 2)
+				return ERR_PTR(-ENOSPC);

One half of aperture is a magic number or something else?

Magic number. NONBLOCK means try, we have a fallback planned.

It more or less comes from the old habit of having to assume that all fences take up twice the space we expect due to alignment. And given NONBLOCK means that we should have a better fallback than evicting the majority of the aperture on a whim.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by
#6 lore raw
Quoted 50 lines · Chris Wilson
Quoted 41 lines · Tvrtko Ursulin
Quoted 40 lines · Chris Wilson

If the user requests a mappable binding to the global GTT, we will first unbind an existing mapping if it doesn't match. We will unbind even if there is no possibility that the object can fit in the mappable aperture. This may lead to a ping-pong migration of the object, for example igt/gem_exec_big.

Testcase: igt/gem_exec_big

---
  drivers/gpu/drm/i915/i915_gem.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +9 -1
index 2f939f90984b..f33aa9bb95c0 100644
@@ -3144,6 +3144,9 @@ search_free:
  			goto err_unpin;
  		}
+
+		GEM_BUG_ON(vma->node.start < start);
+		GEM_BUG_ON(vma->node.start + vma->node.size > end);
  	}
  	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
@@ -3843,7 +3846,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
  			 u64 alignment,
  			 u64 flags)
  {
-	struct i915_address_space *vm = &to_i915(obj->base.dev)->ggtt.base;
+	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+	struct i915_address_space *vm = &dev_priv->ggtt.base;
  	struct i915_vma *vma;
  	int ret;
@@ -3858,6 +3862,19 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
  		    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)))
  			return ERR_PTR(-ENOSPC);
+		if (flags & PIN_MAPPABLE) {
+			u32 fence_size;
+
+			fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
Quoted 8 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · line 3875

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +7 -0
+							    i915_gem_object_get_tiling(obj));
+			if (fence_size > dev_priv->ggtt.mappable_end)
+				return ERR_PTR(-E2BIG);
+
+			if (flags & PIN_NONBLOCK &&
+			    fence_size > dev_priv->ggtt.mappable_end / 2)
+				return ERR_PTR(-ENOSPC);

One half of aperture is a magic number or something else?

Quoted 6 lines

Magic number. NONBLOCK means try, we have a fallback planned.

It more or less comes from the old habit of having to assume that all fences take up twice the space we expect due to alignment. And given NONBLOCK means that we should have a better fallback than evicting the majority of the aperture on a whim.

Ok I couldn't not think of any potential bad interactions.

If you add a comment explaining the reasoning:

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 54 lines · Tvrtko Ursulin
Quoted 52 lines · Chris Wilson
Quoted 41 lines · Tvrtko Ursulin
Quoted 40 lines · Chris Wilson

If the user requests a mappable binding to the global GTT, we will first unbind an existing mapping if it doesn't match. We will unbind even if there is no possibility that the object can fit in the mappable aperture. This may lead to a ping-pong migration of the object, for example igt/gem_exec_big.

Testcase: igt/gem_exec_big

---
 drivers/gpu/drm/i915/i915_gem.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +9 -1
index 2f939f90984b..f33aa9bb95c0 100644
@@ -3144,6 +3144,9 @@ search_free:
 			goto err_unpin;
 		}
+
+		GEM_BUG_ON(vma->node.start < start);
+		GEM_BUG_ON(vma->node.start + vma->node.size > end);
 	}
 	GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, obj->cache_level));
@@ -3843,7 +3846,8 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 			 u64 alignment,
 			 u64 flags)
 {
-	struct i915_address_space *vm = &to_i915(obj->base.dev)->ggtt.base;
+	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+	struct i915_address_space *vm = &dev_priv->ggtt.base;
 	struct i915_vma *vma;
 	int ret;
@@ -3858,6 +3862,19 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
 		    (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)))
 			return ERR_PTR(-ENOSPC);
+		if (flags & PIN_MAPPABLE) {
+			u32 fence_size;
+
+			fence_size = i915_gem_get_ggtt_size(dev_priv, vma->size,
Quoted 8 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · line 3875

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +7 -0
+							    i915_gem_object_get_tiling(obj));
+			if (fence_size > dev_priv->ggtt.mappable_end)
+				return ERR_PTR(-E2BIG);
+
+			if (flags & PIN_NONBLOCK &&
+			    fence_size > dev_priv->ggtt.mappable_end / 2)
+				return ERR_PTR(-ENOSPC);

One half of aperture is a magic number or something else?

Magic number. NONBLOCK means try, we have a fallback planned.

Quoted 8 lines
Quoted 4 lines

It more or less comes from the old habit of having to assume that all fences take up twice the space we expect due to alignment. And given NONBLOCK means that we should have a better fallback than evicting the majority of the aperture on a whim.

Ok I couldn't not think of any potential bad interactions.

If you add a comment explaining the reasoning:

Felt in the mood to write a few sentences. Hopefully they make sense in the morning. Thanks,
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx