blob: 6ca55c5bed3c2d6d8a8e4d08ace7bac5a9ccf413 [file] [log] [blame]
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +00001/*
2 * Copyright © 2014-2017 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
25#ifndef _INTEL_GUC_H_
26#define _INTEL_GUC_H_
27
28#include "intel_uncore.h"
Michal Wajdeczkoe8668bb2017-10-16 14:47:14 +000029#include "intel_guc_fw.h"
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000030#include "intel_guc_fwif.h"
31#include "intel_guc_ct.h"
32#include "intel_guc_log.h"
33#include "intel_uc_fw.h"
34#include "i915_guc_reg.h"
35#include "i915_vma.h"
36
Michal Wajdeczkod9e2e012017-10-16 14:47:13 +000037/*
38 * Top level structure of GuC. It handles firmware loading and manages client
39 * pool and doorbells. intel_guc owns a i915_guc_client to replace the legacy
40 * ExecList submission.
41 */
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000042struct intel_guc {
43 struct intel_uc_fw fw;
44 struct intel_guc_log log;
45 struct intel_guc_ct ct;
46
47 /* Log snapshot if GuC errors during load */
48 struct drm_i915_gem_object *load_err_log;
49
50 /* intel_guc_recv interrupt related state */
51 bool interrupts_enabled;
52
53 struct i915_vma *ads_vma;
54 struct i915_vma *stage_desc_pool;
55 void *stage_desc_pool_vaddr;
56 struct ida stage_ids;
Michał Winiarskib8e5eb92017-10-25 22:00:11 +020057 struct i915_vma *shared_data;
58 void *shared_data_vaddr;
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000059
60 struct i915_guc_client *execbuf_client;
Dave Gordone12ab162017-10-26 16:17:37 +020061 struct i915_guc_client *preempt_client;
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000062
63 DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
Joonas Lahtinenfaf65482017-10-06 11:49:40 +030064 /* Cyclic counter mod pagesize */
65 u32 db_cacheline;
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000066
67 /* GuC's FW specific registers used in MMIO send */
68 struct {
69 u32 base;
70 unsigned int count;
71 enum forcewake_domains fw_domains;
72 } send_regs;
73
74 /* To serialize the intel_guc_send actions */
75 struct mutex send_mutex;
76
77 /* GuC's FW specific send function */
78 int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
79
80 /* GuC's FW specific notify function */
81 void (*notify)(struct intel_guc *guc);
82};
83
84static
85inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
86{
87 return guc->send(guc, action, len);
88}
89
90static inline void intel_guc_notify(struct intel_guc *guc)
91{
92 guc->notify(guc);
93}
94
Michal Wajdeczkod9e2e012017-10-16 14:47:13 +000095/*
96 * GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP),
97 * which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is
98 * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects
99 * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM.
100 */
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +0000101static inline u32 guc_ggtt_offset(struct i915_vma *vma)
102{
103 u32 offset = i915_ggtt_offset(vma);
104
105 GEM_BUG_ON(offset < GUC_WOPCM_TOP);
106 GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
107
108 return offset;
109}
110
111void intel_guc_init_early(struct intel_guc *guc);
112void intel_guc_init_send_regs(struct intel_guc *guc);
Michal Wajdeczko5d53be42017-10-16 14:47:11 +0000113void intel_guc_init_params(struct intel_guc *guc);
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +0000114int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
115int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
116int intel_guc_sample_forcewake(struct intel_guc *guc);
117int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
118int intel_guc_suspend(struct drm_i915_private *dev_priv);
119int intel_guc_resume(struct drm_i915_private *dev_priv);
120struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +0000121u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
122
123#endif