Skip to contentSkip to conversation

drm/drm_vma_manager.c: Remove useless goto statement

PATCH Superseded Liviu Dudau 4 participants 10 messages Nov 1, 2017 – Nov 2, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/drm_vma_manager.c: Remove useless goto statement

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 <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +0 -2
index 28f1226576f8c..e545a7b2bcafc 100644
@@ -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);
Signature · 6 lines
2.14.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Quoting Liviu Dudau (2017-11-01 14:04:24)

Quoted 17 lines

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 <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +0 -0
index 28f1226576f8c..e545a7b2bcafc 100644

drivers/gpu/drm/drm_vma_manager.c int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, · line 217

Quoted 5 lines
drivers/gpu/drm/drm_vma_manager.c +0 -2
@@ -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
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 20 lines · Chris Wilson

Quoting Liviu Dudau (2017-11-01 14:04:24)

Quoted 19 lines

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 <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +0 -0
index 28f1226576f8c..e545a7b2bcafc 100644
@@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
        }
 
Quoted 6 lines

drivers/gpu/drm/drm_vma_manager.c int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, · line 217

Quoted 3 lines
drivers/gpu/drm/drm_vma_manager.c +0 -2
        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

Quoted 1 line

-Chris

Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Chris Wilson
Quoted 20 lines · Chris Wilson

Quoting Liviu Dudau (2017-11-01 14:04:24)

Quoted 19 lines

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 <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +0 -0
index 28f1226576f8c..e545a7b2bcafc 100644
@@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
        }
 
Quoted 6 lines

drivers/gpu/drm/drm_vma_manager.c int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, · line 217

Quoted 3 lines
drivers/gpu/drm/drm_vma_manager.c +0 -2
        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

Quoted 1 line

-Chris

Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Quoting Liviu Dudau (2017-11-01 14:20:53)

Quoted 28 lines · Chris Wilson
Quoted 20 lines

Quoting Liviu Dudau (2017-11-01 14:04:24)

Quoted 19 lines

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 <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +0 -0
index 28f1226576f8c..e545a7b2bcafc 100644
@@ -213,8 +213,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
        }
 
Quoted 6 lines

drivers/gpu/drm/drm_vma_manager.c int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, · line 217

Quoted 3 lines
drivers/gpu/drm/drm_vma_manager.c +0 -2
        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...

Quoted 3 lines

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

drivers/gpu/drm/drm_vma_manager.c +5 -9
index 28f1226576f8..ba7857ed4361 100644
@@ -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 [email protected]? That will give us some reassurance that the change isn't outright horrible. ;)
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

PATCH v2 1/1 drm/drm_vma_manager.c: Remove useless goto statement

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. Rework the function (as suggested by Chris Wilson) to eliminate the need for the goto and associated label.

v2: rewrite function to remove all goto statements.

Fixes db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/drm_vma_manager.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_vma_manager.c +5 -10
index 28f1226576f8c..23c749c05b5aa 100644
@@ -203,21 +203,16 @@ EXPORT_SYMBOL(drm_vma_offset_lookup_locked);
 int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
 		       struct drm_vma_offset_node *node, unsigned long pages)
 {
-	int ret;
+	int ret = 0;
 
 	write_lock(&mgr->vm_lock);
 
-	if (drm_mm_node_allocated(&node->vm_node)) {
-		ret = 0;
-		goto out_unlock;
-	}
+	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;
 }
 EXPORT_SYMBOL(drm_vma_offset_add);
Signature · 6 lines
2.14.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 1/1
#6 lore raw

Quoting Liviu Dudau (2017-11-01 14:44:58)

Quoted 11 lines

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. Rework the function (as suggested by Chris Wilson) to eliminate the need for the goto and associated label.

v2: rewrite function to remove all goto statements.

Fixes db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
Cc Chris Wilson <[email protected]>

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 7 lines · Chris Wilson

Quoting Liviu Dudau (2017-11-01 14:44:58)

Quoted 6 lines

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. Rework the function (as suggested by Chris Wilson) to eliminate the need for the goto and associated label.

Quoted 6 lines
Quoted 5 lines

v2: rewrite function to remove all goto statements.

Fixes db2395eccf08i ("drm: Convert drm_vma_manager to embedded interval-tree in drm_mm")
Cc Chris Wilson <[email protected]>

Applied to drm-misc-next.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

✓ Fi.CI.BAT: success for drm/drm_vma_manager.c: Remove useless goto statement

In reply to Liviu Dudau
== Series Details ==

== Series Details ==

Series: drm/drm_vma_manager.c: Remove useless goto statement
URL : https://patchwork.freedesktop.org/series/32987/
State : success

== Summary ==

Series 32987v1 drm/drm_vma_manager.c: Remove useless goto statement
https://patchwork.freedesktop.org/api/1.0/series/32987/revisions/1/mbox/

Test gem_ctx_switch:

        Subgroup basic-default-heavy:
                incomplete -> PASS       (fi-glk-dsi)
fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:447s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:379s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:539s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:276s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:508s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:503s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:510s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:494s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:569s
fi-cnl-y         total:217  pass:196  dwarn:0   dfail:0   fail:0   skip:20 
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:431s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:258s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:586s
fi-glk-dsi       total:289  pass:257  dwarn:0   dfail:0   fail:2   skip:30  time:491s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:438s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:430s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:429s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:506s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:470s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:486s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:572s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:481s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:584s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:571s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:454s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:598s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:649s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:521s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:500s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:572s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:420s

fff06da054b4752eabf7d4103d30a281f8de96d9 drm-tip: 2017y-11m-01d-13h-47m-20s UTC integration manifest c78001f8a807 drm/drm_vma_manager.c: Remove useless goto statement

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6296/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

✓ Fi.CI.IGT: success for drm/drm_vma_manager.c: Remove useless goto statement

In reply to Liviu Dudau
== Series Details ==

== Series Details ==

Series: drm/drm_vma_manager.c: Remove useless goto statement
URL : https://patchwork.freedesktop.org/series/32987/
State : success

== Summary ==

Test kms_flip:

        Subgroup flip-vs-blocking-wf-vblank:
                fail       -> PASS       (shard-hsw)
        Subgroup wf_vblank-vs-modeset-interruptible:
                dmesg-warn -> PASS       (shard-hsw) fdo#102614
Test gem_exec_suspend:
        Subgroup basic-S4:
                fail       -> SKIP       (shard-hsw)
Test drv_module_reload:
        Subgroup basic-reload:
                dmesg-warn -> PASS       (shard-hsw) fdo#102707

fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707

shard-hsw total:2539 pass:1432 dwarn:1 dfail:0 fail:8 skip:1098 time:9224s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6296/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx