drm/i915: Remove context pointer from ppgtt struct

Submitted by Michel Thierry on July 30, 2014, 11:25 a.m.

Details

Message ID 1406719520-17071-1-git-send-email-michel.thierry@intel.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Michel Thierry July 30, 2014, 11:25 a.m.
After new vma/ppgtt lifetime rules, the ppgtt can outlive the context
it was created for.

- Renamed create_vm_for_ctx to i915_ppgtt_create as ctx/ppgtt are no
longer referenced.
- Updated per_file_stats to cope with this change.

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

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 96612a5..35c0f09 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -322,7 +322,7 @@  static int per_file_stats(int id, void *ptr, void *data)
 
 	if (USES_FULL_PPGTT(obj->base.dev)) {
 		list_for_each_entry(vma, &obj->vma_list, vma_link) {
-			struct i915_hw_ppgtt *ppgtt;
+			struct intel_context *ctx;
 
 			if (!drm_mm_node_allocated(&vma->node))
 				continue;
@@ -332,8 +332,8 @@  static int per_file_stats(int id, void *ptr, void *data)
 				continue;
 			}
 
-			ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
-			if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
+			ctx = container_of(vma->vm, struct intel_context, vm);
+			if (ctx && ctx->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 3e7cb50..43da325 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -210,7 +210,7 @@  i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
 }
 
 static struct i915_hw_ppgtt *
-create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
+i915_ppgtt_create(struct drm_device *dev)
 {
 	struct i915_hw_ppgtt *ppgtt;
 	int ret;
@@ -225,7 +225,6 @@  create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
 		return ERR_PTR(ret);
 	}
 
-	ppgtt->ctx = ctx;
 	return ppgtt;
 }
 
@@ -315,7 +314,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);
 
 		if (IS_ERR_OR_NULL(ppgtt)) {
 			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 8d6f7c1..dd70b0f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -258,8 +258,6 @@  struct i915_hw_ppgtt {
 		dma_addr_t *gen8_pt_dma_addr[4];
 	};
 
-	struct intel_context *ctx;
-
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
 	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
 			 struct intel_engine_cs *ring,

Comments

On Wed, Jul 30, 2014 at 12:25:20PM +0100, Michel Thierry wrote:
> After new vma/ppgtt lifetime rules, the ppgtt can outlive the context
> it was created for.
> 
> - Renamed create_vm_for_ctx to i915_ppgtt_create as ctx/ppgtt are no
> longer referenced.
> - Updated per_file_stats to cope with this change.
> 
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Michel Thierry <michel.thierry@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c     | 6 +++---
>  drivers/gpu/drm/i915/i915_gem_context.c | 5 ++---
>  drivers/gpu/drm/i915/i915_gem_gtt.h     | 2 --
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 96612a5..35c0f09 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -322,7 +322,7 @@ static int per_file_stats(int id, void *ptr, void *data)
>  
>  	if (USES_FULL_PPGTT(obj->base.dev)) {
>  		list_for_each_entry(vma, &obj->vma_list, vma_link) {
> -			struct i915_hw_ppgtt *ppgtt;
> +			struct intel_context *ctx;
>  
>  			if (!drm_mm_node_allocated(&vma->node))
>  				continue;
> @@ -332,8 +332,8 @@ static int per_file_stats(int id, void *ptr, void *data)
>  				continue;
>  			}
>  
> -			ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
> -			if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv)
> +			ctx = container_of(vma->vm, struct intel_context, vm);

That doesn't really work.
-Daniel

> +			if (ctx && ctx->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 3e7cb50..43da325 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -210,7 +210,7 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
>  }
>  
>  static struct i915_hw_ppgtt *
> -create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
> +i915_ppgtt_create(struct drm_device *dev)
>  {
>  	struct i915_hw_ppgtt *ppgtt;
>  	int ret;
> @@ -225,7 +225,6 @@ create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
>  		return ERR_PTR(ret);
>  	}
>  
> -	ppgtt->ctx = ctx;
>  	return ppgtt;
>  }
>  
> @@ -315,7 +314,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);
>  
>  		if (IS_ERR_OR_NULL(ppgtt)) {
>  			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
> index 8d6f7c1..dd70b0f 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.h
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
> @@ -258,8 +258,6 @@ struct i915_hw_ppgtt {
>  		dma_addr_t *gen8_pt_dma_addr[4];
>  	};
>  
> -	struct intel_context *ctx;
> -
>  	int (*enable)(struct i915_hw_ppgtt *ppgtt);
>  	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
>  			 struct intel_engine_cs *ring,
> -- 
> 2.0.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> -----Original Message-----
> From: Daniel Vetter [mailto:daniel.vetter@ffwll.ch] On Behalf Of Daniel
> Vetter
> Sent: Wednesday, July 30, 2014 12:59 PM
> To: Thierry, Michel
> Cc: intel-gfx@lists.freedesktop.org; Daniel Vetter
> Subject: Re: [Intel-gfx] [PATCH] drm/i915: Remove context pointer from
> ppgtt struct
> 
> On Wed, Jul 30, 2014 at 12:25:20PM +0100, Michel Thierry wrote:
> > After new vma/ppgtt lifetime rules, the ppgtt can outlive the context
> > it was created for.
> >
> > - Renamed create_vm_for_ctx to i915_ppgtt_create as ctx/ppgtt are no
> > longer referenced.
> > - Updated per_file_stats to cope with this change.
> >
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Signed-off-by: Michel Thierry <michel.thierry@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_debugfs.c     | 6 +++---
> >  drivers/gpu/drm/i915/i915_gem_context.c | 5 ++---
> >  drivers/gpu/drm/i915/i915_gem_gtt.h     | 2 --
> >  3 files changed, 5 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c
> b/drivers/gpu/drm/i915/i915_debugfs.c
> > index 96612a5..35c0f09 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -322,7 +322,7 @@ static int per_file_stats(int id, void *ptr, void
*data)
> >
> >  	if (USES_FULL_PPGTT(obj->base.dev)) {
> >  		list_for_each_entry(vma, &obj->vma_list, vma_link) {
> > -			struct i915_hw_ppgtt *ppgtt;
> > +			struct intel_context *ctx;
> >
> >  			if (!drm_mm_node_allocated(&vma->node))
> >  				continue;
> > @@ -332,8 +332,8 @@ static int per_file_stats(int id, void *ptr, void
*data)
> >  				continue;
> >  			}
> >
> > -			ppgtt = container_of(vma->vm, struct
> i915_hw_ppgtt, base);
> > -			if (ppgtt->ctx && ppgtt->ctx->file_priv != stats-
> >file_priv)
> > +			ctx = container_of(vma->vm, struct intel_context,
> vm);
> 
> That doesn't really work.
> -Daniel

Indeed, sorry about that. I'm sending v2. 

> 
> > +			if (ctx && ctx->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 3e7cb50..43da325 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_context.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> > @@ -210,7 +210,7 @@ i915_gem_alloc_context_obj(struct drm_device
> *dev, size_t size)
> >  }
> >
> >  static struct i915_hw_ppgtt *
> > -create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
> > +i915_ppgtt_create(struct drm_device *dev)
> >  {
> >  	struct i915_hw_ppgtt *ppgtt;
> >  	int ret;
> > @@ -225,7 +225,6 @@ create_vm_for_ctx(struct drm_device *dev, struct
> intel_context *ctx)
> >  		return ERR_PTR(ret);
> >  	}
> >
> > -	ppgtt->ctx = ctx;
> >  	return ppgtt;
> >  }
> >
> > @@ -315,7 +314,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);
> >
> >  		if (IS_ERR_OR_NULL(ppgtt)) {
> >  			DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n",
> > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h
> b/drivers/gpu/drm/i915/i915_gem_gtt.h
> > index 8d6f7c1..dd70b0f 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_gtt.h
> > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
> > @@ -258,8 +258,6 @@ struct i915_hw_ppgtt {
> >  		dma_addr_t *gen8_pt_dma_addr[4];
> >  	};
> >
> > -	struct intel_context *ctx;
> > -
> >  	int (*enable)(struct i915_hw_ppgtt *ppgtt);
> >  	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
> >  			 struct intel_engine_cs *ring,
> > --
> > 2.0.3
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch