mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 00:55:28 +07:00
79ffac8599
In the current scheme, on submitting a request we take a single global GEM wakeref, which trickles down to wake up all GT power domains. This is undesirable as we would like to be able to localise our power management to the available power domains and to remove the global GEM operations from the heart of the driver. (The intent there is to push global GEM decisions to the boundary as used by the GEM user interface.) Now during request construction, each request is responsible via its logical context to acquire a wakeref on each power domain it intends to utilize. Currently, each request takes a wakeref on the engine(s) and the engines themselves take a chipset wakeref. This gives us a transition on each engine which we can extend if we want to insert more powermangement control (such as soft rc6). The global GEM operations that currently require a struct_mutex are reduced to listening to pm events from the chipset GT wakeref. As we reduce the struct_mutex requirement, these listeners should evaporate. Perhaps the biggest immediate change is that this removes the struct_mutex requirement around GT power management, allowing us greater flexibility in request construction. Another important knock-on effect, is that by tracking engine usage, we can insert a switch back to the kernel context on that engine immediately, avoiding any extra delay or inserting global synchronisation barriers. This makes tracking when an engine and its associated contexts are idle much easier -- important for when we forgo our assumed execution ordering and need idle barriers to unpin used contexts. In the process, it means we remove a large chunk of code whose only purpose was to switch back to the kernel context. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Imre Deak <imre.deak@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
183 lines
5.7 KiB
C
183 lines
5.7 KiB
C
/*
|
|
* Copyright © 2016 Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef __I915_GEM_CONTEXT_H__
|
|
#define __I915_GEM_CONTEXT_H__
|
|
|
|
#include "i915_gem_context_types.h"
|
|
|
|
#include "gt/intel_context.h"
|
|
|
|
#include "i915_gem.h"
|
|
#include "i915_scheduler.h"
|
|
#include "intel_device_info.h"
|
|
|
|
struct drm_device;
|
|
struct drm_file;
|
|
|
|
static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(CONTEXT_CLOSED, &ctx->flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_closed(struct i915_gem_context *ctx)
|
|
{
|
|
GEM_BUG_ON(i915_gem_context_is_closed(ctx));
|
|
set_bit(CONTEXT_CLOSED, &ctx->flags);
|
|
}
|
|
|
|
static inline bool i915_gem_context_no_error_capture(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(UCONTEXT_NO_ERROR_CAPTURE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_no_error_capture(struct i915_gem_context *ctx)
|
|
{
|
|
set_bit(UCONTEXT_NO_ERROR_CAPTURE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_clear_no_error_capture(struct i915_gem_context *ctx)
|
|
{
|
|
clear_bit(UCONTEXT_NO_ERROR_CAPTURE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline bool i915_gem_context_is_bannable(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(UCONTEXT_BANNABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_bannable(struct i915_gem_context *ctx)
|
|
{
|
|
set_bit(UCONTEXT_BANNABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_clear_bannable(struct i915_gem_context *ctx)
|
|
{
|
|
clear_bit(UCONTEXT_BANNABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline bool i915_gem_context_is_recoverable(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(UCONTEXT_RECOVERABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_recoverable(struct i915_gem_context *ctx)
|
|
{
|
|
set_bit(UCONTEXT_RECOVERABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_clear_recoverable(struct i915_gem_context *ctx)
|
|
{
|
|
clear_bit(UCONTEXT_RECOVERABLE, &ctx->user_flags);
|
|
}
|
|
|
|
static inline bool i915_gem_context_is_banned(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(CONTEXT_BANNED, &ctx->flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_banned(struct i915_gem_context *ctx)
|
|
{
|
|
set_bit(CONTEXT_BANNED, &ctx->flags);
|
|
}
|
|
|
|
static inline bool i915_gem_context_force_single_submission(const struct i915_gem_context *ctx)
|
|
{
|
|
return test_bit(CONTEXT_FORCE_SINGLE_SUBMISSION, &ctx->flags);
|
|
}
|
|
|
|
static inline void i915_gem_context_set_force_single_submission(struct i915_gem_context *ctx)
|
|
{
|
|
__set_bit(CONTEXT_FORCE_SINGLE_SUBMISSION, &ctx->flags);
|
|
}
|
|
|
|
int __i915_gem_context_pin_hw_id(struct i915_gem_context *ctx);
|
|
static inline int i915_gem_context_pin_hw_id(struct i915_gem_context *ctx)
|
|
{
|
|
if (atomic_inc_not_zero(&ctx->hw_id_pin_count))
|
|
return 0;
|
|
|
|
return __i915_gem_context_pin_hw_id(ctx);
|
|
}
|
|
|
|
static inline void i915_gem_context_unpin_hw_id(struct i915_gem_context *ctx)
|
|
{
|
|
GEM_BUG_ON(atomic_read(&ctx->hw_id_pin_count) == 0u);
|
|
atomic_dec(&ctx->hw_id_pin_count);
|
|
}
|
|
|
|
static inline bool i915_gem_context_is_kernel(struct i915_gem_context *ctx)
|
|
{
|
|
return !ctx->file_priv;
|
|
}
|
|
|
|
/* i915_gem_context.c */
|
|
int __must_check i915_gem_contexts_init(struct drm_i915_private *dev_priv);
|
|
void i915_gem_contexts_lost(struct drm_i915_private *dev_priv);
|
|
void i915_gem_contexts_fini(struct drm_i915_private *dev_priv);
|
|
|
|
int i915_gem_context_open(struct drm_i915_private *i915,
|
|
struct drm_file *file);
|
|
void i915_gem_context_close(struct drm_file *file);
|
|
|
|
void i915_gem_context_release(struct kref *ctx_ref);
|
|
struct i915_gem_context *
|
|
i915_gem_context_create_gvt(struct drm_device *dev);
|
|
|
|
int i915_gem_vm_create_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file);
|
|
int i915_gem_vm_destroy_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file);
|
|
|
|
int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file);
|
|
int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file);
|
|
int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv);
|
|
int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file);
|
|
|
|
struct i915_gem_context *
|
|
i915_gem_context_create_kernel(struct drm_i915_private *i915, int prio);
|
|
|
|
static inline struct i915_gem_context *
|
|
i915_gem_context_get(struct i915_gem_context *ctx)
|
|
{
|
|
kref_get(&ctx->ref);
|
|
return ctx;
|
|
}
|
|
|
|
static inline void i915_gem_context_put(struct i915_gem_context *ctx)
|
|
{
|
|
kref_put(&ctx->ref, i915_gem_context_release);
|
|
}
|
|
|
|
struct i915_lut_handle *i915_lut_handle_alloc(void);
|
|
void i915_lut_handle_free(struct i915_lut_handle *lut);
|
|
|
|
#endif /* !__I915_GEM_CONTEXT_H__ */
|