[Intel-gfx] [RFC 15/31] drm/i915: Stop using I915_READ/WRITE in intel_wopcm_init_hw

Rodrigo Vivi rodrigo.vivi at intel.com
Fri Jun 14 15:52:29 UTC 2019


On Fri, Jun 14, 2019 at 04:17:15PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> More legacy mmio accessor removal. We pass in intel_gt explicitly allowing
> code to use new intel_uncore_read/write helpers.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

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

> ---
>  drivers/gpu/drm/i915/i915_gem.c    |  2 +-
>  drivers/gpu/drm/i915/intel_wopcm.c | 31 ++++++++++++++++--------------
>  drivers/gpu/drm/i915/intel_wopcm.h |  4 +++-
>  3 files changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 77d9d092b2f4..b7f88e2bd7df 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1275,7 +1275,7 @@ static int init_hw(struct intel_gt *gt)
>  		goto out;
>  	}
>  
> -	ret = intel_wopcm_init_hw(&i915->wopcm);
> +	ret = intel_wopcm_init_hw(&i915->wopcm, gt);
>  	if (ret) {
>  		DRM_ERROR("Enabling WOPCM failed (%d)\n", ret);
>  		goto out;
> diff --git a/drivers/gpu/drm/i915/intel_wopcm.c b/drivers/gpu/drm/i915/intel_wopcm.c
> index 7b4ba84b9fb8..931987e37241 100644
> --- a/drivers/gpu/drm/i915/intel_wopcm.c
> +++ b/drivers/gpu/drm/i915/intel_wopcm.c
> @@ -225,17 +225,18 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
>  	return 0;
>  }
>  
> -static inline int write_and_verify(struct drm_i915_private *dev_priv,
> -				   i915_reg_t reg, u32 val, u32 mask,
> -				   u32 locked_bit)
> +static int
> +write_and_verify(struct intel_gt *gt,
> +		 i915_reg_t reg, u32 val, u32 mask, u32 locked_bit)
>  {
> +	struct intel_uncore *uncore = gt->uncore;
>  	u32 reg_val;
>  
>  	GEM_BUG_ON(val & ~mask);
>  
> -	I915_WRITE(reg, val);
> +	intel_uncore_write(uncore, reg, val);
>  
> -	reg_val = I915_READ(reg);
> +	reg_val = intel_uncore_read(uncore, reg);
>  
>  	return (reg_val & mask) != (val | locked_bit) ? -EIO : 0;
>  }
> @@ -250,29 +251,30 @@ static inline int write_and_verify(struct drm_i915_private *dev_priv,
>   *
>   * Return: 0 on success. -EIO if registers were locked with incorrect values.
>   */
> -int intel_wopcm_init_hw(struct intel_wopcm *wopcm)
> +int intel_wopcm_init_hw(struct intel_wopcm *wopcm, struct intel_gt *gt)
>  {
> -	struct drm_i915_private *dev_priv = wopcm_to_i915(wopcm);
> +	struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
> +	struct intel_uncore *uncore = gt->uncore;
>  	u32 huc_agent;
>  	u32 mask;
>  	int err;
>  
> -	if (!USES_GUC(dev_priv))
> +	if (!USES_GUC(i915))
>  		return 0;
>  
> -	GEM_BUG_ON(!HAS_GUC(dev_priv));
> +	GEM_BUG_ON(!HAS_GUC(i915));
>  	GEM_BUG_ON(!wopcm->guc.size);
>  	GEM_BUG_ON(!wopcm->guc.base);
>  
> -	err = write_and_verify(dev_priv, GUC_WOPCM_SIZE, wopcm->guc.size,
> +	err = write_and_verify(gt, GUC_WOPCM_SIZE, wopcm->guc.size,
>  			       GUC_WOPCM_SIZE_MASK | GUC_WOPCM_SIZE_LOCKED,
>  			       GUC_WOPCM_SIZE_LOCKED);
>  	if (err)
>  		goto err_out;
>  
> -	huc_agent = USES_HUC(dev_priv) ? HUC_LOADING_AGENT_GUC : 0;
> +	huc_agent = USES_HUC(i915) ? HUC_LOADING_AGENT_GUC : 0;
>  	mask = GUC_WOPCM_OFFSET_MASK | GUC_WOPCM_OFFSET_VALID | huc_agent;
> -	err = write_and_verify(dev_priv, DMA_GUC_WOPCM_OFFSET,
> +	err = write_and_verify(gt, DMA_GUC_WOPCM_OFFSET,
>  			       wopcm->guc.base | huc_agent, mask,
>  			       GUC_WOPCM_OFFSET_VALID);
>  	if (err)
> @@ -283,8 +285,9 @@ int intel_wopcm_init_hw(struct intel_wopcm *wopcm)
>  err_out:
>  	DRM_ERROR("Failed to init WOPCM registers:\n");
>  	DRM_ERROR("DMA_GUC_WOPCM_OFFSET=%#x\n",
> -		  I915_READ(DMA_GUC_WOPCM_OFFSET));
> -	DRM_ERROR("GUC_WOPCM_SIZE=%#x\n", I915_READ(GUC_WOPCM_SIZE));
> +		  intel_uncore_read(uncore, DMA_GUC_WOPCM_OFFSET));
> +	DRM_ERROR("GUC_WOPCM_SIZE=%#x\n",
> +		  intel_uncore_read(uncore, GUC_WOPCM_SIZE));
>  
>  	return err;
>  }
> diff --git a/drivers/gpu/drm/i915/intel_wopcm.h b/drivers/gpu/drm/i915/intel_wopcm.h
> index 114401971520..56aaed4d64ff 100644
> --- a/drivers/gpu/drm/i915/intel_wopcm.h
> +++ b/drivers/gpu/drm/i915/intel_wopcm.h
> @@ -9,6 +9,8 @@
>  
>  #include <linux/types.h>
>  
> +struct intel_gt;
> +
>  /**
>   * struct intel_wopcm - Overall WOPCM info and WOPCM regions.
>   * @size: Size of overall WOPCM.
> @@ -41,6 +43,6 @@ static inline u32 intel_wopcm_guc_size(struct intel_wopcm *wopcm)
>  
>  void intel_wopcm_init_early(struct intel_wopcm *wopcm);
>  int intel_wopcm_init(struct intel_wopcm *wopcm);
> -int intel_wopcm_init_hw(struct intel_wopcm *wopcm);
> +int intel_wopcm_init_hw(struct intel_wopcm *wopcm, struct intel_gt *gt);
>  
>  #endif
> -- 
> 2.20.1
> 


More information about the Intel-gfx mailing list