1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #ifndef _XE_PM_H_ 7 #define _XE_PM_H_ 8 9 #include <linux/cleanup.h> 10 #include <linux/pm_runtime.h> 11 12 #define DEFAULT_VRAM_THRESHOLD 300 /* in MB */ 13 14 struct xe_device; 15 16 int xe_pm_suspend(struct xe_device *xe); 17 int xe_pm_resume(struct xe_device *xe); 18 19 int xe_pm_init_early(struct xe_device *xe); 20 int xe_pm_init(struct xe_device *xe); 21 void xe_pm_fini(struct xe_device *xe); 22 bool xe_pm_runtime_suspended(struct xe_device *xe); 23 int xe_pm_runtime_suspend(struct xe_device *xe); 24 int xe_pm_runtime_resume(struct xe_device *xe); 25 void xe_pm_runtime_get(struct xe_device *xe); 26 int xe_pm_runtime_get_ioctl(struct xe_device *xe); 27 void xe_pm_runtime_put(struct xe_device *xe); 28 bool xe_pm_runtime_get_if_active(struct xe_device *xe); 29 bool xe_pm_runtime_get_if_in_use(struct xe_device *xe); 30 void xe_pm_runtime_get_noresume(struct xe_device *xe); 31 bool xe_pm_runtime_resume_and_get(struct xe_device *xe); 32 void xe_pm_assert_unbounded_bridge(struct xe_device *xe); 33 int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold); 34 void xe_pm_d3cold_allowed_toggle(struct xe_device *xe); 35 bool xe_rpm_reclaim_safe(const struct xe_device *xe); 36 struct task_struct *xe_pm_read_callback_task(struct xe_device *xe); 37 int xe_pm_block_on_suspend(struct xe_device *xe); 38 void xe_pm_might_block_on_suspend(void); 39 int xe_pm_module_init(void); 40 41 static inline void __xe_pm_runtime_noop(struct xe_device *xe) {} 42 43 DEFINE_GUARD(xe_pm_runtime, struct xe_device *, 44 xe_pm_runtime_get(_T), xe_pm_runtime_put(_T)) 45 DEFINE_GUARD(xe_pm_runtime_noresume, struct xe_device *, 46 xe_pm_runtime_get_noresume(_T), xe_pm_runtime_put(_T)) 47 DEFINE_GUARD_COND(xe_pm_runtime, _ioctl, xe_pm_runtime_get_ioctl(_T), _RET >= 0) 48 49 /* 50 * Used when a function needs to release runtime PM in all possible cases 51 * and error paths, but the wakeref was already acquired by a different 52 * function (i.e., get() has already happened so only a put() is needed). 53 */ 54 DEFINE_GUARD(xe_pm_runtime_release_only, struct xe_device *, 55 __xe_pm_runtime_noop(_T), xe_pm_runtime_put(_T)); 56 57 #endif 58