summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-07-16 16:39:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-08-27 09:39:45 +0100
commit51baabb562caf1e1009bad5cae7efef126590117 (patch)
tree2a38d51e587e5d8b3175e7b2886d5e6b508cb614 /lib
parentdd5f40f50c02e8ef68ac9bbee3e94302e7baeed3 (diff)
Add bare-metal interface to adjust cacheing (i.e. snoop status) of a bo
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/drmtest.c52
-rw-r--r--lib/drmtest.h3
2 files changed, 55 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2101f6a9..d605f797 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -252,6 +252,58 @@ void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
assert(st.tiling_mode == tiling);
}
+struct local_drm_i915_gem_cacheing {
+ uint32_t handle;
+ uint32_t cacheing;
+};
+
+#define LOCAL_DRM_I915_GEM_SET_CACHEING 0x2f
+#define LOCAL_DRM_I915_GEM_GET_CACHEING 0x30
+#define LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING \
+ DRM_IOW(DRM_COMMAND_BASE + LOCAL_DRM_I915_GEM_SET_CACHEING, struct local_drm_i915_gem_cacheing)
+#define LOCAL_DRM_IOCTL_I915_GEM_GET_CACHEING \
+ DRM_IOWR(DRM_COMMAND_BASE + LOCAL_DRM_I915_GEM_GET_CACHEING, struct local_drm_i915_gem_cacheing)
+
+int gem_has_cacheing(int fd)
+{
+ struct local_drm_i915_gem_cacheing arg;
+ int ret;
+
+ arg.handle = gem_create(fd, 4096);
+ if (arg.handle == 0)
+ return 0;
+
+ arg.cacheing = 0;
+ ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
+ gem_close(fd, arg.handle);
+
+ return ret == 0;
+}
+
+void gem_set_cacheing(int fd, uint32_t handle, int cacheing)
+{
+ struct local_drm_i915_gem_cacheing arg;
+ int ret;
+
+ arg.handle = handle;
+ arg.cacheing = cacheing;
+ ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
+ assert(ret == 0);
+}
+
+int gem_get_cacheing(int fd, uint32_t handle)
+{
+ struct local_drm_i915_gem_cacheing arg;
+ int ret;
+
+ arg.handle = handle;
+ arg.cacheing = 0;
+ ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_GET_CACHEING, &arg);
+ assert(ret == 0);
+
+ return arg.cacheing;
+}
+
void gem_close(int fd, uint32_t handle)
{
struct drm_gem_close close_bo;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 0cffa394..31951edf 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -45,6 +45,9 @@ void gem_quiescent_gpu(int fd);
/* ioctl wrappers and similar stuff for bare metal testing */
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride);
+int gem_has_cacheing(int fd);
+void gem_set_cacheing(int fd, uint32_t handle, int cacheing);
+int gem_get_cacheing(int fd, uint32_t handle);
void gem_close(int fd, uint32_t handle);
void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size);
void gem_read(int fd, uint32_t handle, uint32_t offset, void *buf, uint32_t size);