All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 04/15] drm/i915: Track file_priv, not ctx in the ppgtt structure
Date: Wed,  6 Aug 2014 15:04:47 +0200	[thread overview]
Message-ID: <1407330298-27065-4-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1407330298-27065-1-git-send-email-daniel.vetter@ffwll.ch>

Hardware contexts reference a ppgtt, not the other way round. And the
only user of this (in debugfs) actually only cares about which file
the ppgtt is associated with. So give it what it wants.

While at it give the ppgtt create function a proper name&place.

Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_debugfs.c     |  2 +-
 drivers/gpu/drm/i915/i915_gem_context.c | 22 +---------------------
 drivers/gpu/drm/i915/i915_gem_gtt.c     | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_gtt.h     |  6 +++++-
 4 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 330caa1ab9f9..5c40d49042b8 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -333,7 +333,7 @@ static int per_file_stats(int id, void *ptr, void *data)
 			}
 
 			ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
-			if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
+			if (ppgtt->file_priv != stats->file_priv)
 				continue;
 
 			if (obj->ring) /* XXX per-vma statistic */
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 899c6a7a5920..3b8367aa8404 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -181,26 +181,6 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
 	return obj;
 }
 
-static struct i915_hw_ppgtt *
-create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
-{
-	struct i915_hw_ppgtt *ppgtt;
-	int ret;
-
-	ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
-	if (!ppgtt)
-		return ERR_PTR(-ENOMEM);
-
-	ret = i915_ppgtt_init(dev, ppgtt);
-	if (ret) {
-		kfree(ppgtt);
-		return ERR_PTR(ret);
-	}
-
-	ppgtt->ctx = ctx;
-	return ppgtt;
-}
-
 static struct intel_context *
 __create_hw_context(struct drm_device *dev,
 		    struct drm_i915_file_private *file_priv)
@@ -287,7 +267,7 @@ i915_gem_create_context(struct drm_device *dev,
 	}
 
 	if (create_vm) {
-		struct i915_hw_ppgtt *ppgtt = create_vm_for_ctx(dev, ctx);
+		struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv);
 
 		if (IS_ERR_OR_NULL(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 baa94199239b..83ee41e5c1c7 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1222,6 +1222,27 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
 	return ret;
 }
 
+struct i915_hw_ppgtt *
+i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
+{
+	struct i915_hw_ppgtt *ppgtt;
+	int ret;
+
+	ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL);
+	if (!ppgtt)
+		return ERR_PTR(-ENOMEM);
+
+	ret = i915_ppgtt_init(dev, ppgtt);
+	if (ret) {
+		kfree(ppgtt);
+		return ERR_PTR(ret);
+	}
+
+	ppgtt->file_priv = fpriv;
+
+	return ppgtt;
+}
+
 void  i915_ppgtt_release(struct kref *kref)
 {
 	struct i915_hw_ppgtt *ppgtt =
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 380e034c66f8..0b04ef6167f8 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -34,6 +34,8 @@
 #ifndef __I915_GEM_GTT_H__
 #define __I915_GEM_GTT_H__
 
+struct drm_i915_file_private;
+
 typedef uint32_t gen6_gtt_pte_t;
 typedef uint64_t gen8_gtt_pte_t;
 typedef gen8_gtt_pte_t gen8_ppgtt_pde_t;
@@ -258,7 +260,7 @@ struct i915_hw_ppgtt {
 		dma_addr_t *gen8_pt_dma_addr[4];
 	};
 
-	struct intel_context *ctx;
+	struct drm_i915_file_private *file_priv;
 
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
 	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
@@ -276,6 +278,8 @@ bool intel_enable_ppgtt(struct drm_device *dev, bool full);
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
 void i915_ppgtt_release(struct kref *kref);
+struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
+					struct drm_i915_file_private *fpriv);
 static inline void i915_ppgtt_get(struct i915_hw_ppgtt *ppgtt)
 {
 	if (ppgtt)
-- 
1.9.3

  parent reply	other threads:[~2014-08-06 14:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 13:04 [PATCH 01/15] drm/i915: vma/ppgtt lifetime rules Daniel Vetter
2014-08-06 13:04 ` [PATCH 02/15] drm/i915: Some cleanups for the ppgtt lifetime handling Daniel Vetter
2014-08-08 13:00   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 03/15] drm/i915: Move i915_gem_chipset_flush to where it belongs Daniel Vetter
2014-08-12  8:45   ` Thierry, Michel
2014-08-06 13:04 ` Daniel Vetter [this message]
2014-08-06 13:04 ` [PATCH 05/15] drm/i915: Only refcount ppgtt if it actually is one Daniel Vetter
2014-08-08 13:02   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 06/15] drm/i915: Add proper prefix to obj_to_ggtt Daniel Vetter
2014-08-06 13:04 ` [PATCH 07/15] drm/i915: Allow i915_gem_setup_global_gtt to fail Daniel Vetter
2014-08-12  8:48   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 08/15] drm/i915: Fix up checks for aliasing ppgtt Daniel Vetter
2014-08-08 13:03   ` Thierry, Michel
2014-08-08 13:49     ` Daniel Vetter
2014-08-08 14:00       ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 09/15] drm/i915: Initialize the aliasing ppgtt as part of global gtt Daniel Vetter
2014-08-06 18:19   ` [PATCH 1/2] drm/i915: Rework ppgtt init to no require an aliasing ppgtt Daniel Vetter
2014-08-06 18:19     ` [PATCH 2/2] drm/i915: Initialize the aliasing ppgtt as part of global gtt Daniel Vetter
2014-08-08 13:04       ` Thierry, Michel
2014-08-06 19:55     ` [PATCH 1/2] drm/i915: Rework ppgtt init to no require an aliasing ppgtt Daniel Vetter
2014-08-12  8:58     ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 10/15] drm/i915: Only track real ppgtt for a context Daniel Vetter
2014-08-06 13:04 ` [PATCH 11/15] drm/i915: Drop create_vm argument to i915_gem_create_context Daniel Vetter
2014-08-08 13:06   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 12/15] drm/i915: Extract common cleanup into i915_ppgtt_release Daniel Vetter
2014-08-08 13:07   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 13/15] drm/i915: Extract commmon global gtt cleanup code Daniel Vetter
2014-08-08 13:08   ` Thierry, Michel
2014-08-06 13:04 ` [PATCH 14/15] drm/i915: Cleanup aliasging ppgtt alongside the global gtt Daniel Vetter
2014-08-08 13:09   ` Thierry, Michel
2014-08-12 14:05     ` Daniel Vetter
2014-08-06 13:04 ` [PATCH 15/15] drm/i915: don't touch console_lock for I915_FBDEV=n 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:
  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=1407330298-27065-4-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --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.