]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/xe: Add mutex locking to devcoredump
authorJohn Harrison <John.C.Harrison@Intel.com>
Thu, 28 Nov 2024 21:08:24 +0000 (13:08 -0800)
committerJohn Harrison <John.C.Harrison@Intel.com>
Mon, 2 Dec 2024 23:50:44 +0000 (15:50 -0800)
commit906c4b306e9340f6ffd6d44904ebc86e62e63627
tree7b57ef86ac31c7c24010ec4451e9013d47f1f90c
parent90f51a7f4ec1004fc4ddfbc6d1f1068d85ef4771
drm/xe: Add mutex locking to devcoredump

There are now multiple places that can trigger a coredump. Some of
which can happen in parallel. There is already a check against
capturing multiple dumps sequentially, but without locking it doesn't
guarantee to work against concurrent dumps. And if two dumps do happen
in parallel, they can end up doing Bad Things such as one call stack
freeing the data the other call stack is still processing. Which leads
to a crashed kernel.

Further, it is possible for the DRM timeout to expire and trigger a
free of the capture while a user is still reading that capture out
through sysfs. Again leading to dodgy pointer problems.

So, add a mutext lock around the capture, read and free functions to
prevent inteference.

v2: Swap tiny scope spin_lock for larger scope mutex and fix
kernel-doc comment (review feedback from Matthew Brost)
v3: Move mutex locks to exclude worker thread and add reclaim
annotation (review feedback from Matthew Brost)
v4: Fix typo.

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241128210824.3302147-4-John.C.Harrison@Intel.com
drivers/gpu/drm/xe/xe_devcoredump.c
drivers/gpu/drm/xe/xe_devcoredump_types.h