All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
@ 2012-10-11 21:53 Marcin Slusarz
       [not found] ` <20121011215309.GA3511-OI9uyE9O0yo@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Marcin Slusarz @ 2012-10-11 21:53 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/gpu/drm/nouveau/core/core/gpuobj.c         | 6 +++++-
 drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
index c2a7608..48121d2 100644
--- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
+++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
@@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
 			nv_wo32(gpuobj, i, 0x00000000);
 	}
 
+	if (gpuobj->node)
+		nouveau_mm_free(gpuobj->node_heap, &gpuobj->node);
+
 	if (gpuobj->heap.block_size)
-		nouveau_mm_fini(&gpuobj->heap);
+		WARN_ON(nouveau_mm_fini(&gpuobj->heap));
 
 	nouveau_object_destroy(&gpuobj->base);
 }
@@ -114,6 +117,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
 				      max(align, (u32)1), &gpuobj->node);
 		if (ret)
 			return ret;
+		gpuobj->node_heap = heap;
 
 		gpuobj->addr += gpuobj->node->offset;
 	}
diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
index d09adf1..f65bf5b 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
@@ -16,7 +16,10 @@ struct nouveau_vm;
 struct nouveau_gpuobj {
 	struct nouveau_object base;
 	struct nouveau_object *parent;
+
+	struct nouveau_mm *node_heap;
 	struct nouveau_mm_node *node;
+
 	struct nouveau_mm heap;
 
 	u32 flags;
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
       [not found] ` <20121011215309.GA3511-OI9uyE9O0yo@public.gmane.org>
@ 2012-10-16 21:41   ` Marcin Slusarz
  2012-10-19  6:05   ` Ben Skeggs
  1 sibling, 0 replies; 7+ messages in thread
From: Marcin Slusarz @ 2012-10-16 21:41 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/gpu/drm/nouveau/core/core/gpuobj.c         | 6 +++++-
>  drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> index c2a7608..48121d2 100644
> --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
>  			nv_wo32(gpuobj, i, 0x00000000);
>  	}
>  
> +	if (gpuobj->node)
> +		nouveau_mm_free(gpuobj->node_heap, &gpuobj->node);
> +
>  	if (gpuobj->heap.block_size)
> -		nouveau_mm_fini(&gpuobj->heap);
> +		WARN_ON(nouveau_mm_fini(&gpuobj->heap));
>  
>  	nouveau_object_destroy(&gpuobj->base);
>  }
> @@ -114,6 +117,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
>  				      max(align, (u32)1), &gpuobj->node);
>  		if (ret)
>  			return ret;
> +		gpuobj->node_heap = heap;
>  
>  		gpuobj->addr += gpuobj->node->offset;
>  	}
> diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> index d09adf1..f65bf5b 100644
> --- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> +++ b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> @@ -16,7 +16,10 @@ struct nouveau_vm;
>  struct nouveau_gpuobj {
>  	struct nouveau_object base;
>  	struct nouveau_object *parent;
> +
> +	struct nouveau_mm *node_heap;
>  	struct nouveau_mm_node *node;
> +
>  	struct nouveau_mm heap;
>  
>  	u32 flags;
> -- 

What's wrong with this patch?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
       [not found] ` <20121011215309.GA3511-OI9uyE9O0yo@public.gmane.org>
  2012-10-16 21:41   ` Marcin Slusarz
@ 2012-10-19  6:05   ` Ben Skeggs
       [not found]     ` <20121019060514.GA11173-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Ben Skeggs @ 2012-10-19  6:05 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/gpu/drm/nouveau/core/core/gpuobj.c         | 6 +++++-
>  drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> index c2a7608..48121d2 100644
> --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
>  			nv_wo32(gpuobj, i, 0x00000000);
>  	}
>  
> +	if (gpuobj->node)
> +		nouveau_mm_free(gpuobj->node_heap, &gpuobj->node);
> +
if (gpuobj->node) {
	nouveau_mm_free(&nv_gpuobj(gpuobj->parent)->heap,
			&gpuobj->node);
}

Or something to that effect, instead of having to store the heap
pointer again.

>  	if (gpuobj->heap.block_size)
> -		nouveau_mm_fini(&gpuobj->heap);
> +		WARN_ON(nouveau_mm_fini(&gpuobj->heap));
Alright, I get this.  However, perhaps we should go the full hog here
and make nouveau_mm_fini() directly do the WARN_ON() in this situation?

There was, once upon a time, reasons for it not doing this, I don't
believe they're valid anymore though.

If you want to do this, that'd be great.  Bonus points for being in a
separate patch :)

>  
>  	nouveau_object_destroy(&gpuobj->base);
>  }
> @@ -114,6 +117,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
>  				      max(align, (u32)1), &gpuobj->node);
>  		if (ret)
>  			return ret;
> +		gpuobj->node_heap = heap;
>  
>  		gpuobj->addr += gpuobj->node->offset;
>  	}
> diff --git a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> index d09adf1..f65bf5b 100644
> --- a/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> +++ b/drivers/gpu/drm/nouveau/core/include/core/gpuobj.h
> @@ -16,7 +16,10 @@ struct nouveau_vm;
>  struct nouveau_gpuobj {
>  	struct nouveau_object base;
>  	struct nouveau_object *parent;
> +
> +	struct nouveau_mm *node_heap;
>  	struct nouveau_mm_node *node;
> +
>  	struct nouveau_mm heap;
>  
>  	u32 flags;
> -- 
> 1.7.12
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
       [not found]     ` <20121019060514.GA11173-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
@ 2012-10-21 22:19       ` Marcin Slusarz
       [not found]         ` <20121021221935.GA2925-OI9uyE9O0yo@public.gmane.org>
  2012-10-21 22:20       ` [PATCH v2] " Marcin Slusarz
  2012-10-21 22:21       ` [PATCH] drm/nouveau: warn when trying to free mm which is still in use Marcin Slusarz
  2 siblings, 1 reply; 7+ messages in thread
From: Marcin Slusarz @ 2012-10-21 22:19 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, Oct 19, 2012 at 04:05:14PM +1000, Ben Skeggs wrote:
> On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
> > Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> >  drivers/gpu/drm/nouveau/core/core/gpuobj.c         | 6 +++++-
> >  drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
> >  2 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > index c2a7608..48121d2 100644
> > --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
> >  			nv_wo32(gpuobj, i, 0x00000000);
> >  	}
> >  
> > +	if (gpuobj->node)
> > +		nouveau_mm_free(gpuobj->node_heap, &gpuobj->node);
> > +
> if (gpuobj->node) {
> 	nouveau_mm_free(&nv_gpuobj(gpuobj->parent)->heap,
> 			&gpuobj->node);
> }
> 
> Or something to that effect, instead of having to store the heap
> pointer again.

Oh, right.
(Somehow I assumed pargpu to be different object than parent when
I first read it.)

> >  	if (gpuobj->heap.block_size)
> > -		nouveau_mm_fini(&gpuobj->heap);
> > +		WARN_ON(nouveau_mm_fini(&gpuobj->heap));
> Alright, I get this.  However, perhaps we should go the full hog here
> and make nouveau_mm_fini() directly do the WARN_ON() in this situation?
> 
> There was, once upon a time, reasons for it not doing this, I don't
> believe they're valid anymore though.

OK.

Marcin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
       [not found]     ` <20121019060514.GA11173-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
  2012-10-21 22:19       ` Marcin Slusarz
@ 2012-10-21 22:20       ` Marcin Slusarz
  2012-10-21 22:21       ` [PATCH] drm/nouveau: warn when trying to free mm which is still in use Marcin Slusarz
  2 siblings, 0 replies; 7+ messages in thread
From: Marcin Slusarz @ 2012-10-21 22:20 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

v2: use already existing parent

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/gpu/drm/nouveau/core/core/gpuobj.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
index c2a7608..18b3f5c 100644
--- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
+++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
@@ -39,6 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
 			nv_wo32(gpuobj, i, 0x00000000);
 	}
 
+	if (gpuobj->node) {
+		nouveau_mm_free(&nv_gpuobj(gpuobj->parent)->heap,
+				&gpuobj->node);
+	}
+
 	if (gpuobj->heap.block_size)
 		nouveau_mm_fini(&gpuobj->heap);
 
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] drm/nouveau: warn when trying to free mm which is still in use
       [not found]     ` <20121019060514.GA11173-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
  2012-10-21 22:19       ` Marcin Slusarz
  2012-10-21 22:20       ` [PATCH v2] " Marcin Slusarz
@ 2012-10-21 22:21       ` Marcin Slusarz
  2 siblings, 0 replies; 7+ messages in thread
From: Marcin Slusarz @ 2012-10-21 22:21 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/gpu/drm/nouveau/core/core/mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c b/drivers/gpu/drm/nouveau/core/core/mm.c
index bfddf87..4d62064 100644
--- a/drivers/gpu/drm/nouveau/core/core/mm.c
+++ b/drivers/gpu/drm/nouveau/core/core/mm.c
@@ -236,7 +236,7 @@ nouveau_mm_fini(struct nouveau_mm *mm)
 	int nodes = 0;
 
 	list_for_each_entry(node, &mm->nodes, nl_entry) {
-		if (nodes++ == mm->heap_nodes)
+		if (WARN_ON(nodes++ == mm->heap_nodes))
 			return -EBUSY;
 	}
 
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak
       [not found]         ` <20121021221935.GA2925-OI9uyE9O0yo@public.gmane.org>
@ 2012-10-21 22:43           ` Ben Skeggs
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Skeggs @ 2012-10-21 22:43 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Mon, Oct 22, 2012 at 12:19:35AM +0200, Marcin Slusarz wrote:
> On Fri, Oct 19, 2012 at 04:05:14PM +1000, Ben Skeggs wrote:
> > On Thu, Oct 11, 2012 at 11:53:09PM +0200, Marcin Slusarz wrote:
> > > Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > ---
> > >  drivers/gpu/drm/nouveau/core/core/gpuobj.c         | 6 +++++-
> > >  drivers/gpu/drm/nouveau/core/include/core/gpuobj.h | 3 +++
> > >  2 files changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > > index c2a7608..48121d2 100644
> > > --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > > +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> > > @@ -39,8 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
> > >  			nv_wo32(gpuobj, i, 0x00000000);
> > >  	}
> > >  
> > > +	if (gpuobj->node)
> > > +		nouveau_mm_free(gpuobj->node_heap, &gpuobj->node);
> > > +
> > if (gpuobj->node) {
> > 	nouveau_mm_free(&nv_gpuobj(gpuobj->parent)->heap,
> > 			&gpuobj->node);
> > }
> > 
> > Or something to that effect, instead of having to store the heap
> > pointer again.
Thanks, merged both patches :)

> 
> Oh, right.
> (Somehow I assumed pargpu to be different object than parent when
> I first read it.)
> 
> > >  	if (gpuobj->heap.block_size)
> > > -		nouveau_mm_fini(&gpuobj->heap);
> > > +		WARN_ON(nouveau_mm_fini(&gpuobj->heap));
> > Alright, I get this.  However, perhaps we should go the full hog here
> > and make nouveau_mm_fini() directly do the WARN_ON() in this situation?
> > 
> > There was, once upon a time, reasons for it not doing this, I don't
> > believe they're valid anymore though.
> 
> OK.
> 
> Marcin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-21 22:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 21:53 [PATCH] drm/nouveau: fix nouveau_mm/nouveau_mm_node leak Marcin Slusarz
     [not found] ` <20121011215309.GA3511-OI9uyE9O0yo@public.gmane.org>
2012-10-16 21:41   ` Marcin Slusarz
2012-10-19  6:05   ` Ben Skeggs
     [not found]     ` <20121019060514.GA11173-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
2012-10-21 22:19       ` Marcin Slusarz
     [not found]         ` <20121021221935.GA2925-OI9uyE9O0yo@public.gmane.org>
2012-10-21 22:43           ` Ben Skeggs
2012-10-21 22:20       ` [PATCH v2] " Marcin Slusarz
2012-10-21 22:21       ` [PATCH] drm/nouveau: warn when trying to free mm which is still in use Marcin Slusarz

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.