kms: Various gpu removal fixes
- Remove gpu from `kms_state.api` as well - Don't use `from_node_id` on device removal - Free resources asap via `refresh_used_devices`
This commit is contained in:
parent
3d3a566a3c
commit
359c3ad899
1 changed files with 10 additions and 2 deletions
|
|
@ -470,9 +470,15 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn device_removed(&mut self, dev: dev_t, dh: &DisplayHandle) -> Result<()> {
|
pub fn device_removed(&mut self, dev: dev_t, dh: &DisplayHandle) -> Result<()> {
|
||||||
let drm_node = DrmNode::from_dev_id(dev)?;
|
|
||||||
let mut outputs_removed = Vec::new();
|
|
||||||
let backend = self.backend.kms();
|
let backend = self.backend.kms();
|
||||||
|
// we can't use DrmNode::from_node_id, because that assumes the node is still on sysfs
|
||||||
|
let drm_node = backend
|
||||||
|
.drm_devices
|
||||||
|
.values()
|
||||||
|
.find_map(|device| (device.dev_node.dev_id() == dev).then_some(device.dev_node))
|
||||||
|
.with_context(|| format!("Couldn't find drm node for {}", dev))?;
|
||||||
|
|
||||||
|
let mut outputs_removed = Vec::new();
|
||||||
if let Some(mut device) = backend.drm_devices.shift_remove(&drm_node) {
|
if let Some(mut device) = backend.drm_devices.shift_remove(&drm_node) {
|
||||||
if let Some(mut leasing_global) = device.leasing_global.take() {
|
if let Some(mut leasing_global) = device.leasing_global.take() {
|
||||||
leasing_global.disable_global::<State>();
|
leasing_global.disable_global::<State>();
|
||||||
|
|
@ -490,6 +496,7 @@ impl State {
|
||||||
.destroy_global::<State>(dh, socket.dmabuf_global);
|
.destroy_global::<State>(dh, socket.dmabuf_global);
|
||||||
dh.remove_global::<State>(socket.drm_global);
|
dh.remove_global::<State>(socket.drm_global);
|
||||||
}
|
}
|
||||||
|
backend.api.as_mut().remove_node(&device.render_node);
|
||||||
let was_primary = *backend.primary_node.read().unwrap() == Some(device.render_node);
|
let was_primary = *backend.primary_node.read().unwrap() == Some(device.render_node);
|
||||||
if was_primary {
|
if was_primary {
|
||||||
if let Err(err) = backend.select_primary_gpu(dh) {
|
if let Err(err) = backend.select_primary_gpu(dh) {
|
||||||
|
|
@ -500,6 +507,7 @@ impl State {
|
||||||
self.common
|
self.common
|
||||||
.output_configuration_state
|
.output_configuration_state
|
||||||
.remove_heads(outputs_removed.iter());
|
.remove_heads(outputs_removed.iter());
|
||||||
|
backend.refresh_used_devices()?;
|
||||||
|
|
||||||
if self.backend.kms().session.is_active() {
|
if self.backend.kms().session.is_active() {
|
||||||
for output in outputs_removed {
|
for output in outputs_removed {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue