winsys/svga: use new ioctl for logging
authorRoland Scheidegger <sroland@vmware.com>
Thu, 24 Oct 2019 04:10:46 +0000 (06:10 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jan 2020 10:56:06 +0000 (10:56 +0000)
Use the new ioctl for logging (rather than duplicating what the kernel
is doing). This way it's also independent from the actual guest/host
mechanism to do the logging.

Signed-off-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3614>

src/gallium/winsys/svga/drm/vmw_msg.c
src/gallium/winsys/svga/drm/vmw_screen.h
src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
src/gallium/winsys/svga/drm/vmwgfx_drm.h

index 2a2d6a612978a0873adfd2f7a81bbcb69db3b2ec..e664769c279ea42db0f1108d0806b0d1db6b16de 100644 (file)
@@ -31,6 +31,9 @@
 #include "pipe/p_defines.h"
 #include "svga_winsys.h"
 #include "vmw_msg.h"
+#include "vmwgfx_drm.h"
+#include "vmw_screen.h"
+#include "xf86drm.h"
 
 
 #define MESSAGE_STATUS_SUCCESS  0x0001
@@ -424,6 +427,7 @@ void
 vmw_svga_winsys_host_log(struct svga_winsys_screen *sws, const char *log)
 {
    struct rpc_channel channel;
+   struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
    char *msg;
    int msg_len;
    int ret;
@@ -444,9 +448,21 @@ vmw_svga_winsys_host_log(struct svga_winsys_screen *sws, const char *log)
 
    sprintf(msg, "log %s", log);
 
-   if (!(ret = vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))) {
-      ret = vmw_send_msg(&channel, msg);
-      vmw_close_channel(&channel);
+   if (vws->ioctl.have_drm_2_17) {
+      struct drm_vmw_msg_arg msg_arg;
+
+      memset(&msg_arg, 0, sizeof(msg_arg));
+      msg_arg.send = (uint64_t) (unsigned long) (msg);
+      msg_arg.send_only = 1;
+
+      ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_MSG,
+                                &msg_arg, sizeof(msg_arg));
+
+   } else {
+      if (!(ret = vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))) {
+         ret = vmw_send_msg(&channel, msg);
+         vmw_close_channel(&channel);
+      }
    }
 
    if (ret)
index e0b1bb33bc4642f90f8eadc197fec165841e38d7..c55de4a2b6fb4a79d096795962a81447424a8dac 100644 (file)
@@ -78,6 +78,8 @@ struct vmw_winsys_screen
       boolean have_drm_2_9;
       uint32_t drm_execbuf_version;
       boolean have_drm_2_15;
+      boolean have_drm_2_16;
+      boolean have_drm_2_17;
    } ioctl;
 
    struct {
index 2e84c811e82fe49e646092e55e333346ce8348b3..4ce953fee8ded20cb1516c3f664f9c5482aa0023 100644 (file)
@@ -973,7 +973,6 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
    drmVersionPtr version;
    boolean drm_gb_capable;
    boolean have_drm_2_5;
-   boolean have_drm_2_16;
    const char *getenv_val;
 
    VMW_FUNC;
@@ -990,8 +989,10 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
       (version->version_major == 2 && version->version_minor > 8);
    vws->ioctl.have_drm_2_15 = version->version_major > 2 ||
       (version->version_major == 2 && version->version_minor > 14);
-   have_drm_2_16 = version->version_major > 2 ||
+   vws->ioctl.have_drm_2_16 = version->version_major > 2 ||
       (version->version_major == 2 && version->version_minor > 15);
+   vws->ioctl.have_drm_2_17 = version->version_major > 2 ||
+      (version->version_major == 2 && version->version_minor > 16);
 
    vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1;
 
@@ -1116,7 +1117,7 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
       else
          vws->ioctl.num_cap_3d = SVGA3D_DEVCAP_MAX;
 
-      if (have_drm_2_16) {
+      if (vws->ioctl.have_drm_2_16) {
          vws->base.have_coherent = TRUE;
          getenv_val = getenv("SVGA_FORCE_COHERENT");
          if (getenv_val && strcmp(getenv_val, "0") != 0)
index 02cab33f2f25cae9ad5a885c198319ccfe942e5d..fcb741e3068f206dd107a41c40e3e18728c3190d 100644 (file)
@@ -71,6 +71,7 @@ extern "C" {
 #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
 #define DRM_VMW_GB_SURFACE_CREATE_EXT   27
 #define DRM_VMW_GB_SURFACE_REF_EXT      28
+#define DRM_VMW_MSG                     29
 
 /*************************************************************************/
 /**
@@ -1213,6 +1214,22 @@ union drm_vmw_gb_surface_reference_ext_arg {
        struct drm_vmw_surface_arg req;
 };
 
+/**
+ * struct drm_vmw_msg_arg
+ *
+ * @send: Pointer to user-space msg string (null terminated).
+ * @receive: Pointer to user-space receive buffer.
+ * @send_only: Boolean whether this is only sending or receiving too.
+ *
+ * Argument to the DRM_VMW_MSG ioctl.
+ */
+struct drm_vmw_msg_arg {
+       __u64 send;
+       __u64 receive;
+       __s32 send_only;
+       __u32 receive_len;
+};
+
 #if defined(__cplusplus)
 }
 #endif