From: Huang Rui <ray.huang@amd.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/ttm: Warn on pinning without holding a reference
Date: Wed, 28 Oct 2020 19:52:18 +0800 [thread overview]
Message-ID: <20201028115218.GD1767271@hr-amd> (raw)
In-Reply-To: <20201028113120.3641237-1-daniel.vetter@ffwll.ch>
On Wed, Oct 28, 2020 at 07:31:20PM +0800, Daniel Vetter wrote:
> 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 <daniel.vetter@intel.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: Huang Rui <ray.huang@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
> include/drm/ttm/ttm_bo_api.h | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index f51b5e20fa17..a011072ab61d 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -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);
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 37102e45e496..b45aee23d7d0 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -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;
> }
>
> --
> 2.28.0
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-10-28 11:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 11:31 [PATCH] drm/ttm: Warn on pinning without holding a reference Daniel Vetter
2020-10-28 11:52 ` Huang Rui [this message]
2020-10-28 12:11 ` Christian König
2020-11-27 15:44 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201028115218.GD1767271@hr-amd \
--to=ray.huang@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.