b232e6d2cd921be4944466e6e36f7537ea25e442
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / gem / selftests / igt_gem_utils.c
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2018 Intel Corporation
5  */
6
7 #include "igt_gem_utils.h"
8
9 #include "gem/i915_gem_context.h"
10 #include "gem/i915_gem_pm.h"
11 #include "gt/intel_context.h"
12
13 #include "i915_request.h"
14
15 struct i915_request *
16 igt_request_alloc(struct i915_gem_context *ctx, struct intel_engine_cs *engine)
17 {
18         struct intel_context *ce;
19         struct i915_request *rq;
20
21         /*
22          * Pinning the contexts may generate requests in order to acquire
23          * GGTT space, so do this first before we reserve a seqno for
24          * ourselves.
25          */
26         ce = i915_gem_context_get_engine(ctx, engine->id);
27         if (IS_ERR(ce))
28                 return ERR_CAST(ce);
29
30         rq = intel_context_create_request(ce);
31         intel_context_put(ce);
32
33         return rq;
34 }