1
0
Fork 0
forked from wry/wry

Merge pull request #626 from mahkoh/jorth/log-udmabuf

udmabuf: log device status
This commit is contained in:
mahkoh 2025-10-02 20:20:22 +02:00 committed by GitHub
commit 987bc5ee25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,8 +3,8 @@ use {
allocator::{Allocator, AllocatorError, BufferObject, BufferUsage, MappedBuffer},
format::Format,
utils::{
clonecell::CloneCell, compat::IoctlNumber, errorfmt::ErrorFmt, oserror::OsError,
page_size::page_size,
clonecell::CloneCell, compat::IoctlNumber, errorfmt::ErrorFmt, once::Once,
oserror::OsError, page_size::page_size,
},
video::{
LINEAR_MODIFIER, Modifier,
@ -54,6 +54,7 @@ pub enum UdmabufError {
#[derive(Default)]
pub struct UdmabufHolder {
logged: Once,
udmabuf: CloneCell<Option<Option<Rc<Udmabuf>>>>,
}
@ -64,14 +65,18 @@ impl UdmabufHolder {
}
match Udmabuf::new() {
Ok(u) => {
log::info!("Opened /dev/udmabuf");
let u = Rc::new(u);
self.udmabuf.set(Some(Some(u.clone())));
Some(u)
}
Err(UdmabufError::Open(OsError(c::EPERM))) => None,
Err(e) => {
log::error!("Could not create udmabuf device: {}", ErrorFmt(e));
self.udmabuf.set(Some(None));
self.logged.exec(|| {
log::warn!("Unable to open /dev/udmabuf: {}", ErrorFmt(&e));
});
if !matches!(e, UdmabufError::Open(OsError(c::EPERM))) {
self.udmabuf.set(Some(None));
}
None
}
}