Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bde13ebd authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Introduce i915_ggtt_offset()



This little helper only exists to safely discard the upper unused 32bits
of the general 64-bit VMA address - as we know that all Global GTT
currently are less than 4GiB in size and so that the upper bits must be
zero. In many places, we use a u32 for the global GTT offset and we want
to document where we are discarding the full VMA offset.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471254551-25805-28-git-send-email-chris@chris-wilson.co.uk
parent 058d88c4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2008,7 +2008,7 @@ static void i915_dump_lrc_obj(struct seq_file *m,

	if (vma->flags & I915_VMA_GLOBAL_BIND)
		seq_printf(m, "\tBound in GGTT at 0x%08x\n",
			   lower_32_bits(vma->node.start));
			   i915_ggtt_offset(vma));

	if (i915_gem_object_get_pages(vma->obj)) {
		seq_puts(m, "\tFailed to get pages for context object\n\n");
+1 −1
Original line number Diff line number Diff line
@@ -3330,7 +3330,7 @@ static inline unsigned long
i915_gem_object_ggtt_offset(struct drm_i915_gem_object *o,
			    const struct i915_ggtt_view *view)
{
	return i915_gem_object_to_ggtt(o, view)->node.start;
	return i915_ggtt_offset(i915_gem_object_to_ggtt(o, view));
}

/* i915_gem_fence.c */
+5 −6
Original line number Diff line number Diff line
@@ -767,7 +767,7 @@ i915_gem_gtt_pread(struct drm_device *dev,

		i915_gem_object_pin_pages(obj);
	} else {
		node.start = vma->node.start;
		node.start = i915_ggtt_offset(vma);
		node.allocated = false;
		ret = i915_gem_object_put_fence(obj);
		if (ret)
@@ -1071,7 +1071,7 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_private *i915,

		i915_gem_object_pin_pages(obj);
	} else {
		node.start = vma->node.start;
		node.start = i915_ggtt_offset(vma);
		node.allocated = false;
		ret = i915_gem_object_put_fence(obj);
		if (ret)
@@ -1712,7 +1712,7 @@ int i915_gem_fault(struct vm_area_struct *area, struct vm_fault *vmf)
		goto err_unpin;

	/* Finally, remap it using the new GTT offset */
	pfn = ggtt->mappable_base + vma->node.start;
	pfn = ggtt->mappable_base + i915_ggtt_offset(vma);
	pfn >>= PAGE_SHIFT;

	if (unlikely(view.type == I915_GGTT_VIEW_PARTIAL)) {
@@ -3759,10 +3759,9 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,

		WARN(i915_vma_is_pinned(vma),
		     "bo is already pinned in ggtt with incorrect alignment:"
		     " offset=%08x %08x, req.alignment=%llx, req.map_and_fenceable=%d,"
		     " offset=%08x, req.alignment=%llx, req.map_and_fenceable=%d,"
		     " obj->map_and_fenceable=%d\n",
		     upper_32_bits(vma->node.start),
		     lower_32_bits(vma->node.start),
		     i915_ggtt_offset(vma),
		     alignment,
		     !!(flags & PIN_MAPPABLE),
		     obj->map_and_fenceable);
+4 −2
Original line number Diff line number Diff line
@@ -631,7 +631,8 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)

	intel_ring_emit(ring, MI_NOOP);
	intel_ring_emit(ring, MI_SET_CONTEXT);
	intel_ring_emit(ring, req->ctx->engine[RCS].state->node.start | flags);
	intel_ring_emit(ring,
			i915_ggtt_offset(req->ctx->engine[RCS].state) | flags);
	/*
	 * w/a: MI_SET_CONTEXT must always be followed by MI_NOOP
	 * WaMiSetContext_Hang:snb,ivb,vlv
@@ -660,7 +661,8 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
					MI_STORE_REGISTER_MEM |
					MI_SRM_LRM_GLOBAL_GTT);
			intel_ring_emit_reg(ring, last_reg);
			intel_ring_emit(ring, engine->scratch->node.start);
			intel_ring_emit(ring,
					i915_ggtt_offset(engine->scratch));
			intel_ring_emit(ring, MI_NOOP);
		}
		intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_ENABLE);
+9 −0
Original line number Diff line number Diff line
@@ -272,6 +272,15 @@ static inline bool i915_vma_has_active_engine(const struct i915_vma *vma,
	return vma->active & BIT(engine);
}

static inline u32 i915_ggtt_offset(const struct i915_vma *vma)
{
	GEM_BUG_ON(!i915_vma_is_ggtt(vma));
	GEM_BUG_ON(!vma->node.allocated);
	GEM_BUG_ON(upper_32_bits(vma->node.start));
	GEM_BUG_ON(upper_32_bits(vma->node.start + vma->node.size - 1));
	return lower_32_bits(vma->node.start);
}

struct i915_page_dma {
	struct page *page;
	union {
Loading