Commit graph

100 commits

Author SHA1 Message Date
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
Robert Tarasov
43150cd614 crosvm: match rutabaga_gfx with tot vulkano
depends on https://github.com/vulkano-rs/vulkano/pull/1861

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

Change-Id: I988b4eb1199944a5bdd455e24deac4ed97aa4393
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3524122
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-03-16 18:45:39 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Dennis Kempin
5f46e21c02 Remove rutabaga_gfx_ffi from workspace
The crate requires special compilation flags that conflict with the
workspace flags.

We may want to consider moving it to common/ so the test runner can
compile it in a separate workspace.

This brings us one step closer to be able to run
`cargo build --workspace` with no excludes.

BUG=b:206689789
TEST=./tools/presubmit

Change-Id: Ice747ced00f81db0a8e05ff2bc43d4d0e323e456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-11 15:58:56 +00:00
Kaiyi Li
74abb9de04 rutabaga_gfx: use as to perform type conversion
On Windows os_handle is of type void*, can't use Into::into to cast to
i64. Use as i64 instead.

Test: launch_cvd
Change-Id: I7fe44dbadf5214ff9bfd81482f5b598091a8f692
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3448217
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-02-10 16:30:04 +00:00
Kaiyi Li
3ff6bbd1ac rutabaga_gfx: change os_handle type
Windows HANDLE is defined as void* which is incompatible with current
os_handle type i32. Change that to i64.

TEST=launch_cvd --gpu_mode=gfxstream
BUG=b:217977329

Change-Id: I78c6c4c0d7573773ed530d8987b932438222144f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3445529
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-02-08 21:31:45 +00:00
Anton Romanov
cb3cabe3ba Upgrade rust toolchain version to 1.58.1
Pre 1.58.1 have CVE-2022-21658
Cros toolchain got upgraded to 1.58.1

BUG=None
TEST=cq

Change-Id: I2ce5a08b40bcc4895c4f2ecef83efd4162d67494
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3435385
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-02-04 02:20:36 +00:00
Gurchetan Singh
dca095864f rutabaga_gfx: stream_renderer_create_blob and related functions
This CL adds stream_renderer_create_blob and export_blob
support.

BUG=b:208516032
TEST=run gfxstream

Change-Id: I312e266df04e0291ecefce05d3a63c527e6d87af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429702
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-02-03 03:23:58 +00:00
Gurchetan Singh
7d7fb7c567 rutabaga_gfx: get component from context type
The component type information is useful from time to time.

BUG=b:208516032
TEST=run gfxstream

Change-Id: I16be012064f2c764f021ae52c09c2371f2a29ccc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429701
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-02 18:14:06 +00:00
Chia-I Wu
3d27a4b747 rutabaga_gfx: enable debug callback on arm
v2: add va_list and share code between x86/arm debug_callback.

BUG=b:209647747
TEST=cargo fmt
TEST=tail -f /var/log/messages

Change-Id: I0a8ac703aacb95ac0b4df069aa6e2b48401d8c3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320959
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:27 +00:00
Chia-I Wu
bdd15ba5e7 rutabaga_gfx: fix virgl_renderer_bindings generator
There are three fixes

 - rustfmt the generated code
 - define VIRGL_RENDERER_UNSTABLE_APIS
 - use ${sysroot}/usr/include/virglrenderer.h by default, and use the
   checked out repo only when --virglrenderer is specified

BUG=b:209647747
TEST=tail -f /var/log/messages

Change-Id: Iabd337be140b8b82ffc9e3488b812ed30ef28027
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429700
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:26 +00:00
Chia-I Wu
198320c1c5 rutabaga_gfx: simplify debug_callback
The va_list can be consumed.  There is no need to simulate a va_copy
before calling vsnprintf.

BUG=b:209647747
TEST=tail -f /var/log/messages

Change-Id: Ib61f22bd55b013d2ebdb7e2c983f530b86ea1ab3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429699
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Phillip Pearson <philpearson@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:25 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Gurchetan Singh
fb7ee340dc rutabaga_gfx: use stream_renderer_map_info
Don't assume write combine mappings always.

BUG=b:213604148
TEST=dEQP-VK.memory.*

Change-Id: Ic1b50f52945e8735fa166b9dd5f37adbda809472
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3399584
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-01-18 22:40:30 +00:00
Jason Macnak
9b812ce96f rutabaga_gfx: gfxstream: Update gfxstream_backend_init()
... to add the `gfxstream_callbacks` param which was added in
aosp/1927497. This param is only used in specific forks of Crosvm
but is present in the common Gfxstream project.

BUG=b:214097104
TEST=launch_cvd --gpu_mode=gfxstream

Change-Id: I3870692dd7ea55653c9761e787ff747d20df44d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3381902
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alistair Delva <adelva@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-01-12 18:27:22 +00:00
Phillip Pearson
1675e32f36 virgl_renderer: Fix incorrect usage of CString
Calling CString::into_raw, changing the length of the string, then
passing it to CString::from_raw is not allowed:
https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_raw

This uses a vector instead, and truncates it to the length reported by
vsnprintf.

BUG=b:209867862
TEST=Borealis boots, and accelerated graphics work.

Change-Id: I4b08eabda74086819b3fb437247a5f2ef962defe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3324614
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Phillip Pearson <philpearson@google.com>
2021-12-16 21:58:33 +00:00
Chia-I Wu
4b94a925df rutabaga: rename VIRGL_RENDERER_MULTI_PROCESS
It was renamed to VIRGL_RENDERER_RENDER_SERVER in virglrenderer.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ic00be726e720686023ab90e611df67b4e733beb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331737
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-13 06:23:11 +00:00
Chia-I Wu
cba95dba9c rutabaga_gfx: fix gfxstream build
Fix

error[E0560]: struct `renderer_utils::VirglCookie` has no field named `None`
   --> rutabaga_gfx/src/gfxstream.rs:213:13
    |
213 |             None,
    |             ^^^^ `renderer_utils::VirglCookie` does not have this field
    |
    = note: available fields are: `fence_state`, `render_server_fd`

Also silience all warnings related to render server.

Change-Id: I19ef8746b63379a5517ba9abd3faf4e9da0abfc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328098
Auto-Submit: Chia-I Wu <olv@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-10 01:54:35 +00:00
Chia-I Wu
11e32f6ece rutabaga_gfx: prepare for VIRGL_RENDERER_MULTI_PROCESS
When the flag is set, virglrenderer can use the get_server_fd callback
to get the socket to the render server.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I692b5068a04e841b0a0ed2344a77908e720e19eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283506
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:07 +00:00
Chia-I Wu
e39bbbd025 rutabaga_gfx: add RUTABAGA_MEM_HANDLE_TYPE_SHM
virglrenderer can return an fd of type VIRGL_RENDERER_BLOB_FD_TYPE_SHM.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ie8def22f3dc6dc13a4972955aadabb91be838493
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283505
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:06 +00:00
Chia-I Wu
844160daf1 rutabaga_gfx: re-generate virglrenderer bindings
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ife4ef9ef3db4ad421ed0b24e902dd0d06915273f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283504
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:03 +00:00
Chia-I Wu
39ad06d10a rutabaga_gfx: impl Drop for VirglRenderer
We should clean up virglrenderer.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I6fb0075f28a7c1fb35ff977e98652326e1297da4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315232
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:02 +00:00
Keiichi Watanabe
879868ad0f Fix cargo-doc warnings
BUG=none
TEST=./tools/cargo-doc

Change-Id: If2a89761d47464eb139f1f32c8cb3cb10fad3f81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305959
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-09 14:34:33 +00:00
Gurchetan Singh
7d5f0fef45 devices: gpu: update protocols
- F_CONTEXT_INIT is in Linux 5.16 now
- F_RESOURCE_SYNC should come before other features now.

BUG=b:208516032
TEST=compile

Change-Id: I8dfed584b544d6140ba80c2d474dedfcb679417e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3309197
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
2021-12-01 19:34:00 +00:00
Keiichi Watanabe
91019884bb sys_util: Replace unsafe use of iovecs
`sys_util::recv_iovecs_with_fds` was implemented as a safe function, but
it was actually unsafe because it assumed that the caller would give a
slice of `libc::iovec` where each `iov_base` points a valid memory
region with `iov_len`.

To make the function truly safe, it should take a slice of IoSliceMut
instead.

BUG=none
TEST=cargo test in sys_util/vmm_vhost
TEST=vhost-user block still works

Change-Id: I45458ee4545af13ce7e0955fb67b3703b147e7df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288733
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-26 14:28:28 +00:00
Dennis Kempin
a1e42f07ea Enable clippy on more workspace crates
As before, some are automatically fixed by clippy, some manually
fixed.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: Ifcab4cf60775ee6bb7d4530af6406a74958432ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283683
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-15 23:55:42 +00:00
Dennis Kempin
c3dedf3cc1 cleanup: Fix previously disabled clippy checks
There were not too many cases here. This fixes:

- comparison_chain
- wrong_self_convention
- upper_case_acronyms
- from_over_into
- let-and-return

The collapsible_if check is moved to the permanently
allowed checks. The cases we do have improve
readability or semantics.

BUG=chromium:908640
TEST=Kokoro

Change-Id: I6e905d08e2a87aa0862d4d1cf5ff57b60e95fa7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3278776
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-12 23:23:48 +00:00