Intel-GFX Archive on
 help / color / Atom feed
From: Daniel Vetter <>
To: Intel Graphics Development <>
Cc: Daniel Vetter <>
Subject: [PATCH] drm/i915: optimize the shmem_pwrite slowpath handling
Date: Thu, 15 Nov 2012 16:53:58 +0100
Message-ID: <> (raw)
In-Reply-To: <453bf0$>

Since we drop dev->struct_mutex when going through the slowpath, the
object might have been moved out of the cpu domain. Hence we need to
clflush the entire object to ensure that after the ioctl returns,
everything is coherent again (interwoven writes are ill-defined

But we only need to do this if we start in the cpu domain and the
object requires flushing for coherency. So don't do the flushing if
the object is coherent anyway or if we've done in-line clfushing

v2: i915_gem_clflush_object already checks whether the object is
coherent and if so, drops the flushing. Hence we don't need to check
that ourselves, simplifying the condition.

v3: Reorder the checks for better clarify (and adjust the comment
accordingly), suggested by Chris Wilson.

Signed-off-by: Daniel Vetter <>
 drivers/gpu/drm/i915/i915_gem.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index eaaf095..851f787 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -830,9 +830,13 @@ out:
 	if (hit_slowpath) {
-		/* Fixup: Flush dirty cachelines in case the object isn't in the
-		 * cpu write domain anymore. */
-		if (obj->base.write_domain != I915_GEM_DOMAIN_CPU) {
+		/*
+		 * Fixup: Flush cpu caches in case we didn't flush the dirty
+		 * cachelines in-line while writing and the object moved
+		 * out of the cpu write domain while we've dropped the lock.
+		 */
+		if (!needs_clflush_after &&
+		    obj->base.write_domain != I915_GEM_DOMAIN_CPU) {

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 14:40 [PATCH 1/2] drm/i915: simplify shmem pwrite/pread " Daniel Vetter
2012-11-15 14:40 ` [PATCH 2/2] drm/i915: optimize the shmem_pwrite " Daniel Vetter
2012-11-15 15:00   ` Chris Wilson
2012-11-15 15:02   ` Chris Wilson
2012-11-15 15:20     ` [PATCH] " Daniel Vetter
2012-11-15 15:37       ` Chris Wilson
2012-11-15 15:53         ` Daniel Vetter [this message]
2012-11-15 16:07           ` Chris Wilson
2012-11-29 12:49             ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Intel-GFX Archive on

Archives are clonable:
	git clone --mirror intel-gfx/git/0.git
	git clone --mirror intel-gfx/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 intel-gfx intel-gfx/ \
	public-inbox-index intel-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone