Commit 46edb0a3 authored by Rodrigo Vivi's avatar Rodrigo Vivi

drm/xe: Fix xe_pm_runtime_get_if_active return

Current callers of this function are already taking the result
to a boolean and using in an if. It might be a problem because
current function might return negative error codes on failure,
without increasing the reference counter.

In this scenario we could end up with extra 'put' call ending
in unbalanced scenarios.

Let's fix it, while aligning with the current xe_pm_get_if_in_use
style.
Tested-by: default avatarFrancois Dugast <francois.dugast@intel.com>
Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240522170105.327472-1-rodrigo.vivi@intel.comSigned-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 40672b79
...@@ -505,12 +505,12 @@ int xe_pm_runtime_get_ioctl(struct xe_device *xe) ...@@ -505,12 +505,12 @@ int xe_pm_runtime_get_ioctl(struct xe_device *xe)
* xe_pm_runtime_get_if_active - Get a runtime_pm reference if device active * xe_pm_runtime_get_if_active - Get a runtime_pm reference if device active
* @xe: xe device instance * @xe: xe device instance
* *
* Returns: Any number greater than or equal to 0 for success, negative error * Return: True if device is awake (regardless the previous number of references)
* code otherwise. * and a new reference was taken, false otherwise.
*/ */
int xe_pm_runtime_get_if_active(struct xe_device *xe) bool xe_pm_runtime_get_if_active(struct xe_device *xe)
{ {
return pm_runtime_get_if_active(xe->drm.dev); return pm_runtime_get_if_active(xe->drm.dev) > 0;
} }
/** /**
......
...@@ -29,7 +29,7 @@ int xe_pm_runtime_resume(struct xe_device *xe); ...@@ -29,7 +29,7 @@ int xe_pm_runtime_resume(struct xe_device *xe);
void xe_pm_runtime_get(struct xe_device *xe); void xe_pm_runtime_get(struct xe_device *xe);
int xe_pm_runtime_get_ioctl(struct xe_device *xe); int xe_pm_runtime_get_ioctl(struct xe_device *xe);
void xe_pm_runtime_put(struct xe_device *xe); void xe_pm_runtime_put(struct xe_device *xe);
int xe_pm_runtime_get_if_active(struct xe_device *xe); bool xe_pm_runtime_get_if_active(struct xe_device *xe);
bool xe_pm_runtime_get_if_in_use(struct xe_device *xe); bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
void xe_pm_runtime_get_noresume(struct xe_device *xe); void xe_pm_runtime_get_noresume(struct xe_device *xe);
bool xe_pm_runtime_resume_and_get(struct xe_device *xe); bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment