Submitted By: Douglas R. Reno <renodr at linuxfromscratch dot org>
Date: 2020-01-29
Initial Package Version: 19.3.3
Origin: Upstream (MR 3614) + Self
Description: Fixes a Xorg Segmentation Fault when using Xorg under
VMWare Workstation (or any device that uses the SVGA
driver). This also adapts it to driver changes in
Linux 5.3+ for allowing OpenGL 4.5/4.6/Vulkan 1.1 to
function in the VMWare DRM driver. This also fixes
several graphical glitches and bugs that have been
present since Mesa-19.2.0 (with the introduction of
OpenGL-4.5).
diff -Naurp mesa-19.3.3.orig/src/gallium/auxiliary/util/u_debug_flush.c mesa-19.3.3/src/gallium/auxiliary/util/u_debug_flush.c
old
|
new
|
|
51 | 51 | #include <stdio.h> |
52 | 52 | |
53 | 53 | /* Future improvement: Use realloc instead? */ |
54 | | #define DEBUG_FLUSH_MAP_DEPTH 16 |
| 54 | #define DEBUG_FLUSH_MAP_DEPTH 32 |
55 | 55 | |
56 | 56 | struct debug_map_item { |
57 | 57 | struct debug_stack_frame *frame; |
diff -Naurp mesa-19.3.3.orig/src/gallium/drivers/svga/svga_format.c mesa-19.3.3/src/gallium/drivers/svga/svga_format.c
old
|
new
|
static const struct vgpu10_format_entry
|
207 | 207 | [ PIPE_FORMAT_L32_SINT ] = { SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, SVGA3D_R32_SINT, TF_XXX1 }, |
208 | 208 | [ PIPE_FORMAT_L32A32_SINT ] = { SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, SVGA3D_R32G32_SINT, TF_XXXY }, |
209 | 209 | [ PIPE_FORMAT_R10G10B10A2_UINT ] = { SVGA3D_R10G10B10A2_UINT, SVGA3D_R10G10B10A2_UINT, SVGA3D_R10G10B10A2_UINT, 0 }, |
| 210 | [ PIPE_FORMAT_COUNT ] = {SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0}, |
210 | 211 | }; |
211 | 212 | |
212 | 213 | |
diff -Naurp mesa-19.3.3.orig/src/gallium/drivers/svga/svga_pipe_blit.c mesa-19.3.3/src/gallium/drivers/svga/svga_pipe_blit.c
old
|
new
|
svga_resource_copy_region(struct pipe_co
|
881 | 881 | try_blit(svga, &blit)) |
882 | 882 | goto done; |
883 | 883 | |
884 | | copy_region_fallback(svga, dst_tex, dst_level, dstx, dsty, dstz, |
885 | | src_tex, src_level, src_box); |
| 884 | if (!try_cpu_copy_region(svga, &blit)) { |
| 885 | if (!try_blit(svga, &blit)) |
| 886 | debug_printf("Blit failed.\n"); |
| 887 | } |
886 | 888 | } |
887 | 889 | |
888 | 890 | done: |
diff -Naurp mesa-19.3.3.orig/src/gallium/drivers/svga/svga_resource_texture.c mesa-19.3.3/src/gallium/drivers/svga/svga_resource_texture.c
old
|
new
|
svga_texture_transfer_map(struct pipe_co
|
531 | 531 | struct svga_transfer *st; |
532 | 532 | struct svga_winsys_surface *surf = tex->handle; |
533 | 533 | boolean use_direct_map = svga_have_gb_objects(svga) && |
534 | | !svga_have_gb_dma(svga); |
| 534 | (!svga_have_gb_dma(svga) || (usage & PIPE_TRANSFER_WRITE)); |
535 | 535 | void *map = NULL; |
536 | 536 | int64_t begin = svga_get_time(svga); |
537 | 537 | |
diff -Naurp mesa-19.3.3.orig/src/gallium/drivers/svga/svga_state_tgsi_transform.c mesa-19.3.3/src/gallium/drivers/svga/svga_state_tgsi_transform.c
old
|
new
|
emulate_point_sprite(struct svga_context
|
131 | 131 | tgsi_dump(new_tokens, 0); |
132 | 132 | } |
133 | 133 | |
134 | | templ.tokens = new_tokens; |
| 134 | pipe_shader_state_from_tgsi(&templ, new_tokens); |
135 | 135 | templ.stream_output.num_outputs = 0; |
136 | 136 | |
137 | 137 | if (streamout) { |
diff -Naurp mesa-19.3.3.orig/src/gallium/winsys/svga/drm/vmwgfx_drm.h mesa-19.3.3/src/gallium/winsys/svga/drm/vmwgfx_drm.h
old
|
new
|
extern "C" {
|
71 | 71 | #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26 |
72 | 72 | #define DRM_VMW_GB_SURFACE_CREATE_EXT 27 |
73 | 73 | #define DRM_VMW_GB_SURFACE_REF_EXT 28 |
| 74 | #define DRM_VMW_MSG 29 |
74 | 75 | |
75 | 76 | /*************************************************************************/ |
76 | 77 | /** |
… |
… |
union drm_vmw_gb_surface_reference_ext_a
|
1213 | 1214 | struct drm_vmw_surface_arg req; |
1214 | 1215 | }; |
1215 | 1216 | |
| 1217 | /** |
| 1218 | * struct drm_vmw_msg_arg |
| 1219 | * |
| 1220 | * @send: Pointer to user-space msg string (null terminated). |
| 1221 | * @receive: Pointer to user-space receive buffer. |
| 1222 | * @send_only: Boolean for whether this is only sending or receiving too. |
| 1223 | * |
| 1224 | * Argument to the DRM_VMW_MSG ioctl. |
| 1225 | */ |
| 1226 | struct drm_vmw_msg_arg { |
| 1227 | __u64 send; |
| 1228 | __u64 receive; |
| 1229 | __s32 send_only; |
| 1230 | __u32 receive_len; |
| 1231 | }; |
| 1232 | |
1216 | 1233 | #if defined(__cplusplus) |
1217 | 1234 | } |
1218 | 1235 | #endif |
diff -Naurp mesa-19.3.3.orig/src/gallium/winsys/svga/drm/vmw_msg.c mesa-19.3.3/src/gallium/winsys/svga/drm/vmw_msg.c
old
|
new
|
|
31 | 31 | #include "pipe/p_defines.h" |
32 | 32 | #include "svga_winsys.h" |
33 | 33 | #include "vmw_msg.h" |
| 34 | #include "vmwgfx_drm.h" |
| 35 | #include "vmw_screen.h" |
| 36 | #include "xf86drm.h" |
34 | 37 | |
35 | 38 | |
36 | 39 | #define MESSAGE_STATUS_SUCCESS 0x0001 |
… |
… |
void
|
424 | 427 | vmw_svga_winsys_host_log(struct svga_winsys_screen *sws, const char *log) |
425 | 428 | { |
426 | 429 | struct rpc_channel channel; |
| 430 | struct vmw_winsys_screen *vws = vmw_winsys_screen(sws); |
427 | 431 | char *msg; |
428 | 432 | int msg_len; |
429 | 433 | int ret; |
… |
… |
vmw_svga_winsys_host_log(struct svga_win
|
444 | 448 | |
445 | 449 | sprintf(msg, "log %s", log); |
446 | 450 | |
447 | | if (!(ret = vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))) { |
448 | | ret = vmw_send_msg(&channel, msg); |
449 | | vmw_close_channel(&channel); |
| 451 | if (vws->ioctl.have_drm_2_17) { |
| 452 | struct drm_vmw_msg_arg msg_arg; |
| 453 | |
| 454 | memset(&msg_arg, 0, sizeof(msg_arg)); |
| 455 | msg_arg.send = (uint64_t) (unsigned long) (msg); |
| 456 | msg_arg.send_only = 1; |
| 457 | |
| 458 | ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_MSG, |
| 459 | &msg_arg, sizeof(msg_arg)); |
| 460 | } else { |
| 461 | if (!(ret = vmw_open_channel(&channel, RPCI_PROTOCOL_NUM))) { |
| 462 | ret = vmw_send_msg(&channel, msg); |
| 463 | vmw_close_channel(&channel); |
| 464 | } |
450 | 465 | } |
451 | 466 | |
452 | 467 | if (ret) |
diff -Naurp mesa-19.3.3.orig/src/gallium/winsys/svga/drm/vmw_screen.h mesa-19.3.3/src/gallium/winsys/svga/drm/vmw_screen.h
old
|
new
|
struct vmw_winsys_screen
|
78 | 78 | boolean have_drm_2_9; |
79 | 79 | uint32_t drm_execbuf_version; |
80 | 80 | boolean have_drm_2_15; |
| 81 | boolean have_drm_2_16; |
| 82 | boolean have_drm_2_17; |
81 | 83 | } ioctl; |
82 | 84 | |
83 | 85 | struct { |
diff -Naurp mesa-19.3.3.orig/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c mesa-19.3.3/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
old
|
new
|
vmw_ioctl_region_map(struct vmw_region *
|
694 | 694 | return NULL; |
695 | 695 | } |
696 | 696 | |
| 697 | (void) madvise(map, region->size, MADV_HUGEPAGE); |
697 | 698 | region->data = map; |
698 | 699 | } |
699 | 700 | |
… |
… |
vmw_ioctl_init(struct vmw_winsys_screen
|
973 | 974 | drmVersionPtr version; |
974 | 975 | boolean drm_gb_capable; |
975 | 976 | boolean have_drm_2_5; |
976 | | boolean have_drm_2_16; |
977 | 977 | const char *getenv_val; |
978 | 978 | |
979 | 979 | VMW_FUNC; |
… |
… |
vmw_ioctl_init(struct vmw_winsys_screen
|
990 | 990 | (version->version_major == 2 && version->version_minor > 8); |
991 | 991 | vws->ioctl.have_drm_2_15 = version->version_major > 2 || |
992 | 992 | (version->version_major == 2 && version->version_minor > 14); |
993 | | have_drm_2_16 = version->version_major > 2 || |
| 993 | vws->ioctl.have_drm_2_16 = version->version_major > 2 || |
994 | 994 | (version->version_major == 2 && version->version_minor > 15); |
| 995 | vws->ioctl.have_drm_2_17 = version->version_major > 2 || |
| 996 | (version->version_major == 2 && version->version_minor > 16); |
995 | 997 | |
996 | 998 | vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1; |
997 | 999 | |
… |
… |
vmw_ioctl_init(struct vmw_winsys_screen
|
1116 | 1118 | else |
1117 | 1119 | vws->ioctl.num_cap_3d = SVGA3D_DEVCAP_MAX; |
1118 | 1120 | |
1119 | | if (have_drm_2_16) { |
| 1121 | if (vws->ioctl.have_drm_2_16) { |
1120 | 1122 | vws->base.have_coherent = TRUE; |
1121 | 1123 | getenv_val = getenv("SVGA_FORCE_COHERENT"); |
1122 | 1124 | if (getenv_val && strcmp(getenv_val, "0") != 0) |