summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_wakeref.c
diff options
context:
space:
mode:
authorAndrzej Hajda <andrzej.hajda@intel.com>2023-10-30 18:40:12 +0100
committerAndrzej Hajda <andrzej.hajda@intel.com>2023-11-20 12:36:54 +0100
commitb49e894c3fd83f67aae2a4778b98ea3838e41020 (patch)
tree44761e7054f280460a35a5cf8c911d01b38b9ccf /drivers/gpu/drm/i915/intel_wakeref.c
parentdfed6b58d54f3a5d7e6bc1fb060e2c936330eba2 (diff)
downloadlinux-b49e894c3fd83f67aae2a4778b98ea3838e41020.tar.gz
linux-b49e894c3fd83f67aae2a4778b98ea3838e41020.tar.bz2
linux-b49e894c3fd83f67aae2a4778b98ea3838e41020.zip
drm/i915: Replace custom intel runtime_pm tracker with ref_tracker library
Beside reusing existing code, the main advantage of ref_tracker is tracking per instance of wakeref. It allows also to catch double put. On the other side we lose information about the first acquire and the last release, but the advantages outweigh it. Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231030-ref_tracker_i915-v1-1-006fe6b96421@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_wakeref.c')
-rw-r--r--drivers/gpu/drm/i915/intel_wakeref.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
index 623a69089386..2401b88b55a4 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.c
+++ b/drivers/gpu/drm/i915/intel_wakeref.c
@@ -191,3 +191,31 @@ void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
intel_wakeref_auto(wf, 0);
INTEL_WAKEREF_BUG_ON(wf->wakeref);
}
+
+void intel_ref_tracker_show(struct ref_tracker_dir *dir,
+ struct drm_printer *p)
+{
+ const size_t buf_size = PAGE_SIZE;
+ char *buf, *sb, *se;
+ size_t count;
+
+ buf = kmalloc(buf_size, GFP_NOWAIT);
+ if (!buf)
+ return;
+
+ count = ref_tracker_dir_snprint(dir, buf, buf_size);
+ if (!count)
+ goto free;
+ /* printk does not like big buffers, so we split it */
+ for (sb = buf; *sb; sb = se + 1) {
+ se = strchrnul(sb, '\n');
+ drm_printf(p, "%.*s", (int)(se - sb + 1), sb);
+ if (!*se)
+ break;
+ }
+ if (count >= buf_size)
+ drm_printf(p, "\n...dropped %zd extra bytes of leak report.\n",
+ count + 1 - buf_size);
+free:
+ kfree(buf);
+}