aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'freedreno/freedreno_priv.h')
-rw-r--r--freedreno/freedreno_priv.h66
1 files changed, 60 insertions, 6 deletions
diff --git a/freedreno/freedreno_priv.h b/freedreno/freedreno_priv.h
index 32170391..6c9e509f 100644
--- a/freedreno/freedreno_priv.h
+++ b/freedreno/freedreno_priv.h
@@ -29,10 +29,6 @@
29#ifndef FREEDRENO_PRIV_H_ 29#ifndef FREEDRENO_PRIV_H_
30#define FREEDRENO_PRIV_H_ 30#define FREEDRENO_PRIV_H_
31 31
32#ifdef HAVE_CONFIG_H
33#include "config.h"
34#endif
35
36#include <stdlib.h> 32#include <stdlib.h>
37#include <errno.h> 33#include <errno.h>
38#include <string.h> 34#include <string.h>
@@ -49,6 +45,7 @@
49#include "xf86atomic.h" 45#include "xf86atomic.h"
50 46
51#include "util_double_list.h" 47#include "util_double_list.h"
48#include "util_math.h"
52 49
53#include "freedreno_drmif.h" 50#include "freedreno_drmif.h"
54#include "freedreno_ringbuffer.h" 51#include "freedreno_ringbuffer.h"
@@ -66,7 +63,8 @@ struct fd_device_funcs {
66 uint32_t flags, uint32_t *handle); 63 uint32_t flags, uint32_t *handle);
67 struct fd_bo * (*bo_from_handle)(struct fd_device *dev, 64 struct fd_bo * (*bo_from_handle)(struct fd_device *dev,
68 uint32_t size, uint32_t handle); 65 uint32_t size, uint32_t handle);
69 struct fd_pipe * (*pipe_new)(struct fd_device *dev, enum fd_pipe_id id); 66 struct fd_pipe * (*pipe_new)(struct fd_device *dev, enum fd_pipe_id id,
67 unsigned prio);
70 void (*destroy)(struct fd_device *dev); 68 void (*destroy)(struct fd_device *dev);
71}; 69};
72 70
@@ -102,6 +100,9 @@ struct fd_device {
102 struct fd_bo_cache bo_cache; 100 struct fd_bo_cache bo_cache;
103 101
104 int closefd; /* call close(fd) upon destruction */ 102 int closefd; /* call close(fd) upon destruction */
103
104 /* just for valgrind: */
105 int bo_size;
105}; 106};
106 107
107drm_private void fd_bo_cache_init(struct fd_bo_cache *cache, int coarse); 108drm_private void fd_bo_cache_init(struct fd_bo_cache *cache, int coarse);
@@ -152,6 +153,7 @@ struct fd_bo_funcs {
152 int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op); 153 int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op);
153 void (*cpu_fini)(struct fd_bo *bo); 154 void (*cpu_fini)(struct fd_bo *bo);
154 int (*madvise)(struct fd_bo *bo, int willneed); 155 int (*madvise)(struct fd_bo *bo, int willneed);
156 uint64_t (*iova)(struct fd_bo *bo);
155 void (*destroy)(struct fd_bo *bo); 157 void (*destroy)(struct fd_bo *bo);
156}; 158};
157 159
@@ -169,7 +171,6 @@ struct fd_bo {
169 time_t free_time; /* time when added to bucket-list */ 171 time_t free_time; /* time when added to bucket-list */
170}; 172};
171 173
172#define ALIGN(v,a) (((v) + (a) - 1) & ~((a) - 1))
173#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 174#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
174 175
175#define enable_debug 0 /* TODO make dynamic */ 176#define enable_debug 0 /* TODO make dynamic */
@@ -196,4 +197,57 @@ offset_bytes(void *end, void *start)
196 return ((char *)end) - ((char *)start); 197 return ((char *)end) - ((char *)start);
197} 198}
198 199
200#if HAVE_VALGRIND
201# include <memcheck.h>
202
203/*
204 * For tracking the backing memory (if valgrind enabled, we force a mmap
205 * for the purposes of tracking)
206 */
207static inline void VG_BO_ALLOC(struct fd_bo *bo)
208{
209 if (bo && RUNNING_ON_VALGRIND) {
210 VALGRIND_MALLOCLIKE_BLOCK(fd_bo_map(bo), bo->size, 0, 1);
211 }
212}
213
214static inline void VG_BO_FREE(struct fd_bo *bo)
215{
216 VALGRIND_FREELIKE_BLOCK(bo->map, 0);
217}
218
219/*
220 * For tracking bo structs that are in the buffer-cache, so that valgrind
221 * doesn't attribute ownership to the first one to allocate the recycled
222 * bo.
223 *
224 * Note that the list_head in fd_bo is used to track the buffers in cache
225 * so disable error reporting on the range while they are in cache so
226 * valgrind doesn't squawk about list traversal.
227 *
228 */
229static inline void VG_BO_RELEASE(struct fd_bo *bo)
230{
231 if (RUNNING_ON_VALGRIND) {
232 VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(bo, bo->dev->bo_size);
233 VALGRIND_MAKE_MEM_NOACCESS(bo, bo->dev->bo_size);
234 VALGRIND_FREELIKE_BLOCK(bo->map, 0);
235 }
236}
237static inline void VG_BO_OBTAIN(struct fd_bo *bo)
238{
239 if (RUNNING_ON_VALGRIND) {
240 VALGRIND_MAKE_MEM_DEFINED(bo, bo->dev->bo_size);
241 VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(bo, bo->dev->bo_size);
242 VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, 1);
243 }
244}
245#else
246static inline void VG_BO_ALLOC(struct fd_bo *bo) {}
247static inline void VG_BO_FREE(struct fd_bo *bo) {}
248static inline void VG_BO_RELEASE(struct fd_bo *bo) {}
249static inline void VG_BO_OBTAIN(struct fd_bo *bo) {}
250#endif
251
252
199#endif /* FREEDRENO_PRIV_H_ */ 253#endif /* FREEDRENO_PRIV_H_ */