Skip to content

Commit d7126c0

Browse files
committed
Merge tag 'drm-xe-next-fixes-2024-09-19' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-next
Driver Changes: - Fix macro for checking minimum GuC version (Michal Wajdeczko) - Fix CCS offset calculation for some BMG SKUs (Matthew Auld) - Fix locking on memory usage reporting via fdinfo and BO destroy (Matthew Auld) - Fix GPU page fault handler on a closed VM (Matthew Brost) - Fix overflow in oa batch buffer (José) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/lr6vhd7x5eb7gubd7utfmnwzvfqfslji4kssxyqisynzlvqjni@svgm6jot7r66
2 parents 338aae5 + 6c10ba0 commit d7126c0

File tree

7 files changed

+69
-17
lines changed

7 files changed

+69
-17
lines changed

drivers/gpu/drm/xe/xe_bb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ __xe_bb_create_job(struct xe_exec_queue *q, struct xe_bb *bb, u64 *addr)
6565
{
6666
u32 size = drm_suballoc_size(bb->bo);
6767

68-
bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
68+
if (bb->len == 0 || bb->cs[bb->len - 1] != MI_BATCH_BUFFER_END)
69+
bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
6970

7071
xe_gt_assert(q->gt, bb->len * 4 + bb_prefetch(q->gt) <= size);
7172

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,20 @@ void xe_bo_put_commit(struct llist_head *deferred)
23202320
drm_gem_object_free(&bo->ttm.base.refcount);
23212321
}
23222322

2323+
void xe_bo_put(struct xe_bo *bo)
2324+
{
2325+
might_sleep();
2326+
if (bo) {
2327+
#ifdef CONFIG_PROC_FS
2328+
if (bo->client)
2329+
might_lock(&bo->client->bos_lock);
2330+
#endif
2331+
if (bo->ggtt_node && bo->ggtt_node->ggtt)
2332+
might_lock(&bo->ggtt_node->ggtt->lock);
2333+
drm_gem_object_put(&bo->ttm.base);
2334+
}
2335+
}
2336+
23232337
/**
23242338
* xe_bo_dumb_create - Create a dumb bo as backing for a fb
23252339
* @file_priv: ...

drivers/gpu/drm/xe/xe_bo.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ static inline struct xe_bo *xe_bo_get(struct xe_bo *bo)
126126
return bo;
127127
}
128128

129-
static inline void xe_bo_put(struct xe_bo *bo)
130-
{
131-
if (bo)
132-
drm_gem_object_put(&bo->ttm.base);
133-
}
129+
void xe_bo_put(struct xe_bo *bo);
134130

135131
static inline void __xe_bo_unset_bulk_move(struct xe_bo *bo)
136132
{

drivers/gpu/drm/xe/xe_drm_client.c

Lines changed: 41 additions & 9 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);
@@ -164,12 +168,9 @@ static void bo_meminfo(struct xe_bo *bo,
164168
struct drm_memory_stats stats[TTM_NUM_MEM_TYPES])
165169
{
166170
u64 sz = bo->size;
167-
u32 mem_type;
171+
u32 mem_type = bo->ttm.resource->mem_type;
168172

169-
if (bo->placement.placement)
170-
mem_type = bo->placement.placement->mem_type;
171-
else
172-
mem_type = XE_PL_TT;
173+
xe_bo_assert_held(bo);
173174

174175
if (drm_gem_object_is_shared_for_memory_stats(&bo->ttm.base))
175176
stats[mem_type].shared += sz;
@@ -196,6 +197,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
196197
struct xe_drm_client *client;
197198
struct drm_gem_object *obj;
198199
struct xe_bo *bo;
200+
LLIST_HEAD(deferred);
199201
unsigned int id;
200202
u32 mem_type;
201203

@@ -206,7 +208,20 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
206208
idr_for_each_entry(&file->object_idr, obj, id) {
207209
struct xe_bo *bo = gem_to_xe_bo(obj);
208210

209-
bo_meminfo(bo, stats);
211+
if (dma_resv_trylock(bo->ttm.base.resv)) {
212+
bo_meminfo(bo, stats);
213+
xe_bo_unlock(bo);
214+
} else {
215+
xe_bo_get(bo);
216+
spin_unlock(&file->table_lock);
217+
218+
xe_bo_lock(bo, false);
219+
bo_meminfo(bo, stats);
220+
xe_bo_unlock(bo);
221+
222+
xe_bo_put(bo);
223+
spin_lock(&file->table_lock);
224+
}
210225
}
211226
spin_unlock(&file->table_lock);
212227

@@ -215,11 +230,28 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
215230
list_for_each_entry(bo, &client->bos_list, client_link) {
216231
if (!kref_get_unless_zero(&bo->ttm.base.refcount))
217232
continue;
218-
bo_meminfo(bo, stats);
219-
xe_bo_put(bo);
233+
234+
if (dma_resv_trylock(bo->ttm.base.resv)) {
235+
bo_meminfo(bo, stats);
236+
xe_bo_unlock(bo);
237+
} else {
238+
spin_unlock(&client->bos_lock);
239+
240+
xe_bo_lock(bo, false);
241+
bo_meminfo(bo, stats);
242+
xe_bo_unlock(bo);
243+
244+
spin_lock(&client->bos_lock);
245+
/* The bo ref will prevent this bo from being removed from the list */
246+
xe_assert(xef->xe, !list_empty(&bo->client_link));
247+
}
248+
249+
xe_bo_put_deferred(bo, &deferred);
220250
}
221251
spin_unlock(&client->bos_lock);
222252

253+
xe_bo_put_commit(&deferred);
254+
223255
for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
224256
if (!xe_mem_type_to_name[mem_type])
225257
continue;

drivers/gpu/drm/xe/xe_gt_pagefault.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
212212
* TODO: Change to read lock? Using write lock for simplicity.
213213
*/
214214
down_write(&vm->lock);
215+
216+
if (xe_vm_is_closed(vm)) {
217+
err = -ENOENT;
218+
goto unlock_vm;
219+
}
220+
215221
vma = lookup_vma(vm, pf->page_addr);
216222
if (!vma) {
217223
err = -EINVAL;

drivers/gpu/drm/xe/xe_guc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
*/
1919
#define MAKE_GUC_VER(maj, min, pat) (((maj) << 16) | ((min) << 8) | (pat))
2020
#define MAKE_GUC_VER_STRUCT(ver) MAKE_GUC_VER((ver).major, (ver).minor, (ver).patch)
21-
#define GUC_SUBMIT_VER(guc) MAKE_VER_STRUCT((guc)->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY])
22-
#define GUC_FIRMWARE_VER(guc) MAKE_VER_STRUCT((guc)->fw.versions.found[XE_UC_FW_VER_RELEASE])
21+
#define GUC_SUBMIT_VER(guc) \
22+
MAKE_GUC_VER_STRUCT((guc)->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY])
23+
#define GUC_FIRMWARE_VER(guc) \
24+
MAKE_GUC_VER_STRUCT((guc)->fw.versions.found[XE_UC_FW_VER_RELEASE])
2325

2426
struct drm_printer;
2527

drivers/gpu/drm/xe/xe_vram.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ static inline u64 get_flat_ccs_offset(struct xe_gt *gt, u64 tile_size)
182182
offset = offset_hi << 32; /* HW view bits 39:32 */
183183
offset |= offset_lo << 6; /* HW view bits 31:6 */
184184
offset *= num_enabled; /* convert to SW view */
185+
offset = round_up(offset, SZ_128K); /* SW must round up to nearest 128K */
185186

186187
/* We don't expect any holes */
187188
xe_assert_msg(xe, offset == (xe_mmio_read64_2x32(gt, GSMBASE) - ccs_size),

0 commit comments

Comments
 (0)