Commit cdeea858 authored by Andi Shyti's avatar Andi Shyti Committed by Matt Roper

drm/i915: Remove unused i915->ggtt

The reference to the GGTT from the private date is not used
anymore. Remove it.

The ggtt in the root gt will now be dynamically allocated and the
deallocation handled by the drmm_* managed allocation.
Suggested-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: default avatarSujaritha Sundaresan <sujaritha.sundaresan@intel.com>
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211219212500.61432-7-andi.shyti@linux.intel.com
parent 17190a34
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* Copyright © 2019 Intel Corporation * Copyright © 2019 Intel Corporation
*/ */
#include <drm/drm_managed.h>
#include "intel_gt_debugfs.h" #include "intel_gt_debugfs.h"
#include "gem/i915_gem_lmem.h" #include "gem/i915_gem_lmem.h"
...@@ -83,9 +85,11 @@ int intel_gt_probe_lmem(struct intel_gt *gt) ...@@ -83,9 +85,11 @@ int intel_gt_probe_lmem(struct intel_gt *gt)
return 0; return 0;
} }
void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt) int intel_gt_assign_ggtt(struct intel_gt *gt)
{ {
gt->ggtt = ggtt; gt->ggtt = drmm_kzalloc(&gt->i915->drm, sizeof(*gt->ggtt), GFP_KERNEL);
return gt->ggtt ? 0 : -ENOMEM;
} }
static const struct intel_mmio_range icl_l3bank_steering_table[] = { static const struct intel_mmio_range icl_l3bank_steering_table[] = {
......
...@@ -36,7 +36,7 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc *huc) ...@@ -36,7 +36,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_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_assign_ggtt(struct intel_gt *gt);
int intel_gt_probe_lmem(struct intel_gt *gt); int intel_gt_probe_lmem(struct intel_gt *gt);
int intel_gt_init_mmio(struct intel_gt *gt); int intel_gt_init_mmio(struct intel_gt *gt);
int __must_check intel_gt_init_hw(struct intel_gt *gt); int __must_check intel_gt_init_hw(struct intel_gt *gt);
......
...@@ -569,7 +569,9 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv) ...@@ -569,7 +569,9 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
i915_perf_init(dev_priv); i915_perf_init(dev_priv);
intel_gt_init_hw_early(to_gt(dev_priv), &dev_priv->ggtt); ret = intel_gt_assign_ggtt(to_gt(dev_priv));
if (ret)
goto err_perf;
ret = i915_ggtt_probe_hw(dev_priv); ret = i915_ggtt_probe_hw(dev_priv);
if (ret) if (ret)
......
...@@ -1008,8 +1008,6 @@ struct drm_i915_private { ...@@ -1008,8 +1008,6 @@ struct drm_i915_private {
struct drm_atomic_state *modeset_restore_state; struct drm_atomic_state *modeset_restore_state;
struct drm_modeset_acquire_ctx reset_ctx; struct drm_modeset_acquire_ctx reset_ctx;
struct i915_ggtt ggtt; /* VM representing the global address space */
struct i915_gem_mm mm; struct i915_gem_mm mm;
/* Kernel Modesetting */ /* Kernel Modesetting */
......
...@@ -1737,26 +1737,28 @@ int i915_gem_gtt_mock_selftests(void) ...@@ -1737,26 +1737,28 @@ int i915_gem_gtt_mock_selftests(void)
SUBTEST(igt_gtt_insert), SUBTEST(igt_gtt_insert),
}; };
struct drm_i915_private *i915; struct drm_i915_private *i915;
struct i915_ggtt *ggtt; struct intel_gt *gt;
int err; int err;
i915 = mock_gem_device(); i915 = mock_gem_device();
if (!i915) if (!i915)
return -ENOMEM; return -ENOMEM;
ggtt = kmalloc(sizeof(*ggtt), GFP_KERNEL); /* allocate the ggtt */
if (!ggtt) { err = intel_gt_assign_ggtt(to_gt(i915));
err = -ENOMEM; if (err)
goto out_put; goto out_put;
}
mock_init_ggtt(i915, ggtt);
err = i915_subtests(tests, ggtt); gt = to_gt(i915);
mock_init_ggtt(gt);
err = i915_subtests(tests, gt->ggtt);
mock_device_flush(i915); mock_device_flush(i915);
i915_gem_drain_freed_objects(i915); i915_gem_drain_freed_objects(i915);
mock_fini_ggtt(ggtt); mock_fini_ggtt(gt->ggtt);
kfree(ggtt);
out_put: out_put:
mock_destroy_device(i915); mock_destroy_device(i915);
return err; return err;
......
...@@ -922,26 +922,28 @@ int i915_vma_mock_selftests(void) ...@@ -922,26 +922,28 @@ int i915_vma_mock_selftests(void)
SUBTEST(igt_vma_partial), SUBTEST(igt_vma_partial),
}; };
struct drm_i915_private *i915; struct drm_i915_private *i915;
struct i915_ggtt *ggtt; struct intel_gt *gt;
int err; int err;
i915 = mock_gem_device(); i915 = mock_gem_device();
if (!i915) if (!i915)
return -ENOMEM; return -ENOMEM;
ggtt = kmalloc(sizeof(*ggtt), GFP_KERNEL); /* allocate the ggtt */
if (!ggtt) { err = intel_gt_assign_ggtt(to_gt(i915));
err = -ENOMEM; if (err)
goto out_put; goto out_put;
}
mock_init_ggtt(i915, ggtt);
err = i915_subtests(tests, ggtt); gt = to_gt(i915);
mock_init_ggtt(gt);
err = i915_subtests(tests, gt->ggtt);
mock_device_flush(i915); mock_device_flush(i915);
i915_gem_drain_freed_objects(i915); i915_gem_drain_freed_objects(i915);
mock_fini_ggtt(ggtt); mock_fini_ggtt(gt->ggtt);
kfree(ggtt);
out_put: out_put:
mock_destroy_device(i915); mock_destroy_device(i915);
return err; return err;
......
...@@ -194,8 +194,13 @@ struct drm_i915_private *mock_gem_device(void) ...@@ -194,8 +194,13 @@ struct drm_i915_private *mock_gem_device(void)
mock_init_contexts(i915); mock_init_contexts(i915);
mock_init_ggtt(i915, &i915->ggtt); /* allocate the ggtt */
to_gt(i915)->vm = i915_vm_get(&i915->ggtt.vm); ret = intel_gt_assign_ggtt(to_gt(i915));
if (ret)
goto err_unlock;
mock_init_ggtt(to_gt(i915));
to_gt(i915)->vm = i915_vm_get(&to_gt(i915)->ggtt->vm);
mkwrite_device_info(i915)->platform_engine_mask = BIT(0); mkwrite_device_info(i915)->platform_engine_mask = BIT(0);
to_gt(i915)->info.engine_mask = BIT(0); to_gt(i915)->info.engine_mask = BIT(0);
......
...@@ -104,12 +104,12 @@ static void mock_unbind_ggtt(struct i915_address_space *vm, ...@@ -104,12 +104,12 @@ static void mock_unbind_ggtt(struct i915_address_space *vm,
{ {
} }
void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt) void mock_init_ggtt(struct intel_gt *gt)
{ {
memset(ggtt, 0, sizeof(*ggtt)); struct i915_ggtt *ggtt = gt->ggtt;
ggtt->vm.gt = to_gt(i915); ggtt->vm.gt = gt;
ggtt->vm.i915 = i915; ggtt->vm.i915 = gt->i915;
ggtt->vm.is_ggtt = true; ggtt->vm.is_ggtt = true;
ggtt->gmadr = (struct resource) DEFINE_RES_MEM(0, 2048 * PAGE_SIZE); ggtt->gmadr = (struct resource) DEFINE_RES_MEM(0, 2048 * PAGE_SIZE);
...@@ -128,7 +128,6 @@ void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt) ...@@ -128,7 +128,6 @@ void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt)
ggtt->vm.vma_ops.unbind_vma = mock_unbind_ggtt; ggtt->vm.vma_ops.unbind_vma = mock_unbind_ggtt;
i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT); i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT);
to_gt(i915)->ggtt = ggtt;
} }
void mock_fini_ggtt(struct i915_ggtt *ggtt) void mock_fini_ggtt(struct i915_ggtt *ggtt)
......
...@@ -27,8 +27,9 @@ ...@@ -27,8 +27,9 @@
struct drm_i915_private; struct drm_i915_private;
struct i915_ggtt; struct i915_ggtt;
struct intel_gt;
void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt); void mock_init_ggtt(struct intel_gt *gt);
void mock_fini_ggtt(struct i915_ggtt *ggtt); void mock_fini_ggtt(struct i915_ggtt *ggtt);
struct i915_ppgtt *mock_ppgtt(struct drm_i915_private *i915, const char *name); struct i915_ppgtt *mock_ppgtt(struct drm_i915_private *i915, const char *name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment