xref: /openbmc/linux/drivers/gpu/drm/msm/msm_gpu.h (revision cfebe3fd)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2013 Red Hat
4  * Author: Rob Clark <robdclark@gmail.com>
5  */
6 
7 #ifndef __MSM_GPU_H__
8 #define __MSM_GPU_H__
9 
10 #include <linux/adreno-smmu-priv.h>
11 #include <linux/clk.h>
12 #include <linux/devfreq.h>
13 #include <linux/interconnect.h>
14 #include <linux/pm_opp.h>
15 #include <linux/regulator/consumer.h>
16 
17 #include "msm_drv.h"
18 #include "msm_fence.h"
19 #include "msm_ringbuffer.h"
20 #include "msm_gem.h"
21 
22 struct msm_gem_submit;
23 struct msm_gpu_perfcntr;
24 struct msm_gpu_state;
25 struct msm_file_private;
26 
27 struct msm_gpu_config {
28 	const char *ioname;
29 	unsigned int nr_rings;
30 };
31 
32 /* So far, with hardware that I've seen to date, we can have:
33  *  + zero, one, or two z180 2d cores
34  *  + a3xx or a2xx 3d core, which share a common CP (the firmware
35  *    for the CP seems to implement some different PM4 packet types
36  *    but the basics of cmdstream submission are the same)
37  *
38  * Which means that the eventual complete "class" hierarchy, once
39  * support for all past and present hw is in place, becomes:
40  *  + msm_gpu
41  *    + adreno_gpu
42  *      + a3xx_gpu
43  *      + a2xx_gpu
44  *    + z180_gpu
45  */
46 struct msm_gpu_funcs {
47 	int (*get_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
48 			 uint32_t param, uint64_t *value, uint32_t *len);
49 	int (*set_param)(struct msm_gpu *gpu, struct msm_file_private *ctx,
50 			 uint32_t param, uint64_t value, uint32_t len);
51 	int (*hw_init)(struct msm_gpu *gpu);
52 	int (*pm_suspend)(struct msm_gpu *gpu);
53 	int (*pm_resume)(struct msm_gpu *gpu);
54 	void (*submit)(struct msm_gpu *gpu, struct msm_gem_submit *submit);
55 	void (*flush)(struct msm_gpu *gpu, struct msm_ringbuffer *ring);
56 	irqreturn_t (*irq)(struct msm_gpu *irq);
57 	struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu);
58 	void (*recover)(struct msm_gpu *gpu);
59 	void (*destroy)(struct msm_gpu *gpu);
60 #if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP)
61 	/* show GPU status in debugfs: */
62 	void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state,
63 			struct drm_printer *p);
64 	/* for generation specific debugfs: */
65 	void (*debugfs_init)(struct msm_gpu *gpu, struct drm_minor *minor);
66 #endif
67 	u64 (*gpu_busy)(struct msm_gpu *gpu, unsigned long *out_sample_rate);
68 	struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu);
69 	int (*gpu_state_put)(struct msm_gpu_state *state);
70 	unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);
71 	void (*gpu_set_freq)(struct msm_gpu *gpu, struct dev_pm_opp *opp);
72 	struct msm_gem_address_space *(*create_address_space)
73 		(struct msm_gpu *gpu, struct platform_device *pdev);
74 	struct msm_gem_address_space *(*create_private_address_space)
75 		(struct msm_gpu *gpu);
76 	uint32_t (*get_rptr)(struct msm_gpu *gpu, struct msm_ringbuffer *ring);
77 };
78 
79 /* Additional state for iommu faults: */
80 struct msm_gpu_fault_info {
81 	u64 ttbr0;
82 	unsigned long iova;
83 	int flags;
84 	const char *type;
85 	const char *block;
86 };
87 
88 /**
89  * struct msm_gpu_devfreq - devfreq related state
90  */
91 struct msm_gpu_devfreq {
92 	/** devfreq: devfreq instance */
93 	struct devfreq *devfreq;
94 
95 	/**
96 	 * idle_constraint:
97 	 *
98 	 * A PM QoS constraint to limit max freq while the GPU is idle.
99 	 */
100 	struct dev_pm_qos_request idle_freq;
101 
102 	/**
103 	 * boost_constraint:
104 	 *
105 	 * A PM QoS constraint to boost min freq for a period of time
106 	 * until the boost expires.
107 	 */
108 	struct dev_pm_qos_request boost_freq;
109 
110 	/**
111 	 * busy_cycles: Last busy counter value, for calculating elapsed busy
112 	 * cycles since last sampling period.
113 	 */
114 	u64 busy_cycles;
115 
116 	/** time: Time of last sampling period. */
117 	ktime_t time;
118 
119 	/** idle_time: Time of last transition to idle: */
120 	ktime_t idle_time;
121 
122 	struct devfreq_dev_status average_status;
123 
124 	/**
125 	 * idle_work:
126 	 *
127 	 * Used to delay clamping to idle freq on active->idle transition.
128 	 */
129 	struct msm_hrtimer_work idle_work;
130 
131 	/**
132 	 * boost_work:
133 	 *
134 	 * Used to reset the boost_constraint after the boost period has
135 	 * elapsed
136 	 */
137 	struct msm_hrtimer_work boost_work;
138 };
139 
140 struct msm_gpu {
141 	const char *name;
142 	struct drm_device *dev;
143 	struct platform_device *pdev;
144 	const struct msm_gpu_funcs *funcs;
145 
146 	struct adreno_smmu_priv adreno_smmu;
147 
148 	/* performance counters (hw & sw): */
149 	spinlock_t perf_lock;
150 	bool perfcntr_active;
151 	struct {
152 		bool active;
153 		ktime_t time;
154 	} last_sample;
155 	uint32_t totaltime, activetime;    /* sw counters */
156 	uint32_t last_cntrs[5];            /* hw counters */
157 	const struct msm_gpu_perfcntr *perfcntrs;
158 	uint32_t num_perfcntrs;
159 
160 	struct msm_ringbuffer *rb[MSM_GPU_MAX_RINGS];
161 	int nr_rings;
162 
163 	/**
164 	 * sysprof_active:
165 	 *
166 	 * The count of contexts that have enabled system profiling.
167 	 */
168 	refcount_t sysprof_active;
169 
170 	/**
171 	 * cur_ctx_seqno:
172 	 *
173 	 * The ctx->seqno value of the last context to submit rendering,
174 	 * and the one with current pgtables installed (for generations
175 	 * that support per-context pgtables).  Tracked by seqno rather
176 	 * than pointer value to avoid dangling pointers, and cases where
177 	 * a ctx can be freed and a new one created with the same address.
178 	 */
179 	int cur_ctx_seqno;
180 
181 	/*
182 	 * List of GEM active objects on this gpu.  Protected by
183 	 * msm_drm_private::mm_lock
184 	 */
185 	struct list_head active_list;
186 
187 	/**
188 	 * lock:
189 	 *
190 	 * General lock for serializing all the gpu things.
191 	 *
192 	 * TODO move to per-ring locking where feasible (ie. submit/retire
193 	 * path, etc)
194 	 */
195 	struct mutex lock;
196 
197 	/**
198 	 * active_submits:
199 	 *
200 	 * The number of submitted but not yet retired submits, used to
201 	 * determine transitions between active and idle.
202 	 *
203 	 * Protected by active_lock
204 	 */
205 	int active_submits;
206 
207 	/** lock: protects active_submits and idle/active transitions */
208 	struct mutex active_lock;
209 
210 	/* does gpu need hw_init? */
211 	bool needs_hw_init;
212 
213 	/**
214 	 * global_faults: number of GPU hangs not attributed to a particular
215 	 * address space
216 	 */
217 	int global_faults;
218 
219 	void __iomem *mmio;
220 	int irq;
221 
222 	struct msm_gem_address_space *aspace;
223 
224 	/* Power Control: */
225 	struct regulator *gpu_reg, *gpu_cx;
226 	struct clk_bulk_data *grp_clks;
227 	int nr_clocks;
228 	struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk;
229 	uint32_t fast_rate;
230 
231 	/* Hang and Inactivity Detection:
232 	 */
233 #define DRM_MSM_INACTIVE_PERIOD   66 /* in ms (roughly four frames) */
234 
235 #define DRM_MSM_HANGCHECK_DEFAULT_PERIOD 500 /* in ms */
236 	struct timer_list hangcheck_timer;
237 
238 	/* Fault info for most recent iova fault: */
239 	struct msm_gpu_fault_info fault_info;
240 
241 	/* work for handling GPU ioval faults: */
242 	struct kthread_work fault_work;
243 
244 	/* work for handling GPU recovery: */
245 	struct kthread_work recover_work;
246 
247 	/** retire_event: notified when submits are retired: */
248 	wait_queue_head_t retire_event;
249 
250 	/* work for handling active-list retiring: */
251 	struct kthread_work retire_work;
252 
253 	/* worker for retire/recover: */
254 	struct kthread_worker *worker;
255 
256 	struct drm_gem_object *memptrs_bo;
257 
258 	struct msm_gpu_devfreq devfreq;
259 
260 	uint32_t suspend_count;
261 
262 	struct msm_gpu_state *crashstate;
263 
264 	/* Enable clamping to idle freq when inactive: */
265 	bool clamp_to_idle;
266 
267 	/* True if the hardware supports expanded apriv (a650 and newer) */
268 	bool hw_apriv;
269 
270 	struct thermal_cooling_device *cooling;
271 };
272 
273 static inline struct msm_gpu *dev_to_gpu(struct device *dev)
274 {
275 	struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev);
276 	return container_of(adreno_smmu, struct msm_gpu, adreno_smmu);
277 }
278 
279 /* It turns out that all targets use the same ringbuffer size */
280 #define MSM_GPU_RINGBUFFER_SZ SZ_32K
281 #define MSM_GPU_RINGBUFFER_BLKSIZE 32
282 
283 #define MSM_GPU_RB_CNTL_DEFAULT \
284 		(AXXX_CP_RB_CNTL_BUFSZ(ilog2(MSM_GPU_RINGBUFFER_SZ / 8)) | \
285 		AXXX_CP_RB_CNTL_BLKSZ(ilog2(MSM_GPU_RINGBUFFER_BLKSIZE / 8)))
286 
287 static inline bool msm_gpu_active(struct msm_gpu *gpu)
288 {
289 	int i;
290 
291 	for (i = 0; i < gpu->nr_rings; i++) {
292 		struct msm_ringbuffer *ring = gpu->rb[i];
293 
294 		if (fence_after(ring->fctx->last_fence, ring->memptrs->fence))
295 			return true;
296 	}
297 
298 	return false;
299 }
300 
301 /* Perf-Counters:
302  * The select_reg and select_val are just there for the benefit of the child
303  * class that actually enables the perf counter..  but msm_gpu base class
304  * will handle sampling/displaying the counters.
305  */
306 
307 struct msm_gpu_perfcntr {
308 	uint32_t select_reg;
309 	uint32_t sample_reg;
310 	uint32_t select_val;
311 	const char *name;
312 };
313 
314 /*
315  * The number of priority levels provided by drm gpu scheduler.  The
316  * DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some
317  * cases, so we don't use it (no need for kernel generated jobs).
318  */
319 #define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_MIN)
320 
321 /**
322  * struct msm_file_private - per-drm_file context
323  *
324  * @queuelock:    synchronizes access to submitqueues list
325  * @submitqueues: list of &msm_gpu_submitqueue created by userspace
326  * @queueid:      counter incremented each time a submitqueue is created,
327  *                used to assign &msm_gpu_submitqueue.id
328  * @aspace:       the per-process GPU address-space
329  * @ref:          reference count
330  * @seqno:        unique per process seqno
331  */
332 struct msm_file_private {
333 	rwlock_t queuelock;
334 	struct list_head submitqueues;
335 	int queueid;
336 	struct msm_gem_address_space *aspace;
337 	struct kref ref;
338 	int seqno;
339 
340 	/**
341 	 * sysprof:
342 	 *
343 	 * The value of MSM_PARAM_SYSPROF set by userspace.  This is
344 	 * intended to be used by system profiling tools like Mesa's
345 	 * pps-producer (perfetto), and restricted to CAP_SYS_ADMIN.
346 	 *
347 	 * Setting a value of 1 will preserve performance counters across
348 	 * context switches.  Setting a value of 2 will in addition
349 	 * suppress suspend.  (Performance counters lose state across
350 	 * power collapse, which is undesirable for profiling in some
351 	 * cases.)
352 	 *
353 	 * The value automatically reverts to zero when the drm device
354 	 * file is closed.
355 	 */
356 	int sysprof;
357 
358 	/** comm: Overridden task comm, see MSM_PARAM_COMM */
359 	char *comm;
360 
361 	/** cmdline: Overridden task cmdline, see MSM_PARAM_CMDLINE */
362 	char *cmdline;
363 
364 	/**
365 	 * elapsed:
366 	 *
367 	 * The total (cumulative) elapsed time GPU was busy with rendering
368 	 * from this context in ns.
369 	 */
370 	uint64_t elapsed_ns;
371 
372 	/**
373 	 * cycles:
374 	 *
375 	 * The total (cumulative) GPU cycles elapsed attributed to this
376 	 * context.
377 	 */
378 	uint64_t cycles;
379 
380 	/**
381 	 * entities:
382 	 *
383 	 * Table of per-priority-level sched entities used by submitqueues
384 	 * associated with this &drm_file.  Because some userspace apps
385 	 * make assumptions about rendering from multiple gl contexts
386 	 * (of the same priority) within the process happening in FIFO
387 	 * order without requiring any fencing beyond MakeCurrent(), we
388 	 * create at most one &drm_sched_entity per-process per-priority-
389 	 * level.
390 	 */
391 	struct drm_sched_entity *entities[NR_SCHED_PRIORITIES * MSM_GPU_MAX_RINGS];
392 };
393 
394 /**
395  * msm_gpu_convert_priority - Map userspace priority to ring # and sched priority
396  *
397  * @gpu:        the gpu instance
398  * @prio:       the userspace priority level
399  * @ring_nr:    [out] the ringbuffer the userspace priority maps to
400  * @sched_prio: [out] the gpu scheduler priority level which the userspace
401  *              priority maps to
402  *
403  * With drm/scheduler providing it's own level of prioritization, our total
404  * number of available priority levels is (nr_rings * NR_SCHED_PRIORITIES).
405  * Each ring is associated with it's own scheduler instance.  However, our
406  * UABI is that lower numerical values are higher priority.  So mapping the
407  * single userspace priority level into ring_nr and sched_prio takes some
408  * care.  The userspace provided priority (when a submitqueue is created)
409  * is mapped to ring nr and scheduler priority as such:
410  *
411  *   ring_nr    = userspace_prio / NR_SCHED_PRIORITIES
412  *   sched_prio = NR_SCHED_PRIORITIES -
413  *                (userspace_prio % NR_SCHED_PRIORITIES) - 1
414  *
415  * This allows generations without preemption (nr_rings==1) to have some
416  * amount of prioritization, and provides more priority levels for gens
417  * that do have preemption.
418  */
419 static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio,
420 		unsigned *ring_nr, enum drm_sched_priority *sched_prio)
421 {
422 	unsigned rn, sp;
423 
424 	rn = div_u64_rem(prio, NR_SCHED_PRIORITIES, &sp);
425 
426 	/* invert sched priority to map to higher-numeric-is-higher-
427 	 * priority convention
428 	 */
429 	sp = NR_SCHED_PRIORITIES - sp - 1;
430 
431 	if (rn >= gpu->nr_rings)
432 		return -EINVAL;
433 
434 	*ring_nr = rn;
435 	*sched_prio = sp;
436 
437 	return 0;
438 }
439 
440 /**
441  * struct msm_gpu_submitqueues - Userspace created context.
442  *
443  * A submitqueue is associated with a gl context or vk queue (or equiv)
444  * in userspace.
445  *
446  * @id:        userspace id for the submitqueue, unique within the drm_file
447  * @flags:     userspace flags for the submitqueue, specified at creation
448  *             (currently unusued)
449  * @ring_nr:   the ringbuffer used by this submitqueue, which is determined
450  *             by the submitqueue's priority
451  * @faults:    the number of GPU hangs associated with this submitqueue
452  * @last_fence: the sequence number of the last allocated fence (for error
453  *             checking)
454  * @ctx:       the per-drm_file context associated with the submitqueue (ie.
455  *             which set of pgtables do submits jobs associated with the
456  *             submitqueue use)
457  * @node:      node in the context's list of submitqueues
458  * @fence_idr: maps fence-id to dma_fence for userspace visible fence
459  *             seqno, protected by submitqueue lock
460  * @lock:      submitqueue lock
461  * @ref:       reference count
462  * @entity:    the submit job-queue
463  */
464 struct msm_gpu_submitqueue {
465 	int id;
466 	u32 flags;
467 	u32 ring_nr;
468 	int faults;
469 	uint32_t last_fence;
470 	struct msm_file_private *ctx;
471 	struct list_head node;
472 	struct idr fence_idr;
473 	struct mutex lock;
474 	struct kref ref;
475 	struct drm_sched_entity *entity;
476 };
477 
478 struct msm_gpu_state_bo {
479 	u64 iova;
480 	size_t size;
481 	void *data;
482 	bool encoded;
483 };
484 
485 struct msm_gpu_state {
486 	struct kref ref;
487 	struct timespec64 time;
488 
489 	struct {
490 		u64 iova;
491 		u32 fence;
492 		u32 seqno;
493 		u32 rptr;
494 		u32 wptr;
495 		void *data;
496 		int data_size;
497 		bool encoded;
498 	} ring[MSM_GPU_MAX_RINGS];
499 
500 	int nr_registers;
501 	u32 *registers;
502 
503 	u32 rbbm_status;
504 
505 	char *comm;
506 	char *cmd;
507 
508 	struct msm_gpu_fault_info fault_info;
509 
510 	int nr_bos;
511 	struct msm_gpu_state_bo *bos;
512 };
513 
514 static inline void gpu_write(struct msm_gpu *gpu, u32 reg, u32 data)
515 {
516 	msm_writel(data, gpu->mmio + (reg << 2));
517 }
518 
519 static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg)
520 {
521 	return msm_readl(gpu->mmio + (reg << 2));
522 }
523 
524 static inline void gpu_rmw(struct msm_gpu *gpu, u32 reg, u32 mask, u32 or)
525 {
526 	msm_rmw(gpu->mmio + (reg << 2), mask, or);
527 }
528 
529 static inline u64 gpu_read64(struct msm_gpu *gpu, u32 lo, u32 hi)
530 {
531 	u64 val;
532 
533 	/*
534 	 * Why not a readq here? Two reasons: 1) many of the LO registers are
535 	 * not quad word aligned and 2) the GPU hardware designers have a bit
536 	 * of a history of putting registers where they fit, especially in
537 	 * spins. The longer a GPU family goes the higher the chance that
538 	 * we'll get burned.  We could do a series of validity checks if we
539 	 * wanted to, but really is a readq() that much better? Nah.
540 	 */
541 
542 	/*
543 	 * For some lo/hi registers (like perfcounters), the hi value is latched
544 	 * when the lo is read, so make sure to read the lo first to trigger
545 	 * that
546 	 */
547 	val = (u64) msm_readl(gpu->mmio + (lo << 2));
548 	val |= ((u64) msm_readl(gpu->mmio + (hi << 2)) << 32);
549 
550 	return val;
551 }
552 
553 static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val)
554 {
555 	/* Why not a writeq here? Read the screed above */
556 	msm_writel(lower_32_bits(val), gpu->mmio + (lo << 2));
557 	msm_writel(upper_32_bits(val), gpu->mmio + (hi << 2));
558 }
559 
560 int msm_gpu_pm_suspend(struct msm_gpu *gpu);
561 int msm_gpu_pm_resume(struct msm_gpu *gpu);
562 
563 void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx,
564 			 struct drm_printer *p);
565 
566 int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx);
567 struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx,
568 		u32 id);
569 int msm_submitqueue_create(struct drm_device *drm,
570 		struct msm_file_private *ctx,
571 		u32 prio, u32 flags, u32 *id);
572 int msm_submitqueue_query(struct drm_device *drm, struct msm_file_private *ctx,
573 		struct drm_msm_submitqueue_query *args);
574 int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id);
575 void msm_submitqueue_close(struct msm_file_private *ctx);
576 
577 void msm_submitqueue_destroy(struct kref *kref);
578 
579 int msm_file_private_set_sysprof(struct msm_file_private *ctx,
580 				 struct msm_gpu *gpu, int sysprof);
581 void __msm_file_private_destroy(struct kref *kref);
582 
583 static inline void msm_file_private_put(struct msm_file_private *ctx)
584 {
585 	kref_put(&ctx->ref, __msm_file_private_destroy);
586 }
587 
588 static inline struct msm_file_private *msm_file_private_get(
589 	struct msm_file_private *ctx)
590 {
591 	kref_get(&ctx->ref);
592 	return ctx;
593 }
594 
595 void msm_devfreq_init(struct msm_gpu *gpu);
596 void msm_devfreq_cleanup(struct msm_gpu *gpu);
597 void msm_devfreq_resume(struct msm_gpu *gpu);
598 void msm_devfreq_suspend(struct msm_gpu *gpu);
599 void msm_devfreq_boost(struct msm_gpu *gpu, unsigned factor);
600 void msm_devfreq_active(struct msm_gpu *gpu);
601 void msm_devfreq_idle(struct msm_gpu *gpu);
602 
603 int msm_gpu_hw_init(struct msm_gpu *gpu);
604 
605 void msm_gpu_perfcntr_start(struct msm_gpu *gpu);
606 void msm_gpu_perfcntr_stop(struct msm_gpu *gpu);
607 int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime,
608 		uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs);
609 
610 void msm_gpu_retire(struct msm_gpu *gpu);
611 void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit);
612 
613 int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
614 		struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
615 		const char *name, struct msm_gpu_config *config);
616 
617 struct msm_gem_address_space *
618 msm_gpu_create_private_address_space(struct msm_gpu *gpu, struct task_struct *task);
619 
620 void msm_gpu_cleanup(struct msm_gpu *gpu);
621 
622 struct msm_gpu *adreno_load_gpu(struct drm_device *dev);
623 void __init adreno_register(void);
624 void __exit adreno_unregister(void);
625 
626 static inline void msm_submitqueue_put(struct msm_gpu_submitqueue *queue)
627 {
628 	if (queue)
629 		kref_put(&queue->ref, msm_submitqueue_destroy);
630 }
631 
632 static inline struct msm_gpu_state *msm_gpu_crashstate_get(struct msm_gpu *gpu)
633 {
634 	struct msm_gpu_state *state = NULL;
635 
636 	mutex_lock(&gpu->lock);
637 
638 	if (gpu->crashstate) {
639 		kref_get(&gpu->crashstate->ref);
640 		state = gpu->crashstate;
641 	}
642 
643 	mutex_unlock(&gpu->lock);
644 
645 	return state;
646 }
647 
648 static inline void msm_gpu_crashstate_put(struct msm_gpu *gpu)
649 {
650 	mutex_lock(&gpu->lock);
651 
652 	if (gpu->crashstate) {
653 		if (gpu->funcs->gpu_state_put(gpu->crashstate))
654 			gpu->crashstate = NULL;
655 	}
656 
657 	mutex_unlock(&gpu->lock);
658 }
659 
660 /*
661  * Simple macro to semi-cleanly add the MAP_PRIV flag for targets that can
662  * support expanded privileges
663  */
664 #define check_apriv(gpu, flags) \
665 	(((gpu)->hw_apriv ? MSM_BO_MAP_PRIV : 0) | (flags))
666 
667 
668 #endif /* __MSM_GPU_H__ */
669