]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915/opregion: Cleanup opregion after errors during driver loading
authorImre Deak <imre.deak@intel.com>
Wed, 8 Mar 2023 16:25:02 +0000 (18:25 +0200)
committerImre Deak <imre.deak@intel.com>
Fri, 10 Mar 2023 16:17:07 +0000 (18:17 +0200)
Clean up the opregion state if something fails after
intel_opregion_setup() is called.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230308162503.3219200-2-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_opregion.c
drivers/gpu/drm/i915/display/intel_opregion.h
drivers/gpu/drm/i915/i915_driver.c

index bbcc2142d7df54194e4a64f52a29c6c71f90190d..b7973a05d022d741f8d3286a2e120283360d89ca 100644 (file)
@@ -1237,6 +1237,14 @@ void intel_opregion_unregister(struct drm_i915_private *i915)
                unregister_acpi_notifier(&opregion->acpi_notifier);
                opregion->acpi_notifier.notifier_call = NULL;
        }
+}
+
+void intel_opregion_cleanup(struct drm_i915_private *i915)
+{
+       struct intel_opregion *opregion = &i915->display.opregion;
+
+       if (!opregion->header)
+               return;
 
        /* just clear all opregion memory pointers now */
        memunmap(opregion->header);
index d02e6696a050e12dec491bd2674bdbda88f3cf28..181eb3e9abbf34b722d4c7ad487325a3ac350559 100644 (file)
@@ -60,6 +60,7 @@ struct intel_opregion {
 #ifdef CONFIG_ACPI
 
 int intel_opregion_setup(struct drm_i915_private *dev_priv);
+void intel_opregion_cleanup(struct drm_i915_private *i915);
 
 void intel_opregion_register(struct drm_i915_private *dev_priv);
 void intel_opregion_unregister(struct drm_i915_private *dev_priv);
index 4a2dc43791c39a43794777b8c208975dd1ecf8b7..12b5296ee74482df2b87b4f772791dfeef206dd7 100644 (file)
@@ -531,7 +531,7 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
        ret = i915_pcode_init(dev_priv);
        if (ret)
-               goto err_msi;
+               goto err_opregion;
 
        /*
         * Fill the dram structure to get the system dram info. This will be
@@ -552,6 +552,8 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
        return 0;
 
+err_opregion:
+       intel_opregion_cleanup(dev_priv);
 err_msi:
        if (pdev->msi_enabled)
                pci_disable_msi(pdev);
@@ -577,6 +579,8 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 
        i915_perf_fini(dev_priv);
 
+       intel_opregion_cleanup(dev_priv);
+
        if (pdev->msi_enabled)
                pci_disable_msi(pdev);