blob: 19ca5933a0908328bc4f8e3eb9b75d89ad834a11 [file] [log] [blame]
Alex Dai33a732f2015-08-12 15:43:36 +01001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24#ifndef _INTEL_GUC_H_
25#define _INTEL_GUC_H_
26
27#include "intel_guc_fwif.h"
28#include "i915_guc_reg.h"
29
Chris Wilsone73bdd22016-04-13 17:35:01 +010030struct drm_i915_gem_request;
31
Dave Gordon44a28b12015-08-12 15:43:41 +010032struct i915_guc_client {
33 struct drm_i915_gem_object *client_obj;
Dave Gordon0d92a6a2016-04-19 16:08:34 +010034 void *client_base; /* first page (only) of above */
Alex Daid1675192015-08-12 15:43:43 +010035 struct intel_context *owner;
Dave Gordon44a28b12015-08-12 15:43:41 +010036 struct intel_guc *guc;
37 uint32_t priority;
38 uint32_t ctx_index;
39
40 uint32_t proc_desc_offset;
41 uint32_t doorbell_offset;
42 uint32_t cookie;
43 uint16_t doorbell_id;
44 uint16_t padding; /* Maintain alignment */
45
46 uint32_t wq_offset;
47 uint32_t wq_size;
Dave Gordon44a28b12015-08-12 15:43:41 +010048 uint32_t wq_tail;
Alex Daia5916e82016-04-19 16:08:35 +010049 uint32_t unused; /* Was 'wq_head' */
Dave Gordon44a28b12015-08-12 15:43:41 +010050
51 /* GuC submission statistics & status */
Alex Dai397097b2016-01-23 11:58:14 -080052 uint64_t submissions[GUC_MAX_ENGINES_NUM];
Dave Gordon44a28b12015-08-12 15:43:41 +010053 uint32_t q_fail;
54 uint32_t b_fail;
55 int retcode;
Dave Gordon0d92a6a2016-04-19 16:08:34 +010056 int spare; /* pad to 32 DWords */
Dave Gordon44a28b12015-08-12 15:43:41 +010057};
58
Alex Dai33a732f2015-08-12 15:43:36 +010059enum intel_guc_fw_status {
60 GUC_FIRMWARE_FAIL = -1,
61 GUC_FIRMWARE_NONE = 0,
62 GUC_FIRMWARE_PENDING,
63 GUC_FIRMWARE_SUCCESS
64};
65
66/*
67 * This structure encapsulates all the data needed during the process
68 * of fetching, caching, and loading the firmware image into the GuC.
69 */
70struct intel_guc_fw {
71 struct drm_device * guc_dev;
72 const char * guc_fw_path;
73 size_t guc_fw_size;
74 struct drm_i915_gem_object * guc_fw_obj;
75 enum intel_guc_fw_status guc_fw_fetch_status;
76 enum intel_guc_fw_status guc_fw_load_status;
77
78 uint16_t guc_fw_major_wanted;
79 uint16_t guc_fw_minor_wanted;
80 uint16_t guc_fw_major_found;
81 uint16_t guc_fw_minor_found;
Alex Daifeda33e2015-10-19 16:10:54 -070082
83 uint32_t header_size;
84 uint32_t header_offset;
85 uint32_t rsa_size;
86 uint32_t rsa_offset;
87 uint32_t ucode_size;
88 uint32_t ucode_offset;
Alex Dai33a732f2015-08-12 15:43:36 +010089};
90
91struct intel_guc {
92 struct intel_guc_fw guc_fw;
Alex Dai33a732f2015-08-12 15:43:36 +010093 uint32_t log_flags;
Alex Dai4c7e77f2015-08-12 15:43:40 +010094 struct drm_i915_gem_object *log_obj;
Alex Daibac427f2015-08-12 15:43:39 +010095
Alex Dai68371a92015-12-18 12:00:09 -080096 struct drm_i915_gem_object *ads_obj;
97
Alex Daibac427f2015-08-12 15:43:39 +010098 struct drm_i915_gem_object *ctx_pool_obj;
99 struct ida ctx_ids;
Dave Gordon44a28b12015-08-12 15:43:41 +0100100
101 struct i915_guc_client *execbuf_client;
102
Dave Gordon44a28b12015-08-12 15:43:41 +0100103 DECLARE_BITMAP(doorbell_bitmap, GUC_MAX_DOORBELLS);
104 uint32_t db_cacheline; /* Cyclic counter mod pagesize */
105
106 /* Action status & statistics */
107 uint64_t action_count; /* Total commands issued */
108 uint32_t action_cmd; /* Last command word */
109 uint32_t action_status; /* Last return status */
110 uint32_t action_fail; /* Total number of failures */
111 int32_t action_err; /* Last error code */
112
Alex Dai397097b2016-01-23 11:58:14 -0800113 uint64_t submissions[GUC_MAX_ENGINES_NUM];
114 uint32_t last_seqno[GUC_MAX_ENGINES_NUM];
Alex Dai33a732f2015-08-12 15:43:36 +0100115};
116
117/* intel_guc_loader.c */
118extern void intel_guc_ucode_init(struct drm_device *dev);
119extern int intel_guc_ucode_load(struct drm_device *dev);
120extern void intel_guc_ucode_fini(struct drm_device *dev);
121extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
Alex Daia1c41992015-09-30 09:46:37 -0700122extern int intel_guc_suspend(struct drm_device *dev);
123extern int intel_guc_resume(struct drm_device *dev);
Alex Dai33a732f2015-08-12 15:43:36 +0100124
Alex Daibac427f2015-08-12 15:43:39 +0100125/* i915_guc_submission.c */
126int i915_guc_submission_init(struct drm_device *dev);
Dave Gordon44a28b12015-08-12 15:43:41 +0100127int i915_guc_submission_enable(struct drm_device *dev);
128int i915_guc_submit(struct i915_guc_client *client,
129 struct drm_i915_gem_request *rq);
130void i915_guc_submission_disable(struct drm_device *dev);
Alex Daibac427f2015-08-12 15:43:39 +0100131void i915_guc_submission_fini(struct drm_device *dev);
Alex Daia7e02192015-12-16 11:45:55 -0800132int i915_guc_wq_check_space(struct i915_guc_client *client);
Alex Daibac427f2015-08-12 15:43:39 +0100133
Alex Dai33a732f2015-08-12 15:43:36 +0100134#endif