Skip to content

Commit 87c1a9b

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: mmu: Clippy fixes
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 03684bb commit 87c1a9b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/gpu/drm/asahi/mmu.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ struct UatRegion {
9090
map: io::mem::Mem,
9191
}
9292

93-
/// It's safe to share UAT region records across threads.
93+
/// SAFETY: It's safe to share UAT region records across threads.
9494
unsafe impl Send for UatRegion {}
95+
/// SAFETY: It's safe to share UAT region records across threads.
9596
unsafe impl Sync for UatRegion {}
9697

9798
/// Handoff region flush info structure
@@ -354,7 +355,7 @@ impl gpuvm::DriverGpuVm for VmInner {
354355
.prev_va
355356
.take()
356357
.expect("Multiple step_remap calls with prev_op");
357-
if prev_op.map_and_link_va(self, prev_gpuva, &vm_bo).is_err() {
358+
if prev_op.map_and_link_va(self, prev_gpuva, vm_bo).is_err() {
358359
dev_err!(self.dev.as_ref(), "step_remap: could not relink prev gpuva");
359360
return Err(EINVAL);
360361
}
@@ -365,7 +366,7 @@ impl gpuvm::DriverGpuVm for VmInner {
365366
.next_va
366367
.take()
367368
.expect("Multiple step_remap calls with next_op");
368-
if next_op.map_and_link_va(self, next_gpuva, &vm_bo).is_err() {
369+
if next_op.map_and_link_va(self, next_gpuva, vm_bo).is_err() {
369370
dev_err!(self.dev.as_ref(), "step_remap: could not relink next gpuva");
370371
return Err(EINVAL);
371372
}
@@ -400,7 +401,7 @@ impl VmInner {
400401

401402
/// Returns the translation table base for this Vm
402403
fn ttb(&self) -> u64 {
403-
self.page_table.ttb() as u64
404+
self.page_table.ttb()
404405
}
405406

406407
/// Map an `mm::Node` representing an mapping in VA space.
@@ -542,7 +543,6 @@ pub(crate) struct KernelMappingInner {
542543
}
543544

544545
/// An object mapping into a [`Vm`], which reserves the address range from use by other mappings.
545-
546546
pub(crate) struct KernelMapping(mm::Node<(), KernelMappingInner>);
547547

548548
impl KernelMapping {
@@ -900,6 +900,7 @@ unsafe impl Send for HandoffFlush {}
900900
impl HandoffFlush {
901901
/// Set up a flush operation for the coprocessor
902902
fn begin_flush(&self, start: u64, size: u64) {
903+
// SAFETY: Per the type invariant, this is safe
903904
let flush = unsafe { self.0.as_ref().unwrap() };
904905

905906
let state = flush.state.load(Ordering::Relaxed);
@@ -913,6 +914,7 @@ impl HandoffFlush {
913914

914915
/// Complete a flush operation for the coprocessor
915916
fn end_flush(&self) {
917+
// SAFETY: Per the type invariant, this is safe
916918
let flush = unsafe { self.0.as_ref().unwrap() };
917919
let state = flush.state.load(Ordering::Relaxed);
918920
if state != 2 {
@@ -1462,6 +1464,8 @@ impl Uat {
14621464
let handoff_rgn = Self::map_region(dev.as_ref(), c_str!("handoff"), HANDOFF_SIZE, true)?;
14631465
let ttbs_rgn = Self::map_region(dev.as_ref(), c_str!("ttbs"), SLOTS_SIZE, true)?;
14641466

1467+
// SAFETY: The Handoff struct layout matches the firmware's view of memory at this address,
1468+
// and the region is at least large enough per the size specified above.
14651469
let handoff = unsafe { &(handoff_rgn.map.ptr() as *mut Handoff).as_ref().unwrap() };
14661470

14671471
dev_info!(dev.as_ref(), "MMU: Initializing kernel page table\n");

0 commit comments

Comments
 (0)