Skip to contentSkip to conversation

drm/i915: Update WaFlushCoherentL3CacheLinesAtContextSwitch

PATCH Applied Arun Siluvery 5 participants 11 messages Jul 3, 2015 – Jul 10, 2015

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

PATCH 1/1 drm/i915: Update WaFlushCoherentL3CacheLinesAtContextSwitch

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
 drivers/gpu/drm/i915/i915_reg.h        |  3 +-
 drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
 3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +3 -3
index 306d9e4..430571b 100644
@@ -131,7 +131,7 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
 			.mask = MI_GLOBAL_GTT,
 			.expected = 0,
 	      }},						       ),
-	CMD(  MI_LOAD_REGISTER_MEM,             SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),             SMI,   !F,  0xFF,   W | B,
 	      .reg = { .offset = 1, .mask = 0x007FFFFC },
 	      .bits = {{
 			.offset = 0,
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
 			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {
 					DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");
 					return false;
 				}
@@ -1035,7 +1035,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * allowed mask/value pair given in the whitelist entry.
 			 */
 			if (reg->mask) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {
 					DRM_DEBUG_DRIVER("CMD: Rejected LRM to masked register 0x%08X\n",
 							 reg_addr);
 					return false;
drivers/gpu/drm/i915/i915_reg.h +2 -1
index fa9ccb87..1d1cbe0 100644
@@ -352,6 +352,8 @@
 #define   MI_INVALIDATE_BSD		(1<<7)
 #define   MI_FLUSH_DW_USE_GTT		(1<<2)
 #define   MI_FLUSH_DW_USE_PPGTT		(0<<2)
+#define MI_LOAD_REGISTER_MEM(x) MI_INSTR(0x29, 2*(x)-1)
+#define MI_LOAD_REGISTER_MEM_GEN8(x) MI_INSTR(0x29, 3*(x)-1)
 #define MI_BATCH_BUFFER		MI_INSTR(0x30, 1)
 #define   MI_BATCH_NON_SECURE		(1)
 /* for snb/ivb/vlv this also means "batch in ppgtt" when ppgtt is enabled. */
@@ -456,7 +458,6 @@
 #define MI_CLFLUSH              MI_INSTR(0x27, 0)
 #define MI_REPORT_PERF_COUNT    MI_INSTR(0x28, 0)
 #define   MI_REPORT_PERF_COUNT_GGTT (1<<0)
-#define MI_LOAD_REGISTER_MEM    MI_INSTR(0x29, 0)
 #define MI_LOAD_REGISTER_REG    MI_INSTR(0x2A, 0)
 #define MI_RS_STORE_DATA_IMM    MI_INSTR(0x2B, 0)
 #define MI_LOAD_URB_MEM         MI_INSTR(0x2C, 0)
drivers/gpu/drm/i915/intel_lrc.c +53 -19

84 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 35 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
 drivers/gpu/drm/i915/i915_reg.h        |  3 +-
 drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
 3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
index 306d9e4..430571b 100644
@@ -131,7 +131,7 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
 			.mask = MI_GLOBAL_GTT,
 			.expected = 0,
 	      }},						       ),
-	CMD(  MI_LOAD_REGISTER_MEM,             SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),             SMI,   !F,  0xFF,   W | B,
 	      .reg = { .offset = 1, .mask = 0x007FFFFC },
 	      .bits = {{
 			.offset = 0,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
 			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 46 lines · Chris Wilson
Quoted 35 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
  drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
  drivers/gpu/drm/i915/i915_reg.h        |  3 +-
  drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
  3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
index 306d9e4..430571b 100644
@@ -131,7 +131,7 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
  			.mask = MI_GLOBAL_GTT,
  			.expected = 0,
  	      }},						       ),
-	CMD(  MI_LOAD_REGISTER_MEM,             SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),             SMI,   !F,  0xFF,   W | B,
  	      .reg = { .offset = 1, .mask = 0x007FFFFC },
  	      .bits = {{
  			.offset = 0,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
  			 * only MI_LOAD_REGISTER_IMM commands.
  			 */
  			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 5 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

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

#3 lore raw
Quoted 47 lines · Dave Gordon
Quoted 46 lines · Chris Wilson
Quoted 35 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
   drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
   drivers/gpu/drm/i915/i915_reg.h        |  3 +-
   drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
   3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
index 306d9e4..430571b 100644
@@ -131,7 +131,7 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
   			.mask = MI_GLOBAL_GTT,
   			.expected = 0,
   	      }},						       ),
-	CMD(  MI_LOAD_REGISTER_MEM,             SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),             SMI,   !F,  0xFF,   W | B,
   	      .reg = { .offset = 1, .mask = 0x007FFFFC },
   	      .bits = {{
   			.offset = 0,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
   			 * only MI_LOAD_REGISTER_IMM commands.
   			 */
   			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 8 lines
Quoted 5 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might

true, but cmd parser is only upto GEN7.

regards
Arun

Quoted 5 lines

almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

.Dave.

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

#4 lore raw
In reply to Dave Gordon
Quoted 47 lines · Dave Gordon
Quoted 46 lines · Chris Wilson
Quoted 35 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
 drivers/gpu/drm/i915/i915_reg.h        |  3 +-
 drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
 3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
index 306d9e4..430571b 100644
@@ -131,7 +131,7 @@ static const struct drm_i915_cmd_descriptor common_cmds[] = {
 			.mask = MI_GLOBAL_GTT,
 			.expected = 0,
 	      }},						       ),
-	CMD(  MI_LOAD_REGISTER_MEM,             SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),             SMI,   !F,  0xFF,   W | B,
 	      .reg = { .offset = 1, .mask = 0x007FFFFC },
 	      .bits = {{
 			.offset = 0,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
 			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 53 lines · Daniel Vetter
Quoted 39 lines · Dave Gordon
Quoted 38 lines · Chris Wilson
Quoted 27 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
  drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
  drivers/gpu/drm/i915/i915_reg.h        |  3 +-
  drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
  3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index 306d9e4..430571b 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
  			 * only MI_LOAD_REGISTER_IMM commands.
  			 */
  			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

Quoted 4 lines

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

In the snippet:

Quoted 2 lines

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_cmd_descriptor common_cmds[] = { · line 134

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
-	CMD(  MI_LOAD_REGISTER_MEM,         SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),      SMI,   !F,  0xFF,   W | B,

the (1) goes in the table but is ignored when matching instructions in the stream being parsed. It could just as well be (2) or (0) or (255).

Then, in the test:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-		if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+		if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

the thing on the left of the == is not the instruction being examined, but the entry in the table that matched that instruction. So here also we're not really using the length field, EXCEPT that it MUST be the same as the (arbitrary) value in the table.

So my concern here was not about correctness but comprehensibility and hence maintainability -- after all, if Chris had to look twice it obviously isn't as clear as one would like!

My suggestion was that maybe the "ignored" length field should be 0 to make it less likely that a reader would think this matches exactly (and only) an opcode of 0xa400001. Or maybe (255) would be even more obviously not-a-literal-match?

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

#6 lore raw
Quoted 77 lines · Dave Gordon
Quoted 53 lines · Daniel Vetter
Quoted 39 lines · Dave Gordon
Quoted 38 lines · Chris Wilson
Quoted 27 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
 drivers/gpu/drm/i915/i915_reg.h        |  3 +-
 drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
 3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index 306d9e4..430571b 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
 			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

Quoted 4 lines

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

In the snippet:

Quoted 2 lines

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_cmd_descriptor common_cmds[] = { · line 134

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
-	CMD(  MI_LOAD_REGISTER_MEM,         SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),      SMI,   !F,  0xFF,   W | B,

the (1) goes in the table but is ignored when matching instructions in the stream being parsed. It could just as well be (2) or (0) or (255).

Then, in the test:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-		if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+		if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

the thing on the left of the == is not the instruction being examined, but the entry in the table that matched that instruction. So here also we're not really using the length field, EXCEPT that it MUST be the same as the (arbitrary) value in the table.

Quoted 8 lines

So my concern here was not about correctness but comprehensibility and hence maintainability -- after all, if Chris had to look twice it obviously isn't as clear as one would like!

My suggestion was that maybe the "ignored" length field should be 0 to make it less likely that a reader would think this matches exactly (and only) an opcode of 0xa400001. Or maybe (255) would be even more obviously not-a-literal-match?

Hm, given that the cmd parser is gen7 only I'm not too concerned about this. It is indeed a bit surprising though, and I guess (0) would be less surprising. Otoh other commands with a lenght field also use (1) in a similar fashion, so at least this is consistent.

tbh no opinion here at all from my side, but happy to merge a fixup on top to clarify this, if you can agree on a clear improvement. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
Quoted 87 lines · Daniel Vetter
Quoted 77 lines · Dave Gordon
Quoted 53 lines · Daniel Vetter
Quoted 39 lines · Dave Gordon
Quoted 38 lines · Chris Wilson
Quoted 27 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
  drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
  drivers/gpu/drm/i915/i915_reg.h        |  3 +-
  drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
  3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index 306d9e4..430571b 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
  			 * only MI_LOAD_REGISTER_IMM commands.
  			 */
  			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

Quoted 4 lines

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

In the snippet:

Quoted 2 lines

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_cmd_descriptor common_cmds[] = { · line 134

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
-	CMD(  MI_LOAD_REGISTER_MEM,         SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),      SMI,   !F,  0xFF,   W | B,

the (1) goes in the table but is ignored when matching instructions in the stream being parsed. It could just as well be (2) or (0) or (255).

Then, in the test:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-		if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+		if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

the thing on the left of the == is not the instruction being examined, but the entry in the table that matched that instruction. So here also we're not really using the length field, EXCEPT that it MUST be the same as the (arbitrary) value in the table.

Quoted 8 lines

So my concern here was not about correctness but comprehensibility and hence maintainability -- after all, if Chris had to look twice it obviously isn't as clear as one would like!

My suggestion was that maybe the "ignored" length field should be 0 to make it less likely that a reader would think this matches exactly (and only) an opcode of 0xa400001. Or maybe (255) would be even more obviously not-a-literal-match?

Quoted 8 lines

Hm, given that the cmd parser is gen7 only I'm not too concerned about this. It is indeed a bit surprising though, and I guess (0) would be less surprising. Otoh other commands with a lenght field also use (1) in a similar fashion, so at least this is consistent.

tbh no opinion here at all from my side, but happy to merge a fixup on top to clarify this, if you can agree on a clear improvement. -Daniel

Hi Daniel,

Arun & I have just discussed this and we think we should go with this as-is for now, and then fix all the places that have an opcode macro with a redundant non-zero length in a separate patch.

Thanks,
.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
In reply to Daniel Vetter
Quoted 87 lines · Daniel Vetter
Quoted 77 lines · Dave Gordon
Quoted 53 lines · Daniel Vetter
Quoted 39 lines · Dave Gordon
Quoted 38 lines · Chris Wilson
Quoted 27 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
 drivers/gpu/drm/i915/i915_reg.h        |  3 +-
 drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
 3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index 306d9e4..430571b 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
 			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

Quoted 4 lines

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

In the snippet:

Quoted 2 lines

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_cmd_descriptor common_cmds[] = { · line 134

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
-	CMD(  MI_LOAD_REGISTER_MEM,         SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),      SMI,   !F,  0xFF,   W | B,

the (1) goes in the table but is ignored when matching instructions in the stream being parsed. It could just as well be (2) or (0) or (255).

Then, in the test:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-		if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+		if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

the thing on the left of the == is not the instruction being examined, but the entry in the table that matched that instruction. So here also we're not really using the length field, EXCEPT that it MUST be the same as the (arbitrary) value in the table.

Quoted 8 lines

So my concern here was not about correctness but comprehensibility and hence maintainability -- after all, if Chris had to look twice it obviously isn't as clear as one would like!

My suggestion was that maybe the "ignored" length field should be 0 to make it less likely that a reader would think this matches exactly (and only) an opcode of 0xa400001. Or maybe (255) would be even more obviously not-a-literal-match?

Quoted 7 lines

Hm, given that the cmd parser is gen7 only I'm not too concerned about this. It is indeed a bit surprising though, and I guess (0) would be less surprising. Otoh other commands with a lenght field also use (1) in a similar fashion, so at least this is consistent.

tbh no opinion here at all from my side, but happy to merge a fixup on top to clarify this, if you can agree on a clear improvement.

iirc, the #define used CMD | (2*(x)-1), which blows up if passed in 0. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw
Quoted 93 lines · Chris Wilson
Quoted 92 lines · Daniel Vetter
Quoted 77 lines · Dave Gordon
Quoted 53 lines · Daniel Vetter
Quoted 39 lines · Dave Gordon
Quoted 38 lines · Chris Wilson
Quoted 27 lines · Arun Siluvery

In this WA we need to set GEN8_L3SQCREG4[21:21] and reset it after PIPE_CONTROL instruction but there is a slight complication as this is applied in WA batch where the values are only initialized once.
Dave identified an issue with the current implementation where the register value is read once at the beginning and it is reused; this patch corrects this by saving the register value to memory, update register with the bit of our interest and restore it back with original value.

This implementation uses MI_LOAD_REGISTER_MEM which is currently only used by command parser and was using a default length of 0. This is now updated with correct length and moved to appropriate place.

Cc Chris Wilson <[email protected]>
Cc Dave Gordon <[email protected]>
---
  drivers/gpu/drm/i915/i915_cmd_parser.c |  6 +--
  drivers/gpu/drm/i915/i915_reg.h        |  3 +-
  drivers/gpu/drm/i915/intel_lrc.c       | 72 +++++++++++++++++++++++++---------
  3 files changed, 58 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index 306d9e4..430571b 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *ring, · line 1024

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -1
@@ -1021,7 +1021,7 @@ static bool check_cmd(const struct intel_engine_cs *ring,
  			 * only MI_LOAD_REGISTER_IMM commands.
  			 */
  			if (reg_addr == OACONTROL) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+				if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

I had a double take here, but it all comes out in the wash. For one moment, I thought the cmd matching had changed, but that has the length masked out.

Quoted 1 line
Quoted 1 line

Queued for -next, thanks for the patch.

Quoted 8 lines
Quoted 3 lines

Who will start to complain about all the extra frequent register writes, probably into common power wells....
-Chris

Hmm ... that is quite confusing, especially as the actual opcode in the instruction stream will be MI_LOAD_REGISTER_MEM(2) on GEN8+. It might almost be better to use MI_LOAD_REGISTER_MEM(0) to emphasise that the length field is a wildcard and not something that will be matched exactly.

Quoted 4 lines

There's a separate _GEN8 #define to accomodate the differences, so I don't fully understand your concern. We also don't do any decoding in the kernel
...
-Daniel

In the snippet:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-	CMD(  MI_LOAD_REGISTER_MEM,         SMI,   !F,  0xFF,   W | B,
+	CMD(  MI_LOAD_REGISTER_MEM(1),      SMI,   !F,  0xFF,   W | B,

the (1) goes in the table but is ignored when matching instructions in the stream being parsed. It could just as well be (2) or (0) or (255).

Then, in the test:

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-		if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+		if (desc->cmd.value == MI_LOAD_REGISTER_MEM(1)) {

the thing on the left of the == is not the instruction being examined, but the entry in the table that matched that instruction. So here also we're not really using the length field, EXCEPT that it MUST be the same as the (arbitrary) value in the table.

Quoted 8 lines

So my concern here was not about correctness but comprehensibility and hence maintainability -- after all, if Chris had to look twice it obviously isn't as clear as one would like!

My suggestion was that maybe the "ignored" length field should be 0 to make it less likely that a reader would think this matches exactly (and only) an opcode of 0xa400001. Or maybe (255) would be even more obviously not-a-literal-match?

Hm, given that the cmd parser is gen7 only I'm not too concerned about this. It is indeed a bit surprising though, and I guess (0) would be less surprising. Otoh other commands with a lenght field also use (1) in a similar fashion, so at least this is consistent.

Quoted 5 lines
Quoted 2 lines

tbh no opinion here at all from my side, but happy to merge a fixup on top to clarify this, if you can agree on a clear improvement.

iirc, the #define used CMD | (2*(x)-1), which blows up if passed in 0. -Chris

Yes; and furthermore the MI_LOAD_REGISTER_MEM instruction really doesn't take a list of (register,address) pairs; unlike MI_LOAD_REGISTER_IMMEDIATE it can only load ONE register from ONE memory address. So the (x) is completely bogus anyway, and it should revert to just:

#define MI_LOAD_REGISTER_MEM MI_INSTR(0x29, 1)
#define MI_LOAD_REGISTER_MEM_GEN8 MI_INSTR(0x29, 2)

AFAICS LRI is the only CS register-manipulating opcode that actually supports a variable-length list?

.Dave.

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

Tested-by on v1 1/1
#10 lore raw
In reply to Arun Siluvery

Task id: 6719 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  302/302              302/302
SNB                                  312/316              312/316
IVB                                  343/343              343/343
BYT                                  287/287              287/287
HSW                                  380/380              380/380

-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx