Commit graph

31 commits

Author SHA1 Message Date
Lloyd Pique
aec6536741 virtgpu_cross_domain: Hold a lock for all of bo_create
In crosvm, the MinigbmDevice implementation of the Gralloc interface
assumes that a call to get_image_memory_requirements will be immediately
followed by a matching call to allocate_memory, as the implementation
stashes a buffer allocated by the first call to be returned by the
second.

However on Android multiple processes/threads can be making calls to
allocate memory via CrosGralloc. In particular if the device is
configured to use the cross-domain back-end, and two threads are trying
to allocate memory, the two requests to get the memory requirements for
an allocation can be submitted to crosvm followed by the two requests to
actually allocate memory.

When the assumption is violated, the crosvm code was raising an error
for the SECOND memory requirement request. However the error does not
propagate back to the virtgpu_cross_domain code here. The result is that
the request is understood to have succeeded, and the code here then
reads the size metadata from the response buffer, but that contains the
values from the FIRST memory requirement request. Those values may be

There is a fix for crosvm in review (https://crrev.com/c/6260975) to
not raise an error if the calls are not made in the expected order,
while still maintaining a single stashed buffer. However this means the
memory allocated for one of the two requests must be released, and would
have to be reallocated, at some extra runtime cost as allocating
graphics memory requires allocating physically contiguous memory.

The existing cross-domain code here acquired a simple mutex lock to
maintain a metadata cache, which was held for the duration of the first
call. This change extends the duration of the lock to the entire
allocation request so that the guest always makes the two requests in
the expected order.

BUG=b:395748805,b:355060470
TEST=ARCVM on Corsola starts up under high CPU stress

Change-Id: I6429ea28141ef440345a3eb442066173b3e04802
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6288246
Commit-Queue: Lloyd Pique <lpique@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Lloyd Pique <lpique@google.com>
2025-02-25 04:26:53 -08:00
Ryan Neph
2381df8295 virtgpu_cross_domain: fix planar size calculation
The last plane's size may include any padding bytes introduced by
virtgpu's page-alignment, but its not incorrect, and all other planes
will be exact.

BUG=b:365820897
TEST=Spot check new size calculation for YVU420_ANDROID allocation

Change-Id: I6e88905d7191dca7e68e5dfd773d2fcaac79773d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5849473
Tested-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
2024-09-11 02:25:27 +00:00
Ryan Neph
05865d75bb virtgpu_cross_domain: force LINEAR for YVU420_ANDROID
Metadata query sent to host minigbm detects the YVU420 + LINEAR
combination and internally handle as YVU420_ANDROID to obey Android's
specific layout requirements.

This matches a similar hack applied to the virtgpu_virgl backend long
ago: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2596704

BUG=b:360937659
TEST=Fixes instagram video decode artifacts

Change-Id: I591e427a926327b841be6e280ca57eefab598965
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5849472
Reviewed-by: Chia-I Wu <olv@google.com>
Tested-by: Ryan Neph <ryanneph@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2024-09-10 22:59:26 +00:00
Kaiyi Li
4baf42e47c virtgpu: define capset ids as macros
... to avoid using magic numbers.

TEST=compile
BUG=b:322199104

Change-Id: I8522596f2cb2d0e9bdc381440c7e9ad3bbaa3165
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5246254
Tested-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
2024-01-31 01:44:11 +00:00
Yiwei Zhang
ba0c2cf4ba virtgpu_cross_domain: fix prop query for mt8183 camera quirk
The latest drv_get_os_option consumes the prop name directly without
lowering or etc. Meanwhile, to use strcmp instead of strncmp, we must
query ro.product.name instead since the .device one has suffix.

BUG=b:269982880

Change-Id: I27543975ec0c2a0bd7700ebd59c4dc5dd5dd2793
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4571850
Reviewed-by: Dawn Han <dawnhan@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Amit Pundir <amit.pundir@linaro.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-05-30 18:37:56 +00:00
Dawn Han
3940cbd883 minigbm: move camera work-around
Move mt8183_camera_quirk_ into struct cross_domain_private.
Add a helper `drv_get_os_option` in `drv_helper` to query os option.
Advertise DRM_FORMAT_MTISP_SXYZW10 as supported format in virtgpu_cross_domain.c.
Implement cross domain's own resolve_format_and_use_flags entry point.

BUG=b:269982880

TEST=tested on a kukui machine after applying the change. Camera and
screen recording works fine.

Change-Id: Ia0d6e2cc701477aa6b9542de84e24f8aeb5a29e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4304961
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2023-05-02 21:06:13 +00:00
Dawn Han
84b3a09ef0 minigbm: clean up bo.handles
The multi-planar formats are being allocated into a single plane,
and the minigbm exynos backend is dropped. So we can use `handle` instead of handles as of now.

Remove some of the helper functions that calculate the number of planes.
There is no need to check if there is more than one kernel buffer per buffer object.

Added a new function `drv_gem_close` in `drv_helpers` that can be used by `drv_gem_bo_destroy` and `drv_prime_bo_import`. It can be used to clean the unused gem_handle.

Bug=b:266776512
TEST=camera and screenshot work fine after deploying the change #strongbad
TEST=camera and screenshot work fine after deploying the change #kukui-arc-r
TEST=camera and screenshot work fine after deploying the change, tested a couple of apps in the Google Play Store, and checked file `dma_buf/bufinfo` to see there's no object leaking. #guybrush

Change-Id: Ib63559504e4cb8f1a32ae90170925146613d694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4297873
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2023-04-09 18:57:40 +00:00
Dawn Han
ecbc89179e minigbm: Remove plane in bo_map
Remove the parameter to align with upstream gbm.
For some places that use the number of planes. The number is 1. The
multi-planar formats are being allocated into a single plane, and
minigbm exynos backend is dropped. So we can just set the plane
index to 0 if needed.

Fixed the format in i915.c.

Bug=b:266776512
TEST=camera works after deploying the change #strongbad
TEST=camera works after deploying the change #corsola

Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2023-02-27 19:34:38 +00:00
Dawn Han
d77e164105 minigbm: Relax the validateBufferSize check
Blob formats (aka buffers) get represented as R8 textures with height
of one and width==size. These have no particular stride requirement,
even though the host might ask for a pitch that would make sense for
a 2D R8 texture with height greater than one.

Relax the validateBufferSize check for format_blob rather than set the
stride. As blob defined: buffers of this format must have a height of
1, so height doesn't need to be checked specifically.

BUG=b:269565421
TEST=CQ

Change-Id: I7a8d4dbf292330df0c24b502abd9dbf3dceac728
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4263402
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-02-20 04:00:05 +00:00
Yiwei Zhang
bab69032f2 virtgpu_cross_domain: align with virtgpu_virgl on the scanout formats
Start from aligning with the virgl backend that most platforms stay on.
Later we can do per platform customization in cross_domain backend.

BUG=b:262928949
TEST=CtsNativeHardwareTestCases on mtk

Change-Id: Ic7f1cb2ae9c8485f24dc7da0e27933de18cc59c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4113687
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-12-18 07:54:32 +00:00
Yiwei Zhang
15f826ccb8 virtgpu_cross_domain: always set VIRTGPU_EXECBUF_RING_IDX
On ARCVM platforms involving no vrend ctx, it's not legit to use the
legacy timeline. So no matter wait or not in cross_domain EB, we must
apply VIRTGPU_EXECBUF_RING_IDX.

BUG=b:262920670
TEST=create_fence failure from this EB is gone

Change-Id: I2ab6b620d37ef7d40a5503a98828204cc34a094b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4113686
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-12-18 07:54:30 +00:00
Yiwei Zhang
8f16db9fc8 virtgpu: always make it mappable for GPU_DATA_BUFFER
Venus device memory mapping setup must succeed for AHB VkBuffer.
Meanwhile, the imported AHB can be allocated with only GPU_DATA_BUFFER
flag. So we must add mappable flag in virtgpu backends accordingly.

BUG=b:246814802
TEST=Blob_BlobTest_GpuDataBufferVertexBuffer_BLOB

Change-Id: I88f63c732d3b133daf755d73ed54578605d27112
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3896159
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
2022-09-15 04:52:47 +00:00
Yiwei Zhang
ccfca97d92 cross_domain: format fix
TEST=build

Change-Id: I52c347b81ba0873139e5b63b467b4424233a5c85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3824598
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-08-14 07:13:32 +00:00
Jason Macnak
d0cce89e65 virtgpu_crossdomain: Allow BLOBs with SENSOR_DIRECT_DATA
BUG=b:238609372
TEST= vts -m VtsHalSensorsV2_1TargetTest

Change-Id: Id50e8057a0cc3150bb6b29bd7bdaa31fb7faa1ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3774935
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-26 23:41:34 +00:00
Rob Clark
bb62d42f28 virtgpu_crossdomain: Use guest storage when only CPU access is needed
No need to introduce host storage and mapping to the guest for buffers
that only have CPU access.  Fixes slow performance of sw encoders.

BUG=b:238158981, b:239333100
TEST=cts-tradefed run cts -m CtsVideoTestCases -t android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Perf0320x0240
TEST=cts-tradefed run cts -m CtsCameraTestCases -t android.hardware.camera2.cts.RecordingTest#testSupportedVideoSizes[1]

Change-Id: Iaf88a750ae215d3a02b8415ab93be06b08a7f550
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3777563
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
2022-07-24 10:48:26 +00:00
Rob Clark
8513e1f542 virtgpu_crossdomain: Handle buffer special case
Blob formats (aka buffers) get represented as R8 textures with height
of one and width==size.  These actually have no particular stride
requirement, even though the host might ask for a pitch that would make
sense for a 2D R8 texture with height greater than one.

BUG=b:239335026
TEST=cts-tradefed run cts -m CtsNNAPITestCases

Change-Id: I293f03b1c4292ed50252ea272f7d9e47e6c64ee2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3770014
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
2022-07-19 20:05:31 +00:00
Yiwei Zhang
0495473b90 minigbm: deprecate drv_log to favor log level
TEST=build

Change-Id: I3f0021bfd05eb1ab7c3b35ae2f31d806bc0a58dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761446
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-19 04:16:15 +00:00
Yiwei Zhang
7648f0649b minigbm: fix some formating
TEST=./presubmit.sh

Change-Id: Ia53da4264de6ab637a21ad55029024c52a253c0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761444
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-15 06:50:50 +00:00
Chia-I Wu
52be91e21b virtgpu_crossdomain: add BO_USE_GPU_DATA_BUFFER to DRM_FORMAT_R8
It is used for AHBs that are SSBOs/UBOs.  But I noticed this mainly
because venus's test allocation uses this as well when
VK_ANDROID_external_memory_android_hardware_buffer is enabled.

BUG=b:238663100
TEST=ANGLE

Change-Id: I72bdc73e1afdcb3f23667a77bc892e8402f25188
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3749168
Auto-Submit: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-12 17:44:53 +00:00
Rob Clark
fbf1bd96cc virtgpu_crosdomain: Add camera use flags for NV12
BUG=b:238098098
TEST=cts-tradefed run cts -m CtsGraphicsTestCases -t android.graphics.cts.CameraGpuTest#testCameraImageCaptureAndRendering

Change-Id: Id224a2835975597306e2ee48b3c4dc7b2519b229
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3748699
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-07 04:15:10 +00:00
Gurchetan Singh
c3d282625c minigbm: eliminate fake capset check
It's better just to conditionally advertise cross domain capset
in crosvm.

This is to upstream aosp/2101455.

BUG=173630595
TEST=compile

Change-Id: Ic44176141cade44bfa0cc2fcf457ddafb7ae7195
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3707443
Reviewed-by: Rob Clark <robdclark@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-06-17 07:10:07 +00:00
Rob Clark
9527781c92 virtgpu_crosdomain: Always use _USE_CROSS_DEVICE (when available)
This is required for dma-buf sharing, which is a thing that can happen
for sharing across processes even if it is the same GPU device involved
on both ends.  (Also, anything that gralloc allocates needs to be dmabuf
exportable, so not setting _USE_CROSS_DEVICE is just plain wrong.)

This fixes hangs in deqp-cts when using cross-domain virtgpu backend
(rather than the virgl backend)

BUG=b:230100768
TEST=Run deqp-cts

Change-Id: Ic9204feb0af52ef4a25bcfd554425cb8cd3f3fe1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3696038
Tested-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
2022-06-14 20:23:13 +00:00
Jason Macnak
af840f035b virtgpu_crosdomain: Fix pthread_mutex_init error check
It returns 0 on success.

BUG=b:189133053
TEST=launch cuttlefish w/ cross domain

Change-Id: I991bdf6c3db7eb4a58115fdd82143f207ecd6404
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3203237
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-10-05 07:11:34 +00:00
Yiwei Zhang
b8ad7b88ca minigbm: refactor to add unified resolve_format_and_use_flags helper
It makes more sense to resovle the format and use_flags together to
avoid duplicates.

Add the helper to vc4 and dumb_driver backends since that's missed
from prior frontend refactoring.

Split the resolve helper in virtgpu_virgl for the 3d and 2d paths to
make code logic cleaner.

BUG=b:199524294
TEST=CQ

Change-Id: I89b633ea484f0fc5bb9b4e0548cad017b9970cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200143
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-05 03:43:18 +00:00
Yiwei Zhang
b7a64441ef minigbm: refactor driver helpers
1. frontends access the driver via drv.h only
2. the renamed drv_helpers and drv_array_helpers are for driver only
3. remove extern "C" from drv_helpers.h given not exposed to gralloc
4. remove all redundant includes for those helpers

BUG=b:199524294
TEST=CQ and gralloc builds on aosp

Change-Id: I3f4d33076a6a8161804f1b7c26950ff5496507e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3195651
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-01 18:35:11 +00:00
Yiwei Zhang
e12d3ae83d virtgpu_crosdomain: add metadata_cache_lock
crosdomain specific metadata_cache should be protected by a backend
specific lock to reduce lock contention.

BUG=b:201110412
TEST=CQ

Change-Id: Ic3cedd7ad7903e669f7fba2b5f45d88739fbdc97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188471
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-09-29 07:08:23 +00:00
Yiwei Zhang
afdf87dcd4 minigbm: add more error handling especially for oom
This change also fixes a potential prime_fd leak in mediatek backend.

BUG=b:201110412
TEST=CQ

Change-Id: Ia3e10c94b536f83ecfb6580666103fe654bbc616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188852
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-09-29 07:08:22 +00:00
Yiwei Zhang
c1413ea43a minigbm: conditionally fallback to strip scanout use_flag
Only 2d virtgpu backend needs to fallback here because virtio primary
plane only allows DRM_FORMAT_XRGB8888.

Most our platforms cannot display YV12 (except msm), thus the fallback
is required for the converted DRM_FORMAT_YVU420_ANDROID. For virgl
backend, additionally append a BO_USE_LINEAR as a replacement for the
hack inside compute_virgl_bind_flags.

BUG=b:199524294
TEST=CQ
TEST=gralloctest alloc_combinations
TEST=android.media.cts.VideoDecoderRotationTest

Change-Id: Ic87838ea2aae2b0abf87ed898ad75a3d7e556471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166775
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 19:47:06 +00:00
Gurchetan Singh
4e767d3ae7 minigbm: virtgpu/cross_domain: update protocol
- Update to match latest CONTEXT_INIT proposal
- Update cross domain protocol to match crosvm
  (crrev.com/c/3055850) & Sommelier (crrev.com/c/3054321)

BUG=b:173630595
TEST=local testing with cross domain backend

Change-Id: I7420b03988bc8aed5b2bc53a0c54498a9ee47f86
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3119670
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Nicholas Verne <nverne@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-08-26 22:31:17 +00:00
Gurchetan Singh
b2917b28c2 virtgpu_cross_domain: handle from guest memory
For PCI passthrough and other use cases, it's desirable to get the
render target out of the guest.  In the PCI passthrough case, the
dGPU's memory is not available to the host.

The solution that many people are interested in is to use virtgpu
to allocate, and use the dGPU to render to that guest memory.  This
change adds a flag to the existing blob api, indicating to the host
that it *must* create an OS-specific handle out of guest memory upon
success.

Obviously, this is just for prototyping.  Only when the lords and
princes of dri-devel/mesa-dev -- eyes filled with the light of
upstream, swords as cold as blue ice -- descend from their heavenly
abodes on top of Mount Gogigyeopbbang may we have a proper
solution.

But for now, we'll have to live in our downstream mud hut with yet
another hack.  Oh well!

BUG=b:173630595
TEST=create a bunch of udmabufs

Change-Id: Ia33dc0c415be61423017003d3739c4fb7498dba5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2857886
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-04-30 20:41:42 +00:00
Gurchetan Singh
73c141e48e minigbm: virtgpu/cross_domain: next generation virtgpu backend
This change provides a route to the host side "cross domain"
allocator, which is specialized for resource sharing across domain
boundaries.  It uses the upcoming CONTEXT_INIT ioctl to initialize
the backend when available, and multiple timelines to perform
metadata queries.

While it would be awesome to use the revolutionary Address Space
Graphics (ASG) algorithm for metadata queries, it would be
non-trivial to pull off in minigbm.

Key aspects of the cross-domain allocator are:

* Intelligently falls back to OpenGL texture allocation host-side
  when external memory is not available.  The fallback path is
  named "virgl", even though it encompasses gfxstream and 2D mode.
  More refactorings will be added in the future for further
  clarity.

* Uses host Vulkan or minigbm to perform metadata query, and uses
  a cache to minimize vmexits.

* No shadow memory.  Only zero-copy blobs will be supported if the
  blob is mappable.  Shareable blobs may be compressed or tiled if
  not mappable.

* A commitment to sharing code across Google projects and
  cross-platform GPU virtualization.

The main goal here is to enable faster interation/testing, so this
code is just a prototype.  It should be fine to merge via minigbm,
since the project has a very chill philosophy and even proudly
accepts code that doesn't make any sense (crrev.com/c/2583188)
[so long as existing users are not broken].

BUG=b:173630595
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode

Change-Id: Ie33a46f19e5cdd82a2ac03bcf2351f4a8f294970
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2691716
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-17 07:25:37 +00:00