blob: aa9a7b55be6ead39c93a9a536c55537dd2a930ee [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"
29#include "intel_guc_fwif.h"
30#include "intel_guc_ct.h"
31#include "intel_guc_log.h"
32#include "intel_uc_fw.h"
33#include "i915_guc_reg.h"
34#include "i915_vma.h"
35
36struct intel_guc {
37 struct intel_uc_fw fw;
38 struct intel_guc_log log;
39 struct intel_guc_ct ct;
40
41 /* Log snapshot if GuC errors during load */
42 struct drm_i915_gem_object *load_err_log;
43
44 /* intel_guc_recv interrupt related state */
45 bool interrupts_enabled;
46
47 struct i915_vma *ads_vma;
48 struct i915_vma *stage_desc_pool;
49 void *stage_desc_pool_vaddr;
50 struct ida stage_ids;
51
52 struct i915_guc_client *execbuf_client;
53
54 DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
Joonas Lahtinenfaf65482017-10-06 11:49:40 +030055 /* Cyclic counter mod pagesize */
56 u32 db_cacheline;
Michal Wajdeczko9bf384c2017-10-04 18:13:41 +000057
58 /* GuC's FW specific registers used in MMIO send */
59 struct {
60 u32 base;
61 unsigned int count;
62 enum forcewake_domains fw_domains;
63 } send_regs;
64
65 /* To serialize the intel_guc_send actions */
66 struct mutex send_mutex;
67
68 /* GuC's FW specific send function */
69 int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
70
71 /* GuC's FW specific notify function */
72 void (*notify)(struct intel_guc *guc);
73};
74
75static
76inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
77{
78 return guc->send(guc, action, len);
79}
80
81static inline void intel_guc_notify(struct intel_guc *guc)
82{
83 guc->notify(guc);
84}
85
86static inline u32 guc_ggtt_offset(struct i915_vma *vma)
87{
88 u32 offset = i915_ggtt_offset(vma);
89
90 GEM_BUG_ON(offset < GUC_WOPCM_TOP);
91 GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
92
93 return offset;
94}
95
96void intel_guc_init_early(struct intel_guc *guc);
97void intel_guc_init_send_regs(struct intel_guc *guc);
98int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
99int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
100int intel_guc_sample_forcewake(struct intel_guc *guc);
101int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
102int intel_guc_suspend(struct drm_i915_private *dev_priv);
103int intel_guc_resume(struct drm_i915_private *dev_priv);
104struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
105
106int intel_guc_select_fw(struct intel_guc *guc);
107int intel_guc_init_hw(struct intel_guc *guc);
108u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
109
110#endif