Home | History | Annotate | Line # | Download | only in gt
      1 /*	$NetBSD: intel_engine_pm.h,v 1.3 2021/12/19 12:33:56 riastradh Exp $	*/
      2 
      3 /*
      4  * SPDX-License-Identifier: MIT
      5  *
      6  * Copyright  2019 Intel Corporation
      7  */
      8 
      9 #ifndef INTEL_ENGINE_PM_H
     10 #define INTEL_ENGINE_PM_H
     11 
     12 #include "i915_request.h"
     13 #include "intel_engine_types.h"
     14 #include "intel_wakeref.h"
     15 
     16 static inline bool
     17 intel_engine_pm_is_awake(const struct intel_engine_cs *engine)
     18 {
     19 	return intel_wakeref_is_active(&engine->wakeref);
     20 }
     21 
     22 static inline void intel_engine_pm_get(struct intel_engine_cs *engine)
     23 {
     24 	intel_wakeref_get(&engine->wakeref);
     25 }
     26 
     27 static inline bool intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
     28 {
     29 	return intel_wakeref_get_if_active(&engine->wakeref);
     30 }
     31 
     32 static inline void intel_engine_pm_put(struct intel_engine_cs *engine)
     33 {
     34 	intel_wakeref_put(&engine->wakeref);
     35 }
     36 
     37 static inline void intel_engine_pm_put_async(struct intel_engine_cs *engine)
     38 {
     39 	intel_wakeref_put_async(&engine->wakeref);
     40 }
     41 
     42 static inline void intel_engine_pm_flush(struct intel_engine_cs *engine)
     43 {
     44 	intel_wakeref_unlock_wait(&engine->wakeref);
     45 }
     46 
     47 static inline struct i915_request *
     48 intel_engine_create_kernel_request(struct intel_engine_cs *engine)
     49 {
     50 	struct i915_request *rq;
     51 
     52 	/*
     53 	 * The engine->kernel_context is special as it is used inside
     54 	 * the engine-pm barrier (see __engine_park()), circumventing
     55 	 * the usual mutexes and relying on the engine-pm barrier
     56 	 * instead. So whenever we use the engine->kernel_context
     57 	 * outside of the barrier, we must manually handle the
     58 	 * engine wakeref to serialise with the use inside.
     59 	 */
     60 	intel_engine_pm_get(engine);
     61 	rq = i915_request_create(engine->kernel_context);
     62 	intel_engine_pm_put(engine);
     63 
     64 	return rq;
     65 }
     66 
     67 void intel_engine_init__pm(struct intel_engine_cs *engine);
     68 void intel_engine_fini__pm(struct intel_engine_cs *engine);
     69 
     70 #endif /* INTEL_ENGINE_PM_H */
     71