summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-06-22 16:27:32 +0900
committerMichel Dänzer <michel@daenzer.net>2017-06-27 15:33:00 +0900
commit1b6ff5fd9933c00ec1ec90dfc62e0b531927749b (patch)
tree99747165467e45833562e07bdf0e35a23644db35
parentaf7221e1c4d2dbdfd488eb0976a835584ea8441c (diff)
Improve drmmode_fb_reference debugging code
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). Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/drmmode_display.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index b64a938..f351bb0 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -133,32 +133,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++;
+ 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(AMDGPUEntPtr pAMDGPUEnt,
drmmode_crtc_private_ptr drmmode_crtc,