Commit 763c1e63 authored by Tvrtko Ursulin's avatar Tvrtko Ursulin

drm/i915: Store intel_gt backpointer in vm

This will come useful in the following patch.

v2:
 * Handle mock ggtt.
Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190621070811.7006-21-tvrtko.ursulin@linux.intel.com
parent 759e4a74
...@@ -1603,9 +1603,11 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt) ...@@ -1603,9 +1603,11 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt)
return -ENOMEM; return -ENOMEM;
} }
static void ppgtt_init(struct drm_i915_private *i915, static void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt)
struct i915_ppgtt *ppgtt)
{ {
struct drm_i915_private *i915 = gt->i915;
ppgtt->vm.gt = gt;
ppgtt->vm.i915 = i915; ppgtt->vm.i915 = i915;
ppgtt->vm.dma = &i915->drm.pdev->dev; ppgtt->vm.dma = &i915->drm.pdev->dev;
ppgtt->vm.total = BIT_ULL(INTEL_INFO(i915)->ppgtt_size); ppgtt->vm.total = BIT_ULL(INTEL_INFO(i915)->ppgtt_size);
...@@ -1634,7 +1636,7 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915) ...@@ -1634,7 +1636,7 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915)
if (!ppgtt) if (!ppgtt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ppgtt_init(i915, ppgtt); ppgtt_init(ppgtt, &i915->gt);
/* /*
* From bdw, there is hw support for read-only pages in the PPGTT. * From bdw, there is hw support for read-only pages in the PPGTT.
...@@ -2141,7 +2143,7 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915) ...@@ -2141,7 +2143,7 @@ static struct i915_ppgtt *gen6_ppgtt_create(struct drm_i915_private *i915)
if (!ppgtt) if (!ppgtt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ppgtt_init(i915, &ppgtt->base); ppgtt_init(&ppgtt->base, &i915->gt);
ppgtt->base.vm.allocate_va_range = gen6_alloc_va_range; ppgtt->base.vm.allocate_va_range = gen6_alloc_va_range;
ppgtt->base.vm.clear_range = gen6_ppgtt_clear_range; ppgtt->base.vm.clear_range = gen6_ppgtt_clear_range;
...@@ -3452,10 +3454,12 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt) ...@@ -3452,10 +3454,12 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt)
return 0; return 0;
} }
static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct drm_i915_private *i915) static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt)
{ {
struct drm_i915_private *i915 = gt->i915;
int ret; int ret;
ggtt->vm.gt = gt;
ggtt->vm.i915 = i915; ggtt->vm.i915 = i915;
ggtt->vm.dma = &i915->drm.pdev->dev; ggtt->vm.dma = &i915->drm.pdev->dev;
...@@ -3501,7 +3505,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *i915) ...@@ -3501,7 +3505,7 @@ int i915_ggtt_probe_hw(struct drm_i915_private *i915)
{ {
int ret; int ret;
ret = ggtt_probe_hw(&i915->ggtt, i915); ret = ggtt_probe_hw(&i915->ggtt, &i915->gt);
if (ret) if (ret)
return ret; return ret;
......
...@@ -288,6 +288,7 @@ struct i915_address_space { ...@@ -288,6 +288,7 @@ struct i915_address_space {
struct rcu_work rcu; struct rcu_work rcu;
struct drm_mm mm; struct drm_mm mm;
struct intel_gt *gt;
struct drm_i915_private *i915; struct drm_i915_private *i915;
struct device *dma; struct device *dma;
/* Every address space belongs to a struct file - except for the global /* Every address space belongs to a struct file - except for the global
......
...@@ -98,6 +98,7 @@ void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt) ...@@ -98,6 +98,7 @@ void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt)
{ {
memset(ggtt, 0, sizeof(*ggtt)); memset(ggtt, 0, sizeof(*ggtt));
ggtt->vm.gt = &i915->gt;
ggtt->vm.i915 = i915; ggtt->vm.i915 = i915;
ggtt->vm.is_ggtt = true; ggtt->vm.is_ggtt = true;
......
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