drm/drm_vma_manager.c: Remove useless goto statement

Message ID 20171101140424.2690-1-Liviu.Dudau@arm.com
State New
Headers show
Series
  • drm/drm_vma_manager.c: Remove useless goto statement
Related show

Commit Message

Liviu Dudau Nov. 1, 2017, 2:04 p.m.
Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
interval-tree in drm_mm") removed a line in drm_vma_offset_add() function
that makes checking the result of calling drm_mm_insert_node() and the
goto call redundant. Remove them.

Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Chris Wilson Nov. 1, 2017, 2:11 p.m. | #1
Quoting Liviu Dudau (2017-11-01 14:04:24)
> Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> interval-tree in drm_mm") removed a line in drm_vma_offset_add() function
> that makes checking the result of calling drm_mm_insert_node() and the
> goto call redundant. Remove them.
> 
> Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> ---
>  drivers/gpu/drm/drm_vma_manager.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
> index 28f1226576f8c..e545a7b2bcafc 100644
> --- a/drivers/gpu/drm/drm_vma_manager.c
> +++ b/drivers/gpu/drm/drm_vma_manager.c
> @@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
>         }
>  
>         ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
> -       if (ret)
> -               goto out_unlock;

Whilst you are here, you might consider this function too simple to even
require the out_unlock...
-Chris
Liviu Dudau Nov. 1, 2017, 2:18 p.m. | #2
On Wed, Nov 01, 2017 at 02:11:44PM +0000, Chris Wilson wrote:
> Quoting Liviu Dudau (2017-11-01 14:04:24)
> > Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> > interval-tree in drm_mm") removed a line in drm_vma_offset_add() function
> > that makes checking the result of calling drm_mm_insert_node() and the
> > goto call redundant. Remove them.
> > 
> > Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> > ---
> >  drivers/gpu/drm/drm_vma_manager.c | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
> > index 28f1226576f8c..e545a7b2bcafc 100644
> > --- a/drivers/gpu/drm/drm_vma_manager.c
> > +++ b/drivers/gpu/drm/drm_vma_manager.c
> > @@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
> >         }
> >  
> >         ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
> > -       if (ret)
> > -               goto out_unlock;
> 
> Whilst you are here, you might consider this function too simple to even
> require the out_unlock...

Bah, you are right, should've removed that one too :)

Will send an update shortly.

Thanks!
Liviu

> -Chris
Liviu Dudau Nov. 1, 2017, 2:20 p.m. | #3
On Wed, Nov 01, 2017 at 02:11:44PM +0000, Chris Wilson wrote:
> Quoting Liviu Dudau (2017-11-01 14:04:24)
> > Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> > interval-tree in drm_mm") removed a line in drm_vma_offset_add() function
> > that makes checking the result of calling drm_mm_insert_node() and the
> > goto call redundant. Remove them.
> > 
> > Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> > ---
> >  drivers/gpu/drm/drm_vma_manager.c | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
> > index 28f1226576f8c..e545a7b2bcafc 100644
> > --- a/drivers/gpu/drm/drm_vma_manager.c
> > +++ b/drivers/gpu/drm/drm_vma_manager.c
> > @@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
> >         }
> >  
> >         ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
> > -       if (ret)
> > -               goto out_unlock;
> 
> Whilst you are here, you might consider this function too simple to even
> require the out_unlock...

Actually, looking at the function as it stands after the patch, if I
want to remove the out_unlock label I need to re-write the whole
function. Are you OK with me doing that?

Best regards,
Liviu

> -Chris
Chris Wilson Nov. 1, 2017, 2:25 p.m. | #4
Quoting Liviu Dudau (2017-11-01 14:20:53)
> On Wed, Nov 01, 2017 at 02:11:44PM +0000, Chris Wilson wrote:
> > Quoting Liviu Dudau (2017-11-01 14:04:24)
> > > Commit db2395eccf08i ("drm: Convert drm_vma_manager to embedded
> > > interval-tree in drm_mm") removed a line in drm_vma_offset_add() function
> > > that makes checking the result of calling drm_mm_insert_node() and the
> > > goto call redundant. Remove them.
> > > 
> > > Fixes: db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
> > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> > > ---
> > >  drivers/gpu/drm/drm_vma_manager.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
> > > index 28f1226576f8c..e545a7b2bcafc 100644
> > > --- a/drivers/gpu/drm/drm_vma_manager.c
> > > +++ b/drivers/gpu/drm/drm_vma_manager.c
> > > @@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
> > >         }
> > >  
> > >         ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
> > > -       if (ret)
> > > -               goto out_unlock;
> > 
> > Whilst you are here, you might consider this function too simple to even
> > require the out_unlock...
> 
> Actually, looking at the function as it stands after the patch, if I
> want to remove the out_unlock label I need to re-write the whole
> function. Are you OK with me doing that?

Yes. My suggestion is along the lines of

diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index 28f1226576f8..ba7857ed4361 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -207,17 +207,13 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
 
        write_lock(&mgr->vm_lock);
 
-       if (drm_mm_node_allocated(&node->vm_node)) {
-               ret = 0;
-               goto out_unlock;
-       }
+       ret = 0;
+       if (!drm_mm_node_allocated(&node->vm_node))
+               ret = drm_mm_insert_node(&mgr->vm_addr_space_mm,
+                                        &node->vm_node, pages);
 
-       ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
-       if (ret)
-               goto out_unlock;
-
-out_unlock:
        write_unlock(&mgr->vm_lock);
+
        return ret;
 }

Can you please cc functional patches like this to
intel-gfx@lists.freedesktop.org? That will give us some reassurance that
the change isn't outright horrible. ;)
-Chris

Patch

diff --git a/drivers/gpu/drm/drm_vma_manager.c b/drivers/gpu/drm/drm_vma_manager.c
index 28f1226576f8c..e545a7b2bcafc 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -213,8 +213,6 @@  int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
 	}
 
 	ret = drm_mm_insert_node(&mgr->vm_addr_space_mm, &node->vm_node, pages);
-	if (ret)
-		goto out_unlock;
 
 out_unlock:
 	write_unlock(&mgr->vm_lock);