drm/i915: Fix wakeref cookie handling in debugfs/i915_forcewake_user
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 17 Jan 2019 14:48:31 +0000 (14:48 +0000)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 18 Jan 2019 07:33:43 +0000 (07:33 +0000)
To avoid a false positive of a leaked wakeref, we can store the cookie
in file->private_data and use it in intel_runtime_pm_put.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190117144831.13156-1-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_debugfs.c

index cdf7730a79df1cffce9f20c9006524ae389d1c76..0f100fd5ff2cfc77d5d603713eed486b127e1e3f 100644 (file)
@@ -4413,7 +4413,7 @@ static int i915_forcewake_open(struct inode *inode, struct file *file)
        if (INTEL_GEN(i915) < 6)
                return 0;
 
-       intel_runtime_pm_get(i915);
+       file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915);
        intel_uncore_forcewake_user_get(i915);
 
        return 0;
@@ -4427,7 +4427,8 @@ static int i915_forcewake_release(struct inode *inode, struct file *file)
                return 0;
 
        intel_uncore_forcewake_user_put(i915);
-       intel_runtime_pm_put_unchecked(i915);
+       intel_runtime_pm_put(i915,
+                            (intel_wakeref_t)(uintptr_t)file->private_data);
 
        return 0;
 }