diff options
author | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2024-03-01 13:05:25 -0500 |
---|---|---|
committer | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2024-03-04 12:47:10 -0500 |
commit | 5c9da9fc64a1a6745175c7e77c3a0021a32560a5 (patch) | |
tree | 1f0eea1ada3bfe3335aa319c4655e5b63867e393 /drivers/gpu | |
parent | d6b4137822a1f8d1a6676c18dff551b394557b65 (diff) | |
download | linux-stable-5c9da9fc64a1a6745175c7e77c3a0021a32560a5.tar.gz linux-stable-5c9da9fc64a1a6745175c7e77c3a0021a32560a5.tar.bz2 linux-stable-5c9da9fc64a1a6745175c7e77c3a0021a32560a5.zip |
drm/xe: Convert xe_pm_runtime_{get, put} to void and protect from recursion
With mem_access going away and pm_runtime getting called instead,
we need to protect these against recursions.
The put is asynchronous so there's no need to block it. However, for a
proper balance, we need to ensure that the references are taken and
restored regardless of the flow. So, let's convert them all to void and
use some direct linux/pm_runtime functions.
v2: Rebased and update commit message (Matt).
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240301180526.643505-3-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/xe/xe_pm.c | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/xe/xe_pm.h | 4 |
2 files changed, 16 insertions, 13 deletions
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 3e13a666fcc7..9fbb6f6c598a 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -408,26 +408,29 @@ out: /** * xe_pm_runtime_get - Get a runtime_pm reference and resume synchronously * @xe: xe device instance - * - * Returns: Any number greater than or equal to 0 for success, negative error - * code otherwise. */ -int xe_pm_runtime_get(struct xe_device *xe) +void xe_pm_runtime_get(struct xe_device *xe) { - return pm_runtime_get_sync(xe->drm.dev); + pm_runtime_get_noresume(xe->drm.dev); + + if (xe_pm_read_callback_task(xe) == current) + return; + + pm_runtime_resume(xe->drm.dev); } /** * xe_pm_runtime_put - Put the runtime_pm reference back and mark as idle * @xe: xe device instance - * - * Returns: Any number greater than or equal to 0 for success, negative error - * code otherwise. */ -int xe_pm_runtime_put(struct xe_device *xe) +void xe_pm_runtime_put(struct xe_device *xe) { - pm_runtime_mark_last_busy(xe->drm.dev); - return pm_runtime_put(xe->drm.dev); + if (xe_pm_read_callback_task(xe) == current) { + pm_runtime_put_noidle(xe->drm.dev); + } else { + pm_runtime_mark_last_busy(xe->drm.dev); + pm_runtime_put(xe->drm.dev); + } } /** diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h index 29c20099a3f9..0cb38ca244fe 100644 --- a/drivers/gpu/drm/xe/xe_pm.h +++ b/drivers/gpu/drm/xe/xe_pm.h @@ -26,9 +26,9 @@ void xe_pm_runtime_fini(struct xe_device *xe); bool xe_pm_runtime_suspended(struct xe_device *xe); int xe_pm_runtime_suspend(struct xe_device *xe); int xe_pm_runtime_resume(struct xe_device *xe); -int 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_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_in_use(struct xe_device *xe); bool xe_pm_runtime_resume_and_get(struct xe_device *xe); |