Skip to content

Commit dd886a6

Browse files
mbrost05lucasdemarchi
authored andcommitted
drm/xe: Restore system memory GGTT mappings
GGTT mappings reside on the device and this state is lost during suspend / d3cold thus this state must be restored resume regardless if the BO is in system memory or VRAM. v2: - Unnecessary parentheses around bo->placements[0] (Checkpatch) Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit a19d1db) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent ce0d697 commit dd886a6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ int xe_bo_evict_pinned(struct xe_bo *bo)
886886
if (WARN_ON(!xe_bo_is_pinned(bo)))
887887
return -EINVAL;
888888

889-
if (WARN_ON(!xe_bo_is_vram(bo)))
890-
return -EINVAL;
889+
if (!xe_bo_is_vram(bo))
890+
return 0;
891891

892892
ret = ttm_bo_mem_space(&bo->ttm, &placement, &new_mem, &ctx);
893893
if (ret)
@@ -937,6 +937,7 @@ int xe_bo_restore_pinned(struct xe_bo *bo)
937937
.interruptible = false,
938938
};
939939
struct ttm_resource *new_mem;
940+
struct ttm_place *place = &bo->placements[0];
940941
int ret;
941942

942943
xe_bo_assert_held(bo);
@@ -950,6 +951,9 @@ int xe_bo_restore_pinned(struct xe_bo *bo)
950951
if (WARN_ON(xe_bo_is_vram(bo) || !bo->ttm.ttm))
951952
return -EINVAL;
952953

954+
if (!mem_type_is_vram(place->mem_type))
955+
return 0;
956+
953957
ret = ttm_bo_mem_space(&bo->ttm, &bo->placement, &new_mem, &ctx);
954958
if (ret)
955959
return ret;
@@ -1757,7 +1761,10 @@ int xe_bo_pin(struct xe_bo *bo)
17571761
place->fpfn = (xe_bo_addr(bo, 0, PAGE_SIZE) -
17581762
vram_region_gpu_offset(bo->ttm.resource)) >> PAGE_SHIFT;
17591763
place->lpfn = place->fpfn + (bo->size >> PAGE_SHIFT);
1764+
}
17601765

1766+
if (mem_type_is_vram(place->mem_type) ||
1767+
bo->flags & XE_BO_FLAG_GGTT) {
17611768
spin_lock(&xe->pinned.lock);
17621769
list_add_tail(&bo->pinned_link, &xe->pinned.kernel_bo_present);
17631770
spin_unlock(&xe->pinned.lock);
@@ -1818,7 +1825,8 @@ void xe_bo_unpin(struct xe_bo *bo)
18181825
bo->flags & XE_BO_FLAG_INTERNAL_TEST)) {
18191826
struct ttm_place *place = &(bo->placements[0]);
18201827

1821-
if (mem_type_is_vram(place->mem_type)) {
1828+
if (mem_type_is_vram(place->mem_type) ||
1829+
bo->flags & XE_BO_FLAG_GGTT) {
18221830
spin_lock(&xe->pinned.lock);
18231831
xe_assert(xe, !list_empty(&bo->pinned_link));
18241832
list_del_init(&bo->pinned_link);

drivers/gpu/drm/xe/xe_bo_evict.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ int xe_bo_restore_kernel(struct xe_device *xe)
159159
* should setup the iosys map.
160160
*/
161161
xe_assert(xe, !iosys_map_is_null(&bo->vmap));
162-
xe_assert(xe, xe_bo_is_vram(bo));
163162

164163
xe_bo_put(bo);
165164

0 commit comments

Comments
 (0)