Skip to content

Commit c909d9c

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: gpu: Hook up crashdump generation
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent be07cbf commit c909d9c

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

drivers/gpu/drm/asahi/gpu.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ use crate::driver::{AsahiDevRef, AsahiDevice};
3636
use crate::fw::channels::{ChannelErrorType, PipeType};
3737
use crate::fw::types::{U32, U64};
3838
use crate::{
39-
alloc, buffer, channel, event, fw, gem, hw, initdata, mem, mmu, queue, regs, workqueue,
39+
alloc, buffer, channel, crashdump, event, fw, gem, hw, initdata, mem, mmu, queue, regs,
40+
workqueue,
4041
};
4142

4243
const DEBUG_CLASS: DebugFlags = DebugFlags::Gpu;
@@ -330,11 +331,15 @@ impl rtkit::Operations for GpuManager::ver {
330331
ch.event.poll();
331332
}
332333

333-
fn crashed(data: <Self::Data as ForeignOwnable>::Borrowed<'_>, _crashlog: Option<&[u8]>) {
334+
fn crashed(data: <Self::Data as ForeignOwnable>::Borrowed<'_>, crashlog: Option<&[u8]>) {
334335
let dev = &data.dev;
335336

336337
data.crashed.store(true, Ordering::Relaxed);
337338

339+
if let Err(e) = data.generate_crashdump(crashlog) {
340+
dev_err!(dev.as_ref(), "Could not dump kernel VM pages: {:?}\n", e);
341+
}
342+
338343
if debug_enabled(DebugFlags::OopsOnGpuCrash) {
339344
panic!("GPU firmware crashed");
340345
} else {
@@ -1112,6 +1117,23 @@ impl GpuManager::ver {
11121117

11131118
Ok(())
11141119
}
1120+
1121+
fn generate_crashdump(&self, crashlog: Option<&[u8]>) -> Result {
1122+
// Lock the allocators, to block kernel/FW memory mutations (mostly)
1123+
let kalloc = self.alloc();
1124+
let pages = self.uat.dump_kernel_pages()?;
1125+
core::mem::drop(kalloc);
1126+
1127+
let mut crashdump = crashdump::CrashDumpBuilder::new(pages)?;
1128+
let initdata_addr = self.initdata.gpu_va().get();
1129+
crashdump.add_agx_info(self.cfg, &self.dyncfg, initdata_addr)?;
1130+
if let Some(crashlog) = crashlog {
1131+
crashdump.add_crashlog(crashlog)?;
1132+
}
1133+
let crashdump = crashdump.finalize();
1134+
1135+
Ok(())
1136+
}
11151137
}
11161138

11171139
#[versions(AGX)]

0 commit comments

Comments
 (0)