Skip to contentSkip to conversation

drm/i915: Allow null render state batchbuffers bigger than one page

PATCH New Rodrigo Vivi 2 participants 4 messages Oct 9, 2017 – Oct 10, 2017

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/2 drm/i915: Allow null render state batchbuffers bigger than one page

From: Oscar Mateo <[email protected]>

The new batchbuffer for CNL surpasses the 4096 byte mark.

Cc Mika Kuoppala <[email protected]>
Cc Ben Widawsky <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_render_state.c | 40 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem_render_state.c +21 -19
index 4dd4c2159a92..04f869ee86ce 100644
@@ -60,12 +60,12 @@ render_state_get_rodata(const struct intel_engine_cs *engine)
  * this is sufficient as the null state generator makes the final batch
  * with two passes to build command and state separately. At this point
  * the size of both are known and it compacts them by relocating the state
- * right after the commands taking care of alignment so we should sufficient
- * space below them for adding new commands.
+ * right after the commands taking care of alignment so we should have
+ * sufficient space below them for adding new commands.
  */
-#define OUT_BATCH(batch, i, val)				\
+#define OUT_BATCH(batch, size, i, val)				\
 	do {							\
-		if ((i) >= PAGE_SIZE / sizeof(u32))		\
+		if ((i) >= size / sizeof(u32))			\
 			goto err;				\
 		(batch)[(i)++] = (val);				\
 	} while(0)
@@ -84,7 +84,11 @@ static int render_state_setup(struct intel_render_state *so,
 	if (ret)
 		return ret;
 
-	d = kmap_atomic(i915_gem_object_get_dirty_page(obj, 0));
+	d = i915_gem_object_pin_map(obj, I915_MAP_WB);
+	if (IS_ERR(d)) {
+		ret = PTR_ERR(d);
+		goto out;
+	}
 
 	while (i < rodata->batch_items) {
 		u32 s = rodata->batch[i];
@@ -116,7 +120,7 @@ static int render_state_setup(struct intel_render_state *so,
 	so->batch_size = rodata->batch_items * sizeof(u32);
 
 	while (i % CACHELINE_DWORDS)
-		OUT_BATCH(d, i, MI_NOOP);
+		OUT_BATCH(d, obj->base.size, i, MI_NOOP);
 
 	so->aux_offset = i * sizeof(u32);
 
@@ -139,15 +143,15 @@ static int render_state_setup(struct intel_render_state *so,
 		 */
 		u32 eu_pool_config = 0x00777000;
 
-		OUT_BATCH(d, i, GEN9_MEDIA_POOL_STATE);
-		OUT_BATCH(d, i, GEN9_MEDIA_POOL_ENABLE);
-		OUT_BATCH(d, i, eu_pool_config);
-		OUT_BATCH(d, i, 0);
-		OUT_BATCH(d, i, 0);
-		OUT_BATCH(d, i, 0);
+		OUT_BATCH(d, obj->base.size, i, GEN9_MEDIA_POOL_STATE);
+		OUT_BATCH(d, obj->base.size, i, GEN9_MEDIA_POOL_ENABLE);
+		OUT_BATCH(d, obj->base.size, i, eu_pool_config);
+		OUT_BATCH(d, obj->base.size, i, 0);
+		OUT_BATCH(d, obj->base.size, i, 0);
+		OUT_BATCH(d, obj->base.size, i, 0);
 	}
 
-	OUT_BATCH(d, i, MI_BATCH_BUFFER_END);
+	OUT_BATCH(d, obj->base.size, i, MI_BATCH_BUFFER_END);
 	so->aux_size = i * sizeof(u32) - so->aux_offset;
 	so->aux_offset += so->batch_offset;
 	/*
@@ -158,7 +162,7 @@ static int render_state_setup(struct intel_render_state *so,
 
 	if (needs_clflush)
 		drm_clflush_virt_range(d, i * sizeof(u32));
-	kunmap_atomic(d);
+	i915_gem_object_unpin_map(obj);
 
 	ret = i915_gem_object_set_to_gtt_domain(obj, false);
 out:
@@ -166,7 +170,7 @@ static int render_state_setup(struct intel_render_state *so,
 	return ret;
 
 err:
-	kunmap_atomic(d);
+	i915_gem_object_unpin_map(obj);
 	ret = -EINVAL;
 	goto out;
 }
@@ -187,14 +191,12 @@ int i915_gem_render_state_init(struct intel_engine_cs *engine)
 	if (!rodata)
 		return 0;
 
-	if (rodata->batch_items * 4 > PAGE_SIZE)
-		return -EINVAL;
-
 	so = kmalloc(sizeof(*so), GFP_KERNEL);
 	if (!so)
 		return -ENOMEM;
 
-	obj = i915_gem_object_create_internal(engine->i915, PAGE_SIZE);
+	obj = i915_gem_object_create_internal(engine->i915,
+			PAGE_ALIGN(rodata->batch_items * 4));
 	if (IS_ERR(obj)) {
 		ret = PTR_ERR(obj);
 		goto err_free;
Signature · 6 lines
2.13.5

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

PATCH 2/2 drm/i915/cnl: Add null context for Cannonlake.

Auto generated from IGT containing Oscar's patches:
tools/null_state_gen: Automatically generate the copyright header tools/null_state_gen: Add GEN10 golden context batch buffer creation

I'm now convinced that the safiest approach is to include the golden null context.

Apparently not every userspace initialize all the registers and sometimes they assume its default value.
It seems it is arguable if we should on kernel set all registers to its default value as they are in spec, but to avoid unconsistent values, I agree the safiest is to continue setting them to 0.

At least when something doesn't go as planed we started in a very same state from zero. Instead of starting for random states. This makes the debug easier and system more consistent. So safier.

Cc Joonas Lahtinen <[email protected]>
Cc Oscar Mateo <[email protected]>
Cc Rafael Antognolli <[email protected]>
Cc Kenneth Graunke <[email protected]>
---
 drivers/gpu/drm/i915/Makefile                  |    3 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c   |    2 +
 drivers/gpu/drm/i915/intel_renderstate.h       |    1 +
 drivers/gpu/drm/i915/intel_renderstate_gen10.c | 1687 ++++++++++++++++++++++++
 4 files changed, 1692 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/intel_renderstate_gen10.c
drivers/gpu/drm/i915/Makefile +2 -1
index 66d23b619db1..65526d197778 100644
@@ -72,7 +72,8 @@ i915-y += intel_uc.o \
 i915-y += intel_renderstate_gen6.o \
 	  intel_renderstate_gen7.o \
 	  intel_renderstate_gen8.o \
-	  intel_renderstate_gen9.o
+	  intel_renderstate_gen9.o \
+	  intel_renderstate_gen10.o
 
 # modesetting core code
 i915-y += intel_audio.o \
drivers/gpu/drm/i915/i915_gem_render_state.c +2 -0
index 04f869ee86ce..1bfeb3797b33 100644
@@ -49,6 +49,8 @@ render_state_get_rodata(const struct intel_engine_cs *engine)
 		return &gen8_null_state;
 	case 9:
 		return &gen9_null_state;
+	case 10:
+		return &gen10_null_state;
 	}
 
 	return NULL;
drivers/gpu/drm/i915/intel_renderstate.h +1 -0
index 08f6fea05a2c..3ee3641ad8d1 100644
@@ -43,5 +43,6 @@ extern const struct intel_renderstate_rodata gen6_null_state;
 extern const struct intel_renderstate_rodata gen7_null_state;
 extern const struct intel_renderstate_rodata gen8_null_state;
 extern const struct intel_renderstate_rodata gen9_null_state;
+extern const struct intel_renderstate_rodata gen10_null_state;
 
 #endif /* INTEL_RENDERSTATE_H */
drivers/gpu/drm/i915/intel_renderstate_gen10.c new file +1687 -0

1,687 lines not on this page · raw message

Signature · 6 lines
2.13.5

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

✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Allow null render state batchbuffers bigger than one page

In reply to Rodrigo Vivi
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Allow null render state batchbuffers bigger than one page
URL : https://patchwork.freedesktop.org/series/31614/
State : success

== Summary ==

Series 31614v1 series starting with [1/2] drm/i915: Allow null render state batchbuffers bigger than one page
https://patchwork.freedesktop.org/api/1.0/series/31614/revisions/1/mbox/

Test chamelium:

        Subgroup dp-crc-fast:
                pass       -> FAIL       (fi-kbl-7500u) fdo#102514
Test gem_exec_suspend:
        Subgroup basic-s3:
                pass       -> DMESG-WARN (fi-cfl-s) fdo#103026
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705

fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fdo#103026 https://bugs.freedesktop.org/show_bug.cgi?id=103026
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:459s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:475s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:389s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:572s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:287s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:519s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:531s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:539s
fi-byt-n2820     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:524s
fi-cfl-s         total:289  pass:256  dwarn:1   dfail:0   fail:0   skip:32  time:567s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:631s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:438s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:602s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:439s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:421s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:465s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:512s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:471s
fi-kbl-7500u     total:289  pass:263  dwarn:1   dfail:0   fail:1   skip:24  time:496s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:589s
fi-kbl-7567u     total:289  pass:265  dwarn:4   dfail:0   fail:0   skip:20  time:502s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:592s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:658s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:468s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:665s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:538s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:515s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:474s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:584s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:436s

cdca11b93863e52c22eb49b23695b60a847f1a6b drm-tip: 2017y-10m-09d-21h-23m-15s UTC integration manifest bb301e536150 drm/i915/cnl: Add null context for Cannonlake.
88ac8e751856 drm/i915: Allow null render state batchbuffers bigger than one page

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5962/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.IGT: success for series starting with [1/2] drm/i915: Allow null render state batchbuffers bigger than one page

In reply to Rodrigo Vivi
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Allow null render state batchbuffers bigger than one page
URL : https://patchwork.freedesktop.org/series/31614/
State : success

== Summary ==

shard-hsw total:2482 pass:1347 dwarn:23 dfail:0 fail:9 skip:1103 time:9488s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5962/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx