[PATCH xf86-video-ati 2/2] Improve drmmode_fb_reference debugging code

Alex Deucher alexdeucher at gmail.com
Tue Jun 27 13:53:45 UTC 2017


On Tue, Jun 27, 2017 at 5:38 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> If a reference count is <= 0, call FatalError with the call location
> (in case it doesn't get resolved in the backtrace printed by
> FatalError).
>
> (Ported from amdgpu commit 1b6ff5fd9933c00ec1ec90dfc62e0b531927749b)
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/drmmode_display.h | 29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/src/drmmode_display.h b/src/drmmode_display.h
> index db68054a7..dde27a009 100644
> --- a/src/drmmode_display.h
> +++ b/src/drmmode_display.h
> @@ -141,29 +141,36 @@ enum drmmode_flip_sync {
>
>
>  static inline void
> -drmmode_fb_reference(int drm_fd, struct drmmode_fb **old, struct drmmode_fb *new)
> +drmmode_fb_reference_loc(int drm_fd, struct drmmode_fb **old, struct drmmode_fb *new,
> +                        const char *caller, unsigned line)
>  {
>      if (new) {
> -       if (new->refcnt <= 0)
> -           ErrorF("New FB's refcnt was %d in %s\n", new->refcnt, __func__);
> -       else
> -           new->refcnt++;
> +       if (new->refcnt <= 0) {
> +           FatalError("New FB's refcnt was %d at %s:%u",
> +                      new->refcnt, caller, line);
> +       }
> +
> +       new->refcnt++;
>      }
>
>      if (*old) {
>         if ((*old)->refcnt <= 0) {
> -           ErrorF("Old FB's refcnt was %d in %s\n", (*old)->refcnt, __func__);
> -       } else {
> -           if (--(*old)->refcnt == 0) {
> -               drmModeRmFB(drm_fd, (*old)->handle);
> -               free(*old);
> -           }
> +           FatalError("Old FB's refcnt was %d at %s:%u",
> +                      (*old)->refcnt, caller, line);
> +       }
> +
> +       if (--(*old)->refcnt == 0) {
> +           drmModeRmFB(drm_fd, (*old)->handle);
> +           free(*old);
>         }
>      }
>
>      *old = new;
>  }
>
> +#define drmmode_fb_reference(fd, old, new) \
> +    drmmode_fb_reference_loc(fd, old, new, __func__, __LINE__)
> +
>
>  extern int drmmode_page_flip_target_absolute(RADEONEntPtr pRADEONEnt,
>                                              drmmode_crtc_private_ptr drmmode_crtc,
> --
> 2.13.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list