Rather than try and allocate objects as we perform our early HW probes,
defer the allocation for GGTT objects (such as the scratch page) to later
in the initialisation.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.a...@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_ggtt.c | 38 +++++++++++-----------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index b0b8ded834f0..23c7eb462b2f 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -78,19 +78,29 @@ static int ggtt_init_hw(struct i915_ggtt *ggtt)
  */
 int i915_ggtt_init_hw(struct drm_i915_private *i915)
 {
+       struct i915_ggtt *ggtt = &i915->ggtt;
+       u32 pte_flags;
        int ret;
 
+       ret = setup_scratch_page(&ggtt->vm);
+       if (ret)
+               return ret;
+
+       pte_flags = 0;
+       if (i915_gem_object_is_lmem(ggtt->vm.scratch[0]))
+               pte_flags |= PTE_LM;
+
+       ggtt->vm.scratch[0]->encode =
+               ggtt->vm.pte_encode(px_dma(ggtt->vm.scratch[0]),
+                                   I915_CACHE_NONE, 0);
+
        /*
         * Note that we use page colouring to enforce a guard page at the
         * end of the address space. This is required as the CS may prefetch
         * beyond the end of the batch buffer, across the page boundary,
         * and beyond the end of the GTT if we do not provide a guard.
         */
-       ret = ggtt_init_hw(&i915->ggtt);
-       if (ret)
-               return ret;
-
-       return 0;
+       return ggtt_init_hw(ggtt);
 }
 
 /*
@@ -803,8 +813,6 @@ static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 
size)
        struct drm_i915_private *i915 = ggtt->vm.i915;
        struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
        phys_addr_t phys_addr;
-       u32 pte_flags;
-       int ret;
 
        /* For Modern GENs the PTEs and register space are split in the BAR */
        phys_addr = pci_resource_start(pdev, 0) + pci_resource_len(pdev, 0) / 2;
@@ -825,22 +833,6 @@ static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 
size)
                return -ENOMEM;
        }
 
-       ret = setup_scratch_page(&ggtt->vm);
-       if (ret) {
-               drm_err(&i915->drm, "Scratch setup failed\n");
-               /* iounmap will also get called at remove, but meh */
-               iounmap(ggtt->gsm);
-               return ret;
-       }
-
-       pte_flags = 0;
-       if (i915_gem_object_is_lmem(ggtt->vm.scratch[0]))
-               pte_flags |= PTE_LM;
-
-       ggtt->vm.scratch[0]->encode =
-               ggtt->vm.pte_encode(px_dma(ggtt->vm.scratch[0]),
-                                   I915_CACHE_NONE, pte_flags);
-
        return 0;
 }
 
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to