forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/msm/msm_gpu.h
....@@ -1,29 +1,22 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2013 Red Hat
34 * Author: Rob Clark <robdclark@gmail.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
187 #ifndef __MSM_GPU_H__
198 #define __MSM_GPU_H__
209
10
+#include <linux/adreno-smmu-priv.h>
2111 #include <linux/clk.h>
12
+#include <linux/interconnect.h>
13
+#include <linux/pm_opp.h>
2214 #include <linux/regulator/consumer.h>
2315
2416 #include "msm_drv.h"
2517 #include "msm_fence.h"
2618 #include "msm_ringbuffer.h"
19
+#include "msm_gem.h"
2720
2821 struct msm_gem_submit;
2922 struct msm_gpu_perfcntr;
....@@ -31,9 +24,6 @@
3124
3225 struct msm_gpu_config {
3326 const char *ioname;
34
- const char *irqname;
35
- uint64_t va_start;
36
- uint64_t va_end;
3727 unsigned int nr_rings;
3828 };
3929
....@@ -56,8 +46,7 @@
5646 int (*hw_init)(struct msm_gpu *gpu);
5747 int (*pm_suspend)(struct msm_gpu *gpu);
5848 int (*pm_resume)(struct msm_gpu *gpu);
59
- void (*submit)(struct msm_gpu *gpu, struct msm_gem_submit *submit,
60
- struct msm_file_private *ctx);
49
+ void (*submit)(struct msm_gpu *gpu, struct msm_gem_submit *submit);
6150 void (*flush)(struct msm_gpu *gpu, struct msm_ringbuffer *ring);
6251 irqreturn_t (*irq)(struct msm_gpu *irq);
6352 struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu);
....@@ -68,11 +57,18 @@
6857 void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state,
6958 struct drm_printer *p);
7059 /* for generation specific debugfs: */
71
- int (*debugfs_init)(struct msm_gpu *gpu, struct drm_minor *minor);
60
+ void (*debugfs_init)(struct msm_gpu *gpu, struct drm_minor *minor);
7261 #endif
73
- int (*gpu_busy)(struct msm_gpu *gpu, uint64_t *value);
62
+ unsigned long (*gpu_busy)(struct msm_gpu *gpu);
7463 struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu);
7564 int (*gpu_state_put)(struct msm_gpu_state *state);
65
+ unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);
66
+ void (*gpu_set_freq)(struct msm_gpu *gpu, struct dev_pm_opp *opp);
67
+ struct msm_gem_address_space *(*create_address_space)
68
+ (struct msm_gpu *gpu, struct platform_device *pdev);
69
+ struct msm_gem_address_space *(*create_private_address_space)
70
+ (struct msm_gpu *gpu);
71
+ uint32_t (*get_rptr)(struct msm_gpu *gpu, struct msm_ringbuffer *ring);
7672 };
7773
7874 struct msm_gpu {
....@@ -80,6 +76,8 @@
8076 struct drm_device *dev;
8177 struct platform_device *pdev;
8278 const struct msm_gpu_funcs *funcs;
79
+
80
+ struct adreno_smmu_priv adreno_smmu;
8381
8482 /* performance counters (hw & sw): */
8583 spinlock_t perf_lock;
....@@ -102,6 +100,9 @@
102100 /* does gpu need hw_init? */
103101 bool needs_hw_init;
104102
103
+ /* number of GPU hangs (for all contexts) */
104
+ int global_faults;
105
+
105106 /* worker for handling active-list retiring: */
106107 struct work_struct retire_work;
107108
....@@ -116,6 +117,15 @@
116117 int nr_clocks;
117118 struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk;
118119 uint32_t fast_rate;
120
+
121
+ /* The gfx-mem interconnect path that's used by all GPU types. */
122
+ struct icc_path *icc_path;
123
+
124
+ /*
125
+ * Second interconnect path for some A3xx and all A4xx GPUs to the
126
+ * On Chip MEMory (OCMEM).
127
+ */
128
+ struct icc_path *ocmem_icc_path;
119129
120130 /* Hang and Inactivity Detection:
121131 */
....@@ -135,7 +145,15 @@
135145 } devfreq;
136146
137147 struct msm_gpu_state *crashstate;
148
+ /* True if the hardware supports expanded apriv (a650 and newer) */
149
+ bool hw_apriv;
138150 };
151
+
152
+static inline struct msm_gpu *dev_to_gpu(struct device *dev)
153
+{
154
+ struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev);
155
+ return container_of(adreno_smmu, struct msm_gpu, adreno_smmu);
156
+}
139157
140158 /* It turns out that all targets use the same ringbuffer size */
141159 #define MSM_GPU_RINGBUFFER_SZ SZ_32K
....@@ -177,6 +195,7 @@
177195 u32 flags;
178196 u32 prio;
179197 int faults;
198
+ struct msm_file_private *ctx;
180199 struct list_head node;
181200 struct kref ref;
182201 };
....@@ -185,6 +204,7 @@
185204 u64 iova;
186205 size_t size;
187206 void *data;
207
+ bool encoded;
188208 };
189209
190210 struct msm_gpu_state {
....@@ -199,6 +219,7 @@
199219 u32 wptr;
200220 void *data;
201221 int data_size;
222
+ bool encoded;
202223 } ring[MSM_GPU_MAX_RINGS];
203224
204225 int nr_registers;
....@@ -264,6 +285,7 @@
264285
265286 int msm_gpu_pm_suspend(struct msm_gpu *gpu);
266287 int msm_gpu_pm_resume(struct msm_gpu *gpu);
288
+void msm_gpu_resume_devfreq(struct msm_gpu *gpu);
267289
268290 int msm_gpu_hw_init(struct msm_gpu *gpu);
269291
....@@ -273,12 +295,14 @@
273295 uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs);
274296
275297 void msm_gpu_retire(struct msm_gpu *gpu);
276
-void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
277
- struct msm_file_private *ctx);
298
+void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit);
278299
279300 int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
280301 struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
281302 const char *name, struct msm_gpu_config *config);
303
+
304
+struct msm_gem_address_space *
305
+msm_gpu_create_private_address_space(struct msm_gpu *gpu, struct task_struct *task);
282306
283307 void msm_gpu_cleanup(struct msm_gpu *gpu);
284308
....@@ -320,4 +344,12 @@
320344 mutex_unlock(&gpu->dev->struct_mutex);
321345 }
322346
347
+/*
348
+ * Simple macro to semi-cleanly add the MAP_PRIV flag for targets that can
349
+ * support expanded privileges
350
+ */
351
+#define check_apriv(gpu, flags) \
352
+ (((gpu)->hw_apriv ? MSM_BO_MAP_PRIV : 0) | (flags))
353
+
354
+
323355 #endif /* __MSM_GPU_H__ */