Yiwei Zhang
ac95ecd044
venus: some clang format fixes
...
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18447 >
2022-09-06 19:52:26 +00:00
Clément Guérin
a1a22862c6
venus: implement VK_EXT_physical_device_drm
...
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17387 >
2022-07-07 02:46:45 +00:00
Yiwei Zhang
9f9d543b12
venus: renderer to store allow_vk_wait_syncs capset
...
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Reviewed-by: Chad Versace <chadversary@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16731 >
2022-06-16 19:00:36 +00:00
Yiwei Zhang
2223f13b26
venus: store extension mask in renderer info
...
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15495 >
2022-04-09 00:19:05 +00:00
Oleksandr Gabrylchuk
02fab4cf9e
venus: Implement guest vram blob type.
...
Add support of GUEST_VRAM type of blob. These are dedicated heap memory
allocations required for vk support on hypervisors that don't support
runtime injections of host memory into guest physical address space.
The flow of usage:
1) Host VM reserves dedicated heap memory
2) Device get info about memory reservations and report it to guest
using mmio registers
3) Guest virtio-gpu driver on starts checks mmio registers for
physical address and length of reserved region. Then it reserves it
in guest.
4) On each call of vkAllocateMemory() guest driver gets chunk of
required memory and send it to host using sg list. It uses one sg
entry for 1 blob call. Heap is managed on guest using drm memory
manager (drm_mm).
Signed-off-by: Oleksandr.Gabrylchuk <Oleksandr.Gabrylchuk@opensynergy.com >
Signed-off-by: Andrii Pauk <Andrii.Pauk@opensynergy.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14536 >
2022-03-01 17:25:56 +00:00
Yiwei Zhang
ddba7337c7
venus: init renderer_info at renderer creation (part 1)
...
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14658 >
2022-02-11 21:16:42 +00:00
Andrii Pauk
cf4de7d8ff
venus: Allow usage of virtio-mmio based device
...
Libdrm reports bustype as DRM_BUS_PLATFORM for virtio-mmio
based device. DRM_BUS_PCI is reported only for virtio-pci based
devices. Add possibility to use devices with DRM_BUS_PLATFORM.
Signed-off-by: Andrii Pauk <Andrii.Pauk@opensynergy.com >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14531 >
2022-02-08 17:53:21 +00:00
Chia-I Wu
9c81de7df2
venus: cache shmems
...
Shmems are allocated internally and are only for CPU access. They can
be easily cached.
Venus have 4 sources of shmem allocations
- the ring buffer
- the reply stream
- the indirection submission upload cs
- one cs for each vn_command_buffer
The first one is allocated only once. The other three reallocate
occasionally. The frequencies depend on the workloads.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14179 >
2021-12-15 19:02:29 +00:00
Chia-I Wu
b14dd3a866
venus: prefer VIRTGPU_BLOB_MEM_HOST3D for shmems
...
They are logically contiguously in the host. More importantly, they
enable host process isolation.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13800 >
2021-12-08 21:23:05 +00:00
Chia-I Wu
d7560a71a2
venus: convert bo and shmem to use vn_refcount
...
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13090 >
2021-09-30 03:16:19 +00:00
Yiwei Zhang
cbdec34db3
venus: renderer to check map size only when mappable
...
Cc: 21.2.3 mesa-stable
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12687 >
2021-09-01 22:38:48 +00:00
Marek Olšák
6ede24cf31
util/idalloc: fold the size call into init
...
It's required, otherwise idalloc would fail.
v2: renamed util_idalloc_(mt_)init param initial_num_ids (Pierre-Eric)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com > (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com > (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Chia-I Wu
d0fa4933b7
venus: fix empty submits with BOs
...
Empty submits with BOs (!batch_count && bo_count) were incorrectly
skipped.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11791 >
2021-07-08 21:51:23 +00:00
Chia-I Wu
823d889b21
venus: simplify vn_renderer_sync creation
...
Remove the ability to init/release repeatedly.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11253 >
2021-06-11 23:44:45 +00:00
Chia-I Wu
517828784c
venus: move vn_renderer_sync_ops to vn_renderer
...
To follow vn_renderer_{shmem,bo}_ops.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11253 >
2021-06-11 23:44:45 +00:00
Chia-I Wu
551d7032df
venus: silence compiler warnings
...
Silence warnings in release builds.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11166 >
2021-06-03 17:48:30 +00:00
Chia-I Wu
9814cd8153
venus: fix opaque fd re-import
...
dEQP-VK.api.external.memory.opaque_fd.* re-imports and fails because
external_handles was VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT on
allocation and is VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT on
re-import.
Fixes: ccefcb0baf ("venus: fix misaligned bo_flags between import and query")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11154 >
2021-06-03 05:53:24 +00:00
Yiwei Zhang
ccefcb0baf
venus: fix misaligned bo_flags between import and query
...
For importing an dma_buf fd, export info is not required. Leaving the
bo_flags missing VIRTGPU_BLOB_FLAG_USE_SHAREABLE bit as well as the
VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE bit. Upon querying fd properties,
DMA_BUF handle type will be specified which generates a new bo_flags
not matching the prior one.
This patch aligns the above 2 bits for the dma_buf import path.
Test: vkGetAndroidHardwareBufferPropertiesANDROID should succeed with
a valid AHB with AHARDWAREBUFFER_FORMAT_BLOB format.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11055 >
2021-05-29 04:48:50 +00:00
Yiwei Zhang
1df4c960c6
venus: rename dmabuf to dma_buf when it represents a type
...
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11055 >
2021-05-29 04:48:50 +00:00
Joshua Ashton
6fcf3314d0
venus: Fix zero-initialized fd causing apps to hang/crash
...
Some apps such as Gamescope crash under the mere presence of the virtio Vulkan driver without using a device.
This is because virtgpu::fd is zero-initialized upon allocation, which causes fd 0 to be closed in virtgpu_destroy.
Cc: mesa-stable
Fixes: 247232d5 ("venus: add experimental renderers")
Signed-off-by: Joshua Ashton <joshua@froggi.es >
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl >
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com >
Reviewed-by: Daniel Stone <daniels@collabora.com >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10814 >
2021-05-16 01:47:01 +00:00
Chia-I Wu
38e0067643
venus: fix dmabuf import fail path
...
When we fail, we should not close gem_handle when there is already a bo
with the same gem handle.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10592 >
2021-05-03 20:40:14 +00:00
Chia-I Wu
40fbfd8b5b
venus: fix dmabuf import mmap_size check
...
Do not set mmap_size to info.size. We do not track the size of the BO
anymore.
This fixes
dEQP-VK.api.external.memory.dma_buf.suballocated.device_only.fd_properties
where the test allocates a 1KB VkDeviceMemory, export and call
vkGetMemoryFdPropertiesKHR. It can happen that bo->mmap_size is less
than the aligned info.size.
FWIW, the test fails because it violates a VU:
VUID-vkGetMemoryFdPropertiesKHR-fd-00673
fd must be an external memory handle created outside of the Vulkan API
Fixes: 88f481dd74 ("venus: make sure gem_handle and vn_renderer_bo are 1:1")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10592 >
2021-05-03 20:40:14 +00:00
Chia-I Wu
88f481dd74
venus: make sure gem_handle and vn_renderer_bo are 1:1
...
When two vn_renderer_bo's share the same gem_handle, destroying one of
them would invalidate the other.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
f41a79f948
venus: use sparse array to manage vn_renderer_bo
...
It should be faster. More importantly, we want to use it to keep track
of all BOs for correct dmabuf import.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
c62026165c
venus: move some common members to vn_renderer_bo
...
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
b39ea79c95
venus: merge bo create and init ops
...
There is no good reason to seprate them. I also plan to adopt
util_sparse_array, which requires the kernel BO to be created first (to
use its gem_handle/res_id as the key).
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
2db720330b
venus: move vn_renderer_bo_ops to vn_renderer
...
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
b54a262421
venus: use vn_renderer_shmem
...
vn_renderer_bo_create_cpu becomes unused and is removed.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Chia-I Wu
452a49fe19
venus: add vn_renderer_shmem
...
CPU BOs and GPU BOs are used different enough that it makes sense to
treat them as different objects. This commit adds vn_renderer_shmem to
represent CPU BOs.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10437 >
2021-04-28 12:58:58 -07:00
Yiwei Zhang
282e2c9496
venus: set bo->size to 0 for classic resource
...
bo->size is not used for classic resource since mapping is not allowed.
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10259 >
2021-04-27 00:15:39 +00:00
Yiwei Zhang
757a711f39
venus: fix virtgpu_bo_init_dmabuf for classic resource
...
1. only do size check if the input size is not 0
2. blob_mem can be 0 because guest minigbm uses RESOURCE_CREATE_3D
3. set bo->blob_flags to 0 for classic resource to fail virtgpu_bo_map
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Chia-I Wu <olvaffe@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10273 >
2021-04-16 04:56:19 +00:00
Chia-I Wu
9b71154353
venus: remove vn_renderer_info::has_timeline_sync
...
We are no longer limited to Vulkan 1.1 in VMs.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10146 >
2021-04-14 21:18:10 +00:00
Chia-I Wu
37f03a2c4c
venus: wait on vkQueuePresentKHR
...
Add vn_renderer_info::has_implicit_fencing. Force vkQueueWaitIdle
during vkQueuePresentKHR when it is false.
This kills the performance, but we have to do this until the kernel does
implicit fencing.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10146 >
2021-04-14 21:18:10 +00:00
Chia-I Wu
247232d596
venus: add experimental renderers
...
There are a virtio-gpu renderer and a vtest renderer. The vtest
renderer must be enabled with VN_DEBUG=vtest.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com >
Reviewed-by: Ryan Neph <ryanneph@google.com >
Reviewed-by: Gert Wollny <gert.wollny@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5800 >
2021-04-08 17:15:37 +00:00