[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230111010153.5920-1-jiasheng@iscas.ac.cn>
Date: Wed, 11 Jan 2023 09:01:53 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: jani.nikula@...ux.intel.com, joonas.lahtinen@...ux.intel.com,
rodrigo.vivi@...el.com, tvrtko.ursulin@...ux.intel.com,
airlied@...il.com, daniel@...ll.ch, ville.syrjala@...ux.intel.com,
manasi.d.navare@...el.com, stanislav.lisovskiy@...el.com,
lucas.demarchi@...el.com
Cc: intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH 2/2 v2] drm/i915: Replace alloc*workqueue with DRM helpers
Replace alloc*workqueue with DRM helpers in order to avoid memory leak
Because in `drivers/gpu/drm/i915/i915_driver.c`, if
intel_modeset_init_noirq fails, its workqueues will not be destroyed.
And drop the destroy_workqueue in intel_modeset_driver_remove_noirq to
avoid double free.
Moreover, check the return value since the workqueue may be NULL and
cause NULL pointer dereference.
Fixes: c26a058680dc ("drm/i915: Use a high priority wq for nonblocking plane updates")
Fixes: 757fffcfdffb ("drm/i915: Put all non-blocking modesets onto an ordered wq")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
Changelog:
v1 -> v2:
1. Drop the destroy_workqueue in intel_modeset_driver_remove_noirq.
---
drivers/gpu/drm/i915/display/intel_display.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 6c2686ecb62a..5cbec0af1773 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -41,6 +41,7 @@
#include <drm/drm_damage_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_fourcc.h>
+#include <drm/drm_managed.h>
#include <drm/drm_privacy_screen_consumer.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_rect.h>
@@ -8654,9 +8655,16 @@ int intel_modeset_init_noirq(struct drm_i915_private *i915)
intel_dmc_ucode_init(i915);
- i915->display.wq.modeset = alloc_ordered_workqueue("i915_modeset", 0);
- i915->display.wq.flip = alloc_workqueue("i915_flip", WQ_HIGHPRI |
- WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
+ ret = drmm_alloc_ordered_workqueue(&i915->drm,
+ i915->display.wq.modeset, "i915_modeset", 0);
+ if (ret)
+ goto cleanup_vga_client_pw_domain_dmc;
+
+ ret = drmm_alloc_workqueue(&i915->drm, i915->display.wq.flip,
+ "i915_flip", WQ_HIGHPRI | WQ_UNBOUND,
+ WQ_UNBOUND_MAX_ACTIVE);
+ if (ret)
+ goto cleanup_vga_client_pw_domain_dmc;
intel_mode_config_init(i915);
@@ -9004,9 +9012,6 @@ void intel_modeset_driver_remove_noirq(struct drm_i915_private *i915)
intel_gmbus_teardown(i915);
- destroy_workqueue(i915->display.wq.flip);
- destroy_workqueue(i915->display.wq.modeset);
-
intel_fbc_cleanup(i915);
}
--
2.25.1
Powered by blists - more mailing lists