devices: vvu: fix incorrect VVU PCI feature bits initialization

At present the VVU PCI driver writes the feature bits it wants to
enable to the device feature bits first, and then reads the device
feature bits in the initialization sequence. However, the correct
sequence is reading the device feature bits first, and writing the
feature bits to enable to the driver feature bits next. This incorrect
initialization sequence causes warning messages when you run the VVU
driver.

Fix the driver so that it follows the correct feature bits
initialization sequence.

BUG=b:216752120
TEST=VVU block device works with no warning message.
TEST=presubmit --quick

Change-Id: I7f7536143ee2a037fd71aa216513ad732b407cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3705077
Commit-Queue: Takaya Saeki <takayas@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
Takaya Saeki 2022-06-14 05:26:36 +00:00 committed by Chromeos LUCI
parent f51e3a3ce2
commit 69c8d8093d

View file

@ -296,13 +296,13 @@ impl VvuPciDevice {
lower as u64 | ((upper as u64) << 32)
}
fn set_device_feature(&self, features: u64) {
fn set_guest_feature(&self, features: u64) {
let lower: u32 = (features & (u32::MAX as u64)) as u32;
let upper: u32 = (features >> 32) as u32;
write_common_cfg_field!(self, device_feature_select, 0);
write_common_cfg_field!(self, device_feature, lower);
write_common_cfg_field!(self, device_feature_select, 1);
write_common_cfg_field!(self, device_feature, upper);
write_common_cfg_field!(self, guest_feature_select, 0);
write_common_cfg_field!(self, guest_feature, lower);
write_common_cfg_field!(self, guest_feature_select, 1);
write_common_cfg_field!(self, guest_feature, upper);
}
/// Creates the VVU's virtqueue (i.e. rxq or txq).
@ -459,7 +459,6 @@ impl VvuPciDevice {
// TODO(b/207364742): Support VIRTIO_RING_F_EVENT_IDX.
let required_features = 1u64 << VIRTIO_F_VERSION_1;
self.set_device_feature(required_features);
let enabled_features = self.get_device_feature();
if (required_features & enabled_features) != required_features {
bail!(
@ -468,6 +467,7 @@ impl VvuPciDevice {
enabled_features
);
};
self.set_guest_feature(required_features);
self.set_status(virtio_config::VIRTIO_CONFIG_S_FEATURES_OK as u8);
// Initialize Virtqueues