[PATCH 3/7] WIP - random changes for fault injection bug
Luca Coelho
luciano.coelho at intel.com
Mon Sep 30 09:29:38 UTC 2024
Signed-off-by: Luca Coelho <luciano.coelho at intel.com>
---
drivers/gpu/drm/drm_mode_object.c | 4 +-
.../gpu/drm/i915/display/intel_display_core.h | 2 +
.../drm/i915/display/intel_display_driver.c | 5 ++
drivers/gpu/drm/i915/i915_driver.c | 84 +++++++++++++++----
drivers/video/fbdev/core/fbcon.c | 3 +
5 files changed, 80 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index e943205a2394..861890de3504 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -105,7 +105,9 @@ void drm_mode_object_register(struct drm_device *dev,
void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object)
{
- WARN_ON(!dev->driver->load && dev->registered && !object->free_cb);
+ WARN(!dev->driver->load && dev->registered && !object->free_cb,
+ "dev->driver->load %p dev->registered %u object->free_cb %p\n",
+ dev->driver->load, dev->registered, object->free_cb);
mutex_lock(&dev->mode_config.idr_mutex);
if (object->id) {
diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h
index 982dd9469195..71034d065960 100644
--- a/drivers/gpu/drm/i915/display/intel_display_core.h
+++ b/drivers/gpu/drm/i915/display/intel_display_core.h
@@ -284,6 +284,8 @@ struct intel_display {
/* drm device backpointer */
struct drm_device *drm;
+ bool do_drm_release;
+
/* Display functions */
struct {
/* Top level crtc-ish functions */
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
index c106fb2dd20b..765a0dabe9b8 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -116,6 +116,9 @@ static void intel_mode_config_init(struct drm_i915_private *i915)
{
struct drm_mode_config *mode_config = &i915->drm.mode_config;
+ drm_info(&i915->drm, "LUCA: calling intel_mode_config_init\n");
+ dump_stack();
+
drm_mode_config_init(&i915->drm);
INIT_LIST_HEAD(&i915->display.global.obj_list);
@@ -163,6 +166,8 @@ static void intel_mode_config_init(struct drm_i915_private *i915)
static void intel_mode_config_cleanup(struct drm_i915_private *i915)
{
+ drm_info(&i915->drm, "LUCA: calling intel_mode_config_cleanup\n");
+ dump_stack();
intel_atomic_global_obj_cleanup(i915);
drm_mode_config_cleanup(&i915->drm);
}
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index eac9fae80344..bf245819bfff 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -602,21 +602,24 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
* Perform any steps necessary to make the driver available via kernel
* internal or userspace interfaces.
*/
-static void i915_driver_register(struct drm_i915_private *dev_priv)
+static int i915_driver_register(struct drm_i915_private *dev_priv)
{
struct intel_gt *gt;
unsigned int i;
+ int ret;
i915_gem_driver_register(dev_priv);
i915_pmu_register(dev_priv);
intel_vgpu_register(dev_priv);
+ /* Injection happens here */
/* Reveal our presence to userspace */
- if (drm_dev_register(&dev_priv->drm, 0)) {
+ ret = drm_dev_register(&dev_priv->drm, 0);
+ if (ret) {
drm_err(&dev_priv->drm,
"Failed to register driver for userspace access!\n");
- return;
+ return ret;
}
i915_debugfs_register(dev_priv);
@@ -625,8 +628,11 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
/* Depends on sysfs having been initialized */
i915_perf_register(dev_priv);
- for_each_gt(gt, dev_priv, i)
+ for_each_gt(gt, dev_priv, i) {
+ drm_info(&dev_priv->drm, "LUCA: registering GT %i\n", i);
+ dump_stack();
intel_gt_driver_register(gt);
+ }
intel_pxp_debugfs_register(dev_priv->pxp);
@@ -641,6 +647,10 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
if (i915_switcheroo_register(dev_priv))
drm_err(&dev_priv->drm, "Failed to register vga switcheroo!\n");
+ else
+ dev_priv->display.do_drm_release = true;
+
+ return 0;
}
/**
@@ -652,28 +662,52 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
struct intel_gt *gt;
unsigned int i;
- i915_switcheroo_unregister(dev_priv);
+ /* if (!dev_priv->display.do_drm_release) */
+ /* goto no_drm_release; */
- intel_unregister_dsm_handler();
+ drm_info(&dev_priv->drm, "LUCA: %sunregistering switcheroo\n",
+ dev_priv->display.do_drm_release ? "" : "NOT ");
- intel_runtime_pm_disable(&dev_priv->runtime_pm);
- intel_power_domains_disable(dev_priv);
+ if (dev_priv->display.do_drm_release)
+ i915_switcheroo_unregister(dev_priv);
+
+ if (dev_priv->display.do_drm_release)
+ intel_unregister_dsm_handler();
+
+ if (dev_priv->display.do_drm_release)
+ intel_runtime_pm_disable(&dev_priv->runtime_pm);
- intel_display_driver_unregister(dev_priv);
+ if (dev_priv->display.do_drm_release)
+ intel_power_domains_disable(dev_priv);
+
+ if (dev_priv->display.do_drm_release)
+ intel_display_driver_unregister(dev_priv);
intel_pxp_fini(dev_priv);
- for_each_gt(gt, dev_priv, i)
- intel_gt_driver_unregister(gt);
+ if (dev_priv->display.do_drm_release) {
+ for_each_gt(gt, dev_priv, i) {
+ drm_info(&dev_priv->drm, "LUCA: UNREGISTERING GT %i\n", i);
+ intel_gt_driver_unregister(gt);
+ }
+ } else {
+ drm_info(&dev_priv->drm, "LUCA: NOT unregistering GT %i\n", i);
+ }
- i915_hwmon_unregister(dev_priv);
+ if (dev_priv->display.do_drm_release)
+ i915_hwmon_unregister(dev_priv);
- i915_perf_unregister(dev_priv);
- i915_pmu_unregister(dev_priv);
+ if (dev_priv->display.do_drm_release)
+ i915_perf_unregister(dev_priv);
- i915_teardown_sysfs(dev_priv);
- drm_dev_unplug(&dev_priv->drm);
+ if (dev_priv->display.do_drm_release)
+ i915_teardown_sysfs(dev_priv);
+
+ dev_priv->display.do_drm_release = false;
+ drm_dev_unplug(&dev_priv->drm);
+/* no_drm_release: */
+ i915_pmu_unregister(dev_priv);
i915_gem_driver_unregister(dev_priv);
}
@@ -813,7 +847,10 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto out_cleanup_gem;
- i915_driver_register(i915);
+ /* GT registration happens here */
+ ret = i915_driver_register(i915);
+ if (ret)
+ goto out_cleanup_gem;
enable_rpm_wakeref_asserts(&i915->runtime_pm);
@@ -824,27 +861,40 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
out_cleanup_gem:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_gem_suspend(i915);
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_gem_driver_remove(i915);
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_gem_driver_release(i915);
out_cleanup_modeset2:
/* FIXME clean up the error path */
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
intel_display_driver_remove(i915);
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
intel_irq_uninstall(i915);
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
intel_display_driver_remove_noirq(i915);
goto out_cleanup_modeset;
out_cleanup_irq:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
intel_irq_uninstall(i915);
out_cleanup_modeset:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
intel_display_driver_remove_nogem(i915);
out_cleanup_hw:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_driver_hw_remove(i915);
out_cleanup_mmio:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_driver_mmio_release(i915);
out_runtime_pm_put:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
enable_rpm_wakeref_asserts(&i915->runtime_pm);
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
i915_driver_late_release(i915);
out_pci_disable:
+ drm_info(&i915->drm, "LUCA: i915_driver_probe cleanup line %d\n", __LINE__);
pci_disable_device(pdev);
i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
return ret;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 2e093535884b..fb7956d7e527 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -119,6 +119,9 @@ static struct fb_info *fbcon_info_from_console(int console)
{
WARN_CONSOLE_UNLOCKED();
+ if (WARN(con2fb_map[console] < 0, "LUCA: FBCON %d access\n", console))
+ return NULL;
+
return fbcon_registered_fb[con2fb_map[console]];
}
--
2.45.2
More information about the Intel-gfx-trybot
mailing list