[virglrenderer-devel] [PATCH] virgl: handle getting new capsets.
Dave Airlie
airlied at gmail.com
Thu Feb 15 04:28:19 UTC 2018
From: Dave Airlie <airlied at redhat.com>
This checks the kernel api is new enough and asks for the
larger caps size since the kernel won't mess it up now.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 25 +++++++++++++++++++++----
src/gallium/winsys/virgl/drm/virgl_drm_winsys.h | 1 +
src/gallium/winsys/virgl/drm/virtgpu_drm.h | 2 +-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index fd6ae98a515..276646f948a 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -708,15 +708,20 @@ static int virgl_drm_get_caps(struct virgl_winsys *vws,
bool fill_v2 = false;
memset(&args, 0, sizeof(args));
-
- args.cap_set_id = 1;
+ if (vdws->has_capset_query_fix) {
+ /* if we have the query fix - try and get cap set id 2 first */
+ args.cap_set_id = 2;
+ args.size = sizeof(union virgl_caps);
+ } else {
+ args.cap_set_id = 1;
+ args.size = sizeof(struct virgl_caps_v1);
+ }
args.addr = (unsigned long)&caps->caps;
- args.size = sizeof(union virgl_caps);
ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
-
if (ret == -1 && errno == EINVAL) {
/* Fallback to v1 */
+ args.cap_set_id = 1;
args.size = sizeof(struct virgl_caps_v1);
ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
if (ret == -1)
@@ -813,6 +818,8 @@ static struct virgl_winsys *
virgl_drm_winsys_create(int drmFD)
{
struct virgl_drm_winsys *qdws;
+ int ret;
+ struct drm_virtgpu_getparam getparam = {0};
qdws = CALLOC_STRUCT(virgl_drm_winsys);
if (!qdws)
@@ -847,6 +854,16 @@ virgl_drm_winsys_create(int drmFD)
qdws->base.fence_reference = virgl_fence_reference;
qdws->base.get_caps = virgl_drm_get_caps;
+
+ uint32_t value;
+ getparam.param = VIRTGPU_PARAM_CAPSET_QUERY_FIX;
+ getparam.value = (uint64_t)(uintptr_t)&value;
+ ret = drmIoctl(qdws->fd, DRM_IOCTL_VIRTGPU_GETPARAM, &getparam);
+ if (ret == 0) {
+ if (value == 1)
+ qdws->has_capset_query_fix = true;
+ }
+
return &qdws->base;
}
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
index f6772153a42..b28e7127ca0 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
@@ -64,6 +64,7 @@ struct virgl_drm_winsys
struct util_hash_table *bo_handles;
struct util_hash_table *bo_names;
mtx_t bo_handles_mutex;
+ bool has_capset_query_fix;
};
struct virgl_drm_cmd_buf {
diff --git a/src/gallium/winsys/virgl/drm/virtgpu_drm.h b/src/gallium/winsys/virgl/drm/virtgpu_drm.h
index 30bc3afdd81..f4b885a300c 100644
--- a/src/gallium/winsys/virgl/drm/virtgpu_drm.h
+++ b/src/gallium/winsys/virgl/drm/virtgpu_drm.h
@@ -60,7 +60,7 @@ struct drm_virtgpu_execbuffer {
};
#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
-
+#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2
struct drm_virtgpu_getparam {
uint64_t param;
uint64_t value;
--
2.14.3
More information about the virglrenderer-devel
mailing list