Thomas Gleixner | caab277 | 2019-06-03 07:44:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Red Hat |
| 4 | * Author: Rob Clark <robdclark@gmail.com> |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __MSM_GPU_H__ |
| 8 | #define __MSM_GPU_H__ |
| 9 | |
Rob Clark | 9cba405 | 2020-08-17 15:01:32 -0700 | [diff] [blame] | 10 | #include <linux/adreno-smmu-priv.h> |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 11 | #include <linux/clk.h> |
Jordan Crouse | fcf9d0b | 2019-02-12 11:52:38 +0200 | [diff] [blame] | 12 | #include <linux/interconnect.h> |
Sharat Masetty | 1f60d11 | 2020-07-13 18:11:42 +0530 | [diff] [blame] | 13 | #include <linux/pm_opp.h> |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 14 | #include <linux/regulator/consumer.h> |
| 15 | |
| 16 | #include "msm_drv.h" |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 17 | #include "msm_fence.h" |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 18 | #include "msm_ringbuffer.h" |
Jordan Crouse | 604234f | 2020-09-03 20:03:11 -0600 | [diff] [blame] | 19 | #include "msm_gem.h" |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 20 | |
| 21 | struct msm_gem_submit; |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 22 | struct msm_gpu_perfcntr; |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 23 | struct msm_gpu_state; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 24 | |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 25 | struct msm_gpu_config { |
| 26 | const char *ioname; |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 27 | unsigned int nr_rings; |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 28 | }; |
| 29 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 30 | /* So far, with hardware that I've seen to date, we can have: |
| 31 | * + zero, one, or two z180 2d cores |
| 32 | * + a3xx or a2xx 3d core, which share a common CP (the firmware |
| 33 | * for the CP seems to implement some different PM4 packet types |
| 34 | * but the basics of cmdstream submission are the same) |
| 35 | * |
| 36 | * Which means that the eventual complete "class" hierarchy, once |
| 37 | * support for all past and present hw is in place, becomes: |
| 38 | * + msm_gpu |
| 39 | * + adreno_gpu |
| 40 | * + a3xx_gpu |
| 41 | * + a2xx_gpu |
| 42 | * + z180_gpu |
| 43 | */ |
| 44 | struct msm_gpu_funcs { |
| 45 | int (*get_param)(struct msm_gpu *gpu, uint32_t param, uint64_t *value); |
| 46 | int (*hw_init)(struct msm_gpu *gpu); |
| 47 | int (*pm_suspend)(struct msm_gpu *gpu); |
| 48 | int (*pm_resume)(struct msm_gpu *gpu); |
Jordan Crouse | 15eb9ad | 2020-08-17 15:01:37 -0700 | [diff] [blame] | 49 | void (*submit)(struct msm_gpu *gpu, struct msm_gem_submit *submit); |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 50 | void (*flush)(struct msm_gpu *gpu, struct msm_ringbuffer *ring); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 51 | irqreturn_t (*irq)(struct msm_gpu *irq); |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 52 | struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu); |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 53 | void (*recover)(struct msm_gpu *gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 54 | void (*destroy)(struct msm_gpu *gpu); |
Arnd Bergmann | c878a62 | 2018-08-13 23:23:44 +0200 | [diff] [blame] | 55 | #if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 56 | /* show GPU status in debugfs: */ |
Jordan Crouse | 4f776f4 | 2018-07-24 10:33:25 -0600 | [diff] [blame] | 57 | void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state, |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 58 | struct drm_printer *p); |
Rob Clark | 331dc0b | 2017-12-13 15:12:56 -0500 | [diff] [blame] | 59 | /* for generation specific debugfs: */ |
Wambui Karuga | 7ce84471 | 2020-03-10 16:31:21 +0300 | [diff] [blame] | 60 | void (*debugfs_init)(struct msm_gpu *gpu, struct drm_minor *minor); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 61 | #endif |
Sharat Masetty | de0a3d09 | 2018-10-04 15:11:42 +0530 | [diff] [blame] | 62 | unsigned long (*gpu_busy)(struct msm_gpu *gpu); |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 63 | struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu); |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 64 | int (*gpu_state_put)(struct msm_gpu_state *state); |
Sharat Masetty | de0a3d09 | 2018-10-04 15:11:42 +0530 | [diff] [blame] | 65 | unsigned long (*gpu_get_freq)(struct msm_gpu *gpu); |
Sharat Masetty | 1f60d11 | 2020-07-13 18:11:42 +0530 | [diff] [blame] | 66 | void (*gpu_set_freq)(struct msm_gpu *gpu, struct dev_pm_opp *opp); |
Jordan Crouse | ccac7ce | 2020-05-22 16:03:15 -0600 | [diff] [blame] | 67 | struct msm_gem_address_space *(*create_address_space) |
| 68 | (struct msm_gpu *gpu, struct platform_device *pdev); |
Jordan Crouse | 933415e | 2020-08-17 15:01:40 -0700 | [diff] [blame^] | 69 | struct msm_gem_address_space *(*create_private_address_space) |
| 70 | (struct msm_gpu *gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct msm_gpu { |
| 74 | const char *name; |
| 75 | struct drm_device *dev; |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 76 | struct platform_device *pdev; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 77 | const struct msm_gpu_funcs *funcs; |
| 78 | |
Rob Clark | 9cba405 | 2020-08-17 15:01:32 -0700 | [diff] [blame] | 79 | struct adreno_smmu_priv adreno_smmu; |
| 80 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 81 | /* performance counters (hw & sw): */ |
| 82 | spinlock_t perf_lock; |
| 83 | bool perfcntr_active; |
| 84 | struct { |
| 85 | bool active; |
| 86 | ktime_t time; |
| 87 | } last_sample; |
| 88 | uint32_t totaltime, activetime; /* sw counters */ |
| 89 | uint32_t last_cntrs[5]; /* hw counters */ |
| 90 | const struct msm_gpu_perfcntr *perfcntrs; |
| 91 | uint32_t num_perfcntrs; |
| 92 | |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 93 | struct msm_ringbuffer *rb[MSM_GPU_MAX_RINGS]; |
| 94 | int nr_rings; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 95 | |
| 96 | /* list of GEM active objects: */ |
| 97 | struct list_head active_list; |
| 98 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 99 | /* does gpu need hw_init? */ |
| 100 | bool needs_hw_init; |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 101 | |
Rob Clark | 48dc424 | 2019-04-16 16:13:28 -0700 | [diff] [blame] | 102 | /* number of GPU hangs (for all contexts) */ |
| 103 | int global_faults; |
| 104 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 105 | /* worker for handling active-list retiring: */ |
| 106 | struct work_struct retire_work; |
| 107 | |
| 108 | void __iomem *mmio; |
| 109 | int irq; |
| 110 | |
Rob Clark | 667ce33 | 2016-09-28 19:58:32 -0400 | [diff] [blame] | 111 | struct msm_gem_address_space *aspace; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 112 | |
| 113 | /* Power Control: */ |
| 114 | struct regulator *gpu_reg, *gpu_cx; |
Jordan Crouse | 8e54eea | 2018-08-06 11:33:21 -0600 | [diff] [blame] | 115 | struct clk_bulk_data *grp_clks; |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 116 | int nr_clocks; |
| 117 | struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk; |
Jordan Crouse | 1babd70 | 2017-11-21 12:40:53 -0700 | [diff] [blame] | 118 | uint32_t fast_rate; |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 119 | |
Brian Masney | 00bb924 | 2019-11-21 20:26:43 -0500 | [diff] [blame] | 120 | /* The gfx-mem interconnect path that's used by all GPU types. */ |
Jordan Crouse | fcf9d0b | 2019-02-12 11:52:38 +0200 | [diff] [blame] | 121 | struct icc_path *icc_path; |
| 122 | |
Brian Masney | 00bb924 | 2019-11-21 20:26:43 -0500 | [diff] [blame] | 123 | /* |
| 124 | * Second interconnect path for some A3xx and all A4xx GPUs to the |
| 125 | * On Chip MEMory (OCMEM). |
| 126 | */ |
| 127 | struct icc_path *ocmem_icc_path; |
| 128 | |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 129 | /* Hang and Inactivity Detection: |
| 130 | */ |
| 131 | #define DRM_MSM_INACTIVE_PERIOD 66 /* in ms (roughly four frames) */ |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 132 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 133 | #define DRM_MSM_HANGCHECK_PERIOD 500 /* in ms */ |
| 134 | #define DRM_MSM_HANGCHECK_JIFFIES msecs_to_jiffies(DRM_MSM_HANGCHECK_PERIOD) |
| 135 | struct timer_list hangcheck_timer; |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 136 | struct work_struct recover_work; |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 137 | |
Jordan Crouse | cd414f3 | 2017-10-20 11:06:56 -0600 | [diff] [blame] | 138 | struct drm_gem_object *memptrs_bo; |
Jordan Crouse | f91c14a | 2018-01-10 10:41:54 -0700 | [diff] [blame] | 139 | |
| 140 | struct { |
| 141 | struct devfreq *devfreq; |
| 142 | u64 busy_cycles; |
| 143 | ktime_t time; |
| 144 | } devfreq; |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 145 | |
| 146 | struct msm_gpu_state *crashstate; |
Jordan Crouse | 604234f | 2020-09-03 20:03:11 -0600 | [diff] [blame] | 147 | /* True if the hardware supports expanded apriv (a650 and newer) */ |
| 148 | bool hw_apriv; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 149 | }; |
| 150 | |
Rob Clark | 69a9313 | 2020-08-17 15:01:31 -0700 | [diff] [blame] | 151 | static inline struct msm_gpu *dev_to_gpu(struct device *dev) |
| 152 | { |
Rob Clark | 9cba405 | 2020-08-17 15:01:32 -0700 | [diff] [blame] | 153 | struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev); |
| 154 | return container_of(adreno_smmu, struct msm_gpu, adreno_smmu); |
Rob Clark | 69a9313 | 2020-08-17 15:01:31 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 157 | /* It turns out that all targets use the same ringbuffer size */ |
| 158 | #define MSM_GPU_RINGBUFFER_SZ SZ_32K |
Jordan Crouse | 4d87fc3 | 2017-10-20 11:07:00 -0600 | [diff] [blame] | 159 | #define MSM_GPU_RINGBUFFER_BLKSIZE 32 |
| 160 | |
| 161 | #define MSM_GPU_RB_CNTL_DEFAULT \ |
| 162 | (AXXX_CP_RB_CNTL_BUFSZ(ilog2(MSM_GPU_RINGBUFFER_SZ / 8)) | \ |
| 163 | AXXX_CP_RB_CNTL_BLKSZ(ilog2(MSM_GPU_RINGBUFFER_BLKSIZE / 8))) |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 164 | |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 165 | static inline bool msm_gpu_active(struct msm_gpu *gpu) |
| 166 | { |
Jordan Crouse | f97deca | 2017-10-20 11:06:57 -0600 | [diff] [blame] | 167 | int i; |
| 168 | |
| 169 | for (i = 0; i < gpu->nr_rings; i++) { |
| 170 | struct msm_ringbuffer *ring = gpu->rb[i]; |
| 171 | |
| 172 | if (ring->seqno > ring->memptrs->fence) |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | return false; |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 177 | } |
| 178 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 179 | /* Perf-Counters: |
| 180 | * The select_reg and select_val are just there for the benefit of the child |
| 181 | * class that actually enables the perf counter.. but msm_gpu base class |
| 182 | * will handle sampling/displaying the counters. |
| 183 | */ |
| 184 | |
| 185 | struct msm_gpu_perfcntr { |
| 186 | uint32_t select_reg; |
| 187 | uint32_t sample_reg; |
| 188 | uint32_t select_val; |
| 189 | const char *name; |
| 190 | }; |
| 191 | |
Jordan Crouse | f7de154 | 2017-10-20 11:06:55 -0600 | [diff] [blame] | 192 | struct msm_gpu_submitqueue { |
| 193 | int id; |
| 194 | u32 flags; |
| 195 | u32 prio; |
| 196 | int faults; |
Jordan Crouse | cf655d6 | 2020-08-17 15:01:36 -0700 | [diff] [blame] | 197 | struct msm_file_private *ctx; |
Jordan Crouse | f7de154 | 2017-10-20 11:06:55 -0600 | [diff] [blame] | 198 | struct list_head node; |
| 199 | struct kref ref; |
| 200 | }; |
| 201 | |
Jordan Crouse | cdb9593 | 2018-07-24 10:33:31 -0600 | [diff] [blame] | 202 | struct msm_gpu_state_bo { |
| 203 | u64 iova; |
| 204 | size_t size; |
| 205 | void *data; |
Sharat Masetty | 1df4289 | 2018-11-01 20:16:45 +0530 | [diff] [blame] | 206 | bool encoded; |
Jordan Crouse | cdb9593 | 2018-07-24 10:33:31 -0600 | [diff] [blame] | 207 | }; |
| 208 | |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 209 | struct msm_gpu_state { |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 210 | struct kref ref; |
Arnd Bergmann | 3530a17 | 2018-07-26 14:39:25 +0200 | [diff] [blame] | 211 | struct timespec64 time; |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 212 | |
| 213 | struct { |
| 214 | u64 iova; |
| 215 | u32 fence; |
| 216 | u32 seqno; |
| 217 | u32 rptr; |
| 218 | u32 wptr; |
Jordan Crouse | 43a5668 | 2018-07-24 10:33:29 -0600 | [diff] [blame] | 219 | void *data; |
| 220 | int data_size; |
Sharat Masetty | 1df4289 | 2018-11-01 20:16:45 +0530 | [diff] [blame] | 221 | bool encoded; |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 222 | } ring[MSM_GPU_MAX_RINGS]; |
| 223 | |
| 224 | int nr_registers; |
| 225 | u32 *registers; |
| 226 | |
| 227 | u32 rbbm_status; |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 228 | |
| 229 | char *comm; |
| 230 | char *cmd; |
Jordan Crouse | cdb9593 | 2018-07-24 10:33:31 -0600 | [diff] [blame] | 231 | |
| 232 | int nr_bos; |
| 233 | struct msm_gpu_state_bo *bos; |
Jordan Crouse | e00e473 | 2018-07-24 10:33:24 -0600 | [diff] [blame] | 234 | }; |
| 235 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 236 | static inline void gpu_write(struct msm_gpu *gpu, u32 reg, u32 data) |
| 237 | { |
| 238 | msm_writel(data, gpu->mmio + (reg << 2)); |
| 239 | } |
| 240 | |
| 241 | static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg) |
| 242 | { |
| 243 | return msm_readl(gpu->mmio + (reg << 2)); |
| 244 | } |
| 245 | |
Jordan Crouse | ae53a82 | 2016-11-28 12:28:28 -0700 | [diff] [blame] | 246 | static inline void gpu_rmw(struct msm_gpu *gpu, u32 reg, u32 mask, u32 or) |
| 247 | { |
| 248 | uint32_t val = gpu_read(gpu, reg); |
| 249 | |
| 250 | val &= ~mask; |
| 251 | gpu_write(gpu, reg, val | or); |
| 252 | } |
| 253 | |
| 254 | static inline u64 gpu_read64(struct msm_gpu *gpu, u32 lo, u32 hi) |
| 255 | { |
| 256 | u64 val; |
| 257 | |
| 258 | /* |
| 259 | * Why not a readq here? Two reasons: 1) many of the LO registers are |
| 260 | * not quad word aligned and 2) the GPU hardware designers have a bit |
| 261 | * of a history of putting registers where they fit, especially in |
| 262 | * spins. The longer a GPU family goes the higher the chance that |
| 263 | * we'll get burned. We could do a series of validity checks if we |
| 264 | * wanted to, but really is a readq() that much better? Nah. |
| 265 | */ |
| 266 | |
| 267 | /* |
| 268 | * For some lo/hi registers (like perfcounters), the hi value is latched |
| 269 | * when the lo is read, so make sure to read the lo first to trigger |
| 270 | * that |
| 271 | */ |
| 272 | val = (u64) msm_readl(gpu->mmio + (lo << 2)); |
| 273 | val |= ((u64) msm_readl(gpu->mmio + (hi << 2)) << 32); |
| 274 | |
| 275 | return val; |
| 276 | } |
| 277 | |
| 278 | static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val) |
| 279 | { |
| 280 | /* Why not a writeq here? Read the screed above */ |
| 281 | msm_writel(lower_32_bits(val), gpu->mmio + (lo << 2)); |
| 282 | msm_writel(upper_32_bits(val), gpu->mmio + (hi << 2)); |
| 283 | } |
| 284 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 285 | int msm_gpu_pm_suspend(struct msm_gpu *gpu); |
| 286 | int msm_gpu_pm_resume(struct msm_gpu *gpu); |
Sharat Masetty | de0a3d09 | 2018-10-04 15:11:42 +0530 | [diff] [blame] | 287 | void msm_gpu_resume_devfreq(struct msm_gpu *gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 288 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 289 | int msm_gpu_hw_init(struct msm_gpu *gpu); |
| 290 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 291 | void msm_gpu_perfcntr_start(struct msm_gpu *gpu); |
| 292 | void msm_gpu_perfcntr_stop(struct msm_gpu *gpu); |
| 293 | int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime, |
| 294 | uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs); |
| 295 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 296 | void msm_gpu_retire(struct msm_gpu *gpu); |
Jordan Crouse | 15eb9ad | 2020-08-17 15:01:37 -0700 | [diff] [blame] | 297 | void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 298 | |
| 299 | int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, |
| 300 | struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs, |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 301 | const char *name, struct msm_gpu_config *config); |
| 302 | |
Jordan Crouse | 933415e | 2020-08-17 15:01:40 -0700 | [diff] [blame^] | 303 | struct msm_gem_address_space * |
| 304 | msm_gpu_create_private_address_space(struct msm_gpu *gpu); |
| 305 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 306 | void msm_gpu_cleanup(struct msm_gpu *gpu); |
| 307 | |
Rob Clark | e2550b7 | 2014-09-05 13:30:27 -0400 | [diff] [blame] | 308 | struct msm_gpu *adreno_load_gpu(struct drm_device *dev); |
Rob Clark | bfd28b1 | 2014-09-05 13:06:37 -0400 | [diff] [blame] | 309 | void __init adreno_register(void); |
| 310 | void __exit adreno_unregister(void); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 311 | |
Jordan Crouse | f7de154 | 2017-10-20 11:06:55 -0600 | [diff] [blame] | 312 | static inline void msm_submitqueue_put(struct msm_gpu_submitqueue *queue) |
| 313 | { |
| 314 | if (queue) |
| 315 | kref_put(&queue->ref, msm_submitqueue_destroy); |
| 316 | } |
| 317 | |
Jordan Crouse | c0fec7f | 2018-07-24 10:33:27 -0600 | [diff] [blame] | 318 | static inline struct msm_gpu_state *msm_gpu_crashstate_get(struct msm_gpu *gpu) |
| 319 | { |
| 320 | struct msm_gpu_state *state = NULL; |
| 321 | |
| 322 | mutex_lock(&gpu->dev->struct_mutex); |
| 323 | |
| 324 | if (gpu->crashstate) { |
| 325 | kref_get(&gpu->crashstate->ref); |
| 326 | state = gpu->crashstate; |
| 327 | } |
| 328 | |
| 329 | mutex_unlock(&gpu->dev->struct_mutex); |
| 330 | |
| 331 | return state; |
| 332 | } |
| 333 | |
| 334 | static inline void msm_gpu_crashstate_put(struct msm_gpu *gpu) |
| 335 | { |
| 336 | mutex_lock(&gpu->dev->struct_mutex); |
| 337 | |
| 338 | if (gpu->crashstate) { |
| 339 | if (gpu->funcs->gpu_state_put(gpu->crashstate)) |
| 340 | gpu->crashstate = NULL; |
| 341 | } |
| 342 | |
| 343 | mutex_unlock(&gpu->dev->struct_mutex); |
| 344 | } |
| 345 | |
Jordan Crouse | 604234f | 2020-09-03 20:03:11 -0600 | [diff] [blame] | 346 | /* |
| 347 | * Simple macro to semi-cleanly add the MAP_PRIV flag for targets that can |
| 348 | * support expanded privileges |
| 349 | */ |
| 350 | #define check_apriv(gpu, flags) \ |
| 351 | (((gpu)->hw_apriv ? MSM_BO_MAP_PRIV : 0) | (flags)) |
| 352 | |
| 353 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 354 | #endif /* __MSM_GPU_H__ */ |