Skip to content

Commit 2bced23

Browse files
committed
drm/asahi: pgtable: Clippy fixes
Signed-off-by: Asahi Lina <[email protected]>
1 parent b324025 commit 2bced23

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

drivers/gpu/drm/asahi/pgtable.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const UAT_LEVELS: usize = 3;
4545

4646
/// UAT input address space
4747
pub(crate) const UAT_IAS: usize = 39;
48-
const UAT_IASMSK: u64 = ((1u64 << UAT_IAS) - 1) as u64;
48+
const UAT_IASMSK: u64 = (1u64 << UAT_IAS) - 1;
4949

5050
const PTE_TYPE_BITS: u64 = 3;
5151
const PTE_TYPE_LEAF_TABLE: u64 = 3;
@@ -73,7 +73,7 @@ const HIGH_BITS_PXN: u16 = 1 << 1;
7373
const HIGH_BITS_UXN: u16 = 1 << 2;
7474
const HIGH_BITS_GPU_ACCESS: u16 = 1 << 3;
7575

76-
pub(crate) const PTE_ADDR_BITS: u64 = (!0u64) & (!UAT_PGMSK as u64) & (!UAT_HIGH_BITS);
76+
pub(crate) const PTE_ADDR_BITS: u64 = (!UAT_PGMSK as u64) & (!UAT_HIGH_BITS);
7777

7878
#[derive(Debug, Copy, Clone)]
7979
pub(crate) struct Prot {
@@ -584,14 +584,11 @@ impl UatPageTable {
584584
};
585585
let dst_page = Page::alloc_page(GFP_KERNEL)?;
586586
src_page.with_page_mapped(|psrc| -> Result {
587-
// SAFETY: This could technically still have a data
588-
// race with the firmware or other driver code (or
589-
// even userspace with timestamp buffers), but while
590-
// the Rust language technically says this is UB, in
591-
// the real world, using atomic reads for this is
592-
// guaranteed to never cause any harmful effects
593-
// other than possibly reading torn/unreliable data.
594-
// At least on ARM64 anyway.
587+
// SAFETY: This could technically still have a data race with the firmware
588+
// or other driver code (or even userspace with timestamp buffers), but while
589+
// the Rust language technically says this is UB, in the real world, using
590+
// atomic reads for this is guaranteed to never cause any harmful effects
591+
// other than possibly reading torn/unreliable data. At least on ARM64 anyway.
595592
//
596593
// (Yes, I checked with Rust people about this. ~~ Lina)
597594
//
@@ -602,6 +599,8 @@ impl UatPageTable {
602599
)
603600
};
604601
dst_page.with_page_mapped(|pdst| -> Result {
602+
// SAFETY: We own the destination page, so it is safe to view its contents
603+
// as a u64 slice.
605604
let dst_items = unsafe {
606605
core::slice::from_raw_parts_mut(
607606
pdst as *mut u64,
@@ -650,8 +649,8 @@ impl Drop for UatPageTable {
650649
pr_err!("UATPageTable::drop failed to free page tables\n",);
651650
}
652651
if self.ttb_owned {
653-
// SAFETY: If we own the ttb, it was allocated with Page::into_phys().
654652
mod_pr_debug!("UATPageTable::drop: Free TTB {:#x}\n", self.ttb);
653+
// SAFETY: If we own the ttb, it was allocated with Page::into_phys().
655654
unsafe {
656655
Page::from_phys(self.ttb);
657656
}

0 commit comments

Comments
 (0)