ACPI: Make AC and battery drivers available on !X86
[sfrench/cifs-2.6.git] / drivers / gpu / drm / msm / msm_ringbuffer.h
1 /*
2  * Copyright (C) 2013 Red Hat
3  * 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/>.
16  */
17
18 #ifndef __MSM_RINGBUFFER_H__
19 #define __MSM_RINGBUFFER_H__
20
21 #include "msm_drv.h"
22
23 #define rbmemptr(ring, member)  \
24         ((ring)->memptrs_iova + offsetof(struct msm_rbmemptrs, member))
25
26 #define rbmemptr_stats(ring, index, member) \
27         (rbmemptr((ring), stats) + \
28          ((index) * sizeof(struct msm_gpu_submit_stats)) + \
29          offsetof(struct msm_gpu_submit_stats, member))
30
31 struct msm_gpu_submit_stats {
32         u64 cpcycles_start;
33         u64 cpcycles_end;
34         u64 alwayson_start;
35         u64 alwayson_end;
36 };
37
38 #define MSM_GPU_SUBMIT_STATS_COUNT 64
39
40 struct msm_rbmemptrs {
41         volatile uint32_t rptr;
42         volatile uint32_t fence;
43
44         volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT];
45 };
46
47 struct msm_ringbuffer {
48         struct msm_gpu *gpu;
49         int id;
50         struct drm_gem_object *bo;
51         uint32_t *start, *end, *cur, *next;
52         struct list_head submits;
53         uint64_t iova;
54         uint32_t seqno;
55         uint32_t hangcheck_fence;
56         struct msm_rbmemptrs *memptrs;
57         uint64_t memptrs_iova;
58         struct msm_fence_context *fctx;
59         spinlock_t lock;
60 };
61
62 struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
63                 void *memptrs, uint64_t memptrs_iova);
64 void msm_ringbuffer_destroy(struct msm_ringbuffer *ring);
65
66 /* ringbuffer helpers (the parts that are same for a3xx/a2xx/z180..) */
67
68 static inline void
69 OUT_RING(struct msm_ringbuffer *ring, uint32_t data)
70 {
71         /*
72          * ring->next points to the current command being written - it won't be
73          * committed as ring->cur until the flush
74          */
75         if (ring->next == ring->end)
76                 ring->next = ring->start;
77         *(ring->next++) = data;
78 }
79
80 #endif /* __MSM_RINGBUFFER_H__ */