Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gt: Use to_gt() helper for GGTT accesses

GGTT is currently available both through i915->ggtt and gt->ggtt, and we
eventually want to get rid of the i915->ggtt one.
Use to_gt() for all i915->ggtt accesses to help with the future
refactoring.

During the probe of i915 the early intiialization of the gt
(intel_gt_init_hw_early()) is moved prior to any access to the
ggtt. This because it's in that moment we assign the ggtt to the
gt and we want to do that before using it.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Sujaritha Sundaresan <sujaritha.sundaresan@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211221195946.3180-1-andi.shyti@linux.intel.com

authored by

Michał Winiarski and committed by
Matt Roper
848915c3 816e3be7

+15 -15
+7 -7
drivers/gpu/drm/i915/gt/intel_ggtt.c
··· 84 84 * beyond the end of the batch buffer, across the page boundary, 85 85 * and beyond the end of the GTT if we do not provide a guard. 86 86 */ 87 - ret = ggtt_init_hw(&i915->ggtt); 87 + ret = ggtt_init_hw(to_gt(i915)->ggtt); 88 88 if (ret) 89 89 return ret; 90 90 ··· 705 705 { 706 706 int ret; 707 707 708 - ret = init_ggtt(&i915->ggtt); 708 + ret = init_ggtt(to_gt(i915)->ggtt); 709 709 if (ret) 710 710 return ret; 711 711 712 712 if (INTEL_PPGTT(i915) == INTEL_PPGTT_ALIASING) { 713 - ret = init_aliasing_ppgtt(&i915->ggtt); 713 + ret = init_aliasing_ppgtt(to_gt(i915)->ggtt); 714 714 if (ret) 715 - cleanup_init_ggtt(&i915->ggtt); 715 + cleanup_init_ggtt(to_gt(i915)->ggtt); 716 716 } 717 717 718 718 return 0; ··· 755 755 */ 756 756 void i915_ggtt_driver_release(struct drm_i915_private *i915) 757 757 { 758 - struct i915_ggtt *ggtt = &i915->ggtt; 758 + struct i915_ggtt *ggtt = to_gt(i915)->ggtt; 759 759 760 760 fini_aliasing_ppgtt(ggtt); 761 761 ··· 770 770 */ 771 771 void i915_ggtt_driver_late_release(struct drm_i915_private *i915) 772 772 { 773 - struct i915_ggtt *ggtt = &i915->ggtt; 773 + struct i915_ggtt *ggtt = to_gt(i915)->ggtt; 774 774 775 775 GEM_WARN_ON(kref_read(&ggtt->vm.resv_ref) != 1); 776 776 dma_resv_fini(&ggtt->vm._resv); ··· 1191 1191 { 1192 1192 int ret; 1193 1193 1194 - ret = ggtt_probe_hw(&i915->ggtt, to_gt(i915)); 1194 + ret = ggtt_probe_hw(to_gt(i915)->ggtt, to_gt(i915)); 1195 1195 if (ret) 1196 1196 return ret; 1197 1197
+3 -3
drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
··· 728 728 swizzle_y = I915_BIT_6_SWIZZLE_NONE; 729 729 } 730 730 731 - i915->ggtt.bit_6_swizzle_x = swizzle_x; 732 - i915->ggtt.bit_6_swizzle_y = swizzle_y; 731 + to_gt(i915)->ggtt->bit_6_swizzle_x = swizzle_x; 732 + to_gt(i915)->ggtt->bit_6_swizzle_y = swizzle_y; 733 733 } 734 734 735 735 /* ··· 896 896 struct intel_uncore *uncore = gt->uncore; 897 897 898 898 if (GRAPHICS_VER(i915) < 5 || 899 - i915->ggtt.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_NONE) 899 + to_gt(i915)->ggtt->bit_6_swizzle_x == I915_BIT_6_SWIZZLE_NONE) 900 900 return; 901 901 902 902 intel_uncore_rmw(uncore, DISP_ARB_CTL, 0, DISP_TILE_SURFACE_SWIZZLING);
+2 -2
drivers/gpu/drm/i915/gt/intel_region_lmem.c
··· 15 15 static int init_fake_lmem_bar(struct intel_memory_region *mem) 16 16 { 17 17 struct drm_i915_private *i915 = mem->i915; 18 - struct i915_ggtt *ggtt = &i915->ggtt; 18 + struct i915_ggtt *ggtt = to_gt(i915)->ggtt; 19 19 unsigned long n; 20 20 int ret; 21 21 ··· 131 131 if (!i915->params.fake_lmem_start) 132 132 return ERR_PTR(-ENODEV); 133 133 134 - GEM_BUG_ON(i915_ggtt_has_aperture(&i915->ggtt)); 134 + GEM_BUG_ON(i915_ggtt_has_aperture(to_gt(i915)->ggtt)); 135 135 136 136 /* Your mappable aperture belongs to me now! */ 137 137 mappable_end = pci_resource_len(pdev, 2);
+1 -1
drivers/gpu/drm/i915/gt/selftest_reset.c
··· 19 19 intel_engine_mask_t mask, 20 20 const char *msg) 21 21 { 22 - struct i915_ggtt *ggtt = &gt->i915->ggtt; 22 + struct i915_ggtt *ggtt = gt->ggtt; 23 23 const struct resource *dsm = &gt->i915->dsm; 24 24 resource_size_t num_pages, page; 25 25 struct intel_engine_cs *engine;
+2 -2
drivers/gpu/drm/i915/i915_drv.c
··· 569 569 570 570 i915_perf_init(dev_priv); 571 571 572 + intel_gt_init_hw_early(to_gt(dev_priv), &dev_priv->ggtt); 573 + 572 574 ret = i915_ggtt_probe_hw(dev_priv); 573 575 if (ret) 574 576 goto err_perf; ··· 586 584 ret = intel_memory_regions_hw_probe(dev_priv); 587 585 if (ret) 588 586 goto err_ggtt; 589 - 590 - intel_gt_init_hw_early(to_gt(dev_priv), &dev_priv->ggtt); 591 587 592 588 ret = intel_gt_probe_lmem(to_gt(dev_priv)); 593 589 if (ret)