Re: [Mesa-dev] [PATCH 1/5] winsys/svga: Add an environment variable to force host-backed operation

2019-04-30 Thread Brian Paul

The series looks good to me.

Reviewed-by: Brian Paul 

On 04/30/2019 05:04 AM, Thomas Hellstrom wrote:

The vmwgfx kernel module has a compatibility mode for user-space that is
not guest-backed resource aware. Add an environment variable to facilitate
testing of this mode on guest-backed aware kernels: if the environment
variable SVGA_FORCE_HOST_BACKED is defined, the driver will use host-backed
operation.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: Deepak Rawat 
---
  src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 17 +++--
  1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c 
b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
index 0ec8c1abe11..cdfe284c4c8 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
@@ -967,6 +967,7 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
 drmVersionPtr version;
 boolean drm_gb_capable;
 boolean have_drm_2_5;
+   const char *getenv_val;
  
 VMW_FUNC;
  
@@ -1006,17 +1007,21 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)

goto out_no_3d;
 }
 vws->ioctl.hwversion = gp_arg.value;
-
-   memset(_arg, 0, sizeof(gp_arg));
-   gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
- _arg, sizeof(gp_arg));
+   getenv_val = getenv("SVGA_FORCE_HOST_BACKED");
+   if (!getenv_val || strcmp(getenv_val, "0") == 0) {
+  memset(_arg, 0, sizeof(gp_arg));
+  gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
+  ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+_arg, sizeof(gp_arg));
+   } else {
+  ret = -EINVAL;
+   }
 if (ret)
vws->base.have_gb_objects = FALSE;
 else
vws->base.have_gb_objects =
   !!(gp_arg.value & (uint64_t) SVGA_CAP_GBOBJECTS);
-
+
 if (vws->base.have_gb_objects && !drm_gb_capable)
goto out_no_3d;
  



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 1/5] winsys/svga: Add an environment variable to force host-backed operation

2019-04-30 Thread Thomas Hellstrom
The vmwgfx kernel module has a compatibility mode for user-space that is
not guest-backed resource aware. Add an environment variable to facilitate
testing of this mode on guest-backed aware kernels: if the environment
variable SVGA_FORCE_HOST_BACKED is defined, the driver will use host-backed
operation.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: Deepak Rawat 
---
 src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c 
b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
index 0ec8c1abe11..cdfe284c4c8 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
@@ -967,6 +967,7 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
drmVersionPtr version;
boolean drm_gb_capable;
boolean have_drm_2_5;
+   const char *getenv_val;
 
VMW_FUNC;
 
@@ -1006,17 +1007,21 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
   goto out_no_3d;
}
vws->ioctl.hwversion = gp_arg.value;
-
-   memset(_arg, 0, sizeof(gp_arg));
-   gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
-   ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
- _arg, sizeof(gp_arg));
+   getenv_val = getenv("SVGA_FORCE_HOST_BACKED");
+   if (!getenv_val || strcmp(getenv_val, "0") == 0) {
+  memset(_arg, 0, sizeof(gp_arg));
+  gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
+  ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
+_arg, sizeof(gp_arg));
+   } else {
+  ret = -EINVAL;
+   }
if (ret)
   vws->base.have_gb_objects = FALSE;
else
   vws->base.have_gb_objects =
  !!(gp_arg.value & (uint64_t) SVGA_CAP_GBOBJECTS);
-   
+
if (vws->base.have_gb_objects && !drm_gb_capable)
   goto out_no_3d;
 
-- 
2.20.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev