Introduce a new dedicated trait for types that can be used as serial
input. This trait adds the requirement that the type must implement
`AsRawDescriptor`, which will allow us to use the input as a poll source
instead of having to spin a dedicated thread to call `read()` on it.
BUG=b:228912920
TEST=cargo build
Change-Id: Ib07f7b4e63545fa0f27940553ad6124796f5b3cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Everything that takes a PCI BAR index should use the appropriate
PciBarIndex type rather than u8 (or usize) for better type safety and
descriptiveness.
BUG=b:232838930
TEST=tools/presubmit
Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
The read_bar() and write_bar() functions had an open-coded equivalent of
BAR lookup to find out if the access was intended for the settings BAR
or one of the device-specific extra BARs. Instead, we can reuse the same
BAR lookup code to find the index of the relevant BAR and compare it
against the settings_bar field.
BUG=b:232838930
TEST=tools/presubmit
Change-Id: I2e5f3ccff47d31718e835ccb745db75dbda2e4ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664281
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Define constants for the end of the ranges that exist within the
settings BAR so we can use the range syntax in the match instead of
manually checking against the start and end.
This uses inclusive range (..=) syntax, since exclusive range pattern
syntax (..) is experimental. Therefore, each range has a `_LAST`
constant that is equal to the address of the last valid byte in that
range (first + size - 1).
Rewriting the matches in this way allows us to clean up the two clippy
ignores and makes the code a bit easier to read.
BUG=b:232838930
TEST=tools/clippy
TEST=Boot x86-64 Crostini
Change-Id: Ibb8b5ea055e598c19504b7b1b6753706ad458875
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
We need to open vvu device before we go to jail since we don't have
access to sysfs in jail.
BUG=b:233690640
TEST=manual - fs is usable from a sibling guest when using VVU.
Change-Id: I0340d105b667cce2ba88d7557e64771fa2bedf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3665907
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This was fixed in crrev.com/c/3659824, but a subsequent commit somehow
reverted that line.
BUG=None
TEST=`cargo build` does not display any warning.
Change-Id: Id50ee4f615117ada8c27552e073f7fb04d8d009e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664166
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
We want to eventually reuse these functions in the regular virtio device
code, which uses a different kind of interrupt, so make that parameter
generic.
BUG=b:228912920
TEST=cargo build
Change-Id: I1139ce6626ac7b952b7769db6e66d677607d3307
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600166
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The error path reproduces the code outside of the match arm, so it can
be removed.
BUG=b:228912920
TEST=cargo build
Change-Id: Ibd485a52441be03501041bc4136bab9293c7066b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600165
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Used tx buffers are returned to the driver with 0 bytes written by the
device. The current code makes it look like we return the number of
received bytes, even though this is not the case since
process_transmit_request always returns 0 for some reason.
Make this more clear by explicitly setting 0 bytes used, and making
process_transmit_request return nothing.
BUG=b:228912920
TEST=cargo build
Change-Id: I9094f7a43847d7e29d5390f274d6650ca5ec7c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600164
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
On Unix, instead of getting random data from `/dev/urandom`, it will get
it from the `rand` platform agnostic crate instead.
OsRng.fill_bytes on unix will make a syscall to getrandom(2) if
available, otherwise it will read from `dev/urandom` after a succesful
poll to `dev/random`. Regardless of which way a random data is
retrieved, if the entropy pool is not intialized, `fill_bytes` will
block until it is intialized. This shouldn't be a problem because it is
a one time cost.
This CL will also upstream the Windows implementation of the rng device.
BUG=b:213149162
TEST=built and presubmits
Change-Id: Ic017f11795f8006e0bf2a04eb0478b3a3d336507
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
This allows finer grain selection of context types, and eventually deletion
of preprocessor flags and "default component type".
BUG=b:173630595
TEST=compile
Change-Id: I5669911dfd4d6a7fd290e73ed3939d54fabdb89f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655287
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
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>
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>
Motivation:
* simplify and unify, align more with standard log facade
* code reduction
* remove hardcoded platform-specific things
* a little more flexibility
* easily allow lov level/filtering config as cli argument
Note that there is more code removal than simply loc as updating tests
added few loc
Change-Id: I7beb4b2c28c3462553c6663b234ee38df79f59f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657053
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
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>
crosvm waits on events like exit, reset, crash, guest panic etc and
uses eventfd to wait on these events. As of now, we have 4 eventfds
and may increase.
This is an attempt to consolidate all Vm events into one framework.
Use Tube instead of Event to get consistent behavior between OSes.
Implement a wrapper over Tube to have a consistent API for events.
BUG=None.
TEST=Built crosvm. Ran a minimal vm to panic and verified that crosvm
received the panic event. cargo test on devices.
Change-Id: I313d428de5e3ce3b879982f913918ec0a4a72c35
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3480577
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vineeth Pillai <vineethrp@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
The default case can't call format! with the unexpected type because it
will end up back in fmt until the stack overflows.
BUG=b:232259781
TEST=build and boot Cuttlefish in aosp which uses the unhandled type
Change-Id: I80d9b745cf78859bc7e7e939fcc5f9955507241c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655281
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
Commit-Queue: Devin Moore <devinmoore@google.com>
It was done to avoid deadlock when stats are requested before guest is
up. Implement a stub BalloonStats::NotReady replier until host is up so
that timeout is no longer necessary.
BUG=b:232289535
TEST=few tast crostini/arc tests
Change-Id: I6731b4ee9eaecdd65aebdd3f530f0932b0660c85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652887
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
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>
This reverts commit 0ac97979b6.
Reason for revert: This static configuration for wakeup IRQs is
no longer needed since we have a mechanism for automatic dynamic
configuration of wakeup IRQs based on requests from ChromeOS VM.
BUG=b:228449597
TEST=Boot ManaTEE and verify wakeup from touchpad and other devices.
Change-Id: Ifce6919d3c3ab9e677ee0a6566aba4d720168db5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593741
Reviewed-by: Tomasz Nowicki <tnowicki@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Micah Morton <mortonm@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
All of these call sites are used in cases where a Timer has triggered
a WaitContext because it has expired, so we don't actually want to wait,
just mark the timer expiry as acknowledged.
BUG=b:213153157
TEST=tools/presubmit --all
Change-Id: If91ca66e1810756c0b441e1253f0022870ce1a3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652886
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This reverts commit 716b698659.
Reason for revert: this is wrong in multithreaded mode
Original change's description:
> crosvm: remove balloon stats request timeout
>
> It was done to avoid deadlock when stats are requested before guest is
> up. Implement a stub BalloonStats::NotReady replier until host is up so
> that timeout is no longer necessary.
>
> BUG=b:232289535
> TEST=few tast crostini/arc tests
>
> Change-Id: Ieb6888487ea5b10664b76d8f94330564e7a3c726
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647161
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Auto-Submit: Anton Romanov <romanton@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Anton Romanov <romanton@google.com>
Bug: b:232289535
Change-Id: I11faa967d6030ad4a0c292069b0678260757fda8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3651672
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Anton Romanov <romanton@google.com>
It was done to avoid deadlock when stats are requested before guest is
up. Implement a stub BalloonStats::NotReady replier until host is up so
that timeout is no longer necessary.
BUG=b:232289535
TEST=few tast crostini/arc tests
Change-Id: Ieb6888487ea5b10664b76d8f94330564e7a3c726
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647161
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Use anyhow::Error instead of defining Error enum so that we can provide
more precise error messages easily.
BUG=b:232273004
TEST=run VVU on workstation
Change-Id: I6107fb79b3e7b1a20b11b24c8ec62e2fd8564b78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640877
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Remove `Error::RxDescriptorsExhausted`, which was matched against.
As a result, no variants in `Error` enum appears in pattern matching and
we can switching to `anyhow::Error` easily in a following CL.
BUG=b:232273004
TEST=cargo build
Change-Id: Ie0fb0897b7ec09d901011d7d9e62af3a00b08bc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640876
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The fs device doesn't have Windows specific code. This CL just splits up
system specific code in order be consistent with the formats of other
devices.
BUG=b:229902431
TEST=built and presubmits
Change-Id: I6a1a7c68d89536d8d5f6a1d45c4727739bdca6a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642341
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Main update is separating unix and windows to have their own `Block::new` constructor. Also made a `get_all_features` platform agnostic constructor helper since it can be shared on both platforms.
BUG=b:227364312
TEST=built and presubmits
Change-Id: Ie5073389c7e6961fa397bd07275cafb3d571d66d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578375
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
The biggest change is adding a platform agnostic constructor helper method
`BlockBackend::new_from_async_disk`. `BlockBackend::new` is moved to the
sys module since it's only used by Linux and Windows will have a
`BlockBackend::new_from_files` constructor.
Next step will be to upstream Windows vhost-user block vmm.
BUG=b:227364312
TEST=built and presubmits
Change-Id: I80a6e219f7139c17abb5a00d3ba3e89a9a994030
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3576953
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
When a sibling shuts down, the VVU device process in the guest will exit
BUG=b:216407443
TEST=run vvu on workstation
Change-Id: I0c067b3fbea705dab362f9a3fd05e3770f1dc519
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591104
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
When a usb device is attached to guest kernel, guest kernel will
Try to set the usb configuration to value returned by
usb_choose_configuration. Unless the device has multiple configurations
and host side set it before attach to guest os, it will be same value
as what host kernel would set it during initialization. This would casue
a device reset and for Android devices in adb mode it will cause a
disconnect and reconnect.
Also we should allow user space trying to reset the device by setting
device configuration to active configuration.
BUG=b:123374026
BUG=b:232272092
TEST=Able to attach Pixel2 and Pixel4 to vm
TEST=Run CTS usb device verifer test on both phones
TEST=adb from crostini to test phones
Change-Id: I0e30aaa1b42a18741a2981e256d2268c1a70c46f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Long Cheng <lgcheng@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Flip the switch for Gfxstream to stop using timer-based fence
polling and start using async fence handling callback.
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: I5f00f44d29bd584ad554d8892e9f13448c29c712
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628303
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
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>
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>
The queue size defines the number of available descriptors, that can be
used for exchanging messages between guest and hypervisor. Each
virtio-video command uses at least 1 descriptor (eg. CMD_QUEUE uses 2).
The amount of descriptors in use depends on the number of sessions and
buffers in input and output video queue.
In the worst case scenario the peak number can reach over 672 for 8
simultaneous streams, with 26 + 16 buffers each just for CMD_QUEUE
commands alone.
If the entire queue is overfilled with CMD_QUEUE for OUTPUT queue only,
the driver has no free descriptors for INPUT queue buffers. This leads
to encoder/decoder starvation, hence no OUTPUT buffer can be produced
and no CMD_QUEUE will finish, which leads to dead locking the device.
This patch increases the queue size with consideration of above details
with some headroom to avoid driver's deadlock.
BUG=b:204055006
TEST=App from https://github.com/chromeos/video-decode-encode-demo.git
with 8 simultaneous stream runs without blocking the device.
Change-Id: If51e340dd501b5b261518fba23fc541e3b55af8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606869
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Emilie Roberts <hadrosaur@google.com>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Several devices were accepting virtio ring flags that they don't
actually support; remove these, as well as the common base_features
flags that are provided by the generic virtio device infrastructure.
The features removed from device implementations are:
- VIRTIO_F_VERSION_1: set by base_features()
- VIRTIO_RING_F_EVENT_IDX: set by base_features()
- VIRTIO_RING_F_INDIRECT_DESC: unsupported
- VIRTIO_F_NOTIFY_ON_EMPTY: unsupported
- VHOST_F_LOG_ALL: unsupported
- VIRTIO_F_ANY_LAYOUT: unsupported; transitional devices only
BUG=None
TEST=tools/presubmit --all
Change-Id: I9619d9bb784cb47ec85ffa4e25b7a743284d6da6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582525
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Previously, the check would only accept exactly the combination of bits
we specify in ready_bits due to the == comparison; the second check for
the failed bit would never be reached. Instead, mask off only the bits
we are interested in checking before comparing them.
BUG=None
TEST=tools/presubmit --all
Change-Id: Ib6cccdb249adeb267282ec0e5b51c0ac6b572490
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582524
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This makes the VirtioDevice::device_type() function return type more
descriptive, and it lets us implement fmt::Display for the type instead
of a custom type_to_str() function.
BUG=None
TEST=tools/presubmit --all
Change-Id: Icfc2be37cf31ecab5e73f4b29c2eaaaa417317ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This patch split msi emulation from vfio-pci to a seperate file
msi.rs and make it usable for other devices. And we make pcie
bridge use msi instead of msi-x. The reason to use msi is that
msi-x would need extra mmio bar allocation, which does not work
when bridge is hotplugged into the system.
BUG=None
TEST=check msi functionality in both pcie root port and vfio device
Change-Id: Id262e4635d074c2a952807a625c8a0bf0afbf86a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591961
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Restrict the bindgen patterns so that only the declarations from the
appropriate header are included in each binding, and add the
virtio_config binding to get the source of the VIRTIO_F_ and
VIRTIO_CONFIG_ #defines.
BUG=None
TEST=tools/presubmit --all
Change-Id: I216bd8d3540d918ad9bba162db0ae86b76d73f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582522
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
More or less fully document this file to make it a good documentation
example.
BUG=None
TEST=cargo doc
TEST=cargo test -p devices --doc pci_address
Change-Id: I9a02c057135bc684ccc7897a07cb8cfce77dd388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630423
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Escape the square brackets in doc comments to resolve the rustdoc
warning.
BUG=None
TEST=tools/cargo-doc
Change-Id: I78f60ef65f57b213da2f0e687ee295b7e046db9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630421
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug out interrupt for each removed pcie device. Only one
hotplug out interrupt is needed for all the removed pcie devices.
When the first vfio-pci device send hotplug out vfio command, virtual
pcie root port will inject hotplug out interrrupt. Other vfio-pci device's
hotplug out vfio command just clean virtual pcie root port's structure,
and let virtual pcie root port prepare for the next hotplug in.
BUG=b:185084350
TEST=Check TBT dock's hotplug out function, TBT dock has multi pcie
devices.
Change-Id: I15c2807097c0065d2a78ef269720e57d15eeaf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604291
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug in interrupt for each added pcie device. Only one hotplug
in interrupt is needed for all the added pcie devices.
So this commit adds a hp_interupt field into VfioCommandRequest, only
the last added pcie device sets hp_interrupt to true and requests virtual
pcie root port to inject hotplug in interrupt. Ohter added pcie devices
just create and configure vfio-pci device.
BUG=b:185084350
TEST=Check TBT dock's hotplug in function, TBT dock has multi pcie
devices.
Change-Id: I5a68ec38af9a32de9d4233b48e0aa3681e5a3ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604290
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>