All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/8] drm/i915: Pass hpd_pin to long_pulse_detect()
Date: Thu, 5 Jul 2018 14:14:05 -0700	[thread overview]
Message-ID: <20180705211405.GM734@intel.com> (raw)
In-Reply-To: <20180705164357.28512-7-ville.syrjala@linux.intel.com>

On Thu, Jul 05, 2018 at 07:43:55PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> We're doing a pointless translation from hpd_pin to port simply for
> passing the thing to long_pulse_detect(). Let's pass the hpd_pin
> directly instead.
> 
> This removes the assumption that the hpd_pin and port always
> match. The only other place where we make that assumption anymore
> is intel_hpd_pin_default() and that's fine as it's what determines
> the relationship between the two. If we ever get hardware where
> the hpd pins are wired in more interesting ways it should be
> trivial to handle from now on.
> 
> This should also fix the IS_CNL_WITH_PORT_F() case as that mapped
> pin E back to port F and passed that to
> spt_port_hotplug2_long_detect() which would always return false
> for port F. Now that we pass in pin E directly it'll actually
> do the right thing.
> 
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Fixes: cf53902f48c3 ("drm/i915/cnl: Add HPD support for Port F.")

Thanks!

I could swear that I had a version similar to this somewhere,
but anyways this is much better...

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h      |  2 -
>  drivers/gpu/drm/i915/i915_irq.c      | 95 +++++++++++++++++-------------------
>  drivers/gpu/drm/i915/intel_hotplug.c | 31 ------------
>  3 files changed, 45 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a808bb8aa4d8..5afadc897e76 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2746,8 +2746,6 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
>  void intel_hpd_init(struct drm_i915_private *dev_priv);
>  void intel_hpd_init_work(struct drm_i915_private *dev_priv);
>  void intel_hpd_cancel_work(struct drm_i915_private *dev_priv);
> -enum port intel_hpd_pin_to_port(struct drm_i915_private *dev_priv,
> -				enum hpd_pin pin);
>  enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv,
>  				   enum port port);
>  bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 1c3ff07d9f2d..bb7c754979f8 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -1576,122 +1576,122 @@ static void gen8_gt_irq_handler(struct drm_i915_private *i915,
>  	}
>  }
>  
> -static bool gen11_port_hotplug_long_detect(enum port port, u32 val)
> +static bool gen11_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_C:
> +	switch (pin) {
> +	case HPD_PORT_C:
>  		return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC1);
> -	case PORT_D:
> +	case HPD_PORT_D:
>  		return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC2);
> -	case PORT_E:
> +	case HPD_PORT_E:
>  		return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC3);
> -	case PORT_F:
> +	case HPD_PORT_F:
>  		return val & GEN11_HOTPLUG_CTL_LONG_DETECT(PORT_TC4);
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool bxt_port_hotplug_long_detect(enum port port, u32 val)
> +static bool bxt_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_A:
> +	switch (pin) {
> +	case HPD_PORT_A:
>  		return val & PORTA_HOTPLUG_LONG_DETECT;
> -	case PORT_B:
> +	case HPD_PORT_B:
>  		return val & PORTB_HOTPLUG_LONG_DETECT;
> -	case PORT_C:
> +	case HPD_PORT_C:
>  		return val & PORTC_HOTPLUG_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool icp_ddi_port_hotplug_long_detect(enum port port, u32 val)
> +static bool icp_ddi_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_A:
> +	switch (pin) {
> +	case HPD_PORT_A:
>  		return val & ICP_DDIA_HPD_LONG_DETECT;
> -	case PORT_B:
> +	case HPD_PORT_B:
>  		return val & ICP_DDIB_HPD_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool icp_tc_port_hotplug_long_detect(enum port port, u32 val)
> +static bool icp_tc_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_C:
> +	switch (pin) {
> +	case HPD_PORT_C:
>  		return val & ICP_TC_HPD_LONG_DETECT(PORT_TC1);
> -	case PORT_D:
> +	case HPD_PORT_D:
>  		return val & ICP_TC_HPD_LONG_DETECT(PORT_TC2);
> -	case PORT_E:
> +	case HPD_PORT_E:
>  		return val & ICP_TC_HPD_LONG_DETECT(PORT_TC3);
> -	case PORT_F:
> +	case HPD_PORT_F:
>  		return val & ICP_TC_HPD_LONG_DETECT(PORT_TC4);
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool spt_port_hotplug2_long_detect(enum port port, u32 val)
> +static bool spt_port_hotplug2_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_E:
> +	switch (pin) {
> +	case HPD_PORT_E:
>  		return val & PORTE_HOTPLUG_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool spt_port_hotplug_long_detect(enum port port, u32 val)
> +static bool spt_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_A:
> +	switch (pin) {
> +	case HPD_PORT_A:
>  		return val & PORTA_HOTPLUG_LONG_DETECT;
> -	case PORT_B:
> +	case HPD_PORT_B:
>  		return val & PORTB_HOTPLUG_LONG_DETECT;
> -	case PORT_C:
> +	case HPD_PORT_C:
>  		return val & PORTC_HOTPLUG_LONG_DETECT;
> -	case PORT_D:
> +	case HPD_PORT_D:
>  		return val & PORTD_HOTPLUG_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool ilk_port_hotplug_long_detect(enum port port, u32 val)
> +static bool ilk_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_A:
> +	switch (pin) {
> +	case HPD_PORT_A:
>  		return val & DIGITAL_PORTA_HOTPLUG_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool pch_port_hotplug_long_detect(enum port port, u32 val)
> +static bool pch_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_B:
> +	switch (pin) {
> +	case HPD_PORT_B:
>  		return val & PORTB_HOTPLUG_LONG_DETECT;
> -	case PORT_C:
> +	case HPD_PORT_C:
>  		return val & PORTC_HOTPLUG_LONG_DETECT;
> -	case PORT_D:
> +	case HPD_PORT_D:
>  		return val & PORTD_HOTPLUG_LONG_DETECT;
>  	default:
>  		return false;
>  	}
>  }
>  
> -static bool i9xx_port_hotplug_long_detect(enum port port, u32 val)
> +static bool i9xx_port_hotplug_long_detect(enum hpd_pin pin, u32 val)
>  {
> -	switch (port) {
> -	case PORT_B:
> +	switch (pin) {
> +	case HPD_PORT_B:
>  		return val & PORTB_HOTPLUG_INT_LONG_PULSE;
> -	case PORT_C:
> +	case HPD_PORT_C:
>  		return val & PORTC_HOTPLUG_INT_LONG_PULSE;
> -	case PORT_D:
> +	case HPD_PORT_D:
>  		return val & PORTD_HOTPLUG_INT_LONG_PULSE;
>  	default:
>  		return false;
> @@ -1709,9 +1709,8 @@ static void intel_get_hpd_pins(struct drm_i915_private *dev_priv,
>  			       u32 *pin_mask, u32 *long_mask,
>  			       u32 hotplug_trigger, u32 dig_hotplug_reg,
>  			       const u32 hpd[HPD_NUM_PINS],
> -			       bool long_pulse_detect(enum port port, u32 val))
> +			       bool long_pulse_detect(enum hpd_pin pin, u32 val))
>  {
> -	enum port port;
>  	enum hpd_pin pin;
>  
>  	for_each_hpd_pin(pin) {
> @@ -1720,11 +1719,7 @@ static void intel_get_hpd_pins(struct drm_i915_private *dev_priv,
>  
>  		*pin_mask |= BIT(pin);
>  
> -		port = intel_hpd_pin_to_port(dev_priv, pin);
> -		if (port == PORT_NONE)
> -			continue;
> -
> -		if (long_pulse_detect(port, dig_hotplug_reg))
> +		if (long_pulse_detect(pin, dig_hotplug_reg))
>  			*long_mask |= BIT(pin);
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
> index d9d61d11dd2b..648a13c6043c 100644
> --- a/drivers/gpu/drm/i915/intel_hotplug.c
> +++ b/drivers/gpu/drm/i915/intel_hotplug.c
> @@ -76,37 +76,6 @@
>   * it will use i915_hotplug_work_func where this logic is handled.
>   */
>  
> -/**
> - * intel_hpd_port - return port hard associated with certain pin.
> - * @dev_priv: private driver data pointer
> - * @pin: the hpd pin to get associated port
> - *
> - * Return port that is associatade with @pin and PORT_NONE if no port is
> - * hard associated with that @pin.
> - */
> -enum port intel_hpd_pin_to_port(struct drm_i915_private *dev_priv,
> -				enum hpd_pin pin)
> -{
> -	switch (pin) {
> -	case HPD_PORT_A:
> -		return PORT_A;
> -	case HPD_PORT_B:
> -		return PORT_B;
> -	case HPD_PORT_C:
> -		return PORT_C;
> -	case HPD_PORT_D:
> -		return PORT_D;
> -	case HPD_PORT_E:
> -		if (IS_CNL_WITH_PORT_F(dev_priv))
> -			return PORT_F;
> -		return PORT_E;
> -	case HPD_PORT_F:
> -		return PORT_F;
> -	default:
> -		return PORT_NONE; /* no port for this pin */
> -	}
> -}
> -
>  /**
>   * intel_hpd_pin_default - return default pin associated with certain port.
>   * @dev_priv: private driver data pointer
> -- 
> 2.16.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-07-05 21:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 16:43 [PATCH 0/8] drm/i915: Hotplug cleanups and whanot Ville Syrjala
2018-07-05 16:43 ` [PATCH 1/8] drm/i915: Introduce for_each_intel_dp() Ville Syrjala
2018-07-05 21:17   ` Rodrigo Vivi
2018-07-05 16:43 ` [PATCH 2/8] drm/i915: Introduce intel_encoder_is_dig_port() Ville Syrjala
2018-07-06 17:01   ` Rodrigo Vivi
2018-07-05 16:43 ` [PATCH 3/8] drm/i915: Rewrite mst suspend/resume in terms of encoders Ville Syrjala
2018-07-05 21:29   ` Rodrigo Vivi
2018-07-06 10:42     ` Ville Syrjälä
2018-07-06 17:00       ` Rodrigo Vivi
2018-07-05 16:43 ` [PATCH 4/8] drm/i915: Nuke dev_priv->irq_port[] Ville Syrjala
2018-07-09 21:27   ` Rodrigo Vivi
2018-07-05 16:43 ` [PATCH 5/8] drm/i915: s/int i/enum hpd_pin pin/ Ville Syrjala
2018-07-09 21:28   ` Rodrigo Vivi
2018-07-05 16:43 ` [PATCH 6/8] drm/i915: Pass hpd_pin to long_pulse_detect() Ville Syrjala
2018-07-05 21:14   ` Rodrigo Vivi [this message]
2018-07-05 16:43 ` [PATCH 7/8] drm/i915: Assert that our hpd pin bitmasks don't overflow Ville Syrjala
2018-07-05 16:52   ` Chris Wilson
2018-07-05 17:51     ` Ville Syrjälä
2018-07-05 17:57       ` Chris Wilson
2018-07-05 16:43 ` [PATCH 8/8] drm/i915: Print the long_mask alongside the pin_mask Ville Syrjala
2018-07-05 18:00   ` Chris Wilson
2018-07-05 20:55 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Hotplug cleanups and whanot Patchwork
2018-07-05 20:58 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-07-05 21:14 ` ✓ Fi.CI.BAT: success " Patchwork
2018-07-06 11:05 ` ✓ 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=20180705211405.GM734@intel.com \
    --to=rodrigo.vivi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.