drm/i915: Stop using I915_READ/WRITE in intel_wopcm_init_hw
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 21 Jun 2019 07:07:55 +0000 (08:07 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 21 Jun 2019 12:48:32 +0000 (13:48 +0100)
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@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190621070811.7006-17-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/intel_wopcm.c
drivers/gpu/drm/i915/intel_wopcm.h

index 1760a076113048e7c8c8cca6204317fd124ca627..8966f32fe2a2c2238b8992df61ab867b0d04b93b 100644 (file)
@@ -1272,7 +1272,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;
index 7b4ba84b9fb8cd31a12c003bccfb9bd7b160ae79..931987e37241b9f314e4a2b93185750f93e77d76 100644 (file)
@@ -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;
 }
index 1144019715209ff664174f99bfc1861b2474ea25..56aaed4d64ff3a22b1b8ca1ef32ffdbae3e10117 100644 (file)
@@ -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