Skip to content

Commit 9bd7ff2

Browse files
matt-auldrodrigovivi
authored andcommitted
drm/xe/client: fix deadlock in show_meminfo()
There is a real deadlock as well as sleeping in atomic() bug in here, if the bo put happens to be the last ref, since bo destruction wants to grab the same spinlock and sleeping locks. Fix that by dropping the ref using xe_bo_put_deferred(), and moving the final commit outside of the lock. Dropping the lock around the put is tricky since the bo can go out of scope and delete itself from the list, making it difficult to navigate to the next list entry. Fixes: 0845233 ("drm/xe: Implement fdinfo memory stats printing") Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2727 Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Cc: Tejas Upadhyay <tejas.upadhyay@intel.com> Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com> Cc: <stable@vger.kernel.org> # v6.8+ Reviewed-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240911155527.178910-5-matthew.auld@intel.com (cherry picked from commit 0083b8e) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent a262cc8 commit 9bd7ff2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpu/drm/xe/xe_drm_client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
196196
struct xe_drm_client *client;
197197
struct drm_gem_object *obj;
198198
struct xe_bo *bo;
199+
LLIST_HEAD(deferred);
199200
unsigned int id;
200201
u32 mem_type;
201202

@@ -215,11 +216,14 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
215216
list_for_each_entry(bo, &client->bos_list, client_link) {
216217
if (!kref_get_unless_zero(&bo->ttm.base.refcount))
217218
continue;
219+
218220
bo_meminfo(bo, stats);
219-
xe_bo_put(bo);
221+
xe_bo_put_deferred(bo, &deferred);
220222
}
221223
spin_unlock(&client->bos_lock);
222224

225+
xe_bo_put_commit(&deferred);
226+
223227
for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
224228
if (!xe_mem_type_to_name[mem_type])
225229
continue;

0 commit comments

Comments
 (0)