drm/xe: Stop setting drvdata to NULL
authorLucas De Marchi <lucas.demarchi@intel.com>
Sat, 22 Feb 2025 00:10:44 +0000 (16:10 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 25 Feb 2025 22:29:06 +0000 (14:29 -0800)
PCI subsystem is not supposed to call the remove() function when probe
fails and doesn't need a protection for that. The only places checking
for NULL drvdata, is on 2 sysfs files and they shouldn't be needed since
the files are removed and reads on open fds just return an error.

For this protection the core driver implementation in
drivers/base/dd.c:device_unbind_cleanup() already sets it to NULL, after
the release of dev resources.

Remove the setting to NULL so it's possible to obtain the xe pointer
from callbacks like the component unbind from device_unbind_cleanup(),
i.e. after xe_pci_remove() already finished.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250222001051.3012936-5-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_device_sysfs.c
drivers/gpu/drm/xe/xe_pci.c
drivers/gpu/drm/xe/xe_survivability_mode.c

index 7375937934fae2f70c0e9c49919e88ef4a91ad95..7efbd4c52791c2a9d6e6f7b68ba3a701b4eb8b28 100644 (file)
@@ -32,9 +32,6 @@ vram_d3cold_threshold_show(struct device *dev,
        struct xe_device *xe = pdev_to_xe_device(pdev);
        int ret;
 
-       if (!xe)
-               return -EINVAL;
-
        xe_pm_runtime_get(xe);
        ret = sysfs_emit(buf, "%d\n", xe->d3cold.vram_threshold);
        xe_pm_runtime_put(xe);
@@ -51,9 +48,6 @@ vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr,
        u32 vram_d3cold_threshold;
        int ret;
 
-       if (!xe)
-               return -EINVAL;
-
        ret = kstrtou32(buff, 0, &vram_d3cold_threshold);
        if (ret)
                return ret;
index f8417f4d8ce6d99ffd31a887e876bd1f4ac175bd..078cc8d960857986249970508e73f537ab8b6c7c 100644 (file)
@@ -765,11 +765,7 @@ static int xe_info_init(struct xe_device *xe,
 
 static void xe_pci_remove(struct pci_dev *pdev)
 {
-       struct xe_device *xe;
-
-       xe = pdev_to_xe_device(pdev);
-       if (!xe) /* driver load aborted, nothing to cleanup */
-               return;
+       struct xe_device *xe = pdev_to_xe_device(pdev);
 
        if (IS_SRIOV_PF(xe))
                xe_pci_sriov_configure(pdev, 0);
@@ -779,7 +775,6 @@ static void xe_pci_remove(struct pci_dev *pdev)
 
        xe_device_remove(xe);
        xe_pm_runtime_fini(xe);
-       pci_set_drvdata(pdev, NULL);
 }
 
 /*
index 02b4eadf84079f9570e06d25a8221a37adb19bf1..04a341606a7c503f6924bd13dd7186b2b768c61c 100644 (file)
@@ -202,7 +202,6 @@ void xe_survivability_mode_remove(struct xe_device *xe)
        sysfs_remove_file(&dev->kobj, &dev_attr_survivability_mode.attr);
        xe_heci_gsc_fini(xe);
        kfree(survivability->info);
-       pci_set_drvdata(pdev, NULL);
 }
 
 /**