blob: 094d64980882d95b3f2ddee2aedf3d5166669d58 [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);
55 uint32_t db_cacheline; /* Cyclic counter mod pagesize */
56
57 /* GuC's FW specific registers used in MMIO send */
58 struct {
59 u32 base;
60 unsigned int count;
61 enum forcewake_domains fw_domains;
62 } send_regs;
63
64 /* To serialize the intel_guc_send actions */
65 struct mutex send_mutex;
66
67 /* GuC's FW specific send function */
68 int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
69
70 /* GuC's FW specific notify function */
71 void (*notify)(struct intel_guc *guc);
72};
73
74static
75inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
76{
77 return guc->send(guc, action, len);
78}
79
80static inline void intel_guc_notify(struct intel_guc *guc)
81{
82 guc->notify(guc);
83}
84
85static inline u32 guc_ggtt_offset(struct i915_vma *vma)
86{
87 u32 offset = i915_ggtt_offset(vma);
88
89 GEM_BUG_ON(offset < GUC_WOPCM_TOP);
90 GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
91
92 return offset;
93}
94
95void intel_guc_init_early(struct intel_guc *guc);
96void intel_guc_init_send_regs(struct intel_guc *guc);
97int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
98int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
99int intel_guc_sample_forcewake(struct intel_guc *guc);
100int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
101int intel_guc_suspend(struct drm_i915_private *dev_priv);
102int intel_guc_resume(struct drm_i915_private *dev_priv);
103struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
104
105int intel_guc_select_fw(struct intel_guc *guc);
106int intel_guc_init_hw(struct intel_guc *guc);
107u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
108
109#endif