Skip to content

Commit ae2c6d8

Browse files
committed
Merge tag 'drm-xe-next-fixes-2024-09-12' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-next
Driver Changes: - Fix usefafter-free when provisioning VF (Matthew Auld) - Suppress rpm warning on false positive (Rodrigo) - Fix memleak on ioctl error path (Dafna) - Fix use-after-free while inserting ggtt (Michal Wajdeczko) - Add Wa_15016589081 workaround (Tejas) - Fix error path on suspend (Maarten) Signed-off-by: Dave Airlie <[email protected]> From: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/az6xs2z6zj3brq2h5wgaaoxwnqktrwbvxoyckrz7gbywsso734@a6v7gytqbcd6
2 parents 26df39d + f1a4dce commit ae2c6d8

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

drivers/gpu/drm/xe/regs/xe_gt_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

106106
#define CHICKEN_RASTER_1 XE_REG_MCR(0x6204, XE_REG_OPTION_MASKED)
107107
#define DIS_SF_ROUND_NEAREST_EVEN REG_BIT(8)
108+
#define DIS_CLIP_NEGATIVE_BOUNDING_BOX REG_BIT(6)
108109

109110
#define CHICKEN_RASTER_2 XE_REG_MCR(0x6208, XE_REG_OPTION_MASKED)
110111
#define TBIMR_FAST_CLIP REG_BIT(5)

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ struct xe_exec_queue *xe_exec_queue_create_bind(struct xe_device *xe,
223223
gt->usm.reserved_bcs_instance,
224224
false);
225225

226-
if (!hwe)
226+
if (!hwe) {
227+
xe_vm_put(migrate_vm);
227228
return ERR_PTR(-EINVAL);
229+
}
228230

229231
q = xe_exec_queue_create(xe, migrate_vm,
230232
BIT(hwe->logical_instance), 1, hwe,

drivers/gpu/drm/xe/xe_ggtt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,19 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
619619
bo->ggtt_node = xe_ggtt_node_init(ggtt);
620620
if (IS_ERR(bo->ggtt_node)) {
621621
err = PTR_ERR(bo->ggtt_node);
622+
bo->ggtt_node = NULL;
622623
goto out;
623624
}
624625

625626
mutex_lock(&ggtt->lock);
626627
err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node->base, bo->size,
627628
alignment, 0, start, end, 0);
628-
if (err)
629+
if (err) {
629630
xe_ggtt_node_fini(bo->ggtt_node);
630-
else
631+
bo->ggtt_node = NULL;
632+
} else {
631633
xe_ggtt_map_bo(ggtt, bo);
634+
}
632635
mutex_unlock(&ggtt->lock);
633636

634637
if (!err && bo->flags & XE_BO_FLAG_GGTT_INVALIDATE)

drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
399399
static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
400400
{
401401
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
402-
struct xe_ggtt_node *node = config->ggtt_region;
402+
struct xe_ggtt_node *node;
403403
struct xe_tile *tile = gt_to_tile(gt);
404404
struct xe_ggtt *ggtt = tile->mem.ggtt;
405405
u64 alignment = pf_get_ggtt_alignment(gt);
@@ -411,14 +411,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
411411

412412
size = round_up(size, alignment);
413413

414-
if (xe_ggtt_node_allocated(node)) {
414+
if (xe_ggtt_node_allocated(config->ggtt_region)) {
415415
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
416416
if (unlikely(err))
417417
return err;
418418

419-
pf_release_ggtt(tile, node);
419+
pf_release_vf_config_ggtt(gt, config);
420420
}
421-
xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
421+
xe_gt_assert(gt, !xe_ggtt_node_allocated(config->ggtt_region));
422422

423423
if (!size)
424424
return 0;

drivers/gpu/drm/xe/xe_pm.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
416416
xe_display_pm_suspend_late(xe);
417417
out:
418418
if (err)
419-
xe_display_pm_resume(xe, true);
419+
xe_display_pm_runtime_resume(xe);
420420
xe_rpm_lockmap_release(xe);
421421
xe_pm_write_callback_task(xe, NULL);
422422
return err;
@@ -595,6 +595,22 @@ bool xe_pm_runtime_get_if_in_use(struct xe_device *xe)
595595
return pm_runtime_get_if_in_use(xe->drm.dev) > 0;
596596
}
597597

598+
/*
599+
* Very unreliable! Should only be used to suppress the false positive case
600+
* in the missing outer rpm protection warning.
601+
*/
602+
static bool xe_pm_suspending_or_resuming(struct xe_device *xe)
603+
{
604+
#ifdef CONFIG_PM
605+
struct device *dev = xe->drm.dev;
606+
607+
return dev->power.runtime_status == RPM_SUSPENDING ||
608+
dev->power.runtime_status == RPM_RESUMING;
609+
#else
610+
return false;
611+
#endif
612+
}
613+
598614
/**
599615
* xe_pm_runtime_get_noresume - Bump runtime PM usage counter without resuming
600616
* @xe: xe device instance
@@ -611,8 +627,11 @@ void xe_pm_runtime_get_noresume(struct xe_device *xe)
611627

612628
ref = xe_pm_runtime_get_if_in_use(xe);
613629

614-
if (drm_WARN(&xe->drm, !ref, "Missing outer runtime PM protection\n"))
630+
if (!ref) {
615631
pm_runtime_get_noresume(xe->drm.dev);
632+
drm_WARN(&xe->drm, !xe_pm_suspending_or_resuming(xe),
633+
"Missing outer runtime PM protection\n");
634+
}
616635
}
617636

618637
/**

drivers/gpu/drm/xe/xe_wa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ static const struct xe_rtp_entry_sr lrc_was[] = {
733733
DIS_PARTIAL_AUTOSTRIP |
734734
DIS_AUTOSTRIP))
735735
},
736+
{ XE_RTP_NAME("15016589081"),
737+
XE_RTP_RULES(GRAPHICS_VERSION(2001), ENGINE_CLASS(RENDER)),
738+
XE_RTP_ACTIONS(SET(CHICKEN_RASTER_1, DIS_CLIP_NEGATIVE_BOUNDING_BOX))
739+
},
736740

737741
{}
738742
};

0 commit comments

Comments
 (0)