From: Lucas De Marchi <lucas.demarchi@intel.com>
To: <intel-xe@lists.freedesktop.org>
Subject: [PATCH v2 04/11] drm/xe: Stop setting drvdata to NULL
Date: Fri, 21 Feb 2025 16:10:44 -0800 [thread overview]
Message-ID: <20250222001051.3012936-5-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20250222001051.3012936-1-lucas.demarchi@intel.com>
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>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/xe_device_sysfs.c | 6 ------
drivers/gpu/drm/xe/xe_pci.c | 7 +------
drivers/gpu/drm/xe/xe_survivability_mode.c | 1 -
3 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c
index 7375937934fae..7efbd4c52791c 100644
--- a/drivers/gpu/drm/xe/xe_device_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_device_sysfs.c
@@ -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;
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 70b697fde5b96..41ec6825b9bcc 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -770,11 +770,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);
@@ -784,7 +780,6 @@ static void xe_pci_remove(struct pci_dev *pdev)
xe_device_remove(xe);
xe_pm_runtime_fini(xe);
- pci_set_drvdata(pdev, NULL);
}
/*
diff --git a/drivers/gpu/drm/xe/xe_survivability_mode.c b/drivers/gpu/drm/xe/xe_survivability_mode.c
index 02b4eadf84079..04a341606a7c5 100644
--- a/drivers/gpu/drm/xe/xe_survivability_mode.c
+++ b/drivers/gpu/drm/xe/xe_survivability_mode.c
@@ -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);
}
/**
--
2.48.1
next prev parent reply other threads:[~2025-02-22 0:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-22 0:10 [PATCH v2 00/11] Cleanup error handling on probe, batch 2 Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 01/11] drivers: base: devres: Allow to release group on device release Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 02/11] drivers: base: devres: Fix find_group() documentation Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 03/11] drivers: base: component: Add debug message for unbind Lucas De Marchi
2025-02-22 7:19 ` Upadhyay, Tejas
2025-02-22 0:10 ` Lucas De Marchi [this message]
2025-02-22 0:10 ` [PATCH v2 05/11] drm/xe: Switch from xe to devm actions Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 06/11] drm/xe: Drop remove callback support Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 07/11] drm/xe/display: Drop xe_display_driver_remove() Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 08/11] drm/xe: Move survivability entirely to xe_pci Lucas De Marchi
2025-02-24 4:40 ` Riana Tauro
2025-02-22 0:10 ` [PATCH v2 09/11] drm/xe: Stop ignoring errors from xe_heci_gsc_init() Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 10/11] drm/xe: Rename update_device_info() after sriov Lucas De Marchi
2025-02-22 0:10 ` [PATCH v2 11/11] drm/xe: Stop ignoring errors from xe_ttm_sys_mgr_init() Lucas De Marchi
2025-02-22 0:16 ` ✓ CI.Patch_applied: success for Cleanup error handling on probe, batch 2 (rev2) Patchwork
2025-02-22 0:17 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-22 0:18 ` ✓ CI.KUnit: success " Patchwork
2025-02-22 0:34 ` ✓ CI.Build: " Patchwork
2025-02-22 0:37 ` ✓ CI.Hooks: " Patchwork
2025-02-22 0:38 ` ✓ CI.checksparse: " Patchwork
2025-02-22 1:04 ` ✓ Xe.CI.BAT: " Patchwork
2025-02-22 14:19 ` ✗ Xe.CI.Full: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250222001051.3012936-5-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox