All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 45/64] drm/i915: Store owning file on the i915_address_space
Date: Thu,  7 Jul 2016 09:41:51 +0100	[thread overview]
Message-ID: <1467880930-23082-45-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1467880930-23082-1-git-send-email-chris@chris-wilson.co.uk>

For the global GTT (and aliasing GTT), the address space is owned by the
device (it is a global resource) and so the per-file owner field is
NULL. For per-process GTT (where we create an address space per
context), each is owned by the opening file. We can use this ownership
information to both distinguish GGTT and ppGTT address spaces, as well
as occasionally inspect the owner.

v2: Whitespace, tells us who owns i915_address_space

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_debugfs.c     |  2 +-
 drivers/gpu/drm/i915/i915_drv.h         |  1 -
 drivers/gpu/drm/i915/i915_gem_context.c |  3 ++-
 drivers/gpu/drm/i915/i915_gem_gtt.c     | 30 +++++++++++++++---------------
 drivers/gpu/drm/i915/i915_gem_gtt.h     | 17 +++++++++++------
 5 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index c7dd739eada5..327064823bb0 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -356,7 +356,7 @@ static int per_file_stats(int id, void *ptr, void *data)
 				= container_of(vma->vm,
 					       struct i915_hw_ppgtt,
 					       base);
-			if (ppgtt->file_priv != stats->file_priv)
+			if (ppgtt->base.file != stats->file_priv)
 				continue;
 		}
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 66490046ab37..a19d18ea074e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3280,7 +3280,6 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)
 	return container_of(vm, struct i915_hw_ppgtt, base);
 }
 
-
 static inline bool i915_gem_obj_ggtt_bound(struct drm_i915_gem_object *obj)
 {
 	return i915_gem_obj_ggtt_bound_view(obj, &i915_ggtt_view_normal);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index ed071fb1b713..c213fafe41d9 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -327,7 +327,8 @@ i915_gem_create_context(struct drm_device *dev,
 		return ctx;
 
 	if (USES_FULL_PPGTT(dev)) {
-		struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv);
+		struct i915_hw_ppgtt *ppgtt =
+			i915_ppgtt_create(to_i915(dev), file_priv);
 
 		if (IS_ERR(ppgtt)) {
 			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 5b09db68df73..c25117bed1e9 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2107,11 +2107,12 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
 	return 0;
 }
 
-static int __hw_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
+static int __hw_ppgtt_init(struct i915_hw_ppgtt *ppgtt,
+			   struct drm_i915_private *dev_priv)
 {
-	ppgtt->base.dev = dev;
+	ppgtt->base.dev = &dev_priv->drm;
 
-	if (INTEL_INFO(dev)->gen < 8)
+	if (INTEL_INFO(dev_priv)->gen < 8)
 		return gen6_ppgtt_init(ppgtt);
 	else
 		return gen8_ppgtt_init(ppgtt);
@@ -2146,15 +2147,17 @@ static void gtt_write_workarounds(struct drm_device *dev)
 		I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT);
 }
 
-static int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
+static int i915_ppgtt_init(struct i915_hw_ppgtt *ppgtt,
+			   struct drm_i915_private *dev_priv,
+			   struct drm_i915_file_private *file_priv)
 {
-	struct drm_i915_private *dev_priv = to_i915(dev);
-	int ret = 0;
+	int ret;
 
-	ret = __hw_ppgtt_init(dev, ppgtt);
+	ret = __hw_ppgtt_init(ppgtt, dev_priv);
 	if (ret == 0) {
 		kref_init(&ppgtt->ref);
 		i915_address_space_init(&ppgtt->base, dev_priv);
+		ppgtt->base.file = file_priv;
 	}
 
 	return ret;
@@ -2186,7 +2189,8 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
 }
 
 struct i915_hw_ppgtt *
-i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
+i915_ppgtt_create(struct drm_i915_private *dev_priv,
+		  struct drm_i915_file_private *fpriv)
 {
 	struct i915_hw_ppgtt *ppgtt;
 	int ret;
@@ -2195,14 +2199,12 @@ i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
 	if (!ppgtt)
 		return ERR_PTR(-ENOMEM);
 
-	ret = i915_ppgtt_init(dev, ppgtt);
+	ret = i915_ppgtt_init(ppgtt, dev_priv, fpriv);
 	if (ret) {
 		kfree(ppgtt);
 		return ERR_PTR(ret);
 	}
 
-	ppgtt->file_priv = fpriv;
-
 	trace_i915_ppgtt_create(&ppgtt->base);
 
 	return ppgtt;
@@ -2792,9 +2794,8 @@ int i915_gem_init_ggtt(struct drm_device *dev)
 		if (!ppgtt)
 			return -ENOMEM;
 
-		ret = __hw_ppgtt_init(dev, ppgtt);
+		ret = __hw_ppgtt_init(ppgtt, dev_priv);
 		if (ret) {
-			ppgtt->base.cleanup(&ppgtt->base);
 			kfree(ppgtt);
 			return ret;
 		}
@@ -3220,7 +3221,6 @@ int i915_ggtt_init_hw(struct drm_device *dev)
 	}
 
 	ggtt->base.dev = dev;
-	ggtt->base.is_ggtt = true;
 
 	ret = ggtt->probe(ggtt);
 	if (ret)
@@ -3312,7 +3312,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
 
 			struct i915_hw_ppgtt *ppgtt;
 
-			if (vm->is_ggtt)
+			if (i915_is_ggtt(vm))
 				ppgtt = dev_priv->mm.aliasing_ppgtt;
 			else
 				ppgtt = i915_vm_to_ppgtt(vm);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index a0370bf950f5..33cc010e90f5 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -272,12 +272,19 @@ struct i915_pml4 {
 struct i915_address_space {
 	struct drm_mm mm;
 	struct drm_device *dev;
+	/* Every address space belongs to a struct file - except for the global
+	 * GTT that is owned by the driver (and so @file is set to NULL). In
+	 * principle, no information should leak from one context to another
+	 * (or between files/processes etc) unless explicitly shared by the
+	 * owner. Tracking the owner is important in order to free up per-file
+	 * objects along with the file, to aide resource tracking, and to
+	 * assign blame.
+	 */
+	struct drm_i915_file_private *file;
 	struct list_head global_link;
 	u64 start;		/* Start offset always 0 for dri2 */
 	u64 total;		/* size addr space maps (ex. 2GB for ggtt) */
 
-	bool is_ggtt;
-
 	struct i915_page_scratch *scratch_page;
 	struct i915_page_table *scratch_pt;
 	struct i915_page_directory *scratch_pd;
@@ -338,7 +345,7 @@ struct i915_address_space {
 			u32 flags);
 };
 
-#define i915_is_ggtt(V) ((V)->is_ggtt)
+#define i915_is_ggtt(V) (!(V)->file)
 
 /* The Graphics Translation Table is the way in which GEN hardware translates a
  * Graphics Virtual Address into a Physical Address. In addition to the normal
@@ -380,8 +387,6 @@ struct i915_hw_ppgtt {
 		struct i915_page_directory pd;		/* GEN6-7 */
 	};
 
-	struct drm_i915_file_private *file_priv;
-
 	gen6_pte_t __iomem *pd_addr;
 
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
@@ -528,7 +533,7 @@ void i915_ggtt_cleanup_hw(struct drm_device *dev);
 
 int i915_ppgtt_init_hw(struct drm_device *dev);
 void i915_ppgtt_release(struct kref *kref);
-struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
+struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_i915_private *dev_priv,
 					struct drm_i915_file_private *fpriv);
 static inline void i915_ppgtt_get(struct i915_hw_ppgtt *ppgtt)
 {
-- 
2.8.1

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

  parent reply	other threads:[~2016-07-07  8:43 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07  8:41 [PATCH 01/64] drm/i915/breadcrumbs: Queue hangcheck before sleeping Chris Wilson
2016-07-07  8:41 ` [PATCH 02/64] drm/i915: Preserve current RPS frequency across init Chris Wilson
2016-07-07  8:41 ` [PATCH 03/64] drm/i915: Remove superfluous powersave work flushing Chris Wilson
2016-07-07  8:41 ` [PATCH 04/64] drm/i915: Defer enabling rc6 til after we submit the first batch/context Chris Wilson
2016-07-07  8:41 ` [PATCH 05/64] drm/i915: Remove temporary RPM wakeref assert disables Chris Wilson
2016-07-07  8:41 ` [PATCH 06/64] drm: Restore double clflush on the last partial cacheline Chris Wilson
2016-07-12 13:57   ` Daniel Vetter
2016-07-12 13:57     ` Daniel Vetter
2016-07-13  8:07     ` [Intel-gfx] " Mika Kuoppala
2016-07-13  8:07       ` Mika Kuoppala
2016-07-07  8:41 ` [PATCH 07/64] drm/i915: Move GEM request routines to i915_gem_request.c Chris Wilson
2016-07-07  8:41 ` [PATCH 08/64] drm/i915: Retire oldest completed request before allocating next Chris Wilson
2016-07-07  9:41   ` Tvrtko Ursulin
2016-07-07  9:45     ` Chris Wilson
2016-07-07 10:03       ` Tvrtko Ursulin
2016-07-07 10:10         ` Chris Wilson
2016-07-08  9:21   ` Mika Kuoppala
2016-07-08  9:28     ` Chris Wilson
2016-07-07  8:41 ` [PATCH 09/64] drm/i915: Mark all current requests as complete before resetting them Chris Wilson
2016-07-07 16:09   ` Mika Kuoppala
2016-07-07  8:41 ` [PATCH 10/64] drm/i915: Derive GEM requests from dma-fence Chris Wilson
2016-07-07  8:41 ` [PATCH 11/64] drm/i915: Disable waitboosting for fence_wait() Chris Wilson
2016-07-07  8:41 ` [PATCH 12/64] drm/i915: Disable waitboosting for mmioflips/semaphores Chris Wilson
2016-07-07  8:41 ` [PATCH 13/64] drm/i915: Export our request as a dma-buf fence on the reservation object Chris Wilson
2016-07-07  8:41 ` [PATCH 14/64] drm/i915: Wait on external rendering for GEM objects Chris Wilson
2016-07-07  8:41 ` [PATCH 15/64] drm/i915: Mark imported dma-buf objects as being coherent Chris Wilson
2016-07-07  8:41 ` [PATCH 16/64] drm/i915: Rename request reference/unreference to get/put Chris Wilson
2016-07-07  8:41 ` [PATCH 17/64] drm/i915: Rename i915_gem_context_reference/unreference() Chris Wilson
2016-07-07  8:41 ` [PATCH 18/64] drm/i915: Wrap drm_gem_object_lookup in i915_gem_object_lookup Chris Wilson
2016-07-07  8:41 ` [PATCH 19/64] drm/i915: Wrap drm_gem_object_reference in i915_gem_object_get Chris Wilson
2016-07-07  8:41 ` [PATCH 20/64] drm/i915: Rename drm_gem_object_unreference in preparation for lockless free Chris Wilson
2016-07-07  8:41 ` [PATCH 21/64] drm/i915: Rename drm_gem_object_unreference_unlocked " Chris Wilson
2016-07-07  8:41 ` [PATCH 22/64] drm/i915: Treat ringbuffer writes as write to normal memory Chris Wilson
2016-07-07  8:41 ` [PATCH 23/64] drm/i915: Rename ring->virtual_start as ring->vaddr Chris Wilson
2016-07-07  8:41 ` [PATCH 24/64] drm/i915: Convert i915_semaphores_is_enabled over to early sanitize Chris Wilson
2016-07-07  8:41 ` [PATCH 25/64] drm/i915: Unify intel_logical_ring_emit and intel_ring_emit Chris Wilson
2016-07-07  8:41 ` [PATCH 26/64] drm/i915: Rename request->ringbuf to request->ring Chris Wilson
2016-07-07  8:41 ` [PATCH 27/64] drm/i915: Rename backpointer from intel_ringbuffer to intel_engine_cs Chris Wilson
2016-07-07  8:41 ` [PATCH 28/64] drm/i915: Rename intel_context[engine].ringbuf Chris Wilson
2016-07-07  8:41 ` [PATCH 29/64] drm/i915: Rename struct intel_ringbuffer to struct intel_ring Chris Wilson
2016-07-07  8:41 ` [PATCH 30/64] drm/i915: Rename residual ringbuf parameters Chris Wilson
2016-07-07  8:41 ` [PATCH 31/64] drm/i915: Rename intel_pin_and_map_ring() Chris Wilson
2016-07-07  8:41 ` [PATCH 32/64] drm/i915: Remove obsolete engine->gpu_caches_dirty Chris Wilson
2016-07-07  8:41 ` [PATCH 33/64] drm/i915: Simplify request_alloc by returning the allocated request Chris Wilson
2016-07-07  8:41 ` [PATCH 34/64] drm/i915: Unify legacy/execlists emission of MI_BATCHBUFFER_START Chris Wilson
2016-07-07  8:41 ` [PATCH 35/64] drm/i915: Convert engine->write_tail to operate on a request Chris Wilson
2016-07-07  8:41 ` [PATCH 36/64] drm/i915: Unify request submission Chris Wilson
2016-07-07  8:41 ` [PATCH 37/64] drm/i915: Stop passing caller's num_dwords to engine->semaphore.signal() Chris Wilson
2016-07-07  8:41 ` [PATCH 38/64] drm/i915: Reuse legacy breadcrumbs + tail emission Chris Wilson
2016-07-07  8:41 ` [PATCH 39/64] drm/i915/ringbuffer: Specialise SNB+ request emission for semaphores Chris Wilson
2016-07-07  8:41 ` [PATCH 40/64] drm/i915: Remove duplicate golden render state init from execlists Chris Wilson
2016-07-07  8:41 ` [PATCH 41/64] drm/i915: Unify legacy/execlists submit_execbuf callbacks Chris Wilson
2016-07-07  8:41 ` [PATCH 42/64] drm/i915: Simplify calling engine->sync_to Chris Wilson
2016-07-07  8:41 ` [PATCH 43/64] drm/i915: Amalgamate GGTT/ppGTT vma debug list walkers Chris Wilson
2016-07-07  8:41 ` [PATCH 44/64] drm/i915: Split early global GTT initialisation Chris Wilson
2016-07-07  8:41 ` Chris Wilson [this message]
2016-07-07  8:41 ` [PATCH 46/64] drm/i915: Count how many VMA are bound for an object Chris Wilson
2016-07-12 14:30   ` Tvrtko Ursulin
2016-07-12 14:38     ` Chris Wilson
2016-07-12 15:12       ` Tvrtko Ursulin
2016-07-12 16:08         ` Chris Wilson
2016-07-07  8:41 ` [PATCH 47/64] drm/i915: Be more careful when unbinding vma Chris Wilson
2016-07-12 15:04   ` Tvrtko Ursulin
2016-07-12 16:42     ` Chris Wilson
2016-07-13  8:53       ` Tvrtko Ursulin
2016-07-07  8:41 ` [PATCH 48/64] drm/i915: Kill drop_pages() Chris Wilson
2016-07-12 15:14   ` Tvrtko Ursulin
2016-07-07  8:41 ` [PATCH 49/64] drm/i915: Introduce i915_gem_active for request tracking Chris Wilson
2016-07-12 16:05   ` Tvrtko Ursulin
2016-07-12 16:30     ` Chris Wilson
2016-07-13  8:54       ` Tvrtko Ursulin
2016-07-07  8:41 ` [PATCH 50/64] drm/i915: Prepare i915_gem_active for annotations Chris Wilson
2016-07-13 15:40   ` Tvrtko Ursulin
2016-07-13 15:58     ` Chris Wilson
2016-07-14  9:32       ` Tvrtko Ursulin
2016-07-14 10:04         ` Chris Wilson
2016-07-07  8:41 ` [PATCH 51/64] drm/i915: Mark up i915_gem_active for locking annotation Chris Wilson
2016-07-07  8:41 ` [PATCH 52/64] drm/i915: Refactor blocking waits Chris Wilson
2016-07-07  8:41 ` [PATCH 53/64] drm/i915: Rename request->list to link for consistency Chris Wilson
2016-07-07  8:42 ` [PATCH 54/64] drm/i915: Remove obsolete i915_gem_object_flush_active() Chris Wilson
2016-07-07  8:42 ` [PATCH 55/64] drm/i915: Refactor activity tracking for requests Chris Wilson
2016-07-07  8:42 ` [PATCH 56/64] drm/i915: Convert intel_overlay to request tracking Chris Wilson
2016-07-07  8:42 ` [PATCH 57/64] drm/i915: Move the special case wait-request handling to its one caller Chris Wilson
2016-07-07  8:42 ` [PATCH 58/64] drm/i915: Double check activity before relocations Chris Wilson
2016-07-07  8:42 ` [PATCH 59/64] drm/i915: Move request list retirement to i915_gem_request.c Chris Wilson
2016-07-07  8:42 ` [PATCH 60/64] drm/i915: i915_vma_move_to_active prep patch Chris Wilson
2016-07-07  8:42 ` [PATCH 61/64] drm/i915: Track active vma requests Chris Wilson
2016-07-07  8:42 ` [PATCH 62/64] drm/i915: Release vma when the handle is closed Chris Wilson
2016-07-07  8:42 ` [PATCH 63/64] drm/i915: Mark the context and address space as closed Chris Wilson
2016-07-07  8:42 ` [PATCH 64/64] Revert "drm/i915: Clean up associated VMAs on context destruction" Chris Wilson
2016-07-07  9:12 ` ✗ Ro.CI.BAT: warning for series starting with [01/64] drm/i915/breadcrumbs: Queue hangcheck before sleeping Patchwork
2016-07-07  9:28   ` Chris Wilson
2016-07-08  8:44     ` Chris Wilson

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=1467880930-23082-45-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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 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.