Skip to content

Commit 76f4618

Browse files
committed
Merge tag 'drm-xe-fixes-2024-08-22' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
UAPI Changes: - Fix OA format masks which were breaking build with gcc-5 (Geert) Driver Changes: - Fix opregion leak (Lucas) - Fix OA sysfs entry (Ashutosh) - Fix VM dma-resv lock (Brost) - Fix tile fini sequence (Brost) - Prevent UAF around preempt fence (Auld) - Fix DGFX display suspend/resume (Maarten) - Many Xe/Xe2 critical workarounds (Auld, Ngai-Mint, Bommu, Tejas, Daniele) - Fix devm/drmm issues (Daniele) - Fix missing workqueue destroy in xe_gt_pagefault (Stuart) - Drop HW fence pointer to HW fence ctx (Brost) - Free job before xe_exec_queue_put (Brost) Signed-off-by: Dave Airlie <[email protected]> From: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 5159b9d + 9e7f305 commit 76f4618

28 files changed

+265
-45
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ $(obj)/generated/%_wa_oob.c $(obj)/generated/%_wa_oob.h: $(obj)/xe_gen_wa_oob \
2525

2626
uses_generated_oob := \
2727
$(obj)/xe_ggtt.o \
28+
$(obj)/xe_device.o \
2829
$(obj)/xe_gsc.o \
2930
$(obj)/xe_gt.o \
3031
$(obj)/xe_guc.o \
3132
$(obj)/xe_guc_ads.o \
3233
$(obj)/xe_guc_pc.o \
3334
$(obj)/xe_migrate.o \
35+
$(obj)/xe_pat.o \
3436
$(obj)/xe_ring_ops.o \
3537
$(obj)/xe_vm.o \
3638
$(obj)/xe_wa.o \

drivers/gpu/drm/xe/display/xe_display.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ static void xe_display_fini_noirq(void *arg)
132132
return;
133133

134134
intel_display_driver_remove_noirq(xe);
135+
intel_opregion_cleanup(xe);
135136
}
136137

137138
int xe_display_init_noirq(struct xe_device *xe)
@@ -157,8 +158,10 @@ int xe_display_init_noirq(struct xe_device *xe)
157158
intel_display_device_info_runtime_init(xe);
158159

159160
err = intel_display_driver_probe_noirq(xe);
160-
if (err)
161+
if (err) {
162+
intel_opregion_cleanup(xe);
161163
return err;
164+
}
162165

163166
return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_noirq, xe);
164167
}
@@ -280,6 +283,27 @@ static bool suspend_to_idle(void)
280283
return false;
281284
}
282285

286+
static void xe_display_flush_cleanup_work(struct xe_device *xe)
287+
{
288+
struct intel_crtc *crtc;
289+
290+
for_each_intel_crtc(&xe->drm, crtc) {
291+
struct drm_crtc_commit *commit;
292+
293+
spin_lock(&crtc->base.commit_lock);
294+
commit = list_first_entry_or_null(&crtc->base.commit_list,
295+
struct drm_crtc_commit, commit_entry);
296+
if (commit)
297+
drm_crtc_commit_get(commit);
298+
spin_unlock(&crtc->base.commit_lock);
299+
300+
if (commit) {
301+
wait_for_completion(&commit->cleanup_done);
302+
drm_crtc_commit_put(commit);
303+
}
304+
}
305+
}
306+
283307
void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
284308
{
285309
bool s2idle = suspend_to_idle();
@@ -297,6 +321,8 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
297321
if (!runtime)
298322
intel_display_driver_suspend(xe);
299323

324+
xe_display_flush_cleanup_work(xe);
325+
300326
intel_dp_mst_suspend(xe);
301327

302328
intel_hpd_cancel_work(xe);

drivers/gpu/drm/xe/display/xe_dsb_buffer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "intel_display_types.h"
88
#include "intel_dsb_buffer.h"
99
#include "xe_bo.h"
10+
#include "xe_device.h"
11+
#include "xe_device_types.h"
1012
#include "xe_gt.h"
1113

1214
u32 intel_dsb_buffer_ggtt_offset(struct intel_dsb_buffer *dsb_buf)
@@ -16,7 +18,10 @@ u32 intel_dsb_buffer_ggtt_offset(struct intel_dsb_buffer *dsb_buf)
1618

1719
void intel_dsb_buffer_write(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val)
1820
{
21+
struct xe_device *xe = dsb_buf->vma->bo->tile->xe;
22+
1923
iosys_map_wr(&dsb_buf->vma->bo->vmap, idx * 4, u32, val);
24+
xe_device_l2_flush(xe);
2025
}
2126

2227
u32 intel_dsb_buffer_read(struct intel_dsb_buffer *dsb_buf, u32 idx)
@@ -26,9 +31,12 @@ u32 intel_dsb_buffer_read(struct intel_dsb_buffer *dsb_buf, u32 idx)
2631

2732
void intel_dsb_buffer_memset(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size)
2833
{
34+
struct xe_device *xe = dsb_buf->vma->bo->tile->xe;
35+
2936
WARN_ON(idx > (dsb_buf->buf_size - size) / sizeof(*dsb_buf->cmd_buf));
3037

3138
iosys_map_memset(&dsb_buf->vma->bo->vmap, idx * 4, val, size);
39+
xe_device_l2_flush(xe);
3240
}
3341

3442
bool intel_dsb_buffer_create(struct intel_crtc *crtc, struct intel_dsb_buffer *dsb_buf, size_t size)

drivers/gpu/drm/xe/display/xe_fb_pin.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "intel_fb.h"
1111
#include "intel_fb_pin.h"
1212
#include "xe_bo.h"
13+
#include "xe_device.h"
1314
#include "xe_ggtt.h"
1415
#include "xe_gt.h"
1516
#include "xe_pm.h"
@@ -304,6 +305,8 @@ static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
304305
if (ret)
305306
goto err_unpin;
306307

308+
/* Ensure DPT writes are flushed */
309+
xe_device_l2_flush(xe);
307310
return vma;
308311

309312
err_unpin:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
#define LE_CACHEABILITY_MASK REG_GENMASK(1, 0)
8181
#define LE_CACHEABILITY(value) REG_FIELD_PREP(LE_CACHEABILITY_MASK, value)
8282

83+
#define XE2_GAMREQSTRM_CTRL XE_REG(0x4194)
84+
#define CG_DIS_CNTLBUS REG_BIT(6)
85+
8386
#define CCS_AUX_INV XE_REG(0x4208)
8487

8588
#define VD0_AUX_INV XE_REG(0x4218)
@@ -372,6 +375,11 @@
372375

373376
#define XEHPC_L3CLOS_MASK(i) XE_REG_MCR(0xb194 + (i) * 8)
374377

378+
#define XE2_GLOBAL_INVAL XE_REG(0xb404)
379+
380+
#define SCRATCH1LPFC XE_REG(0xb474)
381+
#define EN_L3_RW_CCS_CACHE_FLUSH REG_BIT(0)
382+
375383
#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658)
376384

377385
#define XE2_TDF_CTRL XE_REG(0xb418)
@@ -429,6 +437,7 @@
429437
#define DIS_FIX_EOT1_FLUSH REG_BIT(9)
430438

431439
#define TDL_TSL_CHICKEN XE_REG_MCR(0xe4c4, XE_REG_OPTION_MASKED)
440+
#define STK_ID_RESTRICT REG_BIT(12)
432441
#define SLM_WMTP_RESTORE REG_BIT(11)
433442

434443
#define ROW_CHICKEN XE_REG_MCR(0xe4f0, XE_REG_OPTION_MASKED)

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_tile *tile,
15751575
return bo;
15761576
}
15771577

1578-
static void __xe_bo_unpin_map_no_vm(struct drm_device *drm, void *arg)
1578+
static void __xe_bo_unpin_map_no_vm(void *arg)
15791579
{
15801580
xe_bo_unpin_map_no_vm(arg);
15811581
}
@@ -1590,7 +1590,7 @@ struct xe_bo *xe_managed_bo_create_pin_map(struct xe_device *xe, struct xe_tile
15901590
if (IS_ERR(bo))
15911591
return bo;
15921592

1593-
ret = drmm_add_action_or_reset(&xe->drm, __xe_bo_unpin_map_no_vm, bo);
1593+
ret = devm_add_action_or_reset(xe->drm.dev, __xe_bo_unpin_map_no_vm, bo);
15941594
if (ret)
15951595
return ERR_PTR(ret);
15961596

@@ -1638,7 +1638,7 @@ int xe_managed_bo_reinit_in_vram(struct xe_device *xe, struct xe_tile *tile, str
16381638
if (IS_ERR(bo))
16391639
return PTR_ERR(bo);
16401640

1641-
drmm_release_action(&xe->drm, __xe_bo_unpin_map_no_vm, *src);
1641+
devm_release_action(xe->drm.dev, __xe_bo_unpin_map_no_vm, *src);
16421642
*src = bo;
16431643

16441644
return 0;

drivers/gpu/drm/xe/xe_device.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#include "xe_vm.h"
5555
#include "xe_vram.h"
5656
#include "xe_wait_user_fence.h"
57+
#include "xe_wa.h"
58+
59+
#include <generated/xe_wa_oob.h>
5760

5861
static int xe_file_open(struct drm_device *dev, struct drm_file *file)
5962
{
@@ -820,6 +823,11 @@ void xe_device_td_flush(struct xe_device *xe)
820823
if (!IS_DGFX(xe) || GRAPHICS_VER(xe) < 20)
821824
return;
822825

826+
if (XE_WA(xe_root_mmio_gt(xe), 16023588340)) {
827+
xe_device_l2_flush(xe);
828+
return;
829+
}
830+
823831
for_each_gt(gt, xe, id) {
824832
if (xe_gt_is_media_type(gt))
825833
continue;
@@ -843,6 +851,30 @@ void xe_device_td_flush(struct xe_device *xe)
843851
}
844852
}
845853

854+
void xe_device_l2_flush(struct xe_device *xe)
855+
{
856+
struct xe_gt *gt;
857+
int err;
858+
859+
gt = xe_root_mmio_gt(xe);
860+
861+
if (!XE_WA(gt, 16023588340))
862+
return;
863+
864+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
865+
if (err)
866+
return;
867+
868+
spin_lock(&gt->global_invl_lock);
869+
xe_mmio_write32(gt, XE2_GLOBAL_INVAL, 0x1);
870+
871+
if (xe_mmio_wait32(gt, XE2_GLOBAL_INVAL, 0x1, 0x0, 150, NULL, true))
872+
xe_gt_err_once(gt, "Global invalidation timeout\n");
873+
spin_unlock(&gt->global_invl_lock);
874+
875+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
876+
}
877+
846878
u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size)
847879
{
848880
return xe_device_has_flat_ccs(xe) ?

drivers/gpu/drm/xe/xe_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address);
162162
u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address);
163163

164164
void xe_device_td_flush(struct xe_device *xe);
165+
void xe_device_l2_flush(struct xe_device *xe);
165166

166167
static inline bool xe_device_wedged(struct xe_device *xe)
167168
{

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,35 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
105105

106106
static int __xe_exec_queue_init(struct xe_exec_queue *q)
107107
{
108+
struct xe_vm *vm = q->vm;
108109
int i, err;
109110

111+
if (vm) {
112+
err = xe_vm_lock(vm, true);
113+
if (err)
114+
return err;
115+
}
116+
110117
for (i = 0; i < q->width; ++i) {
111118
q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K);
112119
if (IS_ERR(q->lrc[i])) {
113120
err = PTR_ERR(q->lrc[i]);
114-
goto err_lrc;
121+
goto err_unlock;
115122
}
116123
}
117124

125+
if (vm)
126+
xe_vm_unlock(vm);
127+
118128
err = q->ops->init(q);
119129
if (err)
120130
goto err_lrc;
121131

122132
return 0;
123133

134+
err_unlock:
135+
if (vm)
136+
xe_vm_unlock(vm);
124137
err_lrc:
125138
for (i = i - 1; i >= 0; --i)
126139
xe_lrc_put(q->lrc[i]);
@@ -140,15 +153,7 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
140153
if (IS_ERR(q))
141154
return q;
142155

143-
if (vm) {
144-
err = xe_vm_lock(vm, true);
145-
if (err)
146-
goto err_post_alloc;
147-
}
148-
149156
err = __xe_exec_queue_init(q);
150-
if (vm)
151-
xe_vm_unlock(vm);
152157
if (err)
153158
goto err_post_alloc;
154159

@@ -638,7 +643,6 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
638643

639644
if (xe_vm_in_preempt_fence_mode(vm)) {
640645
q->lr.context = dma_fence_context_alloc(1);
641-
spin_lock_init(&q->lr.lock);
642646

643647
err = xe_vm_add_compute_exec_queue(vm, q);
644648
if (XE_IOCTL_DBG(xe, err))

drivers/gpu/drm/xe/xe_exec_queue_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ struct xe_exec_queue {
126126
u32 seqno;
127127
/** @lr.link: link into VM's list of exec queues */
128128
struct list_head link;
129-
/** @lr.lock: preemption fences lock */
130-
spinlock_t lock;
131129
} lr;
132130

133131
/** @ops: submission backend exec queue operations */

0 commit comments

Comments
 (0)