Skip to content

Commit 21c1c6c

Browse files
committed
Merge tag 'drm-xe-fixes-2024-11-14' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
Driver Changes: - Fix unlock on exec ioctl error path (Matthew Brost) - Fix hibernation on LNL due to ggtt getting lost (Matthew Brost / Matthew Auld) - Fix missing runtime PM in OA release (Ashutosh) Signed-off-by: Dave Airlie <[email protected]> From: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/5ntcf2ssmmvo5dsf2mdcee4guwwmpbm3xrlufgt2pdfmznzjo3@62ygo3bxkock
2 parents 1eb0de8 + c0403e4 commit 21c1c6c

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 23 additions & 20 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);
@@ -947,9 +948,15 @@ int xe_bo_restore_pinned(struct xe_bo *bo)
947948
if (WARN_ON(!xe_bo_is_pinned(bo)))
948949
return -EINVAL;
949950

950-
if (WARN_ON(xe_bo_is_vram(bo) || !bo->ttm.ttm))
951+
if (WARN_ON(xe_bo_is_vram(bo)))
952+
return -EINVAL;
953+
954+
if (WARN_ON(!bo->ttm.ttm && !xe_bo_is_stolen(bo)))
951955
return -EINVAL;
952956

957+
if (!mem_type_is_vram(place->mem_type))
958+
return 0;
959+
953960
ret = ttm_bo_mem_space(&bo->ttm, &bo->placement, &new_mem, &ctx);
954961
if (ret)
955962
return ret;
@@ -1719,6 +1726,7 @@ int xe_bo_pin_external(struct xe_bo *bo)
17191726

17201727
int xe_bo_pin(struct xe_bo *bo)
17211728
{
1729+
struct ttm_place *place = &bo->placements[0];
17221730
struct xe_device *xe = xe_bo_device(bo);
17231731
int err;
17241732

@@ -1749,21 +1757,21 @@ int xe_bo_pin(struct xe_bo *bo)
17491757
*/
17501758
if (IS_DGFX(xe) && !(IS_ENABLED(CONFIG_DRM_XE_DEBUG) &&
17511759
bo->flags & XE_BO_FLAG_INTERNAL_TEST)) {
1752-
struct ttm_place *place = &(bo->placements[0]);
1753-
17541760
if (mem_type_is_vram(place->mem_type)) {
17551761
xe_assert(xe, place->flags & TTM_PL_FLAG_CONTIGUOUS);
17561762

17571763
place->fpfn = (xe_bo_addr(bo, 0, PAGE_SIZE) -
17581764
vram_region_gpu_offset(bo->ttm.resource)) >> PAGE_SHIFT;
17591765
place->lpfn = place->fpfn + (bo->size >> PAGE_SHIFT);
1760-
1761-
spin_lock(&xe->pinned.lock);
1762-
list_add_tail(&bo->pinned_link, &xe->pinned.kernel_bo_present);
1763-
spin_unlock(&xe->pinned.lock);
17641766
}
17651767
}
17661768

1769+
if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) {
1770+
spin_lock(&xe->pinned.lock);
1771+
list_add_tail(&bo->pinned_link, &xe->pinned.kernel_bo_present);
1772+
spin_unlock(&xe->pinned.lock);
1773+
}
1774+
17671775
ttm_bo_pin(&bo->ttm);
17681776

17691777
/*
@@ -1809,23 +1817,18 @@ void xe_bo_unpin_external(struct xe_bo *bo)
18091817

18101818
void xe_bo_unpin(struct xe_bo *bo)
18111819
{
1820+
struct ttm_place *place = &bo->placements[0];
18121821
struct xe_device *xe = xe_bo_device(bo);
18131822

18141823
xe_assert(xe, !bo->ttm.base.import_attach);
18151824
xe_assert(xe, xe_bo_is_pinned(bo));
18161825

1817-
if (IS_DGFX(xe) && !(IS_ENABLED(CONFIG_DRM_XE_DEBUG) &&
1818-
bo->flags & XE_BO_FLAG_INTERNAL_TEST)) {
1819-
struct ttm_place *place = &(bo->placements[0]);
1820-
1821-
if (mem_type_is_vram(place->mem_type)) {
1822-
spin_lock(&xe->pinned.lock);
1823-
xe_assert(xe, !list_empty(&bo->pinned_link));
1824-
list_del_init(&bo->pinned_link);
1825-
spin_unlock(&xe->pinned.lock);
1826-
}
1826+
if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) {
1827+
spin_lock(&xe->pinned.lock);
1828+
xe_assert(xe, !list_empty(&bo->pinned_link));
1829+
list_del_init(&bo->pinned_link);
1830+
spin_unlock(&xe->pinned.lock);
18271831
}
1828-
18291832
ttm_bo_unpin(&bo->ttm);
18301833
}
18311834

drivers/gpu/drm/xe/xe_bo_evict.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ int xe_bo_evict_all(struct xe_device *xe)
3434
u8 id;
3535
int ret;
3636

37-
if (!IS_DGFX(xe))
38-
return 0;
39-
4037
/* User memory */
41-
for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
38+
for (mem_type = XE_PL_TT; mem_type <= XE_PL_VRAM1; ++mem_type) {
4239
struct ttm_resource_manager *man =
4340
ttm_manager_type(bdev, mem_type);
4441

42+
/*
43+
* On igpu platforms with flat CCS we need to ensure we save and restore any CCS
44+
* state since this state lives inside graphics stolen memory which doesn't survive
45+
* hibernation.
46+
*
47+
* This can be further improved by only evicting objects that we know have actually
48+
* used a compression enabled PAT index.
49+
*/
50+
if (mem_type == XE_PL_TT && (IS_DGFX(xe) || !xe_device_has_flat_ccs(xe)))
51+
continue;
52+
4553
if (man) {
4654
ret = ttm_resource_manager_evict_all(bdev, man);
4755
if (ret)
@@ -125,9 +133,6 @@ int xe_bo_restore_kernel(struct xe_device *xe)
125133
struct xe_bo *bo;
126134
int ret;
127135

128-
if (!IS_DGFX(xe))
129-
return 0;
130-
131136
spin_lock(&xe->pinned.lock);
132137
for (;;) {
133138
bo = list_first_entry_or_null(&xe->pinned.evicted,
@@ -159,7 +164,6 @@ int xe_bo_restore_kernel(struct xe_device *xe)
159164
* should setup the iosys map.
160165
*/
161166
xe_assert(xe, !iosys_map_is_null(&bo->vmap));
162-
xe_assert(xe, xe_bo_is_vram(bo));
163167

164168
xe_bo_put(bo);
165169

drivers/gpu/drm/xe/xe_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
203203
write_locked = false;
204204
}
205205
if (err)
206-
goto err_syncs;
206+
goto err_hw_exec_mode;
207207

208208
if (write_locked) {
209209
err = xe_vm_userptr_pin(vm);
210210
downgrade_write(&vm->lock);
211211
write_locked = false;
212212
if (err)
213-
goto err_hw_exec_mode;
213+
goto err_unlock_list;
214214
}
215215

216216
if (!args->num_batch_buffer) {

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,11 @@ static int xe_oa_release(struct inode *inode, struct file *file)
12061206
struct xe_oa_stream *stream = file->private_data;
12071207
struct xe_gt *gt = stream->gt;
12081208

1209+
xe_pm_runtime_get(gt_to_xe(gt));
12091210
mutex_lock(&gt->oa.gt_lock);
12101211
xe_oa_destroy_locked(stream);
12111212
mutex_unlock(&gt->oa.gt_lock);
1213+
xe_pm_runtime_put(gt_to_xe(gt));
12121214

12131215
/* Release the reference the OA stream kept on the driver */
12141216
drm_dev_put(&gt_to_xe(gt)->drm);

0 commit comments

Comments
 (0)