summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/winsys/svga/drm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-08-26 05:30:39 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-08-26 05:30:39 +0000
commit27c93456b58343162f7c4ad20ca6bea0c9a91646 (patch)
tree945c20b63e0b9975ee40f114c5312f8d8f1a2d0b /lib/mesa/src/gallium/winsys/svga/drm
parent875b83a3ee95e248388fbf72271acc80f6f97987 (diff)
Import Mesa 20.1.6
Diffstat (limited to 'lib/mesa/src/gallium/winsys/svga/drm')
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c19
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_msg.c22
2 files changed, 35 insertions, 6 deletions
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c
index 34c5e3417..03db92a64 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c
@@ -63,6 +63,7 @@ struct vmw_gmr_buffer
struct vmw_region *region;
void *map;
unsigned map_flags;
+ unsigned map_count;
};
@@ -104,8 +105,12 @@ vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
{
struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
- vmw_ioctl_region_unmap(buf->region);
-
+ assert(buf->map_count == 0);
+ if (buf->map) {
+ assert(buf->mgr->vws->cache_maps);
+ vmw_ioctl_region_unmap(buf->region);
+ }
+
vmw_ioctl_region_destroy(buf->region);
FREE(buf);
@@ -126,7 +131,6 @@ vmw_gmr_buffer_map(struct pb_buffer *_buf,
if (!buf->map)
return NULL;
-
if ((_buf->usage & VMW_BUFFER_USAGE_SYNC) &&
!(flags & PB_USAGE_UNSYNCHRONIZED)) {
ret = vmw_ioctl_syncforcpu(buf->region,
@@ -137,6 +141,7 @@ vmw_gmr_buffer_map(struct pb_buffer *_buf,
return NULL;
}
+ buf->map_count++;
return buf->map;
}
@@ -153,6 +158,12 @@ vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
!(flags & PB_USAGE_CPU_WRITE),
FALSE);
}
+
+ assert(buf->map_count > 0);
+ if (!--buf->map_count && !buf->mgr->vws->cache_maps) {
+ vmw_ioctl_region_unmap(buf->region);
+ buf->map = NULL;
+ }
}
@@ -364,6 +375,8 @@ vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
(unsigned) PIPE_TRANSFER_DONTBLOCK);
STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED ==
(unsigned) PIPE_TRANSFER_UNSYNCHRONIZED);
+ STATIC_ASSERT((unsigned) PB_USAGE_PERSISTENT ==
+ (unsigned) PIPE_TRANSFER_PERSISTENT);
map = pb_map(vmw_pb_buffer(buf), flags & PB_USAGE_ALL, NULL);
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_msg.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_msg.c
index 2a2d6a612..e664769c2 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_msg.c
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_msg.c
@@ -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)