[Intel-gfx] [PATCH] drm/i915: Only track real ppgtt for a context

2014-08-04 Thread Daniel Vetter
There's a bit a confusion since we track the global gtt,
the aliasing and real ppgtt in the ctx-vm pointer. And not
all callers really bother to check for the different cases and just
presume that it points to a real ppgtt.

Now looking closely we don't actually need -vm to always point at an
address space - the only place that cares actually has fixup code
already to decide whether to look at the per-proces or the global
address space.

So switch to just tracking the ppgtt directly and ditch all the
extraneous code.

v2: Fixup the ppgtt debugfs file to not oops on a NULL ctx-ppgtt.
Also drop the early exit - without aliasing ppgtt we want to dump all
the ppgtts of the contexts if we have full ppgtt.

Cc: Thierry, Michel michel.thie...@intel.com
Cc: Ville Syrjälä ville.syrj...@linux.intel.com
OTC-Jira: VIZ-3724
Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch
---
 drivers/gpu/drm/i915/i915_debugfs.c| 11 ---
 drivers/gpu/drm/i915/i915_drv.h|  3 +--
 drivers/gpu/drm/i915/i915_gem_context.c| 28 +++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  5 +++--
 drivers/gpu/drm/i915/i915_gpu_error.c  | 10 +++---
 5 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 3bf1d20c598b..2bd4beada1bd 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1774,7 +1774,13 @@ static int per_file_ctx(int id, void *ptr, void *data)
 {
struct intel_context *ctx = ptr;
struct seq_file *m = data;
-   struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
+   struct i915_hw_ppgtt *ppgtt = ctx-ppgtt;
+
+   if (!ppgtt) {
+   seq_puts(m,   no ppgtt for context %d\n,
+ctx-user_handle);
+   return 0;
+   }
 
if (i915_gem_context_is_default(ctx))
seq_puts(m,   default context:\n);
@@ -1834,8 +1840,7 @@ static void gen6_ppgtt_info(struct seq_file *m, struct 
drm_device *dev)
seq_printf(m, pd gtt offset: 0x%08x\n, ppgtt-pd_offset);
 
ppgtt-debug_dump(ppgtt, m);
-   } else
-   return;
+   }
 
list_for_each_entry_reverse(file, dev-filelist, lhead) {
struct drm_i915_file_private *file_priv = file-driver_priv;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0762e19f9bc6..3230b08aff13 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -616,7 +616,7 @@ struct intel_context {
uint8_t remap_slice;
struct drm_i915_file_private *file_priv;
struct i915_ctx_hang_stats hang_stats;
-   struct i915_address_space *vm;
+   struct i915_hw_ppgtt *ppgtt;
 
struct {
struct drm_i915_gem_object *rcs_state;
@@ -2504,7 +2504,6 @@ i915_gem_object_ggtt_unbind(struct drm_i915_gem_object 
*obj)
 void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 
 /* i915_gem_context.c */
-#define ctx_to_ppgtt(ctx) container_of((ctx)-vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 7a455fcee3a7..c00e5d027774 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -136,15 +136,8 @@ void i915_gem_context_free(struct kref *ctx_ref)
 {
struct intel_context *ctx = container_of(ctx_ref,
   typeof(*ctx), ref);
-   struct i915_hw_ppgtt *ppgtt = NULL;
 
-   if (ctx-legacy_hw_ctx.rcs_state) {
-   /* We refcount even the aliasing PPGTT to keep the code 
symmetric */
-   if (USES_PPGTT(ctx-legacy_hw_ctx.rcs_state-base.dev))
-   ppgtt = ctx_to_ppgtt(ctx);
-   }
-
-   i915_ppgtt_put(ppgtt);
+   i915_ppgtt_put(ctx-ppgtt);
if (ctx-legacy_hw_ctx.rcs_state)
drm_gem_object_unreference(ctx-legacy_hw_ctx.rcs_state-base);
list_del(ctx-link);
@@ -240,7 +233,6 @@ i915_gem_create_context(struct drm_device *dev,
bool create_vm)
 {
const bool is_global_default_ctx = file_priv == NULL;
-   struct drm_i915_private *dev_priv = dev-dev_private;
struct intel_context *ctx;
int ret = 0;
 
@@ -274,15 +266,10 @@ i915_gem_create_context(struct drm_device *dev,
 PTR_ERR(ppgtt));
ret = PTR_ERR(ppgtt);
goto err_unpin;
-   } else
-   ctx-vm = ppgtt-base;
-   } else if (USES_PPGTT(dev)) {
-   /* For platforms which only have aliasing PPGTT, we fake the
-* address space and 

Re: [Intel-gfx] [PATCH] drm/i915: Only track real ppgtt for a context

2014-08-04 Thread Thierry, Michel


 -Original Message-
 From: Daniel Vetter [mailto:daniel.vet...@ffwll.ch]
 Sent: Monday, August 04, 2014 3:21 PM
 To: Intel Graphics Development
 Cc: Daniel Vetter; Thierry, Michel; Ville Syrjälä
 Subject: [PATCH] drm/i915: Only track real ppgtt for a context
 
 There's a bit a confusion since we track the global gtt,
 the aliasing and real ppgtt in the ctx-vm pointer. And not
 all callers really bother to check for the different cases and just
 presume that it points to a real ppgtt.
 
 Now looking closely we don't actually need -vm to always point at an
 address space - the only place that cares actually has fixup code
 already to decide whether to look at the per-proces or the global
 address space.
 
 So switch to just tracking the ppgtt directly and ditch all the
 extraneous code.
 
 v2: Fixup the ppgtt debugfs file to not oops on a NULL ctx-ppgtt.
 Also drop the early exit - without aliasing ppgtt we want to dump all
 the ppgtts of the contexts if we have full ppgtt.
 
 Cc: Thierry, Michel michel.thie...@intel.com
 Cc: Ville Syrjälä ville.syrj...@linux.intel.com
 OTC-Jira: VIZ-3724
 Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch
 ---
  drivers/gpu/drm/i915/i915_debugfs.c| 11 ---
  drivers/gpu/drm/i915/i915_drv.h|  3 +--
  drivers/gpu/drm/i915/i915_gem_context.c| 28 +++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |  5 +++--
  drivers/gpu/drm/i915/i915_gpu_error.c  | 10 +++---
  5 files changed, 26 insertions(+), 31 deletions(-)
 
 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c
 b/drivers/gpu/drm/i915/i915_debugfs.c
 index 3bf1d20c598b..2bd4beada1bd 100644
 --- a/drivers/gpu/drm/i915/i915_debugfs.c
 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
 @@ -1774,7 +1774,13 @@ static int per_file_ctx(int id, void *ptr, void *data)
  {
   struct intel_context *ctx = ptr;
   struct seq_file *m = data;
 - struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
 + struct i915_hw_ppgtt *ppgtt = ctx-ppgtt;
 +
 + if (!ppgtt) {
 + seq_puts(m,   no ppgtt for context %d\n,
 +  ctx-user_handle);
Should be seq_printf().

 + return 0;
 + }
 
   if (i915_gem_context_is_default(ctx))
   seq_puts(m,   default context:\n);
 @@ -1834,8 +1840,7 @@ static void gen6_ppgtt_info(struct seq_file *m,
 --
 1.9.3

Apart from that, 

Reviewed-by: Michel Thierry michel.thie...@intel.com



smime.p7s
Description: S/MIME cryptographic signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Only track real ppgtt for a context

2014-08-04 Thread Daniel Vetter
There's a bit a confusion since we track the global gtt,
the aliasing and real ppgtt in the ctx-vm pointer. And not
all callers really bother to check for the different cases and just
presume that it points to a real ppgtt.

Now looking closely we don't actually need -vm to always point at an
address space - the only place that cares actually has fixup code
already to decide whether to look at the per-proces or the global
address space.

So switch to just tracking the ppgtt directly and ditch all the
extraneous code.

v2: Fixup the ppgtt debugfs file to not oops on a NULL ctx-ppgtt.
Also drop the early exit - without aliasing ppgtt we want to dump all
the ppgtts of the contexts if we have full ppgtt.

v3: Actually git add the compile fix.

Reviewed-by: Michel Thierry michel.thie...@intel.com
Cc: Thierry, Michel michel.thie...@intel.com
Cc: Ville Syrjälä ville.syrj...@linux.intel.com
OTC-Jira: VIZ-3724
Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch
---
 drivers/gpu/drm/i915/i915_debugfs.c| 11 ---
 drivers/gpu/drm/i915/i915_drv.h|  3 +--
 drivers/gpu/drm/i915/i915_gem_context.c| 28 +++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  5 +++--
 drivers/gpu/drm/i915/i915_gpu_error.c  | 10 +++---
 5 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 3bf1d20c598b..7e8d94b5 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1774,7 +1774,13 @@ static int per_file_ctx(int id, void *ptr, void *data)
 {
struct intel_context *ctx = ptr;
struct seq_file *m = data;
-   struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(ctx);
+   struct i915_hw_ppgtt *ppgtt = ctx-ppgtt;
+
+   if (!ppgtt) {
+   seq_printf(m,   no ppgtt for context %d\n,
+  ctx-user_handle);
+   return 0;
+   }
 
if (i915_gem_context_is_default(ctx))
seq_puts(m,   default context:\n);
@@ -1834,8 +1840,7 @@ static void gen6_ppgtt_info(struct seq_file *m, struct 
drm_device *dev)
seq_printf(m, pd gtt offset: 0x%08x\n, ppgtt-pd_offset);
 
ppgtt-debug_dump(ppgtt, m);
-   } else
-   return;
+   }
 
list_for_each_entry_reverse(file, dev-filelist, lhead) {
struct drm_i915_file_private *file_priv = file-driver_priv;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0762e19f9bc6..3230b08aff13 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -616,7 +616,7 @@ struct intel_context {
uint8_t remap_slice;
struct drm_i915_file_private *file_priv;
struct i915_ctx_hang_stats hang_stats;
-   struct i915_address_space *vm;
+   struct i915_hw_ppgtt *ppgtt;
 
struct {
struct drm_i915_gem_object *rcs_state;
@@ -2504,7 +2504,6 @@ i915_gem_object_ggtt_unbind(struct drm_i915_gem_object 
*obj)
 void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 
 /* i915_gem_context.c */
-#define ctx_to_ppgtt(ctx) container_of((ctx)-vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 7a455fcee3a7..c00e5d027774 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -136,15 +136,8 @@ void i915_gem_context_free(struct kref *ctx_ref)
 {
struct intel_context *ctx = container_of(ctx_ref,
   typeof(*ctx), ref);
-   struct i915_hw_ppgtt *ppgtt = NULL;
 
-   if (ctx-legacy_hw_ctx.rcs_state) {
-   /* We refcount even the aliasing PPGTT to keep the code 
symmetric */
-   if (USES_PPGTT(ctx-legacy_hw_ctx.rcs_state-base.dev))
-   ppgtt = ctx_to_ppgtt(ctx);
-   }
-
-   i915_ppgtt_put(ppgtt);
+   i915_ppgtt_put(ctx-ppgtt);
if (ctx-legacy_hw_ctx.rcs_state)
drm_gem_object_unreference(ctx-legacy_hw_ctx.rcs_state-base);
list_del(ctx-link);
@@ -240,7 +233,6 @@ i915_gem_create_context(struct drm_device *dev,
bool create_vm)
 {
const bool is_global_default_ctx = file_priv == NULL;
-   struct drm_i915_private *dev_priv = dev-dev_private;
struct intel_context *ctx;
int ret = 0;
 
@@ -274,15 +266,10 @@ i915_gem_create_context(struct drm_device *dev,
 PTR_ERR(ppgtt));
ret = PTR_ERR(ppgtt);
goto err_unpin;
-   } else
-   ctx-vm = ppgtt-base;
-   } else if (USES_PPGTT(dev)) {
-   /*