devices: gpu: fix suspend/resume for 2D fallback

When falling back to GPU 2D backend, the default_component remains set
to VirglRenderer. When Rutabaga suspend/resume feature is invoked later,
the default_component is checked and a RutabagaError::InvalidComponent
is thrown because it is not supported by the VirglRenderer backend.

This change sets the default_component to 2D whenever the fallback is
taken.

BUG=b:380180766
TEST=cargo build --features gpu,virgl_renderer

Fixes: fbe3f4696 ("devices: gpu: fallback to 2D backend on failed virgl backend init")
Change-Id: I7858fab5da05f439c74b5b6145683478d0c81433
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6039874
Auto-Submit: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Ryan Neph 2024-11-21 11:34:00 -08:00 committed by crosvm LUCI
parent 2a555e46bb
commit 1f15edcd22

View file

@ -1305,8 +1305,6 @@ impl RutabagaBuilder {
));
}
#[allow(unused_mut)]
let mut fallback_2d = false;
if self.default_component != RutabagaComponentType::Rutabaga2D {
#[cfg(feature = "virgl_renderer")]
if self.default_component == RutabagaComponentType::VirglRenderer {
@ -1323,7 +1321,7 @@ impl RutabagaBuilder {
push_capset(RUTABAGA_CAPSET_DRM);
} else {
log::warn!("error initializing gpu backend=virglrenderer, falling back to 2d.");
fallback_2d = true;
self.default_component = RutabagaComponentType::Rutabaga2D;
};
}
@ -1351,7 +1349,7 @@ impl RutabagaBuilder {
push_capset(RUTABAGA_CAPSET_CROSS_DOMAIN);
}
if self.default_component == RutabagaComponentType::Rutabaga2D || fallback_2d {
if self.default_component == RutabagaComponentType::Rutabaga2D {
let rutabaga_2d = Rutabaga2D::init(fence_handler.clone())?;
rutabaga_components.insert(RutabagaComponentType::Rutabaga2D, rutabaga_2d);
}