Re: [PATCH 53/89] drm/i915/skl: Gen9 Forcewake

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Damien Lespiau <damien.lespiau@xxxxxxxxx> writes:

> From: Zhe Wang <zhe1.wang@xxxxxxxxx>
>
> Implement common forcewake functions shared by Gen9 features.
>
> Signed-off-by: Zhe Wang <zhe1.wang@xxxxxxxxx>
> Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/i915_drv.h     |   5 +-
>  drivers/gpu/drm/i915/i915_reg.h     |   6 ++
>  drivers/gpu/drm/i915/intel_uncore.c | 175 +++++++++++++++++++++++++++++++++++-
>  3 files changed, 184 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 9b0e398..84defa4 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -535,6 +535,7 @@ struct intel_uncore {
>  
>  	unsigned fw_rendercount;
>  	unsigned fw_mediacount;
> +	unsigned fw_blittercount;
>  
>  	struct timer_list force_wake_timer;
>  };
> @@ -2950,7 +2951,9 @@ int vlv_freq_opcode(struct drm_i915_private *dev_priv, int val);
>  
>  #define FORCEWAKE_RENDER	(1 << 0)
>  #define FORCEWAKE_MEDIA		(1 << 1)
> -#define FORCEWAKE_ALL		(FORCEWAKE_RENDER | FORCEWAKE_MEDIA)
> +#define FORCEWAKE_BLITTER	(1 << 2)
> +#define FORCEWAKE_ALL		(FORCEWAKE_RENDER | FORCEWAKE_MEDIA | \
> +					FORCEWAKE_BLITTER)
>  
>  
>  #define I915_READ8(reg)		dev_priv->uncore.funcs.mmio_readb(dev_priv, (reg), true)
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 414c2a5..417075d 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -5738,6 +5738,12 @@ enum punit_power_well {
>  #define   VLV_GTLC_PW_MEDIA_STATUS_MASK		(1 << 5)
>  #define   VLV_GTLC_PW_RENDER_STATUS_MASK	(1 << 7)
>  #define  FORCEWAKE_MT				0xa188 /* multi-threaded */
> +#define  FORCEWAKE_MEDIA_GEN9			0xa270
> +#define  FORCEWAKE_RENDER_GEN9			0xa278
> +#define  FORCEWAKE_BLITTER_GEN9			0xa188
> +#define  FORCEWAKE_ACK_MEDIA_GEN9		0x0D88
> +#define  FORCEWAKE_ACK_RENDER_GEN9		0x0D84
> +#define  FORCEWAKE_ACK_BLITTER_GEN9		0x130044
>  #define   FORCEWAKE_KERNEL			0x1
>  #define   FORCEWAKE_USER			0x2
>  #define  FORCEWAKE_MT_ACK			0x130040
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 3b27fb0..7b7fc9e 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -299,6 +299,154 @@ static void vlv_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)
>  	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
>  }
>  
> +static void __gen9_gt_force_wake_mt_reset(struct drm_i915_private *dev_priv)
> +{
> +	__raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
> +			_MASKED_BIT_DISABLE(0xffff));
> +
> +	__raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
> +			_MASKED_BIT_DISABLE(0xffff));
> +
> +	__raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
> +			_MASKED_BIT_DISABLE(0xffff));
> +}
> +
> +static void __gen9_force_wake_get(struct drm_i915_private *dev_priv,
> +						int fw_engine)
> +{
> +	/* Check for Render Engine */
> +	if (FORCEWAKE_RENDER & fw_engine) {
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_RENDER_GEN9) &
> +						FORCEWAKE_KERNEL) == 0,
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: Render forcewake old ack to clear.\n");
> +
> +		__raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
> +				   _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
> +
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_RENDER_GEN9) &
> +						FORCEWAKE_KERNEL),
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: waiting for Render to ack.\n");
> +	}
> +
> +	/* Check for Media Engine */
> +	if (FORCEWAKE_MEDIA & fw_engine) {
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_MEDIA_GEN9) &
> +						FORCEWAKE_KERNEL) == 0,
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: Media forcewake old ack to clear.\n");
> +
> +		__raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
> +				   _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
> +
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_MEDIA_GEN9) &
> +						FORCEWAKE_KERNEL),
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: waiting for Media to ack.\n");
> +	}
> +
> +	/* Check for Blitter Engine */
> +	if (FORCEWAKE_BLITTER & fw_engine) {
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_BLITTER_GEN9) &
> +						FORCEWAKE_KERNEL) == 0,
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: Blitter forcewake old ack to clear.\n");
> +
> +		__raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
> +				   _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));
> +
> +		if (wait_for_atomic((__raw_i915_read32(dev_priv,
> +						FORCEWAKE_ACK_BLITTER_GEN9) &
> +						FORCEWAKE_KERNEL),
> +					FORCEWAKE_ACK_TIMEOUT_MS))
> +			DRM_ERROR("Timed out: waiting for Blitter to ack.\n");
> +	}
> +}
> +
> +static void __gen9_force_wake_put(struct drm_i915_private *dev_priv,
> +					int fw_engine)
> +{
> +	/* Check for Render Engine */
> +	if (FORCEWAKE_RENDER & fw_engine)
> +		__raw_i915_write32(dev_priv, FORCEWAKE_RENDER_GEN9,
> +				_MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
> +
> +	/* Check for Media Engine */
> +	if (FORCEWAKE_MEDIA & fw_engine)
> +		__raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_GEN9,
> +				_MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
> +
> +	/* Check for Blitter Engine */
> +	if (FORCEWAKE_BLITTER & fw_engine)
> +		__raw_i915_write32(dev_priv, FORCEWAKE_BLITTER_GEN9,
> +				_MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));
> +}
> +
> +void gen9_force_wake_get(struct drm_i915_private *dev_priv,
> +						int fw_engine)

static missing

> +{
> +	unsigned long irqflags;
> +
> +	spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
> +
> +	if (FORCEWAKE_RENDER & fw_engine) {
> +		if (dev_priv->uncore.fw_rendercount++ == 0)
> +			dev_priv->uncore.funcs.force_wake_get(dev_priv,
> +							FORCEWAKE_RENDER);
> +	}
> +
> +	if (FORCEWAKE_MEDIA & fw_engine) {
> +		if (dev_priv->uncore.fw_mediacount++ == 0)
> +			dev_priv->uncore.funcs.force_wake_get(dev_priv,
> +							FORCEWAKE_MEDIA);
> +	}
> +
> +	if (FORCEWAKE_BLITTER & fw_engine) {
> +		if (dev_priv->uncore.fw_blittercount++ == 0)
> +			dev_priv->uncore.funcs.force_wake_get(dev_priv,
> +							FORCEWAKE_BLITTER);
> +	}
> +
> +	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
> +}
> +
> +void gen9_force_wake_put(struct drm_i915_private *dev_priv,
> +						int fw_engine)

static missing

above statics added it is:

Reviewed-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxx>

> +{
> +	unsigned long irqflags;
> +
> +	spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
> +
> +	if (FORCEWAKE_RENDER & fw_engine) {
> +		WARN_ON(dev_priv->uncore.fw_rendercount == 0);
> +		if (--dev_priv->uncore.fw_rendercount == 0)
> +			dev_priv->uncore.funcs.force_wake_put(dev_priv,
> +							FORCEWAKE_RENDER);
> +	}
> +
> +	if (FORCEWAKE_MEDIA & fw_engine) {
> +		WARN_ON(dev_priv->uncore.fw_mediacount == 0);
> +		if (--dev_priv->uncore.fw_mediacount == 0)
> +			dev_priv->uncore.funcs.force_wake_put(dev_priv,
> +							FORCEWAKE_MEDIA);
> +	}
> +
> +	if (FORCEWAKE_BLITTER & fw_engine) {
> +		WARN_ON(dev_priv->uncore.fw_blittercount == 0);
> +		if (--dev_priv->uncore.fw_blittercount == 0)
> +			dev_priv->uncore.funcs.force_wake_put(dev_priv,
> +							FORCEWAKE_BLITTER);
> +	}
> +
> +	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
> +}
> +
>  static void gen6_force_wake_timer(unsigned long arg)
>  {
>  	struct drm_i915_private *dev_priv = (void *)arg;
> @@ -337,6 +485,9 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
>  	if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev) || IS_BROADWELL(dev))
>  		__gen7_gt_force_wake_mt_reset(dev_priv);
>  
> +	if (IS_GEN9(dev))
> +		__gen9_gt_force_wake_mt_reset(dev_priv);
> +
>  	if (restore) { /* If reset with a user forcewake, try to restore */
>  		unsigned fw = 0;
>  
> @@ -346,6 +497,15 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
>  
>  			if (dev_priv->uncore.fw_mediacount)
>  				fw |= FORCEWAKE_MEDIA;
> +		} else if (IS_GEN9(dev)) {
> +			if (dev_priv->uncore.fw_rendercount)
> +				fw |= FORCEWAKE_RENDER;
> +
> +			if (dev_priv->uncore.fw_mediacount)
> +				fw |= FORCEWAKE_MEDIA;
> +
> +			if (dev_priv->uncore.fw_blittercount)
> +				fw |= FORCEWAKE_BLITTER;
>  		} else {
>  			if (dev_priv->uncore.forcewake_count)
>  				fw = FORCEWAKE_ALL;
> @@ -410,6 +570,10 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine)
>  
>  	intel_runtime_pm_get(dev_priv);
>  
> +	/* Redirect to Gen9 specific routine */
> +	if (IS_GEN9(dev_priv->dev))
> +		return gen9_force_wake_get(dev_priv, fw_engine);
> +
>  	/* Redirect to VLV specific routine */
>  	if (IS_VALLEYVIEW(dev_priv->dev))
>  		return vlv_force_wake_get(dev_priv, fw_engine);
> @@ -431,6 +595,12 @@ void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)
>  	if (!dev_priv->uncore.funcs.force_wake_put)
>  		return;
>  
> +	/* Redirect to Gen9 specific routine */
> +	if (IS_GEN9(dev_priv->dev)) {
> +		gen9_force_wake_put(dev_priv, fw_engine);
> +		goto out;
> +	}
> +
>  	/* Redirect to VLV specific routine */
>  	if (IS_VALLEYVIEW(dev_priv->dev)) {
>  		vlv_force_wake_put(dev_priv, fw_engine);
> @@ -835,7 +1005,10 @@ void intel_uncore_init(struct drm_device *dev)
>  
>  	intel_uncore_early_sanitize(dev, false);
>  
> -	if (IS_VALLEYVIEW(dev)) {
> +	if (IS_GEN9(dev)) {
> +		dev_priv->uncore.funcs.force_wake_get = __gen9_force_wake_get;
> +		dev_priv->uncore.funcs.force_wake_put = __gen9_force_wake_put;
> +	} else if (IS_VALLEYVIEW(dev)) {
>  		dev_priv->uncore.funcs.force_wake_get = __vlv_force_wake_get;
>  		dev_priv->uncore.funcs.force_wake_put = __vlv_force_wake_put;
>  	} else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
> -- 
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux