]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Prevent HW access during init from connector get_modes hooks
authorImre Deak <imre.deak@intel.com>
Mon, 12 Feb 2024 17:52:37 +0000 (19:52 +0200)
committerImre Deak <imre.deak@intel.com>
Tue, 13 Feb 2024 11:24:16 +0000 (13:24 +0200)
Prevent accessing the HW from the get_modes hooks of connectors deriving
the mode list from the display's EDID. drm_edid_connector_add_modes()
will return the mode list based on the EDID which was cached during a
previous detection/get_modes call.

This also fixes the NULL deref problem (10085) which was
introduced/revealed by

commit bab87ef4db9a ("drm/i915: Disable hotplug detection handlers during driver init/shutdown")

After the above change MST connectors will not change state during
driver init/shutdown; thus some of these connectors with no I2C/DDC
adapter registered for them (since the given MST port has no sink
connected) may stay then in the 'unknown' connector status. The
get_modes() hook should not try to use the I2C/DDC adapter in this state
(which would lead to the above NULL deref) which this patch ensures.

v2:
- Remove the redundant check from intel_crt_ddc_get_modes().
- Rebase on latest drm-tip.
- Add Fixes: line / related commit notes.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10085
Fixes: bab87ef4db9a ("drm/i915: Disable hotplug detection handlers during driver init/shutdown")
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240212175237.2625812-2-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_crt.c
drivers/gpu/drm/i915/display/intel_dp_mst.c
drivers/gpu/drm/i915/display/intel_dvo.c
drivers/gpu/drm/i915/display/intel_sdvo.c

index b9733a73e21d4357e5716ccc06522fb7ce84eebd..93479db0f89f63bfd14c704460d8b0bb81b8f62b 100644 (file)
@@ -933,6 +933,9 @@ static int intel_crt_get_modes(struct drm_connector *connector)
        struct i2c_adapter *ddc;
        int ret;
 
+       if (!intel_display_driver_check_access(dev_priv))
+               return drm_edid_connector_add_modes(connector);
+
        wakeref = intel_display_power_get(dev_priv,
                                          intel_encoder->power_domain);
 
index 5fa25a5a36b5532282f9e42037c089a2dd4ebeb6..5307ddd4edcf511e7cce25a337ac56a3c110f089 100644 (file)
@@ -1197,6 +1197,7 @@ static bool intel_dp_mst_initial_fastset_check(struct intel_encoder *encoder,
 static int intel_dp_mst_get_ddc_modes(struct drm_connector *connector)
 {
        struct intel_connector *intel_connector = to_intel_connector(connector);
+       struct drm_i915_private *i915 = to_i915(intel_connector->base.dev);
        struct intel_dp *intel_dp = intel_connector->mst_port;
        const struct drm_edid *drm_edid;
        int ret;
@@ -1204,6 +1205,9 @@ static int intel_dp_mst_get_ddc_modes(struct drm_connector *connector)
        if (drm_connector_is_unregistered(connector))
                return intel_connector_update_modes(connector, NULL);
 
+       if (!intel_display_driver_check_access(i915))
+               return drm_edid_connector_add_modes(connector);
+
        drm_edid = drm_dp_mst_edid_read(connector, &intel_dp->mst_mgr, intel_connector->port);
 
        ret = intel_connector_update_modes(connector, drm_edid);
index 8ca9ae4798a8940f8f79473b3030bcb345e716e9..c076da75b066ebb18a2e1f444eea07ad6b56d857 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
+#include <drm/drm_edid.h>
 
 #include "i915_drv.h"
 #include "i915_reg.h"
@@ -338,8 +339,12 @@ intel_dvo_detect(struct drm_connector *_connector, bool force)
 static int intel_dvo_get_modes(struct drm_connector *_connector)
 {
        struct intel_connector *connector = to_intel_connector(_connector);
+       struct drm_i915_private *i915 = to_i915(connector->base.dev);
        int num_modes;
 
+       if (!intel_display_driver_check_access(i915))
+               return drm_edid_connector_add_modes(&connector->base);
+
        /*
         * We should probably have an i2c driver get_modes function for those
         * devices which will have a fixed set of modes determined by the chip
index eb65c8124e60a979a62019442b23241a0b6d6f4e..3b79488357ba633188ba66a3e60e4ed0525510a0 100644 (file)
@@ -2202,12 +2202,16 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
 
 static int intel_sdvo_get_ddc_modes(struct drm_connector *connector)
 {
+       struct drm_i915_private *i915 = to_i915(connector->dev);
        int num_modes = 0;
        const struct drm_edid *drm_edid;
 
        drm_dbg_kms(connector->dev, "[CONNECTOR:%d:%s]\n",
                    connector->base.id, connector->name);
 
+       if (!intel_display_driver_check_access(i915))
+               return drm_edid_connector_add_modes(connector);
+
        /* set the bus switch and get the modes */
        drm_edid = intel_sdvo_get_edid(connector);