From: Ben Widawsky <benjamin.widawsky@intel.com>
To: Intel GFX <intel-gfx@lists.freedesktop.org>
Cc: Ben Widawsky <ben@bwidawsk.net>,
Ben Widawsky <benjamin.widawsky@intel.com>
Subject: [PATCH 1/8] drm/i915: Synchronize pread/pwrite with wait_rendering
Date: Fri, 30 Aug 2013 16:43:54 -0700 [thread overview]
Message-ID: <1377906241-8463-2-git-send-email-benjamin.widawsky@intel.com> (raw)
In-Reply-To: <1377906241-8463-1-git-send-email-benjamin.widawsky@intel.com>
lifted from Daniel:
pread/pwrite isn't about the object's domain at all, but purely about
synchronizing for outstanding rendering. Replacing the call to
set_to_gtt_domain with a wait_rendering would imo improve code
readability. Furthermore we could pimp pread to only block for
outstanding writes and not for reads.
Since you're not the first one to trip over this: Can I volunteer you
for a follow-up patch to fix this?
Recommended-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_gem.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f026153..a839bcb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -41,6 +41,9 @@ static void i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object *o
static void i915_gem_object_flush_cpu_write_domain(struct drm_i915_gem_object *obj,
bool force);
static __must_check int
+i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj,
+ bool readonly);
+static __must_check int
i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
struct i915_address_space *vm,
unsigned alignment,
@@ -430,11 +433,9 @@ i915_gem_shmem_pread(struct drm_device *dev,
* optimizes for the case when the gpu will dirty the data
* anyway again before the next pread happens. */
needs_clflush = !cpu_cache_is_coherent(dev, obj->cache_level);
- if (i915_gem_obj_bound_any(obj)) {
- ret = i915_gem_object_set_to_gtt_domain(obj, false);
- if (ret)
- return ret;
- }
+ ret = i915_gem_object_wait_rendering(obj, false);
+ if (ret)
+ return ret;
}
ret = i915_gem_object_get_pages(obj);
@@ -746,11 +747,9 @@ i915_gem_shmem_pwrite(struct drm_device *dev,
* optimizes for the case when the gpu will use the data
* right away and we therefore have to clflush anyway. */
needs_clflush_after = cpu_write_needs_clflush(obj);
- if (i915_gem_obj_bound_any(obj)) {
- ret = i915_gem_object_set_to_gtt_domain(obj, true);
- if (ret)
- return ret;
- }
+ ret = i915_gem_object_wait_rendering(obj, false);
+ if (ret)
+ return ret;
}
/* Same trick applies to invalidate partially written cachelines read
* before writing. */
--
1.8.4
next prev parent reply other threads:[~2013-08-30 23:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 23:43 [PATCH 0/8] [RESEND] VMA patches Ben Widawsky
2013-08-30 23:43 ` Ben Widawsky [this message]
2013-08-30 23:50 ` [PATCH 1/8] drm/i915: Synchronize pread/pwrite with wait_rendering Chris Wilson
2013-08-31 3:39 ` Ben Widawsky
2013-09-02 6:32 ` Daniel Vetter
2013-09-02 13:14 ` Chris Wilson
2013-09-02 14:12 ` Daniel Vetter
2013-09-03 16:08 ` Daniel Vetter
2013-09-03 23:53 ` Ben Widawsky
2013-08-30 23:43 ` [PATCH 2/8] drm/i915: Extract vm specific part of eviction Ben Widawsky
2013-08-30 23:52 ` Chris Wilson
2013-08-31 3:39 ` Ben Widawsky
2013-08-30 23:43 ` [PATCH 3/8] drm/i915: evict VM instead of everything Ben Widawsky
2013-08-31 0:04 ` Chris Wilson
2013-08-30 23:43 ` [PATCH 4/8] drm/i915: trace vm eviction " Ben Widawsky
2013-08-31 0:06 ` Chris Wilson
2013-08-31 3:40 ` Ben Widawsky
2013-08-30 23:43 ` [PATCH 5/8] drm/i915: Convert active API to VMA Ben Widawsky
2013-08-31 0:08 ` Chris Wilson
2013-08-30 23:43 ` [PATCH 6/8] drm/i915: Add bind/unbind object functions to VM Ben Widawsky
2013-08-31 0:12 ` Chris Wilson
2013-08-31 3:40 ` Ben Widawsky
2013-09-03 14:48 ` Chris Wilson
2013-09-02 12:46 ` Ville Syrjälä
2013-09-04 0:20 ` Ben Widawsky
2013-09-04 7:31 ` Ville Syrjälä
2013-08-30 23:44 ` [PATCH 7/8] drm/i915: Use the new vm [un]bind functions Ben Widawsky
2013-08-30 23:44 ` [PATCH 8/8] drm/i915: eliminate vm->insert_entries() Ben Widawsky
-- strict thread matches above, loose matches on Subject: below --
2013-09-11 21:57 [PATCH 1/8] drm/i915: Synchronize pread/pwrite with wait_rendering Ben Widawsky
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377906241-8463-2-git-send-email-benjamin.widawsky@intel.com \
--to=benjamin.widawsky@intel.com \
--cc=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox