Skip to content

Commit 38b8dcd

Browse files
brian3nguyenThomas Hellström
authored andcommitted
drm/xe: Skip over non leaf pte for PRL generation
The check using xe_child->base.children was insufficient in determining if a pte was a leaf node. So explicitly skip over every non-leaf pt and conditionally abort if there is a scenario where a non-leaf pt is interleaved between leaf pt, which results in the page walker skipping over some leaf pt. Note that the behavior being targeted for abort is PD[0] = 2M PTE PD[1] = PT -> 512 4K PTEs PD[2] = 2M PTE results in abort, page walker won't descend PD[1]. With new abort, ensuring valid PRL before handling a second abort. v2: - Revert to previous assert. - Revised non-leaf handling for interleaf child pt and leaf pte. - Update comments to specifications. (Stuart) - Remove unnecessary XE_PTE_PS64. (Matthew B) v3: - Modify secondary abort to only check non-leaf PTEs. (Matthew B) Fixes: b912138 ("drm/xe: Create page reclaim list on unbind") Signed-off-by: Brian Nguyen <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Cc: Stuart Summers <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Matt Roper <[email protected]> (cherry picked from commit 1d12358) Signed-off-by: Thomas Hellström <[email protected]>
1 parent 7838dd8 commit 38b8dcd

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

drivers/gpu/drm/xe/xe_pt.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,14 +1655,35 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset,
16551655
XE_WARN_ON(!level);
16561656
/* Check for leaf node */
16571657
if (xe_walk->prl && xe_page_reclaim_list_valid(xe_walk->prl) &&
1658-
(!xe_child->base.children || !xe_child->base.children[first])) {
1658+
xe_child->level <= MAX_HUGEPTE_LEVEL) {
16591659
struct iosys_map *leaf_map = &xe_child->bo->vmap;
16601660
pgoff_t count = xe_pt_num_entries(addr, next, xe_child->level, walk);
16611661

16621662
for (pgoff_t i = 0; i < count; i++) {
1663-
u64 pte = xe_map_rd(xe, leaf_map, (first + i) * sizeof(u64), u64);
1663+
u64 pte;
16641664
int ret;
16651665

1666+
/*
1667+
* If not a leaf pt, skip unless non-leaf pt is interleaved between
1668+
* leaf ptes which causes the page walk to skip over the child leaves
1669+
*/
1670+
if (xe_child->base.children && xe_child->base.children[first + i]) {
1671+
u64 pt_size = 1ULL << walk->shifts[xe_child->level];
1672+
bool edge_pt = (i == 0 && !IS_ALIGNED(addr, pt_size)) ||
1673+
(i == count - 1 && !IS_ALIGNED(next, pt_size));
1674+
1675+
if (!edge_pt) {
1676+
xe_page_reclaim_list_abort(xe_walk->tile->primary_gt,
1677+
xe_walk->prl,
1678+
"PT is skipped by walk at level=%u offset=%lu",
1679+
xe_child->level, first + i);
1680+
break;
1681+
}
1682+
continue;
1683+
}
1684+
1685+
pte = xe_map_rd(xe, leaf_map, (first + i) * sizeof(u64), u64);
1686+
16661687
/*
16671688
* In rare scenarios, pte may not be written yet due to racy conditions.
16681689
* In such cases, invalidate the PRL and fallback to full PPC invalidation.
@@ -1674,9 +1695,8 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset,
16741695
}
16751696

16761697
/* Ensure it is a defined page */
1677-
xe_tile_assert(xe_walk->tile,
1678-
xe_child->level == 0 ||
1679-
(pte & (XE_PTE_PS64 | XE_PDE_PS_2M | XE_PDPE_PS_1G)));
1698+
xe_tile_assert(xe_walk->tile, xe_child->level == 0 ||
1699+
(pte & (XE_PDE_PS_2M | XE_PDPE_PS_1G)));
16801700

16811701
/* An entry should be added for 64KB but contigious 4K have XE_PTE_PS64 */
16821702
if (pte & XE_PTE_PS64)
@@ -1701,11 +1721,11 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset,
17011721
killed = xe_pt_check_kill(addr, next, level - 1, xe_child, action, walk);
17021722

17031723
/*
1704-
* Verify PRL is active and if entry is not a leaf pte (base.children conditions),
1705-
* there is a potential need to invalidate the PRL if any PTE (num_live) are dropped.
1724+
* Verify if any PTE are potentially dropped at non-leaf levels, either from being
1725+
* killed or the page walk covers the region.
17061726
*/
1707-
if (xe_walk->prl && level > 1 && xe_child->num_live &&
1708-
xe_child->base.children && xe_child->base.children[first]) {
1727+
if (xe_walk->prl && xe_page_reclaim_list_valid(xe_walk->prl) &&
1728+
xe_child->level > MAX_HUGEPTE_LEVEL && xe_child->num_live) {
17091729
bool covered = xe_pt_covers(addr, next, xe_child->level, &xe_walk->base);
17101730

17111731
/*

0 commit comments

Comments
 (0)