summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2023-05-16 17:54:07 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-20 02:33:51 +0300
commit656d29506ca89b4af1d2380ff4cab15f40ae9e19 (patch)
tree5fce3f82f03ddb6549e1e1a35aa7dd047f71a5bc
parente799485044cb3c0019a226ff3a92a532ca2a4e7e (diff)
downloadlinux-656d29506ca89b4af1d2380ff4cab15f40ae9e19.tar.xz
drm/xe: Do not take any action if our device was removed.
Unfortunately devcoredump infrastructure does not provide and interface for us to force the device removal upon the pci_remove time of our device. The devcoredump is linked at the device level, so when in use it will prevent the module removal, but it doesn't prevent the call of the pci_remove callback. This callback cannot fail anyway and we end up clearing and freeing the entire pci device. Hence, after we removed the pci device, we shouldn't allow any read or free operations to avoid segmentation fault. Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
-rw-r--r--drivers/gpu/drm/xe/xe_devcoredump.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
index 561db73a3c8c..00b9cc44c773 100644
--- a/drivers/gpu/drm/xe/xe_devcoredump.c
+++ b/drivers/gpu/drm/xe/xe_devcoredump.c
@@ -57,6 +57,10 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
struct drm_print_iterator iter;
struct timespec64 ts;
+ /* Our device is gone already... */
+ if (!data || !coredump_to_xe(coredump))
+ return -ENODEV;
+
iter.data = buffer;
iter.offset = 0;
iter.start = offset;
@@ -81,6 +85,10 @@ static void xe_devcoredump_free(void *data)
{
struct xe_devcoredump *coredump = data;
+ /* Our device is gone. Nothing to do... */
+ if (!data || !coredump_to_xe(coredump))
+ return;
+
coredump->captured = false;
drm_info(&coredump_to_xe(coredump)->drm,
"Xe device coredump has been deleted.\n");