Skip to content

Commit

Permalink
Merge tag 'drm-xe-fixes-2024-08-22' of https://gitlab.freedesktop.org…
Browse files Browse the repository at this point in the history
…/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]
  • Loading branch information
airlied committed Aug 22, 2024
2 parents 5159b9d + 9e7f305 commit 76f4618
Show file tree
Hide file tree
Showing 28 changed files with 265 additions and 45 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/xe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ $(obj)/generated/%_wa_oob.c $(obj)/generated/%_wa_oob.h: $(obj)/xe_gen_wa_oob \

uses_generated_oob := \
$(obj)/xe_ggtt.o \
$(obj)/xe_device.o \
$(obj)/xe_gsc.o \
$(obj)/xe_gt.o \
$(obj)/xe_guc.o \
$(obj)/xe_guc_ads.o \
$(obj)/xe_guc_pc.o \
$(obj)/xe_migrate.o \
$(obj)/xe_pat.o \
$(obj)/xe_ring_ops.o \
$(obj)/xe_vm.o \
$(obj)/xe_wa.o \
Expand Down
28 changes: 27 additions & 1 deletion drivers/gpu/drm/xe/display/xe_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static void xe_display_fini_noirq(void *arg)
return;

intel_display_driver_remove_noirq(xe);
intel_opregion_cleanup(xe);
}

int xe_display_init_noirq(struct xe_device *xe)
Expand All @@ -157,8 +158,10 @@ int xe_display_init_noirq(struct xe_device *xe)
intel_display_device_info_runtime_init(xe);

err = intel_display_driver_probe_noirq(xe);
if (err)
if (err) {
intel_opregion_cleanup(xe);
return err;
}

return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_noirq, xe);
}
Expand Down Expand Up @@ -280,6 +283,27 @@ static bool suspend_to_idle(void)
return false;
}

static void xe_display_flush_cleanup_work(struct xe_device *xe)
{
struct intel_crtc *crtc;

for_each_intel_crtc(&xe->drm, crtc) {
struct drm_crtc_commit *commit;

spin_lock(&crtc->base.commit_lock);
commit = list_first_entry_or_null(&crtc->base.commit_list,
struct drm_crtc_commit, commit_entry);
if (commit)
drm_crtc_commit_get(commit);
spin_unlock(&crtc->base.commit_lock);

if (commit) {
wait_for_completion(&commit->cleanup_done);
drm_crtc_commit_put(commit);
}
}
}

void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
{
bool s2idle = suspend_to_idle();
Expand All @@ -297,6 +321,8 @@ void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
if (!runtime)
intel_display_driver_suspend(xe);

xe_display_flush_cleanup_work(xe);

intel_dp_mst_suspend(xe);

intel_hpd_cancel_work(xe);
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/xe/display/xe_dsb_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "intel_display_types.h"
#include "intel_dsb_buffer.h"
#include "xe_bo.h"
#include "xe_device.h"
#include "xe_device_types.h"
#include "xe_gt.h"

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

void intel_dsb_buffer_write(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val)
{
struct xe_device *xe = dsb_buf->vma->bo->tile->xe;

iosys_map_wr(&dsb_buf->vma->bo->vmap, idx * 4, u32, val);
xe_device_l2_flush(xe);
}

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

void intel_dsb_buffer_memset(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size)
{
struct xe_device *xe = dsb_buf->vma->bo->tile->xe;

WARN_ON(idx > (dsb_buf->buf_size - size) / sizeof(*dsb_buf->cmd_buf));

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

bool intel_dsb_buffer_create(struct intel_crtc *crtc, struct intel_dsb_buffer *dsb_buf, size_t size)
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/xe/display/xe_fb_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "intel_fb.h"
#include "intel_fb_pin.h"
#include "xe_bo.h"
#include "xe_device.h"
#include "xe_ggtt.h"
#include "xe_gt.h"
#include "xe_pm.h"
Expand Down Expand Up @@ -304,6 +305,8 @@ static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
if (ret)
goto err_unpin;

/* Ensure DPT writes are flushed */
xe_device_l2_flush(xe);
return vma;

err_unpin:
Expand Down
9 changes: 9 additions & 0 deletions drivers/gpu/drm/xe/regs/xe_gt_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
#define LE_CACHEABILITY_MASK REG_GENMASK(1, 0)
#define LE_CACHEABILITY(value) REG_FIELD_PREP(LE_CACHEABILITY_MASK, value)

#define XE2_GAMREQSTRM_CTRL XE_REG(0x4194)
#define CG_DIS_CNTLBUS REG_BIT(6)

#define CCS_AUX_INV XE_REG(0x4208)

#define VD0_AUX_INV XE_REG(0x4218)
Expand Down Expand Up @@ -372,6 +375,11 @@

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

#define XE2_GLOBAL_INVAL XE_REG(0xb404)

#define SCRATCH1LPFC XE_REG(0xb474)
#define EN_L3_RW_CCS_CACHE_FLUSH REG_BIT(0)

#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658)

#define XE2_TDF_CTRL XE_REG(0xb418)
Expand Down Expand Up @@ -429,6 +437,7 @@
#define DIS_FIX_EOT1_FLUSH REG_BIT(9)

#define TDL_TSL_CHICKEN XE_REG_MCR(0xe4c4, XE_REG_OPTION_MASKED)
#define STK_ID_RESTRICT REG_BIT(12)
#define SLM_WMTP_RESTORE REG_BIT(11)

#define ROW_CHICKEN XE_REG_MCR(0xe4f0, XE_REG_OPTION_MASKED)
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/xe/xe_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_tile *tile,
return bo;
}

static void __xe_bo_unpin_map_no_vm(struct drm_device *drm, void *arg)
static void __xe_bo_unpin_map_no_vm(void *arg)
{
xe_bo_unpin_map_no_vm(arg);
}
Expand All @@ -1590,7 +1590,7 @@ struct xe_bo *xe_managed_bo_create_pin_map(struct xe_device *xe, struct xe_tile
if (IS_ERR(bo))
return bo;

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

Expand Down Expand Up @@ -1638,7 +1638,7 @@ int xe_managed_bo_reinit_in_vram(struct xe_device *xe, struct xe_tile *tile, str
if (IS_ERR(bo))
return PTR_ERR(bo);

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

return 0;
Expand Down
32 changes: 32 additions & 0 deletions drivers/gpu/drm/xe/xe_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
#include "xe_vm.h"
#include "xe_vram.h"
#include "xe_wait_user_fence.h"
#include "xe_wa.h"

#include <generated/xe_wa_oob.h>

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

if (XE_WA(xe_root_mmio_gt(xe), 16023588340)) {
xe_device_l2_flush(xe);
return;
}

for_each_gt(gt, xe, id) {
if (xe_gt_is_media_type(gt))
continue;
Expand All @@ -843,6 +851,30 @@ void xe_device_td_flush(struct xe_device *xe)
}
}

void xe_device_l2_flush(struct xe_device *xe)
{
struct xe_gt *gt;
int err;

gt = xe_root_mmio_gt(xe);

if (!XE_WA(gt, 16023588340))
return;

err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
if (err)
return;

spin_lock(&gt->global_invl_lock);
xe_mmio_write32(gt, XE2_GLOBAL_INVAL, 0x1);

if (xe_mmio_wait32(gt, XE2_GLOBAL_INVAL, 0x1, 0x0, 150, NULL, true))
xe_gt_err_once(gt, "Global invalidation timeout\n");
spin_unlock(&gt->global_invl_lock);

xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
}

u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size)
{
return xe_device_has_flat_ccs(xe) ?
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/xe/xe_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address);
u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address);

void xe_device_td_flush(struct xe_device *xe);
void xe_device_l2_flush(struct xe_device *xe);

static inline bool xe_device_wedged(struct xe_device *xe)
{
Expand Down
24 changes: 14 additions & 10 deletions drivers/gpu/drm/xe/xe_exec_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,35 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,

static int __xe_exec_queue_init(struct xe_exec_queue *q)
{
struct xe_vm *vm = q->vm;
int i, err;

if (vm) {
err = xe_vm_lock(vm, true);
if (err)
return err;
}

for (i = 0; i < q->width; ++i) {
q->lrc[i] = xe_lrc_create(q->hwe, q->vm, SZ_16K);
if (IS_ERR(q->lrc[i])) {
err = PTR_ERR(q->lrc[i]);
goto err_lrc;
goto err_unlock;
}
}

if (vm)
xe_vm_unlock(vm);

err = q->ops->init(q);
if (err)
goto err_lrc;

return 0;

err_unlock:
if (vm)
xe_vm_unlock(vm);
err_lrc:
for (i = i - 1; i >= 0; --i)
xe_lrc_put(q->lrc[i]);
Expand All @@ -140,15 +153,7 @@ struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *v
if (IS_ERR(q))
return q;

if (vm) {
err = xe_vm_lock(vm, true);
if (err)
goto err_post_alloc;
}

err = __xe_exec_queue_init(q);
if (vm)
xe_vm_unlock(vm);
if (err)
goto err_post_alloc;

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

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

err = xe_vm_add_compute_exec_queue(vm, q);
if (XE_IOCTL_DBG(xe, err))
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/xe/xe_exec_queue_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ struct xe_exec_queue {
u32 seqno;
/** @lr.link: link into VM's list of exec queues */
struct list_head link;
/** @lr.lock: preemption fences lock */
spinlock_t lock;
} lr;

/** @ops: submission backend exec queue operations */
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/xe/xe_gsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
struct xe_tile *tile = gt_to_tile(gt);
int ret;

if (XE_WA(gt, 14018094691)) {
if (XE_WA(tile->primary_gt, 14018094691)) {
ret = xe_force_wake_get(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);

/*
Expand All @@ -278,7 +278,7 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)

ret = gsc_upload(gsc);

if (XE_WA(gt, 14018094691))
if (XE_WA(tile->primary_gt, 14018094691))
xe_force_wake_put(gt_to_fw(tile->primary_gt), XE_FORCEWAKE_ALL);

if (ret)
Expand Down Expand Up @@ -437,7 +437,7 @@ int xe_gsc_init(struct xe_gsc *gsc)
return ret;
}

static void free_resources(struct drm_device *drm, void *arg)
static void free_resources(void *arg)
{
struct xe_gsc *gsc = arg;

Expand Down Expand Up @@ -501,7 +501,7 @@ int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc)
gsc->q = q;
gsc->wq = wq;

err = drmm_add_action_or_reset(&xe->drm, free_resources, gsc);
err = devm_add_action_or_reset(xe->drm.dev, free_resources, gsc);
if (err)
return err;

Expand Down
Loading

0 comments on commit 76f4618

Please sign in to comment.