drm/i915/display: cleanup intel_bw_state on i915 module removal
authorPankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Mon, 9 Dec 2019 14:39:02 +0000 (20:09 +0530)
committerUma Shankar <uma.shankar@intel.com>
Tue, 24 Dec 2019 09:31:50 +0000 (15:01 +0530)
intel_bw_state allocated memory is not getting freed even after
module removal.

kmemleak reported backtrace:

    [<0000000079019739>] kmemdup+0x17/0x40
    [<00000000d58c1b9d>] intel_bw_duplicate_state+0x1b/0x40 [i915]
    [<000000007423ed0c>] drm_atomic_get_private_obj_state+0xca/0x140
    [<00000000100e3533>] intel_bw_atomic_check+0x133/0x350 [i915]
    [<00000000126d0e0c>] intel_atomic_check+0x1ab7/0x20d0 [i915]
    [<00000000d5dfc004>] drm_atomic_check_only+0x563/0x810
    [<00000000c9379611>] drm_atomic_commit+0xe/0x50
    [<00000000ec82b765>] drm_atomic_helper_disable_all+0x133/0x160
    [<000000003c44760c>] drm_atomic_helper_shutdown+0x65/0xc0
    [<00000000414e3e5c>] i915_driver_remove+0xcb/0x130 [i915]
    [<00000000f8544c2a>] i915_pci_remove+0x19/0x40 [i915]
    [<000000002dcbd148>] pci_device_remove+0x36/0xb0
    [<000000003c8c6b0a>] device_release_driver_internal+0xe0/0x1c0
    [<00000000580e9566>] unbind_store+0xc3/0x120
    [<00000000869d0df5>] kernfs_fop_write+0x104/0x190
    [<000000004dc1a355>] vfs_write+0xb9/0x1d0

Call the drm_atomic_private_obj_fini(), which inturn calls the
intel_bw_destroy_state() to make sure the intel_bw_state memory is
freed properly.

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191209143921.9240-1-pankaj.laxminarayan.bharadiya@intel.com
drivers/gpu/drm/i915/display/intel_bw.c
drivers/gpu/drm/i915/display/intel_bw.h
drivers/gpu/drm/i915/display/intel_display.c

index dcb66a33be9b291827416c1fc576201c6cf2c640..b228671d5a5d3d5fb89bc24d08f496001c825748 100644 (file)
@@ -486,3 +486,8 @@ int intel_bw_init(struct drm_i915_private *dev_priv)
 
        return 0;
 }
+
+void intel_bw_cleanup(struct drm_i915_private *dev_priv)
+{
+       drm_atomic_private_obj_fini(&dev_priv->bw_obj);
+}
index 9db10af012f4b039363ca7aa5404277dbeca303b..20b9ad241802d7869ed259d0c32e77fb506a3739 100644 (file)
@@ -25,6 +25,7 @@ struct intel_bw_state {
 
 void intel_bw_init_hw(struct drm_i915_private *dev_priv);
 int intel_bw_init(struct drm_i915_private *dev_priv);
+void intel_bw_cleanup(struct drm_i915_private *dev_priv);
 int intel_bw_atomic_check(struct intel_atomic_state *state);
 void intel_bw_crtc_update(struct intel_bw_state *bw_state,
                          const struct intel_crtc_state *crtc_state);
index 6683377d0992e7879388ae06cc196c6aad545745..0a8221ede8759321ae4136dab8e5a4bafd79967c 100644 (file)
@@ -18202,6 +18202,8 @@ void intel_modeset_driver_remove(struct drm_i915_private *i915)
 
        intel_gmbus_teardown(i915);
 
+       intel_bw_cleanup(i915);
+
        destroy_workqueue(i915->flip_wq);
        destroy_workqueue(i915->modeset_wq);