Skip to contentSkip to conversation

drm/i915: Use memset64() to align the ring with MI_NOOP

PATCH In review Chris Wilson 3 participants 7 messages Apr 25, 2018

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

PATCH 1/1 drm/i915: Use memset64() to align the ring with MI_NOOP

When filling the ring to align the emit pointer to the next cacheline, use memset64() rather than open-coding it. As we know that we always have an even number of dwords, we can replace the dword loop with the qword equivalent.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +8 -6
index c68ac605b8a9..07a9a2b4beb7 100644
@@ -1717,22 +1717,24 @@ u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords)
 /* Align the ring tail to a cacheline boundary */
 int intel_ring_cacheline_align(struct i915_request *rq)
 {
-	int num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
-	u32 *cs;
+	int num_dwords;
+	void *cs;
 
+	num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
 	if (num_dwords == 0)
 		return 0;
 
-	num_dwords = CACHELINE_BYTES / sizeof(u32) - num_dwords;
+	num_dwords = CACHELINE_DWORDS - num_dwords;
+	GEM_BUG_ON(num_dwords & 1);
+
 	cs = intel_ring_begin(rq, num_dwords);
 	if (IS_ERR(cs))
 		return PTR_ERR(cs);
 
-	while (num_dwords--)
-		*cs++ = MI_NOOP;
-
+	memset64(cs, 0, num_dwords/2);
 	intel_ring_advance(rq, cs);
 
+	GEM_BUG_ON(rq->ring->emit & CACHELINE_BYTES);
 	return 0;
 }
 
Signature · 6 lines
2.17.0

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

✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use memset64() to align the ring with MI_NOOP

== Series Details ==

== Series Details ==

Series: drm/i915: Use memset64() to align the ring with MI_NOOP
URL : https://patchwork.freedesktop.org/series/42290/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
a2d0462fc7d0 drm/i915: Use memset64() to align the ring with MI_NOOP
-:41: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)
#41: FILE: drivers/gpu/drm/i915/intel_ringbuffer.c:1734:
+	memset64(cs, 0, num_dwords/2);
 	                          ^

total: 0 errors, 0 warnings, 1 checks, 30 lines checked

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

#2 lore raw

✓ Fi.CI.BAT: success for drm/i915: Use memset64() to align the ring with MI_NOOP

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: drm/i915: Use memset64() to align the ring with MI_NOOP
URL : https://patchwork.freedesktop.org/series/42290/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4093 -> Patchwork_8798 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/42290/revisions/1/mbox/

== Known issues ==

Here are the changes found in Patchwork_8798 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_suspend@basic-s3:
      fi-ivb-3520m:       PASS -> DMESG-WARN (fdo#106084) +1

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
      fi-hsw-4770r:       PASS -> FAIL (fdo#103481)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cnl-psr:         PASS -> DMESG-WARN (fdo#104951)

    
    ==== Possible fixes ====

    igt@kms_chamelium@dp-edid-read:
      fi-kbl-7500u:       FAIL (fdo#103841) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-ivb-3520m:       DMESG-WARN (fdo#106084) -> PASS
      fi-bxt-dsi:         INCOMPLETE (fdo#103927) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-glk-j4005:       DMESG-WARN (fdo#106235) -> PASS

fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951
fdo#106084 https://bugs.freedesktop.org/show_bug.cgi?id=106084
fdo#106235 https://bugs.freedesktop.org/show_bug.cgi?id=106235

== Participating hosts (38 -> 34) ==

Missing (4): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq fi-hsw-4200u

== Build changes ==

* Linux: CI_DRM_4093 -> Patchwork_8798

CI_DRM_4093: a47694a9464b96e17b12f0bdb1085d10a61c57e9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4446: e5e8dafc991ee922ec159491c680caff0cfe9235 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8798: a2d0462fc7d03f71bc819c2e777d60c0fef38c58 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4446: a2f486679f467cd6e82578384f56d4aabaa8cf2e @ git://anongit.freedesktop.org/piglit

== Linux commits ==

a2d0462fc7d0 drm/i915: Use memset64() to align the ring with MI_NOOP

== Logs ==

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Chris Wilson
Quoted 28 lines · Chris Wilson

When filling the ring to align the emit pointer to the next cacheline, use memset64() rather than open-coding it. As we know that we always have an even number of dwords, we can replace the dword loop with the qword equivalent.

---
  drivers/gpu/drm/i915/intel_ringbuffer.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index c68ac605b8a9..07a9a2b4beb7 100644
@@ -1717,22 +1717,24 @@ u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords)
  /* Align the ring tail to a cacheline boundary */
  int intel_ring_cacheline_align(struct i915_request *rq)
  {
-	int num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
-	u32 *cs;
+	int num_dwords;
+	void *cs;
 
+	num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
  	if (num_dwords == 0)
  		return 0;
 
-	num_dwords = CACHELINE_BYTES / sizeof(u32) - num_dwords;

drivers/gpu/drm/i915/intel_ringbuffer.c u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords) · line 1733

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
+	num_dwords = CACHELINE_DWORDS - num_dwords;
+	GEM_BUG_ON(num_dwords & 1);
+
  	cs = intel_ring_begin(rq, num_dwords);
  	if (IS_ERR(cs))
  		return PTR_ERR(cs);
 
-	while (num_dwords--)
-		*cs++ = MI_NOOP;
-

BUILD_BUG_ON(MI_NOOP != 0) for paranoid future proofing, since MI_NOOP is now not mentioned in this function, but is meant.

drivers/gpu/drm/i915/intel_ringbuffer.c u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords) · line 1734

Quoted 1 line
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
+	memset64(cs, 0, num_dwords/2);

Spaces around '/' to appease checkpatch and our style.

drivers/gpu/drm/i915/intel_ringbuffer.c u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords) · line 1740

Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
  	intel_ring_advance(rq, cs);
 
+	GEM_BUG_ON(rq->ring->emit & CACHELINE_BYTES);
  	return 0;
  }
 

With whitespace fixed, and preferably BUILD_BUG_ON:

Regards,

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

#4 lore raw

Quoting Tvrtko Ursulin (2018-04-25 15:00:43)

Quoted 37 lines · Chris Wilson
Quoted 35 lines

When filling the ring to align the emit pointer to the next cacheline, use memset64() rather than open-coding it. As we know that we always have an even number of dwords, we can replace the dword loop with the qword equivalent.

---
  drivers/gpu/drm/i915/intel_ringbuffer.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -3
index c68ac605b8a9..07a9a2b4beb7 100644
@@ -1717,22 +1717,24 @@ u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords)
  /* Align the ring tail to a cacheline boundary */
  int intel_ring_cacheline_align(struct i915_request *rq)
  {
-     int num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
-     u32 *cs;
+     int num_dwords;
+     void *cs;
 
+     num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
      if (num_dwords == 0)
              return 0;
 
-     num_dwords = CACHELINE_BYTES / sizeof(u32) - num_dwords;
+     num_dwords = CACHELINE_DWORDS - num_dwords;
+     GEM_BUG_ON(num_dwords & 1);
+
      cs = intel_ring_begin(rq, num_dwords);
      if (IS_ERR(cs))
              return PTR_ERR(cs);
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_ringbuffer.c u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords) · line 1733

Quoted 3 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -3
-     while (num_dwords--)
-             *cs++ = MI_NOOP;
-

BUILD_BUG_ON(MI_NOOP != 0) for paranoid future proofing, since MI_NOOP is now not mentioned in this function, but is meant.

((u64)MI_NOOP << 32 | MI_NOOP) ?
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 38 lines · Chris Wilson

Quoting Tvrtko Ursulin (2018-04-25 15:00:43)

Quoted 37 lines · Chris Wilson
Quoted 35 lines

When filling the ring to align the emit pointer to the next cacheline, use memset64() rather than open-coding it. As we know that we always have an even number of dwords, we can replace the dword loop with the qword equivalent.

---
   drivers/gpu/drm/i915/intel_ringbuffer.c | 14 ++++++++------
   1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -3
index c68ac605b8a9..07a9a2b4beb7 100644
@@ -1717,22 +1717,24 @@ u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords)
   /* Align the ring tail to a cacheline boundary */
   int intel_ring_cacheline_align(struct i915_request *rq)
   {
-     int num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
-     u32 *cs;
+     int num_dwords;
+     void *cs;
 
+     num_dwords = (rq->ring->emit & (CACHELINE_BYTES - 1)) / sizeof(u32);
       if (num_dwords == 0)
               return 0;
 
-     num_dwords = CACHELINE_BYTES / sizeof(u32) - num_dwords;
+     num_dwords = CACHELINE_DWORDS - num_dwords;
+     GEM_BUG_ON(num_dwords & 1);
+
       cs = intel_ring_begin(rq, num_dwords);
       if (IS_ERR(cs))
               return PTR_ERR(cs);
 
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ringbuffer.c u32 *intel_ring_begin(struct i915_request *rq, unsigned int num_dwords) · line 1733

Quoted 3 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -3
-     while (num_dwords--)
-             *cs++ = MI_NOOP;
-

BUILD_BUG_ON(MI_NOOP != 0) for paranoid future proofing, since MI_NOOP is now not mentioned in this function, but is meant.

((u64)MI_NOOP << 32 | MI_NOOP) ?

That also works, can keep the r-b.

Regards,

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

#6 lore raw

✓ Fi.CI.IGT: success for drm/i915: Use memset64() to align the ring with MI_NOOP

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: drm/i915: Use memset64() to align the ring with MI_NOOP
URL : https://patchwork.freedesktop.org/series/42290/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4093_full -> Patchwork_8798_full =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_8798_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_8798_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/42290/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_8798_full:

=== IGT changes ===

    ==== Warnings ====

    igt@gem_mocs_settings@mocs-rc6-blt:
      shard-kbl:          PASS -> SKIP +2

== Known issues ==

Here are the changes found in Patchwork_8798_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_eio@in-flight-contexts-immediate:
      shard-glk:          PASS -> FAIL (fdo#105957)

    igt@kms_flip@2x-wf_vblank-ts-check:
      shard-hsw:          PASS -> FAIL (fdo#103928)

    igt@kms_mmio_vs_cs_flip@setcrtc_vs_cs_flip:
      shard-kbl:          PASS -> DMESG-WARN (fdo#103558, fdo#105602) +10

    
    ==== Possible fixes ====

    igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic:
      shard-hsw:          FAIL (fdo#104873) -> PASS

    igt@kms_flip@flip-vs-modeset-vs-hang-interruptible:
      shard-kbl:          DMESG-WARN (fdo#103558, fdo#105602) -> PASS +1
      shard-snb:          DMESG-WARN (fdo#103821) -> PASS

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1
      shard-hsw:          FAIL (fdo#100368) -> PASS

    igt@kms_frontbuffer_tracking@fbc-suspend:
      shard-kbl:          DMESG-WARN (fdo#103841, fdo#103558, fdo#105602) -> PASS

    igt@kms_sysfs_edid_timing:
      shard-apl:          WARN (fdo#100047) -> PASS

fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103821 https://bugs.freedesktop.org/show_bug.cgi?id=103821
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#105957 https://bugs.freedesktop.org/show_bug.cgi?id=105957

== Participating hosts (6 -> 5) ==

Missing (1): shard-glkb

== Build changes ==

* Linux: CI_DRM_4093 -> Patchwork_8798

CI_DRM_4093: a47694a9464b96e17b12f0bdb1085d10a61c57e9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4446: e5e8dafc991ee922ec159491c680caff0cfe9235 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8798: a2d0462fc7d03f71bc819c2e777d60c0fef38c58 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4446: a2f486679f467cd6e82578384f56d4aabaa8cf2e @ git://anongit.freedesktop.org/piglit

== Logs ==

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