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