Skip to contentSkip to conversation

drm/nouveau: Drop mutex_lock_nested for atomic

PATCH Superseded Daniel Vetter 4 participants 8 messages Aug 2, 2020 – Oct 23, 2020

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

PATCH 1/1 drm/nouveau: Drop mutex_lock_nested for atomic

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
 			return ret;
 	}
 
-	mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+	if (drm_drv_uses_atomic_modeset(drm->dev))
+		mutex_lock(&cli->mutex);
+	else
+		mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
 	ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
 	if (ret == 0) {
 		ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
 			return ret;
 	}

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-	mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+	if (drm_drv_uses_atomic_modeset(drm->dev))
+		mutex_lock(&cli->mutex);
+	else
+		mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
 	ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
 	if (ret == 0) {
 		ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

#2 lore raw

Ben, did you have a chance to look at this?
-Daniel

Quoted 58 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#3 lore raw
Quoted 2 lines · Daniel Vetter

Ben, did you have a chance to look at this?

Ping
-Daniel

Quoted 66 lines
Quoted 56 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Quoted 2 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by
#4 lore raw
Quoted 67 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter

Ben, did you have a chance to look at this?

Ping
-Daniel

Quoted 59 lines
Quoted 57 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Quoted 18 lines
Quoted 7 lines
Quoted 1 line

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#5 lore raw
Quoted 67 lines · Ben Skeggs
Quoted 66 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter

Ben, did you have a chance to look at this?

Ping
-Daniel

Quoted 58 lines
Quoted 56 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Can you pull this in through your tree and maybe give it a spin just to make sure? I don't really have nouveau hardware here.

Also it's entirely stand-alone, I was simply reviewing all the mutex_lock_nested we have in drm, and this one stuck out as probably not necessary anymore, at least with atomic.

I guess I can also just stuff it into drm-misc-next and if it blows up, figure out what to do then :-)
-Daniel

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
Quoted 2 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#6 lore raw
Quoted 69 lines · Daniel Vetter
Quoted 67 lines · Ben Skeggs
Quoted 66 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter

Ben, did you have a chance to look at this?

Ping
-Daniel

Quoted 58 lines
Quoted 56 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Can you pull this in through your tree and maybe give it a spin just to make sure? I don't really have nouveau hardware here.

Yeah, I can do that easily enough.

Ben.

Quoted 33 lines

Also it's entirely stand-alone, I was simply reviewing all the mutex_lock_nested we have in drm, and this one stuck out as probably not necessary anymore, at least with atomic.

I guess I can also just stuff it into drm-misc-next and if it blows up, figure out what to do then :-)
-Daniel

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 8 lines
Quoted 8 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

#7 lore raw
Quoted 70 lines · Ben Skeggs
Quoted 69 lines · Daniel Vetter
Quoted 67 lines · Ben Skeggs
Quoted 66 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter

Ben, did you have a chance to look at this?

Ping
-Daniel

Quoted 58 lines
Quoted 56 lines · Maarten Lankhorst

Op 02-08-2020 om 20:18 schreef Daniel Vetter:

Quoted 41 lines

Purely conjecture, but I think the original locking inversion with the legacy page flip code between flipping and ttm's bo move function shoudn't exist anymore with atomic: With atomic the bo pinning and actual modeset commit is completely separated in the code patsh.

This annotation was originally added in

commit 060810d7abaabcab282e062c595871d661561400

Author: Ben Skeggs <[email protected]>
Date:   Mon Jul 8 14:15:51 2013 +1000

drm/nouveau: fix locking issues in page flipping paths

due to

commit b580c9e2b7ba5030a795aa2fb73b796523d65a78

Author: Maarten Lankhorst <[email protected]>
Date:   Thu Jun 27 13:48:18 2013 +0200

drm/nouveau: make flipping lockdep safe

Cc Maarten Lankhorst <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>

---
I might be totally wrong, so this definitely needs testing :-)

Cheers, Daniel

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -0
index 7806278dce57..a7b2a9bb0ffe 100644
@@ -776,7 +776,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
                      return ret;
      }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, · line 786

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -1
 
-     mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+     if (drm_drv_uses_atomic_modeset(drm->dev))
+             mutex_lock(&cli->mutex);
+     else
+             mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
+
      ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
      if (ret == 0) {
              ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);

Well if you're certain it works now. :)

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Can you pull this in through your tree and maybe give it a spin just to make sure? I don't really have nouveau hardware here.

Yeah, I can do that easily enough.

Hi Ben,

I'm still hanging on this one, doesn't seem to have made it into drm-next. Got lost or still somewhere in a queue?

Thanks, Daniel

Quoted 36 lines

Ben.

Quoted 33 lines

Also it's entirely stand-alone, I was simply reviewing all the mutex_lock_nested we have in drm, and this one stuck out as probably not necessary anymore, at least with atomic.

I guess I can also just stuff it into drm-misc-next and if it blows up, figure out what to do then :-)
-Daniel

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 8 lines
Quoted 8 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch