Skip to content

Commit f0997a0

Browse files
committed
Merge tag 'drm-xe-fixes-2026-04-30' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
API Fixes: - Add missing pad and extensions check (Jonathan) - Reject unsafe PAT indices for CPU cached memory (Jia) Driver Fixes: - Drop registration of guc_submit_wedged_fini from xe_guc_submit_wedge (Brost) - Xe3p tuning and workaround fixes (Roper, Gustavo) - USE drm mm instead of drm SA for CCS read/write (Satya) - Fix leaks and null derefs (Shuicheng) - Fix Wa_18022495364 (Tvrtko) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patch.msgid.link/afO05KvmFMn_7qcY@intel.com
2 parents b006ef5 + 662f9dd commit f0997a0

22 files changed

Lines changed: 621 additions & 105 deletions

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ xe-y += xe_bb.o \
8888
xe_irq.o \
8989
xe_late_bind_fw.o \
9090
xe_lrc.o \
91+
xe_mem_pool.o \
9192
xe_migrate.o \
9293
xe_mmio.o \
9394
xe_mmio_gem.o \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@
583583
#define DISABLE_128B_EVICTION_COMMAND_UDW REG_BIT(36 - 32)
584584
#define LSCFE_SAME_ADDRESS_ATOMICS_COALESCING_DISABLE REG_BIT(35 - 32)
585585

586-
#define ROW_CHICKEN5 XE_REG_MCR(0xe7f0)
586+
#define ROW_CHICKEN5 XE_REG_MCR(0xe7f0, XE_REG_OPTION_MASKED)
587587
#define CPSS_AWARE_DIS REG_BIT(3)
588588

589589
#define SARB_CHICKEN1 XE_REG_MCR(0xe90c)

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,8 +2322,10 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, struct xe_bo *bo,
23222322
}
23232323

23242324
/* XE_BO_FLAG_GGTTx requires XE_BO_FLAG_GGTT also be set */
2325-
if ((flags & XE_BO_FLAG_GGTT_ALL) && !(flags & XE_BO_FLAG_GGTT))
2325+
if ((flags & XE_BO_FLAG_GGTT_ALL) && !(flags & XE_BO_FLAG_GGTT)) {
2326+
xe_bo_free(bo);
23262327
return ERR_PTR(-EINVAL);
2328+
}
23272329

23282330
if (flags & (XE_BO_FLAG_VRAM_MASK | XE_BO_FLAG_STOLEN) &&
23292331
!(flags & XE_BO_FLAG_IGNORE_MIN_PAGE_SIZE) &&
@@ -2342,8 +2344,10 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, struct xe_bo *bo,
23422344
alignment = SZ_4K >> PAGE_SHIFT;
23432345
}
23442346

2345-
if (type == ttm_bo_type_device && aligned_size != size)
2347+
if (type == ttm_bo_type_device && aligned_size != size) {
2348+
xe_bo_free(bo);
23462349
return ERR_PTR(-EINVAL);
2350+
}
23472351

23482352
if (!bo) {
23492353
bo = xe_bo_alloc();

drivers/gpu/drm/xe/xe_bo_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "xe_ggtt_types.h"
1919

2020
struct xe_device;
21+
struct xe_mem_pool_node;
2122
struct xe_vm;
2223

2324
#define XE_BO_MAX_PLACEMENTS 3
@@ -88,7 +89,7 @@ struct xe_bo {
8889
bool ccs_cleared;
8990

9091
/** @bb_ccs: BB instructions of CCS read/write. Valid only for VF */
91-
struct xe_bb *bb_ccs[XE_SRIOV_VF_CCS_CTX_COUNT];
92+
struct xe_mem_pool_node *bb_ccs[XE_SRIOV_VF_CCS_CTX_COUNT];
9293

9394
/**
9495
* @cpu_caching: CPU caching mode. Currently only used for userspace

drivers/gpu/drm/xe/xe_dma_buf.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ struct dma_buf *xe_gem_prime_export(struct drm_gem_object *obj, int flags)
258258
return ERR_PTR(ret);
259259
}
260260

261+
/*
262+
* Takes ownership of @storage: on success it is transferred to the returned
263+
* drm_gem_object; on failure it is freed before returning the error.
264+
* This matches the contract of xe_bo_init_locked() which frees @storage on
265+
* its error paths, so callers need not (and must not) free @storage after
266+
* this call.
267+
*/
261268
static struct drm_gem_object *
262269
xe_dma_buf_init_obj(struct drm_device *dev, struct xe_bo *storage,
263270
struct dma_buf *dma_buf)
@@ -271,8 +278,10 @@ xe_dma_buf_init_obj(struct drm_device *dev, struct xe_bo *storage,
271278
int ret = 0;
272279

273280
dummy_obj = drm_gpuvm_resv_object_alloc(&xe->drm);
274-
if (!dummy_obj)
281+
if (!dummy_obj) {
282+
xe_bo_free(storage);
275283
return ERR_PTR(-ENOMEM);
284+
}
276285

277286
dummy_obj->resv = resv;
278287
xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, ret) {
@@ -281,6 +290,7 @@ xe_dma_buf_init_obj(struct drm_device *dev, struct xe_bo *storage,
281290
if (ret)
282291
break;
283292

293+
/* xe_bo_init_locked() frees storage on error */
284294
bo = xe_bo_init_locked(xe, storage, NULL, resv, NULL, dma_buf->size,
285295
0, /* Will require 1way or 2way for vm_bind */
286296
ttm_bo_type_sg, XE_BO_FLAG_SYSTEM, &exec);
@@ -368,12 +378,15 @@ struct drm_gem_object *xe_gem_prime_import(struct drm_device *dev,
368378
goto out_err;
369379
}
370380

371-
/* Errors here will take care of freeing the bo. */
381+
/*
382+
* xe_dma_buf_init_obj() takes ownership of bo on both success
383+
* and failure, so we must not touch bo after this call.
384+
*/
372385
obj = xe_dma_buf_init_obj(dev, bo, dma_buf);
373-
if (IS_ERR(obj))
386+
if (IS_ERR(obj)) {
387+
dma_buf_detach(dma_buf, attach);
374388
return obj;
375-
376-
389+
}
377390
get_dma_buf(dma_buf);
378391
obj->import_attach = attach;
379392
return obj;

drivers/gpu/drm/xe/xe_eu_stall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,14 @@ static int xe_eu_stall_stream_close(struct inode *inode, struct file *file)
869869
struct xe_eu_stall_data_stream *stream = file->private_data;
870870
struct xe_gt *gt = stream->gt;
871871

872-
drm_dev_put(&gt->tile->xe->drm);
873-
874872
mutex_lock(&gt->eu_stall->stream_lock);
875873
xe_eu_stall_disable_locked(stream);
876874
xe_eu_stall_data_buf_destroy(stream);
877875
xe_eu_stall_stream_free(stream);
878876
mutex_unlock(&gt->eu_stall->stream_lock);
879877

878+
drm_dev_put(&gt->tile->xe->drm);
879+
880880
return 0;
881881
}
882882

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
14051405
if (q->vm && q->hwe->hw_engine_group) {
14061406
err = xe_hw_engine_group_add_exec_queue(q->hwe->hw_engine_group, q);
14071407
if (err)
1408-
goto put_exec_queue;
1408+
goto kill_exec_queue;
14091409
}
14101410
}
14111411

@@ -1416,12 +1416,15 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
14161416
/* user id alloc must always be last in ioctl to prevent UAF */
14171417
err = xa_alloc(&xef->exec_queue.xa, &id, q, xa_limit_32b, GFP_KERNEL);
14181418
if (err)
1419-
goto kill_exec_queue;
1419+
goto del_hw_engine_group;
14201420

14211421
args->exec_queue_id = id;
14221422

14231423
return 0;
14241424

1425+
del_hw_engine_group:
1426+
if (q->vm && q->hwe && q->hwe->hw_engine_group)
1427+
xe_hw_engine_group_del_exec_queue(q->hwe->hw_engine_group, q);
14251428
kill_exec_queue:
14261429
xe_exec_queue_kill(q);
14271430
delete_queue_group:
@@ -1760,7 +1763,7 @@ void xe_exec_queue_tlb_inval_last_fence_put(struct xe_exec_queue *q,
17601763
void xe_exec_queue_tlb_inval_last_fence_put_unlocked(struct xe_exec_queue *q,
17611764
unsigned int type)
17621765
{
1763-
xe_assert(q->vm->xe, type == XE_EXEC_QUEUE_TLB_INVAL_MEDIA_GT ||
1766+
xe_assert(gt_to_xe(q->gt), type == XE_EXEC_QUEUE_TLB_INVAL_MEDIA_GT ||
17641767
type == XE_EXEC_QUEUE_TLB_INVAL_PRIMARY_GT);
17651768

17661769
dma_fence_put(q->tlb_inval[type].last_fence);

drivers/gpu/drm/xe/xe_gsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int query_compatibility_version(struct xe_gsc *gsc)
166166
&rd_offset);
167167
if (err) {
168168
xe_gt_err(gt, "HuC: invalid GSC reply for version query (err=%d)\n", err);
169-
return err;
169+
goto out_bo;
170170
}
171171

172172
compat->major = version_query_rd(xe, &bo->vmap, rd_offset, proj_major);

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,12 @@ static void guc_submit_sw_fini(struct drm_device *drm, void *arg)
259259
}
260260

261261
static void guc_submit_fini(void *arg)
262-
{
263-
struct xe_guc *guc = arg;
264-
265-
/* Forcefully kill any remaining exec queues */
266-
xe_guc_ct_stop(&guc->ct);
267-
guc_submit_reset_prepare(guc);
268-
xe_guc_softreset(guc);
269-
xe_guc_submit_stop(guc);
270-
xe_uc_fw_sanitize(&guc->fw);
271-
xe_guc_submit_pause_abort(guc);
272-
}
273-
274-
static void guc_submit_wedged_fini(void *arg)
275262
{
276263
struct xe_guc *guc = arg;
277264
struct xe_exec_queue *q;
278265
unsigned long index;
279266

267+
/* Drop any wedged queue refs */
280268
mutex_lock(&guc->submission_state.lock);
281269
xa_for_each(&guc->submission_state.exec_queue_lookup, index, q) {
282270
if (exec_queue_wedged(q)) {
@@ -286,6 +274,14 @@ static void guc_submit_wedged_fini(void *arg)
286274
}
287275
}
288276
mutex_unlock(&guc->submission_state.lock);
277+
278+
/* Forcefully kill any remaining exec queues */
279+
xe_guc_ct_stop(&guc->ct);
280+
guc_submit_reset_prepare(guc);
281+
xe_guc_softreset(guc);
282+
xe_guc_submit_stop(guc);
283+
xe_uc_fw_sanitize(&guc->fw);
284+
xe_guc_submit_pause_abort(guc);
289285
}
290286

291287
static const struct xe_exec_queue_ops guc_exec_queue_ops;
@@ -1320,10 +1316,8 @@ static void disable_scheduling_deregister(struct xe_guc *guc,
13201316
void xe_guc_submit_wedge(struct xe_guc *guc)
13211317
{
13221318
struct xe_device *xe = guc_to_xe(guc);
1323-
struct xe_gt *gt = guc_to_gt(guc);
13241319
struct xe_exec_queue *q;
13251320
unsigned long index;
1326-
int err;
13271321

13281322
xe_gt_assert(guc_to_gt(guc), guc_to_xe(guc)->wedged.mode);
13291323

@@ -1335,15 +1329,6 @@ void xe_guc_submit_wedge(struct xe_guc *guc)
13351329
return;
13361330

13371331
if (xe->wedged.mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET) {
1338-
err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
1339-
guc_submit_wedged_fini, guc);
1340-
if (err) {
1341-
xe_gt_err(gt, "Failed to register clean-up on wedged.mode=%s; "
1342-
"Although device is wedged.\n",
1343-
xe_wedged_mode_to_string(XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET));
1344-
return;
1345-
}
1346-
13471332
mutex_lock(&guc->submission_state.lock);
13481333
xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
13491334
if (xe_exec_queue_get_unless_zero(q))

drivers/gpu/drm/xe/xe_lrc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc,
12141214
if (xe_gt_WARN_ON(lrc->gt, max_len < 3))
12151215
return -ENOSPC;
12161216

1217-
*cmd++ = MI_LOAD_REGISTER_IMM | MI_LRI_NUM_REGS(1);
1217+
*cmd++ = MI_LOAD_REGISTER_IMM | MI_LRI_LRM_CS_MMIO | MI_LRI_NUM_REGS(1);
12181218
*cmd++ = CS_DEBUG_MODE2(0).addr;
12191219
*cmd++ = REG_MASKED_FIELD_ENABLE(INSTRUCTION_STATE_CACHE_INVALIDATE);
12201220

0 commit comments

Comments
 (0)