Skip to content

Commit 135be1d

Browse files
committed
Merge tag 'drm-xe-fixes-2024-09-12' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
- Remove a double include (Lucas) - Fix null checks and UAF (Brost) - Fix access_ok check in user_fence_create (Nirmoy) - Fix compat IS_DISPLAY_STEP() range (Jani) - OA fix (Ashutosh) - Fixes in show_meminfo (Auld) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/ZuL-sORu54zfz1Lf@intel.com
2 parents 690e516 + 94c4aa2 commit 135be1d

File tree

8 files changed

+53
-10
lines changed

8 files changed

+53
-10
lines changed

drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
8383
#define HAS_GMD_ID(xe) GRAPHICS_VERx100(xe) >= 1270
8484

8585
/* Workarounds not handled yet */
86-
#define IS_DISPLAY_STEP(xe, first, last) ({u8 __step = (xe)->info.step.display; first <= __step && __step <= last; })
86+
#define IS_DISPLAY_STEP(xe, first, last) ({u8 __step = (xe)->info.step.display; first <= __step && __step < last; })
8787

8888
#define IS_LP(xe) (0)
8989
#define IS_GEN9_LP(xe) (0)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define OAG_OABUFFER_MEMORY_SELECT REG_BIT(0) /* 0: PPGTT, 1: GGTT */
5353

5454
#define OAG_OACONTROL XE_REG(0xdaf4)
55+
#define OAG_OACONTROL_OA_PES_DISAG_EN REG_GENMASK(27, 22)
5556
#define OAG_OACONTROL_OA_CCS_SELECT_MASK REG_GENMASK(18, 16)
5657
#define OAG_OACONTROL_OA_COUNTER_SEL_MASK REG_GENMASK(4, 2)
5758
#define OAG_OACONTROL_OA_COUNTER_ENABLE REG_BIT(0)

drivers/gpu/drm/xe/xe_drm_client.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/slab.h>
1111
#include <linux/types.h>
1212

13+
#include "xe_assert.h"
1314
#include "xe_bo.h"
1415
#include "xe_bo_types.h"
1516
#include "xe_device_types.h"
@@ -151,10 +152,13 @@ void xe_drm_client_add_bo(struct xe_drm_client *client,
151152
*/
152153
void xe_drm_client_remove_bo(struct xe_bo *bo)
153154
{
155+
struct xe_device *xe = ttm_to_xe_device(bo->ttm.bdev);
154156
struct xe_drm_client *client = bo->client;
155157

158+
xe_assert(xe, !kref_read(&bo->ttm.base.refcount));
159+
156160
spin_lock(&client->bos_lock);
157-
list_del(&bo->client_link);
161+
list_del_init(&bo->client_link);
158162
spin_unlock(&client->bos_lock);
159163

160164
xe_drm_client_put(client);
@@ -166,6 +170,8 @@ static void bo_meminfo(struct xe_bo *bo,
166170
u64 sz = bo->size;
167171
u32 mem_type;
168172

173+
xe_bo_assert_held(bo);
174+
169175
if (bo->placement.placement)
170176
mem_type = bo->placement.placement->mem_type;
171177
else
@@ -196,6 +202,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
196202
struct xe_drm_client *client;
197203
struct drm_gem_object *obj;
198204
struct xe_bo *bo;
205+
LLIST_HEAD(deferred);
199206
unsigned int id;
200207
u32 mem_type;
201208

@@ -206,7 +213,20 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
206213
idr_for_each_entry(&file->object_idr, obj, id) {
207214
struct xe_bo *bo = gem_to_xe_bo(obj);
208215

209-
bo_meminfo(bo, stats);
216+
if (dma_resv_trylock(bo->ttm.base.resv)) {
217+
bo_meminfo(bo, stats);
218+
xe_bo_unlock(bo);
219+
} else {
220+
xe_bo_get(bo);
221+
spin_unlock(&file->table_lock);
222+
223+
xe_bo_lock(bo, false);
224+
bo_meminfo(bo, stats);
225+
xe_bo_unlock(bo);
226+
227+
xe_bo_put(bo);
228+
spin_lock(&file->table_lock);
229+
}
210230
}
211231
spin_unlock(&file->table_lock);
212232

@@ -215,11 +235,28 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
215235
list_for_each_entry(bo, &client->bos_list, client_link) {
216236
if (!kref_get_unless_zero(&bo->ttm.base.refcount))
217237
continue;
218-
bo_meminfo(bo, stats);
219-
xe_bo_put(bo);
238+
239+
if (dma_resv_trylock(bo->ttm.base.resv)) {
240+
bo_meminfo(bo, stats);
241+
xe_bo_unlock(bo);
242+
} else {
243+
spin_unlock(&client->bos_lock);
244+
245+
xe_bo_lock(bo, false);
246+
bo_meminfo(bo, stats);
247+
xe_bo_unlock(bo);
248+
249+
spin_lock(&client->bos_lock);
250+
/* The bo ref will prevent this bo from being removed from the list */
251+
xe_assert(xef->xe, !list_empty(&bo->client_link));
252+
}
253+
254+
xe_bo_put_deferred(bo, &deferred);
220255
}
221256
spin_unlock(&client->bos_lock);
222257

258+
xe_bo_put_commit(&deferred);
259+
223260
for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
224261
if (!xe_mem_type_to_name[mem_type])
225262
continue;

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <drm/drm_managed.h>
1111
#include <drm/xe_drm.h>
12-
#include <generated/xe_wa_oob.h>
1312

1413
#include <generated/xe_wa_oob.h>
1514

drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int send_tlb_invalidation(struct xe_guc *guc,
182182
action[1] = seqno;
183183
ret = xe_guc_ct_send_locked(&guc->ct, action, len,
184184
G2H_LEN_DW_TLB_INVALIDATE, 1);
185-
if (!ret && fence) {
185+
if (!ret) {
186186
spin_lock_irq(&gt->tlb_invalidation.pending_lock);
187187
/*
188188
* We haven't actually published the TLB fence as per
@@ -203,7 +203,7 @@ static int send_tlb_invalidation(struct xe_guc *guc,
203203
tlb_timeout_jiffies(gt));
204204
}
205205
spin_unlock_irq(&gt->tlb_invalidation.pending_lock);
206-
} else if (ret < 0 && fence) {
206+
} else if (ret < 0) {
207207
__invalidation_fence_signal(xe, fence);
208208
}
209209
if (!ret) {

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,8 @@ static void __guc_exec_queue_process_msg_resume(struct xe_sched_msg *msg)
13751375

13761376
static void guc_exec_queue_process_msg(struct xe_sched_msg *msg)
13771377
{
1378+
struct xe_device *xe = guc_to_xe(exec_queue_to_guc(msg->private_data));
1379+
13781380
trace_xe_sched_msg_recv(msg);
13791381

13801382
switch (msg->opcode) {
@@ -1394,7 +1396,7 @@ static void guc_exec_queue_process_msg(struct xe_sched_msg *msg)
13941396
XE_WARN_ON("Unknown message type");
13951397
}
13961398

1397-
xe_pm_runtime_put(guc_to_xe(exec_queue_to_guc(msg->private_data)));
1399+
xe_pm_runtime_put(xe);
13981400
}
13991401

14001402
static const struct drm_sched_backend_ops drm_sched_ops = {

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ static void xe_oa_enable(struct xe_oa_stream *stream)
440440
val = __format_to_oactrl(format, regs->oa_ctrl_counter_select_mask) |
441441
__oa_ccs_select(stream) | OAG_OACONTROL_OA_COUNTER_ENABLE;
442442

443+
if (GRAPHICS_VER(stream->oa->xe) >= 20 &&
444+
stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG)
445+
val |= OAG_OACONTROL_OA_PES_DISAG_EN;
446+
443447
xe_mmio_write32(stream->gt, regs->oa_ctrl, val);
444448
}
445449

drivers/gpu/drm/xe/xe_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr,
5555
struct xe_user_fence *ufence;
5656
u64 __user *ptr = u64_to_user_ptr(addr);
5757

58-
if (!access_ok(ptr, sizeof(ptr)))
58+
if (!access_ok(ptr, sizeof(*ptr)))
5959
return ERR_PTR(-EFAULT);
6060

6161
ufence = kmalloc(sizeof(*ufence), GFP_KERNEL);

0 commit comments

Comments
 (0)