drm/ttm: Warn on pinning without holding a reference
Subsystems (3)
PATCH 1/1 drm/ttm: Warn on pinning without holding a reference
Not technically a problem for ttm, but very likely a driver bug and pretty big time confusing for reviewing code.
So warn about it, both at cleanup time (so we catch these for sure) and at pin/unpin time (so we know who's the culprit).
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_api.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
@@ -509,7 +509,7 @@ static void ttm_bo_release(struct kref *kref)* shrinkers, now that they are queued for * destruction. */ -if (bo->pin_count) { +if (WARN_ON (bo->pin_count)) { bo->pin_count =0 ;ttm_bo_del_from_lru (bo);ttm_bo_add_mem_to_lru (bo, &bo->mem);
include/drm/ttm/ttm_bo_api.h +2 -0
@@ -571,6 +571,7 @@ static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo)static inline void ttm_bo_pin (struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv); +WARN_ON_ONCE (!kref_read (&bo->kref)); ++bo->pin_count; }
@@ -584,6 +585,7 @@ static inline void ttm_bo_unpin(struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv);WARN_ON_ONCE (!bo->pin_count); +WARN_ON_ONCE (!kref_read (&bo->kref)); --bo->pin_count; }
Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Daniel Vetter
Not technically a problem for ttm, but very likely a driver bug and pretty big time confusing for reviewing code.
So warn about it, both at cleanup time (so we catch these for sure) and at pin/unpin time (so we know who's the culprit).
Signed-off-by Daniel Vetter <[email protected]>
Quoted 43 lines
Cc Christian Koenig <[email protected]>Cc Huang Rui <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_api.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -509,7 +509,7 @@ static void ttm_bo_release(struct kref *kref)* shrinkers, now that they are queued for * destruction. */ -if (bo->pin_count) { +if (WARN_ON (bo->pin_count)) { bo->pin_count =0 ;ttm_bo_del_from_lru (bo);ttm_bo_add_mem_to_lru (bo, &bo->mem);include/drm/ttm/ttm_bo_api.h +2
-0@@ -571,6 +571,7 @@ static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo)static inline void ttm_bo_pin (struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv); +WARN_ON_ONCE (!kref_read (&bo->kref)); ++bo->pin_count; }@@ -584,6 +585,7 @@ static inline void ttm_bo_unpin(struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv);WARN_ON_ONCE (!bo->pin_count); +WARN_ON_ONCE (!kref_read (&bo->kref)); --bo->pin_count; }Signature · 1 line
2.28.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 28.10.20 um 12:31 schrieb Daniel Vetter:
Quoted 9 lines
Not technically a problem for ttm, but very likely a driver bug and pretty big time confusing for reviewing code.
So warn about it, both at cleanup time (so we catch these for sure) and at pin/unpin time (so we know who's the culprit).
Signed-off-by Daniel Vetter <[email protected]>Cc Christian Koenig <[email protected]>Cc Huang Rui <[email protected]>
Quoted 31 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_api.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -509,7 +509,7 @@ static void ttm_bo_release(struct kref *kref)* shrinkers, now that they are queued for * destruction. */ -if (bo->pin_count) { +if (WARN_ON (bo->pin_count)) { bo->pin_count =0 ;ttm_bo_del_from_lru (bo);ttm_bo_add_mem_to_lru (bo, &bo->mem);include/drm/ttm/ttm_bo_api.h +1
-0@@ -571,6 +571,7 @@ static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo)static inline void ttm_bo_pin (struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv); +WARN_ON_ONCE (!kref_read (&bo->kref)); ++bo->pin_count; }
include/drm/ttm/ttm_bo_api.h static inline void ttm_bo_unpin(struct ttm_buffer_object *bo) · line 591
Quoted 7 lines
include/drm/ttm/ttm_bo_api.h +1
-0@@ -584,6 +585,7 @@ static inline void ttm_bo_unpin(struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv);WARN_ON_ONCE (!bo->pin_count); +WARN_ON_ONCE (!kref_read (&bo->kref)); --bo->pin_count; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Christian König
Am 28.10.20 um 12:31 schrieb Daniel Vetter:
Quoted 3 lines
Not technically a problem for ttm, but very likely a driver bug and pretty big time confusing for reviewing code.
Quoted 8 lines
Quoted 6 lines
So warn about it, both at cleanup time (so we catch these for sure) and at pin/unpin time (so we know who's the culprit).
Signed-off-by Daniel Vetter <[email protected]>Cc Christian Koenig <[email protected]>Cc Huang Rui <[email protected]>Reviewed-by Christian König <[email protected]>
Remembered this patch, pushed it. Thanks to you both for the reviews. -Daniel
Quoted 38 lines
Quoted 37 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_api.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -509,7 +509,7 @@ static void ttm_bo_release(struct kref *kref)* shrinkers, now that they are queued for * destruction. */ -if (bo->pin_count) { +if (WARN_ON (bo->pin_count)) { bo->pin_count =0 ;ttm_bo_del_from_lru (bo);ttm_bo_add_mem_to_lru (bo, &bo->mem);include/drm/ttm/ttm_bo_api.h +2
-0@@ -571,6 +571,7 @@ static inline bool ttm_bo_uses_embedded_gem_object(struct ttm_buffer_object *bo)static inline void ttm_bo_pin (struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv); +WARN_ON_ONCE (!kref_read (&bo->kref)); ++bo->pin_count; }@@ -584,6 +585,7 @@ static inline void ttm_bo_unpin(struct ttm_buffer_object *bo) {dma_resv_assert_held (bo->base.resv);WARN_ON_ONCE (!bo->pin_count); +WARN_ON_ONCE (!kref_read (&bo->kref)); --bo->pin_count; }
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel