[Mesa-dev] [PATCH 5/6] winsys/radeon: test the userptr ioctl to see if it's present
Marek Olšák
maraeo at gmail.com
Wed Feb 11 12:18:15 PST 2015
From: Marek Olšák <marek.olsak at amd.com>
There seems to be no other way to check for support.
The DRM version wasn't bumped.
---
src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 18 ------------------
src/gallium/winsys/radeon/drm/radeon_drm_cs.h | 1 -
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 15 +++++++++++++++
src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 19 +++++++++++++++++++
src/gallium/winsys/radeon/drm/radeon_winsys.h | 1 +
5 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index e3b2c22..e609d68 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -42,24 +42,6 @@
#include <fcntl.h>
#include <stdio.h>
-#ifndef DRM_RADEON_GEM_USERPTR
-
-#define DRM_RADEON_GEM_USERPTR 0x2d
-
-#define RADEON_GEM_USERPTR_READONLY (1 << 0)
-#define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
-#define RADEON_GEM_USERPTR_VALIDATE (1 << 2)
-#define RADEON_GEM_USERPTR_REGISTER (1 << 3)
-
-struct drm_radeon_gem_userptr {
- uint64_t addr;
- uint64_t size;
- uint32_t flags;
- uint32_t handle;
-};
-
-#endif
-
extern const struct pb_vtbl radeon_bo_vtbl;
static INLINE struct radeon_bo *radeon_bo(struct pb_buffer *bo)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
index 089494e..fcc29fe 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
@@ -28,7 +28,6 @@
#define RADEON_DRM_CS_H
#include "radeon_drm_bo.h"
-#include <radeon_drm.h>
struct radeon_cs_context {
uint32_t buf[RADEON_MAX_CMDBUF_DWORDS];
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 72b7931..2b12f4d 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -309,6 +309,21 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
}
}
+ /* Check for userptr support. */
+ {
+ struct drm_radeon_gem_userptr args = {0};
+
+ /* If the ioctl doesn't exist, -EINVAL is returned.
+ *
+ * If the ioctl exists, it should return -EACCES
+ * if RADEON_GEM_USERPTR_READONLY or RADEON_GEM_USERPTR_REGISTER
+ * aren't set.
+ */
+ ws->info.has_userptr =
+ drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_USERPTR,
+ &args, sizeof(args)) == -EACCES;
+ }
+
/* Get GEM info. */
retval = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_INFO,
&gem_info, sizeof(gem_info));
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 1e0c632..5711ffa 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -32,6 +32,25 @@
#include "radeon_winsys.h"
#include "os/os_thread.h"
+#include <radeon_drm.h>
+
+#ifndef DRM_RADEON_GEM_USERPTR
+
+#define DRM_RADEON_GEM_USERPTR 0x2d
+
+#define RADEON_GEM_USERPTR_READONLY (1 << 0)
+#define RADEON_GEM_USERPTR_ANONONLY (1 << 1)
+#define RADEON_GEM_USERPTR_VALIDATE (1 << 2)
+#define RADEON_GEM_USERPTR_REGISTER (1 << 3)
+
+struct drm_radeon_gem_userptr {
+ uint64_t addr;
+ uint64_t size;
+ uint32_t flags;
+ uint32_t handle;
+};
+
+#endif
struct radeon_drm_cs;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 3a6037c..a8cc60a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -214,6 +214,7 @@ struct radeon_info {
boolean has_uvd;
uint32_t vce_fw_version;
+ boolean has_userptr;
uint32_t r300_num_gb_pipes;
uint32_t r300_num_z_pipes;
--
2.1.0
More information about the mesa-dev
mailing list