fix: stop redox-drm on terminal scheme EBADF
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
--- a/src/main.rs
|
||||||
|
+++ b/src/main.rs
|
||||||
|
@@ -24,6 +24,7 @@ use redox_driver_sys::pcid_client::PcidClient;
|
||||||
|
use redox_driver_sys::quirks::PciQuirkFlags;
|
||||||
|
use redox_scheme::{SignalBehavior, Socket};
|
||||||
|
+use syscall04::error::EBADF;
|
||||||
|
|
||||||
|
use crate::driver::{DriverError, DriverEvent, GpuDriver, Result};
|
||||||
|
use crate::drivers::DriverRegistry;
|
||||||
|
@@ -102,10 +103,13 @@ fn run() -> Result<()> {
|
||||||
|
let event_scheme = drm_scheme.clone();
|
||||||
|
|
||||||
|
std::thread::spawn(move || loop {
|
||||||
|
- if let Ok(event) = event_rx.recv() {
|
||||||
|
- if let Ok(mut scheme) = event_scheme.lock() {
|
||||||
|
- scheme.handle_driver_event(event);
|
||||||
|
- }
|
||||||
|
+ let Ok(event) = event_rx.recv() else {
|
||||||
|
+ info!("redox-drm: event producer dropped, stopping driver event thread");
|
||||||
|
+ break;
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ if let Ok(mut scheme) = event_scheme.lock() {
|
||||||
|
+ scheme.handle_driver_event(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@@ -118,6 +122,10 @@ fn run() -> Result<()> {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
+ if e.errno == EBADF {
|
||||||
|
+ info!("redox-drm: scheme fd closed, exiting");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
error!("redox-drm: failed to receive scheme request: {}", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
@@ -145,6 +153,10 @@ fn run() -> Result<()> {
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = socket.write_response(response, SignalBehavior::Restart) {
|
||||||
|
+ if e.errno == EBADF {
|
||||||
|
+ info!("redox-drm: scheme fd closed while writing response, exiting");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
error!("redox-drm: failed to write scheme response: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
--- a/src/main.rs
|
||||||
|
+++ b/src/main.rs
|
||||||
|
@@ -24,6 +24,7 @@ use redox_driver_sys::pcid_client::PcidClient;
|
||||||
|
use redox_driver_sys::quirks::PciQuirkFlags;
|
||||||
|
use redox_scheme::{SignalBehavior, Socket};
|
||||||
|
+use syscall04::error::EBADF;
|
||||||
|
|
||||||
|
use crate::driver::{DriverError, DriverEvent, GpuDriver, Result};
|
||||||
|
use crate::drivers::DriverRegistry;
|
||||||
|
@@ -102,10 +103,13 @@ fn run() -> Result<()> {
|
||||||
|
let event_scheme = drm_scheme.clone();
|
||||||
|
|
||||||
|
std::thread::spawn(move || loop {
|
||||||
|
- if let Ok(event) = event_rx.recv() {
|
||||||
|
- if let Ok(mut scheme) = event_scheme.lock() {
|
||||||
|
- scheme.handle_driver_event(event);
|
||||||
|
- }
|
||||||
|
+ let Ok(event) = event_rx.recv() else {
|
||||||
|
+ info!("redox-drm: event producer dropped, stopping driver event thread");
|
||||||
|
+ break;
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ if let Ok(mut scheme) = event_scheme.lock() {
|
||||||
|
+ scheme.handle_driver_event(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@@ -118,6 +122,10 @@ fn run() -> Result<()> {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
+ if e.errno == EBADF {
|
||||||
|
+ info!("redox-drm: scheme fd closed, exiting");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
error!("redox-drm: failed to receive scheme request: {}", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
@@ -145,6 +153,10 @@ fn run() -> Result<()> {
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = socket.write_response(response, SignalBehavior::Restart) {
|
||||||
|
+ if e.errno == EBADF {
|
||||||
|
+ info!("redox-drm: scheme fd closed while writing response, exiting");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
error!("redox-drm: failed to write scheme response: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,8 +20,10 @@ use redox_driver_sys::pci::{
|
|||||||
enumerate_pci_class, PciDevice, PciDeviceInfo, PciLocation, PCI_CLASS_DISPLAY,
|
enumerate_pci_class, PciDevice, PciDeviceInfo, PciLocation, PCI_CLASS_DISPLAY,
|
||||||
PCI_VENDOR_ID_AMD, PCI_VENDOR_ID_INTEL,
|
PCI_VENDOR_ID_AMD, PCI_VENDOR_ID_INTEL,
|
||||||
};
|
};
|
||||||
|
use redox_driver_sys::pcid_client::PcidClient;
|
||||||
use redox_driver_sys::quirks::PciQuirkFlags;
|
use redox_driver_sys::quirks::PciQuirkFlags;
|
||||||
use redox_scheme::{SignalBehavior, Socket};
|
use redox_scheme::{SignalBehavior, Socket};
|
||||||
|
use syscall04::error::EBADF;
|
||||||
|
|
||||||
use crate::driver::{DriverError, DriverEvent, GpuDriver, Result};
|
use crate::driver::{DriverError, DriverEvent, GpuDriver, Result};
|
||||||
use crate::drivers::DriverRegistry;
|
use crate::drivers::DriverRegistry;
|
||||||
@@ -111,6 +113,10 @@ fn run() -> Result<()> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
if e.errno == EBADF {
|
||||||
|
info!("redox-drm: scheme fd closed, exiting");
|
||||||
|
break;
|
||||||
|
}
|
||||||
error!("redox-drm: failed to receive scheme request: {}", e);
|
error!("redox-drm: failed to receive scheme request: {}", e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -139,6 +145,10 @@ fn run() -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = socket.write_response(response, SignalBehavior::Restart) {
|
if let Err(e) = socket.write_response(response, SignalBehavior::Restart) {
|
||||||
|
if e.errno == EBADF {
|
||||||
|
info!("redox-drm: scheme fd closed while writing response, exiting");
|
||||||
|
break;
|
||||||
|
}
|
||||||
error!("redox-drm: failed to write scheme response: {}", e);
|
error!("redox-drm: failed to write scheme response: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,6 +174,18 @@ fn select_gpu_from_args() -> Result<PciDeviceInfo> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(mut pcid) = PcidClient::connect_default() {
|
||||||
|
let function = pcid.request_config().map_err(|e| {
|
||||||
|
DriverError::Pci(format!("failed to read pcid-spawner handoff config: {e}"))
|
||||||
|
})?;
|
||||||
|
let info = function.device_info();
|
||||||
|
info!(
|
||||||
|
"redox-drm: selected GPU from pcid-spawner handoff at {}",
|
||||||
|
info.location
|
||||||
|
);
|
||||||
|
return Ok(info);
|
||||||
|
}
|
||||||
|
|
||||||
let devices = enumerate_pci_class(PCI_CLASS_DISPLAY)
|
let devices = enumerate_pci_class(PCI_CLASS_DISPLAY)
|
||||||
.map_err(|e| DriverError::Pci(format!("PCI scan failed: {e}")))?;
|
.map_err(|e| DriverError::Pci(format!("PCI scan failed: {e}")))?;
|
||||||
let first = devices
|
let first = devices
|
||||||
@@ -241,8 +263,6 @@ const INTEL_CNL_DMC_KEYS: &[&str] = &["i915/cnl_dmc_ver1_07.bin", "i915/cnl_dmc_
|
|||||||
const INTEL_ICL_DMC_KEYS: &[&str] = &["i915/icl_dmc_ver1_09.bin", "i915/icl_dmc_ver1_07.bin"];
|
const INTEL_ICL_DMC_KEYS: &[&str] = &["i915/icl_dmc_ver1_09.bin", "i915/icl_dmc_ver1_07.bin"];
|
||||||
const INTEL_GLK_DMC_KEYS: &[&str] = &["i915/glk_dmc_ver1_04.bin"];
|
const INTEL_GLK_DMC_KEYS: &[&str] = &["i915/glk_dmc_ver1_04.bin"];
|
||||||
const INTEL_RKL_DMC_KEYS: &[&str] = &["i915/rkl_dmc_ver2_03.bin", "i915/rkl_dmc_ver2_02.bin"];
|
const INTEL_RKL_DMC_KEYS: &[&str] = &["i915/rkl_dmc_ver2_03.bin", "i915/rkl_dmc_ver2_02.bin"];
|
||||||
const INTEL_DG1_DMC_KEYS: &[&str] = &["i915/dg1_dmc_ver2_02.bin"];
|
|
||||||
|
|
||||||
fn intel_display_firmware_keys(device_id: u16) -> Option<&'static [&'static str]> {
|
fn intel_display_firmware_keys(device_id: u16) -> Option<&'static [&'static str]> {
|
||||||
match device_id {
|
match device_id {
|
||||||
// Gen12+ (Tiger Lake and newer)
|
// Gen12+ (Tiger Lake and newer)
|
||||||
@@ -271,8 +291,6 @@ fn intel_display_firmware_keys(device_id: u16) -> Option<&'static [&'static str]
|
|||||||
| 0x9BAA | 0x9BAC | 0x9BC2 | 0x9BC4 | 0x9BC5 | 0x9BC6 | 0x9BC8 | 0x9BCA
|
| 0x9BAA | 0x9BAC | 0x9BC2 | 0x9BC4 | 0x9BC5 | 0x9BC6 | 0x9BC8 | 0x9BCA
|
||||||
| 0x9BCC | 0x9BE6 | 0x9BF6 => Some(INTEL_KBL_DMC_KEYS),
|
| 0x9BCC | 0x9BE6 | 0x9BF6 => Some(INTEL_KBL_DMC_KEYS),
|
||||||
0x0A84 | 0x1A84 | 0x1A85 | 0x5A84 | 0x5A85 => Some(INTEL_GLK_DMC_KEYS),
|
0x0A84 | 0x1A84 | 0x1A85 | 0x5A84 | 0x5A85 => Some(INTEL_GLK_DMC_KEYS),
|
||||||
// DG1 (Gen12)
|
|
||||||
0x4905 | 0x4906 | 0x4907 | 0x4908 | 0x4909 => Some(INTEL_DG1_DMC_KEYS),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user