Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v3 3/6] drm/i915: Remove DDC pin sanitation
Date: Fri, 30 Jun 2023 19:36:34 +0300	[thread overview]
Message-ID: <871qhs3o19.fsf@intel.com> (raw)
In-Reply-To: <20230630155846.29931-4-ville.syrjala@linux.intel.com>

On Fri, 30 Jun 2023, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Stop with the VBT DDC pin sanitation, and instead just check
> that the appropriate DDC pin is still available when initializing
> a HDMI connector.
>
> The reason being that we want to start initializing ports in
> VBT order to deal with VBTs that declare child devices with
> seemingly conflicting ports. As the encoder initialization can
> fail for other reasons (at least for eDP+AUX) we can't know
> upfront which way the conflicts should be resolved.
>
> Note that the old way of sanitizing gave priority to the last
> port declared in the VBT, but now we sort of do the opposite by
> favoring the first encoder to successfully initialize. So far
> we're not aware of HDMI/DDC use cases where this would matter
> but for AUX CH (will be subject to a similar change) there are
> known cases where it matters.
>
> Also note that the old code fell back to the platform default DDC
> pin if the VBT pin was populated but invalid. That doesn't seem like
> such a great idea because the VBT might have later declared another
> port using that platform default pin, and so we might just be
> creating more DDC pin conflicts here. So lets not second guess the
> VBT and simply reject the entire HDMI encoder if the VBT DDC pin is
> invalid.
>
> v2: Pimp the commit message (Jani)
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Fingers crossed!

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_bios.c | 69 ----------------------
>  drivers/gpu/drm/i915/display/intel_hdmi.c | 72 +++++++++++++++++++----
>  2 files changed, 59 insertions(+), 82 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index 4b9bf76e137d..6aeebd3c97f9 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -2230,72 +2230,6 @@ static u8 map_ddc_pin(struct drm_i915_private *i915, u8 vbt_pin)
>  	return 0;
>  }
>  
> -static enum port get_port_by_ddc_pin(struct drm_i915_private *i915, u8 ddc_pin)
> -{
> -	enum port port;
> -
> -	if (!ddc_pin)
> -		return PORT_NONE;
> -
> -	for_each_port(port) {
> -		const struct intel_bios_encoder_data *devdata =
> -			i915->display.vbt.ports[port];
> -
> -		if (devdata && ddc_pin == devdata->child.ddc_pin)
> -			return port;
> -	}
> -
> -	return PORT_NONE;
> -}
> -
> -static void sanitize_ddc_pin(struct intel_bios_encoder_data *devdata,
> -			     enum port port)
> -{
> -	struct drm_i915_private *i915 = devdata->i915;
> -	struct child_device_config *child;
> -	u8 mapped_ddc_pin;
> -	enum port p;
> -
> -	if (!devdata->child.ddc_pin)
> -		return;
> -
> -	mapped_ddc_pin = map_ddc_pin(i915, devdata->child.ddc_pin);
> -	if (!intel_gmbus_is_valid_pin(i915, mapped_ddc_pin)) {
> -		drm_dbg_kms(&i915->drm,
> -			    "Port %c has invalid DDC pin %d, "
> -			    "sticking to defaults\n",
> -			    port_name(port), mapped_ddc_pin);
> -		devdata->child.ddc_pin = 0;
> -		return;
> -	}
> -
> -	p = get_port_by_ddc_pin(i915, devdata->child.ddc_pin);
> -	if (p == PORT_NONE)
> -		return;
> -
> -	drm_dbg_kms(&i915->drm,
> -		    "port %c trying to use the same DDC pin (0x%x) as port %c, "
> -		    "disabling port %c DVI/HDMI support\n",
> -		    port_name(port), mapped_ddc_pin,
> -		    port_name(p), port_name(p));
> -
> -	/*
> -	 * If we have multiple ports supposedly sharing the pin, then dvi/hdmi
> -	 * couldn't exist on the shared port. Otherwise they share the same ddc
> -	 * pin and system couldn't communicate with them separately.
> -	 *
> -	 * Give inverse child device order the priority, last one wins. Yes,
> -	 * there are real machines (eg. Asrock B250M-HDV) where VBT has both
> -	 * port A and port E with the same AUX ch and we must pick port E :(
> -	 */
> -	child = &i915->display.vbt.ports[p]->child;
> -
> -	child->device_type &= ~DEVICE_TYPE_TMDS_DVI_SIGNALING;
> -	child->device_type |= DEVICE_TYPE_NOT_HDMI_OUTPUT;
> -
> -	child->ddc_pin = 0;
> -}
> -
>  static enum port get_port_by_aux_ch(struct drm_i915_private *i915, u8 aux_ch)
>  {
>  	enum port port;
> @@ -2754,9 +2688,6 @@ static void parse_ddi_port(struct intel_bios_encoder_data *devdata)
>  
>  	sanitize_device_type(devdata, port);
>  
> -	if (intel_bios_encoder_supports_dvi(devdata))
> -		sanitize_ddc_pin(devdata, port);
> -
>  	if (intel_bios_encoder_supports_dp(devdata))
>  		sanitize_aux_ch(devdata, port);
>  
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index 7ac5e6c5e00d..8d1c8abfcffa 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -2880,21 +2880,12 @@ static u8 g4x_port_to_ddc_pin(struct drm_i915_private *dev_priv,
>  	return ddc_pin;
>  }
>  
> -static u8 intel_hdmi_ddc_pin(struct intel_encoder *encoder)
> +static u8 intel_hdmi_default_ddc_pin(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>  	enum port port = encoder->port;
>  	u8 ddc_pin;
>  
> -	ddc_pin = intel_bios_hdmi_ddc_pin(encoder->devdata);
> -	if (ddc_pin) {
> -		drm_dbg_kms(&dev_priv->drm,
> -			    "[ENCODER:%d:%s] Using DDC pin 0x%x (VBT)\n",
> -			    encoder->base.base.id, encoder->base.name,
> -			    ddc_pin);
> -		return ddc_pin;
> -	}
> -
>  	if (IS_ALDERLAKE_S(dev_priv))
>  		ddc_pin = adls_port_to_ddc_pin(dev_priv, port);
>  	else if (INTEL_PCH_TYPE(dev_priv) >= PCH_DG1)
> @@ -2916,10 +2907,62 @@ static u8 intel_hdmi_ddc_pin(struct intel_encoder *encoder)
>  	else
>  		ddc_pin = g4x_port_to_ddc_pin(dev_priv, port);
>  
> -	drm_dbg_kms(&dev_priv->drm,
> -		    "[ENCODER:%d:%s] Using DDC pin 0x%x (platform default)\n",
> +	return ddc_pin;
> +}
> +
> +static struct intel_encoder *
> +get_encoder_by_ddc_pin(struct intel_encoder *encoder, u8 ddc_pin)
> +{
> +	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +	struct intel_encoder *other;
> +
> +	for_each_intel_encoder(&i915->drm, other) {
> +		if (other == encoder)
> +			continue;
> +
> +		if (!intel_encoder_is_dig_port(other))
> +			continue;
> +
> +		if (enc_to_dig_port(other)->hdmi.ddc_bus == ddc_pin)
> +			return other;
> +	}
> +
> +	return NULL;
> +}
> +
> +static u8 intel_hdmi_ddc_pin(struct intel_encoder *encoder)
> +{
> +	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +	struct intel_encoder *other;
> +	const char *source;
> +	u8 ddc_pin;
> +
> +	ddc_pin = intel_bios_hdmi_ddc_pin(encoder->devdata);
> +	source = "VBT";
> +
> +	if (!ddc_pin) {
> +		ddc_pin = intel_hdmi_default_ddc_pin(encoder);
> +		source = "platform default";
> +	}
> +
> +	if (!intel_gmbus_is_valid_pin(i915, ddc_pin)) {
> +		drm_dbg_kms(&i915->drm, "[ENCODER:%d:%s] Invalid DDC pin %d\n",
> +			    encoder->base.base.id, encoder->base.name, ddc_pin);
> +		return 0;
> +	}
> +
> +	other = get_encoder_by_ddc_pin(encoder, ddc_pin);
> +	if (other) {
> +		drm_dbg_kms(&i915->drm, "[ENCODER:%d:%s] DDC pin %d already claimed by [ENCODER:%d:%s]\n",
> +			    encoder->base.base.id, encoder->base.name, ddc_pin,
> +			    other->base.base.id, other->base.name);
> +		return 0;
> +	}
> +
> +	drm_dbg_kms(&i915->drm,
> +		    "[ENCODER:%d:%s] Using DDC pin 0x%x (%s)\n",
>  		    encoder->base.base.id, encoder->base.name,
> -		    ddc_pin);
> +		    ddc_pin, source);
>  
>  	return ddc_pin;
>  }
> @@ -2990,6 +3033,9 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port,
>  		return;
>  
>  	intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(intel_encoder);
> +	if (!intel_hdmi->ddc_bus)
> +		return;
> +
>  	ddc = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
>  
>  	drm_connector_init_with_ddc(dev, connector,

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-06-30 16:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30 15:58 [Intel-gfx] [PATCH v3 0/6] drm/i915: Init DDI ports in VBT order Ville Syrjala
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 1/6] drm/i915: Initialize dig_port->aux_ch to NONE to be sure Ville Syrjala
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 2/6] drm/i915: Only populate aux_ch if really needed Ville Syrjala
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 3/6] drm/i915: Remove DDC pin sanitation Ville Syrjala
2023-06-30 16:36   ` Jani Nikula [this message]
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 4/6] drm/i915: Remove AUX CH sanitation Ville Syrjala
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 5/6] drm/i915/bios: Extract intel_bios_encoder_port() Ville Syrjala
2023-06-30 16:28   ` Jani Nikula
2023-06-30 15:58 ` [Intel-gfx] [PATCH v3 6/6] drm/i915: Try to initialize DDI/ICL+ DSI ports for every VBT child device Ville Syrjala
2023-06-30 16:38   ` Jani Nikula
2023-07-05 21:27     ` Ville Syrjälä
2023-06-30 16:56 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Init DDI ports in VBT order (rev5) Patchwork
2023-06-30 16:56 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-06-30 17:14 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2023-07-01 11:07 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Init DDI ports in VBT order (rev6) Patchwork
2023-07-01 11:07 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-07-01 11:20 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-07-01 17:12 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qhs3o19.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox