Skip to contentSkip to conversation

drm/i915: set scan-buffer as uncached on Sandybridge

PATCH Superseded Zhenyu Wang 5 participants 7 messages Oct 25, 2010 – Oct 26, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: set scan-buffer as uncached on Sandybridge

Display engine on Sandybridge is not coherent with LLC, so try to always bind display buffer as uncached on Sandybridge. This fixed screen artifacts seen by using blit engine on Sandybridge.

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 3a98bea..5200ee3 100644
@@ -34,6 +34,7 @@
 #include "intel_bios.h"
 #include "intel_ringbuffer.h"
 #include <linux/io-mapping.h>
+#include <linux/intel-gtt.h>
 
 /* General customization:
  */
drivers/gpu/drm/i915/intel_display.c +8 -0
index 9792285..46d724f 100644
@@ -1579,6 +1579,14 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	obj = intel_fb->obj;
 	obj_priv = to_intel_bo(obj);
 
+	/* 
+	 *  Set uncacheable for scan-out buffer on Sandybridge.
+	 *  Display engine is non-coherent with LLC, and read from
+	 *  main memory only. This ensures data is coherent with display.
+	 */
+	if (IS_GEN6(dev))
+		obj_priv->agp_type = AGP_USER_UNCACHED_MEMORY;
+
 	mutex_lock(&dev->struct_mutex);
 	ret = intel_pin_and_fence_fb_obj(dev, obj);
 	if (ret != 0) {
Signature · 1 line
1.7.1
#1 lore raw

[I haven't seen my first email arrive yet...]

Quoted 3 lines · Zhenyu Wang

Display engine on Sandybridge is not coherent with LLC, so try to always bind display buffer as uncached on Sandybridge. This fixed screen artifacts seen by using blit engine on Sandybridge.

[snip]

drivers/gpu/drm/i915/intel_display.c intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, · line 1589

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
@@ -1579,6 +1579,14 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 	obj = intel_fb->obj;
 	obj_priv = to_intel_bo(obj);
 
+	/* 
+	 *  Set uncacheable for scan-out buffer on Sandybridge.
+	 *  Display engine is non-coherent with LLC, and read from
+	 *  main memory only. This ensures data is coherent with display.
+	 */
+	if (IS_GEN6(dev))
+		obj_priv->agp_type = AGP_USER_UNCACHED_MEMORY;
+

[Quick recap of first email]
You can't do this here, changing the AGP type of a potentially bound object without any locking.

Move this into intel_pin_and_fence_fb_obj(), give it a decent name and make it robust.

int i915_gem_object_enable_scanout(struct drm_i915_gem_object *obj)

{
	int type = IS_GEN6(dev) ? AGP_USER_UNCACHED_MEMORY : AGP_USER_MEMORY;

/* These names are absolutely terrible. we should have just made
* AGR_USER_CACHED_MEMORY the default on gen6 and kept the AGP_USER_MEMORY
* as uncached on all generations, rather than mixing up the cacheability
* status of common enums.
*/

	if (obj->agp_type == type)
		return 0;

	if (obj->gtt_space) {
		int ret = i915_gem_object_unbind(&obj->base);
		if (ret)
			return ret;
	}

	obj->agp_type = type;
	return 0;
}

[And the additional bit of insight...]

Also add a call from intel_user_framebuffer_create, as being the earliest opportunity to avoid the unbind penalty. What is the performance impact of rendering to an uncached buffer on Sandybridge? Should we only be changing the caching status whilst pinned as the framebuffer? Rather than unbinding/rebinding, should we introduce a function [once we have a native GTT interface, Daniel!] to simply update the flags on the PTEs for an object (obviously with suitable flushing).
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw

Hi Chris,
We only need front buffer to be uncached.
I think that will not affect performance since GPU will seldom read back from front buffer. We will measure performance on that.
Thanks
Zou Nan hai

Quoted 73 lines
Quoted 73 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Chris Wilson
Sent: 2010年10月25日 16:23
To: Zhenyu Wang; [email protected]
Cc: stable team
Subject: Re: [Intel-gfx] [PATCH] drm/i915: set scan-buffer as uncached on Sandybridge

[I haven't seen my first email arrive yet...]

Quoted 3 lines · Zhenyu Wang

Display engine on Sandybridge is not coherent with LLC, so try to always bind display buffer as uncached on Sandybridge. This fixed screen artifacts seen by using blit engine on Sandybridge.

[snip]

Review intel_pipe_set_base(struct drm_crtc *crtc, int x, int

Quoted 1 line
(quoted diff) +0 -0
@@ -1579,6 +1579,14 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int

y,

drivers/gpu/drm/i915/intel_display.c intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, · line 1589

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
 	obj = intel_fb->obj;
 	obj_priv = to_intel_bo(obj);
 
+	/*
+	 *  Set uncacheable for scan-out buffer on Sandybridge.
+	 *  Display engine is non-coherent with LLC, and read from
+	 *  main memory only. This ensures data is coherent with display.
+	 */
+	if (IS_GEN6(dev))
+		obj_priv->agp_type = AGP_USER_UNCACHED_MEMORY;
+

[Quick recap of first email]
You can't do this here, changing the AGP type of a potentially bound object without any locking.

Move this into intel_pin_and_fence_fb_obj(), give it a decent name and make it robust.

int i915_gem_object_enable_scanout(struct drm_i915_gem_object *obj)

{
	int type = IS_GEN6(dev) ? AGP_USER_UNCACHED_MEMORY : AGP_USER_MEMORY;

/* These names are absolutely terrible. we should have just made
* AGR_USER_CACHED_MEMORY the default on gen6 and kept the AGP_USER_MEMORY
* as uncached on all generations, rather than mixing up the cacheability
* status of common enums.
*/

	if (obj->agp_type == type)
		return 0;

	if (obj->gtt_space) {
		int ret = i915_gem_object_unbind(&obj->base);
		if (ret)
			return ret;
	}

	obj->agp_type = type;
	return 0;
}

[And the additional bit of insight...]

Also add a call from intel_user_framebuffer_create, as being the earliest opportunity to avoid the unbind penalty. What is the performance impact of rendering to an uncached buffer on Sandybridge? Should we only be changing the caching status whilst pinned as the framebuffer? Rather than unbinding/rebinding, should we introduce a function [once we have a native GTT interface, Daniel!] to simply update the flags on the PTEs for an object (obviously with suitable flushing).
-Chris

Quoted 6 lines
Quoted 6 lines

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

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

#3 lore raw

Hi,

Quoted 3 lines

       We only need front buffer to be uncached.
       I think that will not affect performance since GPU will seldom read back from front buffer. We will measure performance on that.

At least here I have a couple of apps reading back from frontbuffer, and performance on i945+2.13 is horrible.
No idea if it would be worse on SandyBridge if access is uncached, but even slower would *really* hurt.

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

#4 lore raw
Quoted 13 lines
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Clemens Eisserer
Sent: 2010年10月25日 18:31
To: intel-gfx
Subject: Re: [Intel-gfx] [PATCH] drm/i915: set scan-buffer as uncached on Sandybridge

Hi,

Quoted 2 lines

       We only need front buffer to be uncached.
       I think that will not affect performance since GPU will seldom read

Quoted 7 lines
Quoted 7 lines

back from front buffer.

Quoted 1 line

       We will measure performance on that.

At least here I have a couple of apps reading back from frontbuffer, and performance on i945+2.13 is horrible.
No idea if it would be worse on SandyBridge if access is uncached, but even slower would *really* hurt.

Are you reading back from CPU or GPU?

Thanks
Zou Nan hai

Quoted 6 lines
Quoted 6 lines

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

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

#5 lore raw
In reply to Chris Wilson
Quoted 5 lines · Chris Wilson

You can't do this here, changing the AGP type of a potentially bound object without any locking.

Move this into intel_pin_and_fence_fb_obj(), give it a decent name and make it robust.

oh, right, thanks for point this out.

Quoted 23 lines

int i915_gem_object_enable_scanout(struct drm_i915_gem_object *obj)

{
	int type = IS_GEN6(dev) ? AGP_USER_UNCACHED_MEMORY : AGP_USER_MEMORY;

/* These names are absolutely terrible. we should have just made
* AGR_USER_CACHED_MEMORY the default on gen6 and kept the AGP_USER_MEMORY
* as uncached on all generations, rather than mixing up the cacheability
* status of common enums.
*/

	if (obj->agp_type == type)
		return 0;

	if (obj->gtt_space) {
		int ret = i915_gem_object_unbind(&obj->base);
		if (ret)
			return ret;
	}

	obj->agp_type = type;
	return 0;
}
Quoted 5 lines

[And the additional bit of insight...]

Also add a call from intel_user_framebuffer_create, as being the earliest opportunity to avoid the unbind penalty. What is the performance impact of rendering to an uncached buffer on Sandybridge?

I also did another way to fix this by using new GFDT flag for each PTE. Now every flush method for any ring has the ability to sync pages with GFDT bit set, so scan-buffer could be set with GFDT and ensure it's got flush out in time and synced. But we've been told uncached display buffer setting on sandybridge is the plan to go..

Quoted 7 lines

Should we only be changing
the caching status whilst pinned as the framebuffer? Rather than unbinding/rebinding, should we introduce a function [once we have a native GTT interface, Daniel!] to simply update the flags on the PTEs for an object (obviously with suitable flushing).
-Chris

Signature · 3 lines
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

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

maintainer
#6 lore raw
In reply to Zhenyu Wang
Quoted 3 lines · Zhenyu Wang

Display engine on Sandybridge is not coherent with LLC, so try to always bind display buffer as uncached on Sandybridge. This fixed screen artifacts seen by using blit engine on Sandybridge.

Also I assume you need to set this back to the other state on unbind, for pageflipping type apps where we'd reuse the buffers.

Dave.