1. 20 Oct, 2021 2 commits
    • Imre Deak's avatar
      drm/i915/dp: Ensure sink rate values are always valid · 3f61ef97
      Imre Deak authored
      Atm, there are no sink rate values set for DP (vs. eDP) sinks until the
      DPCD capabilities are successfully read from the sink. During this time
      intel_dp->num_common_rates is 0 which can lead to a
      
      intel_dp->common_rates[-1]    (*)
      
      access, which is an undefined behaviour, in the following cases:
      
      - In intel_dp_sync_state(), if the encoder is enabled without a sink
        connected to the encoder's connector (BIOS enabled a monitor, but the
        user unplugged the monitor until the driver loaded).
      - In intel_dp_sync_state() if the encoder is enabled with a sink
        connected, but for some reason the DPCD read has failed.
      - In intel_dp_compute_link_config() if modesetting a connector without
        a sink connected on it.
      - In intel_dp_compute_link_config() if modesetting a connector with a
        a sink connected on it, but before probing the connector first.
      
      To avoid the (*) access in all the above cases, make sure that the sink
      rate table - and hence the common rate table - is always valid, by
      setting a default minimum sink rate when registering the connector
      before anything could use it.
      
      I also considered setting all the DP link rates by default, so that
      modesetting with higher resolution modes also succeeds in the last two
      cases above. However in case a sink is not connected that would stop
      working after the first modeset, due to the LT fallback logic. So this
      would need more work, beyond the scope of this fix.
      
      As I mentioned in the previous patch, I don't think the issue this patch
      fixes is user visible, however it is an undefined behaviour by
      definition and triggers a BUG() in CONFIG_UBSAN builds, hence CC:stable.
      
      v2: Clear the default sink rates, before initializing these for eDP.
      
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4297
      References: https://gitlab.freedesktop.org/drm/intel/-/issues/4298Suggested-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211018143417.1452632-1-imre.deak@intel.com
      3f61ef97
    • Imre Deak's avatar
      drm/i915/dp: Skip the HW readout of DPCD on disabled encoders · 4ec5ffc3
      Imre Deak authored
      Reading out the DP encoders' DPCD during booting or resume is only
      required for enabled encoders: such encoders may be modesetted during
      the initial commit and the link training this involves depends on an
      initialized DPCD. For DDI encoders reading out the DPCD is skipped, do
      the same on pre-DDI platforms.
      
      Atm, the first DPCD readout without a sink connected - which is a likely
      scneario if the encoder is disabled - leaves intel_dp->num_common_rates
      at 0, which resulted in
      
      intel_dp_sync_state()->intel_dp_max_common_rate()
      
      in a
      
      intel_dp->common_rates[-1]
      
      access. This by definition results in an undefined behaviour, though to
      my best knowledge in all HW/compiler configurations it actually results
      in accessing the array item type value preceding the array. In this
      case the preceding value happens to be intel_dp->num_common_rates,
      which is 0, so this issue - by luck - didn't cause a user visible
      problem.
      
      Nevertheless it's still an undefined behaviour and in CONFIG_UBSAN
      builds leads to a kernel BUG() (which revealed this problem for us),
      hence CC:stable.
      
      A related problem in case the encoder is enabled but the sink is not
      connected or the DPCD readout fails is fixed by the next patch.
      
      v2: Amend the commit message describing the root cause of the
          CONFIG_UBSAN BUG().
      
      Fixes: a532cde3 ("drm/i915/tc: Fix TypeC port init/resume time sanitization")
      References: https://gitlab.freedesktop.org/drm/intel/-/issues/4297Reported-and-tested-by: default avatarMat Jonczyk <mat.jonczyk@o2.pl>
      Cc: Mat Jonczyk <mat.jonczyk@o2.pl>
      Cc: José Roberto de Souza <jose.souza@intel.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211018094154.1407705-2-imre.deak@intel.com
      4ec5ffc3
  2. 19 Oct, 2021 13 commits
  3. 18 Oct, 2021 7 commits
  4. 15 Oct, 2021 2 commits
  5. 14 Oct, 2021 12 commits
  6. 12 Oct, 2021 4 commits