drm/i915: Store backpointer to GT in uncore
authorMichał Winiarski <michal.winiarski@intel.com>
Tue, 14 Dec 2021 19:33:31 +0000 (21:33 +0200)
committerMatt Roper <matthew.d.roper@intel.com>
Sat, 18 Dec 2021 05:47:15 +0000 (21:47 -0800)
We now support a per-gt uncore, yet we're not able to infer which GT
we're operating upon.  Let's store a backpointer for now.

At this point the early initialization of the gt needs to be
broken in two parts where the first is needed to assign to the gt
the i915 private data pointer and the uncore. A temporary
function has been made and the two parts are
__intel_gt_init_early() and intel_gt_init_early(). This split
will be fixed in the future with the multitile patch.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211214193346.21231-2-andi.shyti@linux.intel.com
drivers/gpu/drm/i915/gt/intel_gt.c
drivers/gpu/drm/i915/gt/intel_gt.h
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/intel_uncore.c
drivers/gpu/drm/i915/intel_uncore.h
drivers/gpu/drm/i915/selftests/mock_gem_device.c
drivers/gpu/drm/i915/selftests/mock_uncore.c

index 1cb1948..446e56c 100644 (file)
 #include "shmem_utils.h"
 #include "pxp/intel_pxp.h"
 
-void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
+void __intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
 {
-       gt->i915 = i915;
-       gt->uncore = &i915->uncore;
-
        spin_lock_init(&gt->irq_lock);
 
        INIT_LIST_HEAD(&gt->closed_vma);
@@ -46,6 +43,12 @@ void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
        intel_rps_init_early(&gt->rps);
 }
 
+void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
+{
+       gt->i915 = i915;
+       gt->uncore = &i915->uncore;
+}
+
 int intel_gt_probe_lmem(struct intel_gt *gt)
 {
        struct drm_i915_private *i915 = gt->i915;
index 74e7718..3ace129 100644 (file)
@@ -35,6 +35,7 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
 }
 
 void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
+void __intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
 void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
 int intel_gt_probe_lmem(struct intel_gt *gt);
 int intel_gt_init_mmio(struct intel_gt *gt);
index 6ad1555..955da6c 100644 (file)
@@ -312,8 +312,9 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
        intel_device_info_subplatform_init(dev_priv);
        intel_step_init(dev_priv);
 
+       intel_gt_init_early(&dev_priv->gt, dev_priv);
        intel_uncore_mmio_debug_init_early(&dev_priv->mmio_debug);
-       intel_uncore_init_early(&dev_priv->uncore, dev_priv);
+       intel_uncore_init_early(&dev_priv->uncore, &dev_priv->gt);
 
        spin_lock_init(&dev_priv->irq_lock);
        spin_lock_init(&dev_priv->gpu_error.lock);
@@ -344,7 +345,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 
        intel_wopcm_init_early(&dev_priv->wopcm);
 
-       intel_gt_init_early(&dev_priv->gt, dev_priv);
+       __intel_gt_init_early(&dev_priv->gt, dev_priv);
 
        i915_gem_init_early(dev_priv);
 
index a308e86..df33143 100644 (file)
@@ -2061,12 +2061,13 @@ void intel_uncore_cleanup_mmio(struct intel_uncore *uncore)
 }
 
 void intel_uncore_init_early(struct intel_uncore *uncore,
-                            struct drm_i915_private *i915)
+                            struct intel_gt *gt)
 {
        spin_lock_init(&uncore->lock);
-       uncore->i915 = i915;
-       uncore->rpm = &i915->runtime_pm;
-       uncore->debug = &i915->mmio_debug;
+       uncore->i915 = gt->i915;
+       uncore->gt = gt;
+       uncore->rpm = &gt->i915->runtime_pm;
+       uncore->debug = &gt->i915->mmio_debug;
 }
 
 static void uncore_raw_init(struct intel_uncore *uncore)
index d1d17b0..210fe2a 100644 (file)
@@ -129,6 +129,7 @@ struct intel_uncore {
        void __iomem *regs;
 
        struct drm_i915_private *i915;
+       struct intel_gt *gt;
        struct intel_runtime_pm *rpm;
 
        spinlock_t lock; /** lock is also taken in irq contexts. */
@@ -217,7 +218,7 @@ u32 intel_uncore_read_with_mcr_steering(struct intel_uncore *uncore,
 void
 intel_uncore_mmio_debug_init_early(struct intel_uncore_mmio_debug *mmio_debug);
 void intel_uncore_init_early(struct intel_uncore *uncore,
-                            struct drm_i915_private *i915);
+                            struct intel_gt *gt);
 int intel_uncore_setup_mmio(struct intel_uncore *uncore);
 int intel_uncore_init_mmio(struct intel_uncore *uncore);
 void intel_uncore_prune_engine_fw_domains(struct intel_uncore *uncore,
index d0e2e61..eeb632a 100644 (file)
@@ -175,12 +175,12 @@ struct drm_i915_private *mock_gem_device(void)
        mkwrite_device_info(i915)->memory_regions = REGION_SMEM;
        intel_memory_regions_hw_probe(i915);
 
-       mock_uncore_init(&i915->uncore, i915);
-
        spin_lock_init(&i915->gpu_error.lock);
 
        i915_gem_init__mm(i915);
        intel_gt_init_early(&i915->gt, i915);
+       __intel_gt_init_early(&i915->gt, i915);
+       mock_uncore_init(&i915->uncore, i915);
        atomic_inc(&i915->gt.wakeref.count); /* disable; no hw support */
        i915->gt.awake = -ENODEV;
 
index ca57e40..b3790ef 100644 (file)
@@ -42,7 +42,7 @@ __nop_read(64)
 void mock_uncore_init(struct intel_uncore *uncore,
                      struct drm_i915_private *i915)
 {
-       intel_uncore_init_early(uncore, i915);
+       intel_uncore_init_early(uncore, &i915->gt);
 
        ASSIGN_RAW_WRITE_MMIO_VFUNCS(uncore, nop);
        ASSIGN_RAW_READ_MMIO_VFUNCS(uncore, nop);