summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_context.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-03-08 13:25:17 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-03-08 13:59:44 +0000
commit39e2f501c1b431bd9291308e1ef02b9a02fffbee (patch)
treebc19e4e7758795258b96d477fd3b408960493c38 /drivers/gpu/drm/i915/intel_context.h
parent7e3d9a59410d8ea1b4240952485731252ac15f34 (diff)
downloadlinux-39e2f501c1b431bd9291308e1ef02b9a02fffbee.tar.bz2
drm/i915: Split struct intel_context definition to its own header
This complex struct pulling in half the driver deserves its own isolation in preparation for intel_context becoming an outright complicated class of its own. In order to split this beast into its own header also requests splitting several of its dependent types and their dependencies into their own headers as well. v2: Add standalone compilation tests Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190308132522.21573-2-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/intel_context.h')
-rw-r--r--drivers/gpu/drm/i915/intel_context.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/intel_context.h b/drivers/gpu/drm/i915/intel_context.h
new file mode 100644
index 000000000000..dd947692bb0b
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_context.h
@@ -0,0 +1,47 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __INTEL_CONTEXT_H__
+#define __INTEL_CONTEXT_H__
+
+#include "i915_gem_context_types.h"
+#include "intel_context_types.h"
+#include "intel_engine_types.h"
+
+void intel_context_init(struct intel_context *ce,
+ struct i915_gem_context *ctx,
+ struct intel_engine_cs *engine);
+
+static inline struct intel_context *
+to_intel_context(struct i915_gem_context *ctx,
+ const struct intel_engine_cs *engine)
+{
+ return &ctx->__engine[engine->id];
+}
+
+static inline struct intel_context *
+intel_context_pin(struct i915_gem_context *ctx, struct intel_engine_cs *engine)
+{
+ return engine->context_pin(engine, ctx);
+}
+
+static inline void __intel_context_pin(struct intel_context *ce)
+{
+ GEM_BUG_ON(!ce->pin_count);
+ ce->pin_count++;
+}
+
+static inline void intel_context_unpin(struct intel_context *ce)
+{
+ GEM_BUG_ON(!ce->pin_count);
+ if (--ce->pin_count)
+ return;
+
+ GEM_BUG_ON(!ce->ops);
+ ce->ops->unpin(ce);
+}
+
+#endif /* __INTEL_CONTEXT_H__ */