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