diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2019-06-11 21:50:46 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-24 03:29:42 +0000 |
commit | dd11d434730a5dea56106d0533bf42c6b7206ed0 (patch) | |
tree | ed43e4d244f5ecda11d4efd0cb833341339fbd7b /src/linux.rs | |
parent | cc91fc825241a3ac5b00693e0be79c50a9528dab (diff) | |
download | crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar.gz crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar.bz2 crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar.lz crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar.xz crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.tar.zst crosvm-dd11d434730a5dea56106d0533bf42c6b7206ed0.zip |
gpu: Allow more than one resource bridge socket
Currently the wayland device accesses buffers allocated by the gpu device via a dedicated socket connection. Upcoming virtual devices like vdec and camera will also need access to these buffers. Modify the gpu device so that it can process requests on multiple resource_bridge sockets. Each future device that needs access to gpu device buffers should create a new resource bridge socket pair and add it to the list of sockets that the gpu device monitors. The actual interface between the devices is unchanged. BUG=b:133381367 TEST=run glxgears in a crostini container with and without gpu enabled Change-Id: I58693881945965071a53653bf4f86681725267d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652876 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r-- | src/linux.rs | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/linux.rs b/src/linux.rs index 2fe1d5b..48cbe52 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -552,7 +552,7 @@ fn create_gpu_device( cfg: &Config, exit_evt: &EventFd, gpu_device_socket: VmMemoryControlRequestSocket, - gpu_socket: virtio::resource_bridge::ResourceResponseSocket, + gpu_sockets: Vec<virtio::resource_bridge::ResourceResponseSocket>, wayland_socket_path: &Path, ) -> DeviceResult { let jailed_wayland_path = Path::new("/wayland-0"); @@ -560,7 +560,7 @@ fn create_gpu_device( let dev = virtio::Gpu::new( exit_evt.try_clone().map_err(Error::CloneEventFd)?, Some(gpu_device_socket), - Some(gpu_socket), + gpu_sockets, if cfg.sandbox { &jailed_wayland_path } else { @@ -835,36 +835,45 @@ fn create_virtio_devices( } #[cfg_attr(not(feature = "gpu"), allow(unused_mut))] - let mut resource_bridge_wl_socket = None::<virtio::resource_bridge::ResourceRequestSocket>; + let mut resource_bridges = Vec::<virtio::resource_bridge::ResourceResponseSocket>::new(); + + if let Some(wayland_socket_path) = cfg.wayland_socket_path.as_ref() { + #[cfg_attr(not(feature = "gpu"), allow(unused_mut))] + let mut wl_resource_bridge = None::<virtio::resource_bridge::ResourceRequestSocket>; + + #[cfg(feature = "gpu")] + { + if cfg.gpu { + let (wl_socket, gpu_socket) = + virtio::resource_bridge::pair().map_err(Error::CreateSocket)?; + resource_bridges.push(gpu_socket); + wl_resource_bridge = Some(wl_socket); + } + } + + devs.push(create_wayland_device( + cfg, + wayland_socket_path, + wayland_device_socket, + wl_resource_bridge, + )?); + } #[cfg(feature = "gpu")] { if cfg.gpu { if let Some(wayland_socket_path) = &cfg.wayland_socket_path { - let (wl_socket, gpu_socket) = - virtio::resource_bridge::pair().map_err(Error::CreateSocket)?; - resource_bridge_wl_socket = Some(wl_socket); - devs.push(create_gpu_device( cfg, _exit_evt, gpu_device_socket, - gpu_socket, + resource_bridges, wayland_socket_path, )?); } } } - if let Some(wayland_socket_path) = cfg.wayland_socket_path.as_ref() { - devs.push(create_wayland_device( - cfg, - wayland_socket_path, - wayland_device_socket, - resource_bridge_wl_socket, - )?); - } - if let Some(cid) = cfg.cid { devs.push(create_vhost_vsock_device(cfg, cid, mem)?); } |