Skip to content

Commit 387ff31

Browse files
committed
drm/asahi: pgtable: Fix missing nonglobal bit
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 65bdd9f commit 387ff31

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/gpu/drm/asahi/pgtable.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const UAT_IASMSK: u64 = (1u64 << UAT_IAS) - 1;
5050
const PTE_TYPE_BITS: u64 = 3;
5151
const PTE_TYPE_LEAF_TABLE: u64 = 3;
5252

53+
const UAT_NON_GLOBAL: u64 = 1 << 11;
5354
const UAT_AP_SHIFT: u32 = 6;
5455
const UAT_AP_BITS: u64 = 3 << UAT_AP_SHIFT;
5556
const UAT_HIGH_BITS_SHIFT: u32 = 52;
@@ -452,6 +453,16 @@ impl UatPageTable {
452453
self.with_pages(iova_range, true, false, |_, _| Ok(()))
453454
}
454455

456+
fn pte_bits(&self) -> u64 {
457+
if self.ttb_owned {
458+
// Owned page tables are userspace, so non-global
459+
PTE_TYPE_LEAF_TABLE | UAT_NON_GLOBAL
460+
} else {
461+
// The sole non-owned page table is kernelspace, so global
462+
PTE_TYPE_LEAF_TABLE
463+
}
464+
}
465+
455466
pub(crate) fn map_pages(
456467
&mut self,
457468
iova_range: Range<u64>,
@@ -470,6 +481,8 @@ impl UatPageTable {
470481
return Err(EINVAL);
471482
}
472483

484+
let pte_bits = self.pte_bits();
485+
473486
self.with_pages(iova_range, true, false, |iova, ptes| {
474487
for (idx, pte) in ptes.iter().enumerate() {
475488
let ptev = pte.load(Ordering::Relaxed);
@@ -480,10 +493,7 @@ impl UatPageTable {
480493
ptev
481494
);
482495
}
483-
pte.store(
484-
phys | prot.as_pte() | PTE_TYPE_LEAF_TABLE,
485-
Ordering::Relaxed,
486-
);
496+
pte.store(phys | prot.as_pte() | pte_bits, Ordering::Relaxed);
487497
if !one_page {
488498
phys += UAT_PGSZ as PhysicalAddr;
489499
}

0 commit comments

Comments
 (0)