1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2023 Intel Corporation
6 #ifndef __INTEL_RUNTIME_PM_H__
7 #define __INTEL_RUNTIME_PM_H__
9 #include "intel_wakeref.h"
10 #include "xe_device_types.h"
13 #define intel_runtime_pm xe_runtime_pm
15 static inline void disable_rpm_wakeref_asserts(void *rpm)
19 static inline void enable_rpm_wakeref_asserts(void *rpm)
24 intel_runtime_pm_suspended(struct xe_runtime_pm *pm)
26 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
28 return pm_runtime_suspended(xe->drm.dev);
31 static inline intel_wakeref_t intel_runtime_pm_get(struct xe_runtime_pm *pm)
33 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
35 return xe_pm_runtime_resume_and_get(xe) ? INTEL_WAKEREF_DEF : NULL;
38 static inline intel_wakeref_t intel_runtime_pm_get_if_in_use(struct xe_runtime_pm *pm)
40 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
42 return xe_pm_runtime_get_if_in_use(xe) ? INTEL_WAKEREF_DEF : NULL;
45 static inline intel_wakeref_t intel_runtime_pm_get_noresume(struct xe_runtime_pm *pm)
47 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
49 xe_pm_runtime_get_noresume(xe);
51 return INTEL_WAKEREF_DEF;
54 static inline void intel_runtime_pm_put_unchecked(struct xe_runtime_pm *pm)
56 struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
58 xe_pm_runtime_put(xe);
61 static inline void intel_runtime_pm_put(struct xe_runtime_pm *pm, intel_wakeref_t wakeref)
64 intel_runtime_pm_put_unchecked(pm);
67 #define intel_runtime_pm_get_raw intel_runtime_pm_get
68 #define intel_runtime_pm_put_raw intel_runtime_pm_put
69 #define assert_rpm_wakelock_held(x) do { } while (0)
70 #define assert_rpm_raw_wakeref_held(x) do { } while (0)
72 #define with_intel_runtime_pm(rpm, wf) \
73 for ((wf) = intel_runtime_pm_get(rpm); (wf); \
74 intel_runtime_pm_put((rpm), (wf)), (wf) = NULL)