All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Avoid writing relocs with addresses in non-canonical form
@ 2015-12-04 11:33 Michał Winiarski
  2015-12-04 11:56 ` Ville Syrjälä
                   ` (7 more replies)
  0 siblings, 8 replies; 30+ messages in thread
From: Michał Winiarski @ 2015-12-04 11:33 UTC (permalink / raw)
  To: intel-gfx

According to bspec, some parts of HW expect the addresses to be in
a canonical form, where bits [63:48] == [47]. Let's convert addresses to
canonical form prior to relocating and return converted offsets to
userspace.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 9 ++++++---
 drivers/gpu/drm/i915/i915_gem_gtt.h        | 5 +++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index a4c243c..9f27be9 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -395,7 +395,7 @@ i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
 	target_i915_obj = target_vma->obj;
 	target_obj = &target_vma->obj->base;
 
-	target_offset = target_vma->node.start;
+	target_offset = gen8_canonical_addr(target_vma->node.start);
 
 	/* Sandybridge PPGTT errata: We need a global gtt mapping for MI and
 	 * pipe_control writes because the gpu doesn't properly redirect them
@@ -583,6 +583,7 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
 	struct drm_i915_gem_object *obj = vma->obj;
 	struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;
 	uint64_t flags;
+	uint64_t offset;
 	int ret;
 
 	flags = PIN_USER;
@@ -623,8 +624,10 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
 			entry->flags |= __EXEC_OBJECT_HAS_FENCE;
 	}
 
-	if (entry->offset != vma->node.start) {
-		entry->offset = vma->node.start;
+	offset = gen8_canonical_addr(vma->node.start);
+
+	if (entry->offset != offset) {
+		entry->offset = offset;
 		*need_reloc = true;
 	}
 
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 877c32c..65e8f88 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -507,6 +507,11 @@ static inline size_t gen8_pte_count(uint64_t address, uint64_t length)
 	return i915_pte_count(address, length, GEN8_PDE_SHIFT);
 }
 
+static inline uint64_t gen8_canonical_addr(uint64_t address)
+{
+	return ((int64_t)address << 16) >> 16;
+}
+
 static inline dma_addr_t
 i915_page_dir_dma_addr(const struct i915_hw_ppgtt *ppgtt, const unsigned n)
 {
-- 
2.5.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-01-05 10:01 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 11:33 [PATCH] drm/i915: Avoid writing relocs with addresses in non-canonical form Michał Winiarski
2015-12-04 11:56 ` Ville Syrjälä
2015-12-04 12:05 ` Chris Wilson
2015-12-04 15:20 ` [PATCH v2] " Michał Winiarski
2015-12-04 15:39   ` Chris Wilson
2015-12-04 16:18   ` Daniel Vetter
2015-12-04 17:41     ` Winiarski, Michal
2015-12-07  8:31       ` Daniel Vetter
2015-12-10 12:50   ` Chris Wilson
2015-12-11 14:13   ` [PATCH v3] " Michał Winiarski
2015-12-11 14:43     ` Michel Thierry
2015-12-18 16:31     ` Chris Wilson
2015-12-18 20:01     ` [PATCH v4] " Michał Winiarski
2015-12-18 20:26       ` Chris Wilson
2015-12-22 11:00       ` [PATCH v5] " Michał Winiarski
2015-12-22 11:41         ` Winiarski, Michal
2015-12-22 12:37         ` [PATCH v6] " Michał Winiarski
2015-12-22 15:00           ` Chris Wilson
2015-12-29 15:49           ` [PATCH v7] " Michał Winiarski
2015-12-29 16:25             ` Chris Wilson
2015-12-29 17:14             ` [PATCH v8] " Michał Winiarski
2015-12-29 17:24               ` [PATCH v9] " Michał Winiarski
2015-12-29 17:28                 ` Chris Wilson
2016-01-05 10:01                   ` Daniel Vetter
2015-12-29 17:25               ` [PATCH v8] " Chris Wilson
2015-12-19  8:20 ` ✗ warning: Fi.CI.BAT Patchwork
2015-12-22 11:13 ` Patchwork
2015-12-22 14:49 ` Patchwork
2015-12-29 16:20 ` ✗ failure: Fi.CI.BAT Patchwork
2015-12-29 17:49 ` ✗ warning: Fi.CI.BAT Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.