diff mbox series

[v2] drm/i915: Move hotplug inversion logic into separate helper

Message ID 20220922164949.163985-1-gustavo.sousa@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915: Move hotplug inversion logic into separate helper | expand

Commit Message

Gustavo Sousa Sept. 22, 2022, 4:49 p.m. UTC
Use *_hpd_invert() helpers whenever possible to isolate logic specific
to hotplug inversion from common HPD setup logic to improve readability
and maintainability of the source code.

While we only define dg1_hpd_invert() here, future platforms are likely
to have different hotplug inversion needs, thus it makes sense grouping
different implementations under a common suffix.

v2: Fix coding style and prefer to use small *_hdp_invert() helpers
    instead of a generic one.

CC: Jani Nikula <jani.nikula@linux.intel.com>
CC: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
 drivers/gpu/drm/i915/i915_irq.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Jani Nikula Sept. 23, 2022, 8:20 a.m. UTC | #1
On Thu, 22 Sep 2022, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
> Use *_hpd_invert() helpers whenever possible to isolate logic specific
> to hotplug inversion from common HPD setup logic to improve readability
> and maintainability of the source code.
>
> While we only define dg1_hpd_invert() here, future platforms are likely
> to have different hotplug inversion needs, thus it makes sense grouping
> different implementations under a common suffix.
>
> v2: Fix coding style and prefer to use small *_hdp_invert() helpers
>     instead of a generic one.
>
> CC: Jani Nikula <jani.nikula@linux.intel.com>
> CC: Lucas De Marchi <lucas.demarchi@intel.com>
> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>

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

> ---
>  drivers/gpu/drm/i915/i915_irq.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index de06f293e173..87cb05b3b6ce 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -3411,17 +3411,18 @@ static u32 gen11_hotplug_enables(struct drm_i915_private *i915,
>  	}
>  }
>  
> +static void dg1_hpd_invert(struct drm_i915_private *i915)
> +{
> +	u32 val = (INVERT_DDIA_HPD |
> +		   INVERT_DDIB_HPD |
> +		   INVERT_DDIC_HPD |
> +		   INVERT_DDID_HPD);
> +	intel_uncore_rmw(&i915->uncore, SOUTH_CHICKEN1, 0, val);
> +}
> +
>  static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
>  {
> -	u32 val;
> -
> -	val = intel_uncore_read(&dev_priv->uncore, SOUTH_CHICKEN1);
> -	val |= (INVERT_DDIA_HPD |
> -		INVERT_DDIB_HPD |
> -		INVERT_DDIC_HPD |
> -		INVERT_DDID_HPD);
> -	intel_uncore_write(&dev_priv->uncore, SOUTH_CHICKEN1, val);
> -
> +	dg1_hpd_invert(dev_priv);
>  	icp_hpd_irq_setup(dev_priv);
>  }
Lucas De Marchi Sept. 24, 2022, 6:30 a.m. UTC | #2
On Fri, Sep 23, 2022 at 11:20:57AM +0300, Jani Nikula wrote:
>On Thu, 22 Sep 2022, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
>> Use *_hpd_invert() helpers whenever possible to isolate logic specific
>> to hotplug inversion from common HPD setup logic to improve readability
>> and maintainability of the source code.
>>
>> While we only define dg1_hpd_invert() here, future platforms are likely
>> to have different hotplug inversion needs, thus it makes sense grouping
>> different implementations under a common suffix.
>>
>> v2: Fix coding style and prefer to use small *_hdp_invert() helpers
>>     instead of a generic one.
>>
>> CC: Jani Nikula <jani.nikula@linux.intel.com>
>> CC: Lucas De Marchi <lucas.demarchi@intel.com>
>> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
>
>Reviewed-by: Jani Nikula <jani.nikula@intel.com>

applied, thanks

Lucas De Marchi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index de06f293e173..87cb05b3b6ce 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -3411,17 +3411,18 @@  static u32 gen11_hotplug_enables(struct drm_i915_private *i915,
 	}
 }
 
+static void dg1_hpd_invert(struct drm_i915_private *i915)
+{
+	u32 val = (INVERT_DDIA_HPD |
+		   INVERT_DDIB_HPD |
+		   INVERT_DDIC_HPD |
+		   INVERT_DDID_HPD);
+	intel_uncore_rmw(&i915->uncore, SOUTH_CHICKEN1, 0, val);
+}
+
 static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
-	u32 val;
-
-	val = intel_uncore_read(&dev_priv->uncore, SOUTH_CHICKEN1);
-	val |= (INVERT_DDIA_HPD |
-		INVERT_DDIB_HPD |
-		INVERT_DDIC_HPD |
-		INVERT_DDID_HPD);
-	intel_uncore_write(&dev_priv->uncore, SOUTH_CHICKEN1, val);
-
+	dg1_hpd_invert(dev_priv);
 	icp_hpd_irq_setup(dev_priv);
 }