Commit graph

127 commits

Author SHA1 Message Date
Pujun Lun
1c4620794b gpu: add resource_flush() interface.
On Windows, we don't use import_resource_to_display() + flip_to(),
but the newly added resource_flush(). This applies to both Vulkan
and D3D backend. We would need some refactoring for the GpuDisplay
interface to create a better abstraction.

BUG=b:213149288
TEST=presubmit

Change-Id: If1d3dc543a17aa7fabf591aa2c1b87b226e8a4a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3869171
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-01 21:11:50 +00:00
Gurchetan Singh
710b3c9082 rutabaga_gfx: add stream_renderer_vulkan_info
The exact internals of the API may change though.  For example,
using a device UUID is a less error-prone than using physical
device index.

However, this is sufficient to get gfxstream external memory on
atleast some platforms.

BUG=b:235485545
TEST=compile and run ./deqp-vk with kFeature_ExternalBlob enabled

Change-Id: I10d2aaecfbcd61f383dd326184e60942755db196
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864029
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Idan Raiter <idanr@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-08-31 18:03:28 +00:00
Gurchetan Singh
7f5c54392a rutabaga_gfx: update Vulkano to match ToT
- Instance creation requires VulkanLibrary type
- UnsafeImage --> Arc<UnsafeImage>

BUG=b:173630595
TEST=cargo test --features=vulkano

Change-Id: Ie64d06fe0f20d63a19c94ae9fe6c904e83508178
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858687
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-26 20:57:17 +00:00
Rob Clark
84e4fbc2be rutabaga_gfx: Support for cached mappings on msm
This is a stop gap solution until we have some way for the kernel to
report mapping info to crosvm.  But since on arm devices without FWB,
the mapping attributes are the more restrictive of the S1 and S2
mappings, for now we can just map them as cached in the S2 pgtables.

BUG=b:239718180
TEST=cts-tradefed run cts -m CtsVideoTestCases -t android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Perf0320x0240

Change-Id: Ib3f085fd8da768b58e7a6d8deadf3a16c7cbcc4c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3832355
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
2022-08-18 20:33:55 +00:00
Daniel Verkamp
9c12c41185 rutabaga_gfx: remove use of VolatileRef
Replace the command parsing code that used VolatileRef with the new
DataInit::read_from_prefix() function. The code is parsing a normal Rust
&[u8] slice, so it does not need to use volatile loads at all.

BUG=None
TEST=tools/presubmit --all

Change-Id: I1ee57404ae39da3400f455959e7d396f20a0d22b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3823999
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-08-16 18:43:03 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
David Stevens
01e2724335 devices: wl: initialize gralloc after sandboxing
Initializing gralloc may spawn threads, so it needs to be done after
sandboxing the wl device. Initializing gralloc requires expanding the
wl device's sandbox. Rather than trying to maintain a new dedicated
minijail configuration for wl, reuse the gpu's configuration. This
should be sufficient, since virglrenderer has to open minigbm within the
sandboxed gpu process.

BUG=None
TEST=ARCVM and crostini GUI on volteer, zorc-arc-r, grunt-arc-r

Change-Id: I291fb59c665a8ba65058a6f55dee959c839bb43c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3787936
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
2022-07-27 01:54:48 +00:00
David Stevens
e9673a428a wl: allocate dma-bufs in process
Directly allocate dma-bufs within the virtio-wl process and remove the
VmMemoryRequest::AllocateAndRegisterGpuMemory type. This is preparation
for migrating to the SharedMemoryMapper interface.

BUG=b:201745804
TEST=Launch arcvm, launch gedit w/crostini, launch gedit w/vhost-user-wl

Change-Id: I232f1fd3dfdb8d7ed068c6b3c2ea23f35d0ddabc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765012
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-22 02:28:09 +00:00
Gurchetan Singh
51c07a15b3 crosvm: nuke gfxstream syncfd
Nobody ever toggles this flag, implying this flag can be removed.

By default, the gfxstream assumes ANDROID_EMU_virtio_gpu_native_sync
is present, which is the desired behavior.

BUG=b:239639751
TEST=compile gfxstream

Change-Id: I64d19c5fc2c0ac59a87ee25fbd1e7b6ed9522410
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778078
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-21 00:16:41 +00:00
Gurchetan Singh
0ae68e5076 rutabaga_gfx: gfxstream: stream_renderer_context_create
Newer version with context init variable.

BUG=b:235485545
TEST=compile

Change-Id: Ia9ce7a17c59db9839bdb0caf42a97708a3fdb46f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778077
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-20 23:51:30 +00:00
Vikram Auradkar
69f3931ee6 rutabaga_gfx: Upstream cross_domain.rs
BUG=b:213151426
TEST=presubmit. enables windows tests

Change-Id: I1ec80b88c8e66454d7eb911a8d366747528ff4fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3698048
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-13 17:34:42 +00:00
Daniel Verkamp
d4505a7f1c base: replace PollToken with EventToken tree-wide
Pull the declaration of the `EventToken` enum up to the top level of the
base crate, replacing the identical implementations inside sys/windows
and sys/unix.

Use the `EventToken` name consistently throughout the tree to remove the
unix-flavored "poll" nomenclature.

BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all

Change-Id: I0ba42037b533b796797a7a3f6d8d7e71a5592aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642673
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-02 22:30:38 +00:00
Kaiyi Li
bf7a2f37b2 gpu: add new gfxstream initialization flags
BUG=b:233676779
TEST=presubmit

Change-Id: I02103077006c2ac4bc8b3b21bf186de9743530e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668930
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 18:47:41 +00:00
David Stevens
569a58490e base: clarify SharedMemory API
When creating shared memory, 'name' can have one of two meanings. It
could either be a debugging tag with no semantic meaning, or it could
uniquely identify a shared memory object within some namespace. Linux
memfd uses name in the first meaning, whereas Windows (and Linux shm)
uses it in the second meaning.

Currently, crosvm has no use cases for the named shared memory of the
second type, so it is not supported. Make it clear that the SharedMemory
APIs treats name as a debugging-only name. Remove the "anon" and "named"
constructors, since they had no semantic meaning. Also require a name
when constructing a SharedMemory, since there's no reason not to provide
one to make debugging easier.

The only semantic change is setting the name of GuestMemory's underlying
shmem to "crosvm_guest", which it was until recently. This fixes some
ManaTEE tests which use the name to determine CrOS guest memory usage.

BUG=None
TEST=compiles

Change-Id: I78d5046df04d6f19640abbbc67af6bd433a177b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676695
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 03:55:47 +00:00
Ryan Neph
3b24bd0a53 rutabaga_gfx: virglrenderer: enable async_fence_cb
Flip the switch for Virglrenderer's virgl/vrend contexts to stop using
timer-based fence polling and start using async fence handling callback.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I0b309be2086225bbbb7beb0943379a22acb62a07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628304
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-05-31 22:50:14 +00:00
Rob Clark
82c5129590 rutabaga_gfx: Expose "fake" capset for minigbm
minigbm virtgpu_cross_domain backend checks for this capset.  Eventually
once this check is removed in minigbm (once everyone is using the
context-types arg to control whether cross-domain is exposed) we can
drop the dummy capset.  But we need it for now.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I7c955c365f439806c797d1d38daef2e1c9b3079f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3608703
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
d570dc761f rutabaga_gfx: Add cmdline arg to control exposed context types
Add a way to control exposed capsets from cmdline.  This will let us
enable certain context types only in certain VMs, with a single build
of crosvm.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I8d32a22c4c198566e984b06d6aa545796752c128
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636797
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
69ecfb0e39 rutabaga_gfx: Add support for drm native contexts
Expose support for the new virtgpu drm native contexts.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I068e9b14ac47782c9251d9b67156755f2888d17f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469494
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
567c777f15 rutabaga_gfx: conditionally enable capsets based RutabagaBuilder input
If the context_mask is specified, only advertise those capability sets.

If not specified, for backwards compatibility, use the older behavior.
Eventually, the older beahvior may be deprecated.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I3c37f94dfb5df25831d187deff600027aac2382d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Gurchetan Singh
3c77043c19 rutabaga_gfx: consolidate flags into the rutabaga builder
A lot of these flags can be deprecated over time.  For example,
specifying the context type and "use_vulkan" is a bit redundant.
Things like "use_syncfd" and "use_guest_angle" can also be removed.

BUG=b:173630595
TEST=compile

Change-Id: I77bff7f02ebfd3b0e65145d144bfc15afa50f386
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655286
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
6d7a90be3a rutabaga_gfx: add context type mask
A way to control exposed capsets.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I91616405b695be73d6cc872aa5ae2a9dcecd0fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636799
Commit-Queue: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-24 15:05:16 +00:00
Alexandre Courbot
6cabd03d60 gpu: fix unused_mut warning when no gpu feature is enabled
These variables will be left untouched if no GPU feature is enabled,
triggering a compiler warning.

BUG=None
TEST=`cargo build` does not display any warning.

Change-Id: Id1c80bd8f21272dce9e3a3f37cd3350727e5bc9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659824
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-23 08:21:26 +00:00
Rob Clark
953670c3ea virglrenderer: Add cross-domain support
For cross-domain, virgl_renderer needs to be able to import a dmabuf fd
allocated by another component.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I9d6f965589ec24f06a83a6d921a9c00db1f057f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3501130
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
2022-05-20 20:49:55 +00:00
Gurchetan Singh
c1a2fa27b4 rutabaga_gfx: stop unconditionally advertising the cross domain capset
Currently, there are two use cases for the cross domain capset:
   (1) Sommelier
   (2) minigbm

Niether is used by a production VM yet and it was unconditionally
enabled only to enable testing.  To effectively productize, it should
be conditionally enabled, which is done later in this patch series.

BUG=b:173630595
TEST=compile

Change-Id: I736f58065c692d7ee4736f28da30fa28de43f0c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655285
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-19 22:39:47 +00:00
Ryan Neph
bfe3bcf96a rutabaga_gfx: virglrenderer: add support for per-context fencing
Permits virglrenderer contexts to make use of per-context/per-ring
fencing.

BUG=b:175527587
BUG=b:193892617
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Cq-Depend: chromium:3654708
Change-Id: I30028afa5daff2a7a1b0ade13bc9fae2cd548f8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628302
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-19 22:39:47 +00:00
Ryan Neph
646de85eee gfxstream: fix fence_handler not stored in fencing cookie
While we support both the old and new fence handling methods of
b:175527587, we need two copies of the RutabagaFenceHandler (one for
each method).

BUG=b:228051513,b:175527587
TEST=emerge crosvm
TEST=tested by gfxstream team

Change-Id: I516cf135819aebb5128e41b8a9d585e17680c6a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646777
Commit-Queue: Ryan Neph <ryanneph@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-13 18:37:56 +00:00
Daniel Verkamp
f0e09415a5 rutabaga_gfx: silence unused_mut warning for non-virgl builds
When the virgl_renderer and gfxstream features are not enabled (e.g. in
a default `cargo build`), the use_timer_based_fence_polling variable is
never written, so the compiler warns about an unused `mut`. Add an allow
to silence this warning (we could use cfg checks to optionally add the
mut, but that would be much more complex for no real gain).

BUG=None
TEST=cargo build # no warnings

Change-Id: I176185328322d9d65cadce602ed09d43ef9eb4e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646451
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 22:19:43 +00:00
Ryan Neph
d255742197 gfxstream: add support for per-context fencing
This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
This will allow gfxstream to alternate between the main signalling
method (ASG [1]) and the more traditional interrupts when it
makes sense performance-wise.

gfxstream also requires new write fence callbacks that take into
account the ring_idx and ctx_id where the fence is on.

[1] goto.google.com/address-space-graphics

BUG=b:175527587
BUG=b:192614792
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I52b8eb0e70671e8b43bae6e9e5264268bfb076df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628301
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
d5fa537753 rutabaga_gfx: avoid fence_poll() if all components use async_fence_cb
An optional performance optimization that almost completely avoids the
wakeup cost of timer-based fence polling when all RutabagaComponents use
async_fence_cb. There is still a small overhead from the per-loop
virtio_gpu.needs_fence_poll() tests. This overhead will be removed in
later CLs, when timer-based fencing support is removed.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: Id9f14bcbdaa4dcdc42b24be12d85cad2ea0efed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628300
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
e246fff20c rutabaga_gfx: support fence handling via async callback
Adds another method for fencing where a rutabaga component may provide
an asynchronous callback for fence completion. When this method is
enabled, fences no longer need to be polled on the main thread.

When async_fence_cb is enabled, optional polling still occurs for
Rutabaga Components that still rely on it for other purposes (e.g.
virglrenderer for GL query checking).

Both the old and new methods of fence handling are supported with this
CL; e.g. timer-based polling and async callback, but timer-based polling
is the only one active. Follow-up CL(s) will switch to using the async
callback for each RutabagaComponent. Support for the old timer-based
polling will be removed after the async callback method stabilizes in
production.

Also, use a BTreeMap rather a HashMap since we only expect a dozen or so
entries at most. In such cases, a BTreeMap is faster.

* v1 (lfrb@collabora.com): remove all polling + add async_cb
* v2 (ryanneph@google.com): re-introduce optional polling to fix
  virglrenderer that relies on it for GL query checking.
* v3 (ryanneph@google.com): replace timer-based polling with
  eventfd-based poll() signaling for components that want to use it.
* v4 (ryanneph@google.com): add async fence handling beside timer-based
  polling to support both for a short time.

This is a pseudo-reland of commit
a999284da2, but modifications have been
made to support both fencing methods simultaneously.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I28f754aeef01972a01dab7990267415814a36c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628299
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-11 19:44:13 +00:00
Kaiyi Li
ffa8743f2c rutabaga_gfx: add gfxstream search path by using env
TEST=build
BUG=b:199167472
BUG=b:231635891

Change-Id: I8c69e9dad97007305097e9068a57d74163337648
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602045
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-06 22:50:21 +00:00
Rob Clark
5807bd9d80 rutabaga_gfx: enable debug callback on aarch64
BUG=b:231459413
TEST:croslog --follow | grep virgl_renderer.rs:152

Change-Id: I597990dbb1f9e715627db544fa2f84caa6bdfdf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628235
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 00:45:00 +00:00
Ryan Neph
60b6ed0e77 rutabaga_gfx: add context_name param to ffi/lib.rs
Follow-up to commit 13108989b1 to fix
broken rutabaga ffi after introducing the new context_name parameter
to create_context().

BUG=b:230678191
BUG=b:230788302
TEST=emerge crosvm

Change-Id: If1165662e66dd349ef4c52bece26fe724a861b78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621210
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-05-03 23:08:55 +00:00
Ryan Neph
13108989b1 rutabaga_gfx: create_context with an optional name
RutabagaComponents receive an Option<String> with calls to
Rutabaga::create_context(). This is desirable for virglrenderer so that
the guest application name can be used by the host renderer,
particularly to enable application specific GPU driver configs based on
program name matching. It is ignored by other RutabagaComponents for
now.

BUG=b:230678191
TEST=emerge crosvm
TEST=vkcube in VM

Change-Id: Ic08a02040ecc1d2e62795c248a66a88394b268e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3612467
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-04-28 21:41:29 +00:00
Dennis Kempin
ba4adc0efb Add python presubmit checks
This change adds python type and formatting checks and
consolidates code health checks in ./tools/health-check.

Dealing with relative imports in python is tricky, so
we are making ./tools/impl a proper package with no
directly executable files.

Some of the bash shorthands in ./tools had to be converted
to python for this.

To make the new checks pass, we run the formatter and fix
some mypy type checks.

TEST=./tools/health-check
BUG=b:218559722,b:219965702

Change-Id: Ie18d3d6dd2f5a033141e167a6e1aa762791941d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3558592
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:22:53 +00:00
Shao-Chuan Lee
105d68747b Revert "rutabaga_gfx: remove fence polling and enable async callback"
This reverts commit a999284da2.

This also introduces two extra `use` statements to fix the corresponding
errors in the LUCI build, which did not occur in local builds.

Reason for revert: caused deadlock in virglrenderer

Original change's description:
> rutabaga_gfx: remove fence polling and enable async callback
>
> Now that rutabaga users can provide a callback for fence
> completion, fences no longer need to be polled on the main thread.
>
> Optional polling still occurs for Rutabaga Components that still
> rely on it for other purposes (e.g. virglrenderer for GL query
> checking).
>
> Also, use a BTreeMap rather a HashMap since we only expect a dozen
> or so entries at most.  In such cases, a BTreeMap is faster.
>
> * v1 (lfrb@collabora.com): remove all polling + add async_cb
> * v2 (ryanneph@google.com): re-introduce optional polling to fix
>       virglrenderer that relies on it for GL query checking.
> * v3 (ryanneph@google.com): replace timer-based polling with
>       eventfd-based poll() signaling for components that want to
>       use it.
>
> BUG=b:175527587
> TEST=glxgears and vkcube in a crosvm guest VM.
>
> Cq-Depend: chromium:3555854, chromium:3563893
> Change-Id: I8e0181317e954cd15e2b8dc04c9b1329b0a6e182
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2860746
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ryan Neph <ryanneph@google.com>

BUG=b:175527587,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on dedede/kukui-arc-r

Change-Id: I616e3f283a60fe6a260f796cddce67c548b5e304
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584076
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:41 +00:00
Shao-Chuan Lee
a1fac454ed Revert "gfxstream: support async fence cb"
This reverts commit 3c2d5cefa2.

Reason for revert: depends on crrev.com/c/2860746

Original change's description:
> gfxstream: support async fence cb
>
> This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
> This will allow gfxstream to alternate between the main signalling
> method (ASG [1]) and the more traditional interrupts when it
> makes sense performance-wise.
>
> gfxstream also requires new write fence callbacks that take into
> account the ring_idx and ctx_id where the fence is on.
>
> [1] goto.google.com/address-space-graphics
>
> BUG=b:192614792
> TEST=Tested locally with Vulkan cereal
>
> Change-Id: I010d9ebfc71594b393fee062b984a4c6d69404d8
> Reviewed-on:
> https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3027489
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>

BUG=b:192614792,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on
dedede/kukui-arc-r

Change-Id: I4d2c43320880e38e8396cee3b96ce8c32addf39b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584075
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:40 +00:00
Shao-Chuan Lee
c6d01ebdbc Revert "rutabaga_gfx: enable per-context/per-ring fencing for virgl_renderer"
This reverts commit 8452832b97.

Reason for revert: depends on crrev.com/c/2860746

Original change's description:
> rutabaga_gfx: enable per-context/per-ring fencing for virgl_renderer
>
> Permits virglrenderer contexts to make use of per-context/per-ring
> fencing.
>
> BUG=b:193892617
> TEST=Run glxgears and vkcube in a crosvm guest VM.
>
> Change-Id: I9800d3fbab788602a25f2a118619910300126d4b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453115
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ryan Neph <ryanneph@google.com>

BUG=b:193892617,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on dedede/kukui-arc-r

Change-Id: I96be478ed4b994c3ccffa5b3cbc2de00a06332f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584074
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:39 +00:00
Keiichi Watanabe
901cd7df7f Reland "github: Minimize dependencies for document generation"
This is a reland of commit 2b85d4d1e5

Diff from the original CL:
* Changed the return value of `main()` in power_monitor/build.rs
* Ran cargo-check with all features enabled

Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
>   can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
>   dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug=none
TEST=cargo check --all-features

Change-Id: I77ee6543910e3fe7f69be48f8f965eda3433d4e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584063
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 22:30:10 +00:00
Junichi Uekawa
7af06dfc70 Revert "github: Minimize dependencies for document generation"
This reverts commit 2b85d4d1e5.

Reason for revert: breaks powerd compile

Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
>   can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
>   dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug: none
Change-Id: Ie16b65235490071ac4e69bf3f09af3ba0c766eab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581836
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-12 13:15:16 +00:00
Keiichi Watanabe
2b85d4d1e5 github: Minimize dependencies for document generation
Instead of install full dependencies with `install-deps` in GitHub
action, minimize dependencies because we use GitHub only for document
generation.

- Passed `CARGO_DOC` environment when running cargo-doc command so we
  can skip unnecessary build flow when we just want to generate API docs.
- Added a new script `install-docs-deps` to install only doc-related
  dependencies.

BUG=none
TEST=test on GitHub Action at my personal repository

Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 01:41:37 +00:00
Daniel Verkamp
f35f636cc5 Rust 1.60 clippy fixes
BUG=None
TEST=tools/presubmit # with rust-toolchain updated to 1.60.0

Change-Id: I5772e8b0593f8d92003e93aeb2145e87610abe2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3577332
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:40:36 +00:00
Ryan Neph
8452832b97 rutabaga_gfx: enable per-context/per-ring fencing for virgl_renderer
Permits virglrenderer contexts to make use of per-context/per-ring
fencing.

BUG=b:193892617
TEST=Run glxgears and vkcube in a crosvm guest VM.

Change-Id: I9800d3fbab788602a25f2a118619910300126d4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453115
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-06 18:45:11 +00:00
Lingfeng Yang
3c2d5cefa2 gfxstream: support async fence cb
This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
This will allow gfxstream to alternate between the main signalling
method (ASG [1]) and the more traditional interrupts when it
makes sense performance-wise.

gfxstream also requires new write fence callbacks that take into
account the ring_idx and ctx_id where the fence is on.

[1] goto.google.com/address-space-graphics

BUG=b:192614792
TEST=Tested locally with Vulkan cereal

Change-Id: I010d9ebfc71594b393fee062b984a4c6d69404d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3027489
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-04-05 16:34:56 +00:00
Kaiyi Li
bb24159038 gfxstream: fix renderer callbacks definitions
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I1cbfdd6107101e966763e6a2c70cdf66cefe216a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3567644
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-04-05 00:52:59 +00:00
Kaiyi Li
a2bed9b996 gfxstream: remove unused imports
Test: build
Change-Id: I872d3e2b7450a4709a126c774ee82c5e46134e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3569544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-04 20:17:22 +00:00
Ryan Neph
a999284da2 rutabaga_gfx: remove fence polling and enable async callback
Now that rutabaga users can provide a callback for fence
completion, fences no longer need to be polled on the main thread.

Optional polling still occurs for Rutabaga Components that still
rely on it for other purposes (e.g. virglrenderer for GL query
checking).

Also, use a BTreeMap rather a HashMap since we only expect a dozen
or so entries at most.  In such cases, a BTreeMap is faster.

* v1 (lfrb@collabora.com): remove all polling + add async_cb
* v2 (ryanneph@google.com): re-introduce optional polling to fix
      virglrenderer that relies on it for GL query checking.
* v3 (ryanneph@google.com): replace timer-based polling with
      eventfd-based poll() signaling for components that want to
      use it.

BUG=b:175527587
TEST=glxgears and vkcube in a crosvm guest VM.

Cq-Depend: chromium:3555854, chromium:3563893
Change-Id: I8e0181317e954cd15e2b8dc04c9b1329b0a6e182
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2860746
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-01 15:45:58 +00:00
Alexandre Courbot
eea1729c39 rutabaga_gfx: do not support GLX if x feature is not enabled
At the moment compiling with the "virgl_renderer" feature enabled but
"x" disabled results in a link error because the virgl_renderer enables
all its platforms without checking. Fix this by enabling the glx
platform only if the x feature has also been enabled.

BUG=b:226033718
TEST=`cargo build --features "virgl_renderer"` passes.
TEST=`cargo build --features "virgl_renderer,x"` passes and enables GLX
in virgl_renderer.

Change-Id: I85041fc2a3db7e49415add69389bee3160ba4a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539327
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 02:12:23 +00:00
Alexandre Courbot
b0d2e4da00 rutabaga_gfx: make build fail if default component is not enabled
Rutabaga's components are all included in the component type enum, even
those that are not enabled at compile-time. This causes a problem with
crosvm, which selects the virgl renderer as its default component even
if the corresponding cargo feature is not enabled. In such a case we
would get a cryptic panic.

Prevent this from happening by checking at build time that we are not
using a disabled component and return a detailed error if that's the
case.

BUG=b:223485028
TEST=Check that message appears with gpu device is run with the
`virglrenderer` backend but the `virgl_renderer` cargo feature is not
set.

Change-Id: Ib1bea10af82f4230350d19d534023e2b5814489d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3512393
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 00:10:46 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +00:00