Skip to content

Commit 18a2b64

Browse files
committed
drm/asahi: Fix build with !DEV_COREDUMP
Fixes all unused warnings in this case. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 5b0ccdd commit 18a2b64

4 files changed

Lines changed: 27 additions & 4 deletions

File tree

drivers/gpu/drm/asahi/gpu.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use core::slice;
1717
use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
1818

1919
use kernel::{
20-
c_str, devcoredump,
20+
c_str,
2121
error::code::*,
2222
io::mem::{Mem, MemFlags},
2323
macros::versions,
@@ -28,9 +28,11 @@ use kernel::{
2828
lock::{mutex::MutexBackend, Guard},
2929
Arc, Mutex, UniqueArc,
3030
},
31-
time::{msecs_to_jiffies, Delta, Instant, Monotonic},
31+
time::{Delta, Instant, Monotonic},
3232
types::ForeignOwnable,
3333
};
34+
#[cfg(CONFIG_DEV_COREDUMP)]
35+
use kernel::devcoredump;
3436

3537
use crate::alloc::Allocator;
3638
use crate::debug::*;
@@ -341,6 +343,8 @@ impl rtkit::Operations for GpuManager::ver {
341343
if let Err(e) = data.generate_crashdump(crashlog) {
342344
dev_err!(dev.as_ref(), "Could not generate crashdump: {:?}\n", e);
343345
}
346+
#[cfg(not(CONFIG_DEV_COREDUMP))]
347+
let _ = crashlog;
344348

345349
if debug_enabled(DebugFlags::OopsOnGpuCrash) {
346350
panic!("GPU firmware crashed");
@@ -853,13 +857,15 @@ impl GpuManager::ver {
853857
return Err(EIO);
854858
}
855859

860+
#[cfg(CONFIG_DEV_COREDUMP)]
856861
let node = dev.as_ref().of_node().ok_or(EIO)?;
857862

858863
Ok(KBox::new(
859864
hw::DynConfig {
860865
pwr: pwr_cfg,
861866
uat_ttb_base: uat.ttb_base(),
862867
id: gpu_id,
868+
#[cfg(CONFIG_DEV_COREDUMP)]
863869
firmware_version: node.get_property(c_str!("apple,firmware-version"))?,
864870

865871
hw_data_a: Self::load_hwdata_blob(

drivers/gpu/drm/asahi/hw/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ pub(crate) struct DynConfig {
301301
/// Power calibration configuration for this specific chip/device.
302302
pub(crate) pwr: PwrConfig,
303303
/// Firmware version.
304+
#[cfg(CONFIG_DEV_COREDUMP)]
304305
pub(crate) firmware_version: KVec<u32>,
305306

306307
pub(crate) hw_data_a: KVVec<u8>,

drivers/gpu/drm/asahi/mmu.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub(crate) const IOVA_USER_TOP: u64 = 1 << (UAT_IAS as u64);
6666
pub(crate) const IOVA_USER_RANGE: Range<u64> = IOVA_USER_BASE..IOVA_USER_TOP;
6767

6868
/// Upper/kernel base VA
69+
#[cfg(CONFIG_DEV_COREDUMP)]
6970
const IOVA_TTBR1_BASE: u64 = 0xffffff8000000000;
7071
/// Driver-managed kernel base VA
7172
const IOVA_KERN_BASE: u64 = 0xffffffa000000000;
@@ -74,6 +75,7 @@ const IOVA_KERN_TOP: u64 = 0xffffffb000000000;
7475
/// Driver-managed kernel VA range
7576
const IOVA_KERN_RANGE: Range<u64> = IOVA_KERN_BASE..IOVA_KERN_TOP;
7677
/// Full kernel VA range
78+
#[cfg(CONFIG_DEV_COREDUMP)]
7779
const IOVA_KERN_FULL_RANGE: Range<u64> = IOVA_TTBR1_BASE..(!UAT_PGMSK as u64);
7880

7981
const TTBR_VALID: u64 = 0x1; // BIT(0)
@@ -1358,6 +1360,7 @@ impl Uat {
13581360
&self.kernel_lower_vm
13591361
}
13601362

1363+
#[cfg(CONFIG_DEV_COREDUMP)]
13611364
pub(crate) fn dump_kernel_pages(&self) -> Result<KVVec<pgtable::DumpedPage>> {
13621365
let mut inner = self.kernel_vm.inner.exec_lock(None, false)?;
13631366
inner.page_table.dump_pages(IOVA_KERN_FULL_RANGE)

drivers/gpu/drm/asahi/pgtable.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ use core::mem::size_of;
1111
use core::ops::Range;
1212
use core::sync::atomic::{AtomicU64, Ordering};
1313

14-
use kernel::uapi::{PF_R, PF_W, PF_X};
15-
use kernel::{addr::PhysicalAddr, error::Result, page::Page, prelude::*, types::Owned};
14+
#[cfg(CONFIG_DEV_COREDUMP)]
15+
use kernel::{
16+
uapi::{PF_R, PF_W, PF_X},
17+
types::Owned,
18+
};
19+
use kernel::{addr::PhysicalAddr, error::Result, page::Page, prelude::*};
1620

1721
use crate::debug::*;
1822
use crate::util::align;
@@ -74,6 +78,7 @@ const HIGH_BITS_PXN: u16 = 1 << 1;
7478
const HIGH_BITS_UXN: u16 = 1 << 2;
7579
const HIGH_BITS_GPU_ACCESS: u16 = 1 << 3;
7680

81+
#[cfg(CONFIG_DEV_COREDUMP)]
7782
pub(crate) const PTE_ADDR_BITS: u64 = (!UAT_PGMSK as u64) & (!UAT_HIGH_BITS);
7883

7984
#[derive(Debug, Copy, Clone)]
@@ -101,16 +106,20 @@ const PROT_GPU_WO: Prot = Prot::from_bits(AP_GPU, 0, 1);
101106
const PROT_GPU_RW: Prot = Prot::from_bits(AP_GPU, 1, 0);
102107
const _PROT_GPU_NA: Prot = Prot::from_bits(AP_GPU, 1, 1);
103108

109+
#[cfg(CONFIG_DEV_COREDUMP)]
104110
const PF_RW: u32 = PF_R | PF_W;
111+
#[cfg(CONFIG_DEV_COREDUMP)]
105112
const PF_RX: u32 = PF_R | PF_X;
106113

107114
// For crash dumps
115+
#[cfg(CONFIG_DEV_COREDUMP)]
108116
const PROT_TO_PERMS_FW: [[u32; 4]; 4] = [
109117
[0, 0, 0, PF_RW],
110118
[0, PF_RW, 0, PF_RW],
111119
[PF_RX, PF_RX, 0, PF_R],
112120
[PF_RX, PF_RW, 0, PF_R],
113121
];
122+
#[cfg(CONFIG_DEV_COREDUMP)]
114123
const PROT_TO_PERMS_OS: [[u32; 4]; 4] = [
115124
[0, PF_R, PF_W, PF_RW],
116125
[PF_R, 0, PF_RW, PF_RW],
@@ -159,6 +168,7 @@ impl Prot {
159168
}
160169
}
161170

171+
#[cfg(CONFIG_DEV_COREDUMP)]
162172
pub(crate) const fn from_pte(pte: u64) -> Self {
163173
Prot {
164174
high_bits: (pte >> UAT_HIGH_BITS_SHIFT) as u16,
@@ -167,6 +177,7 @@ impl Prot {
167177
}
168178
}
169179

180+
#[cfg(CONFIG_DEV_COREDUMP)]
170181
pub(crate) const fn elf_flags(&self) -> u32 {
171182
let ap = (self.ap & 3) as usize;
172183
let uxn = if self.high_bits & HIGH_BITS_UXN != 0 {
@@ -221,6 +232,7 @@ impl Default for Prot {
221232
}
222233
}
223234

235+
#[cfg(CONFIG_DEV_COREDUMP)]
224236
pub(crate) struct DumpedPage {
225237
pub(crate) iova: u64,
226238
pub(crate) pte: u64,
@@ -541,6 +553,7 @@ impl UatPageTable {
541553
})
542554
}
543555

556+
#[cfg(CONFIG_DEV_COREDUMP)]
544557
pub(crate) fn dump_pages(&mut self, iova_range: Range<u64>) -> Result<KVVec<DumpedPage>> {
545558
let mut pages = KVVec::new();
546559
let oas_mask = self.oas_mask;

0 commit comments

Comments
 (0)