summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Widawsky <benjamin.widawsky@intel.com>2014-02-05 17:25:37 +0000
committerBen Widawsky <benjamin.widawsky@intel.com>2014-02-08 13:14:53 -0800
commitc4ef4a6b76cd6fde56d8002c0938cd817d326fa5 (patch)
tree717a93c0c4ea12a44946be4dd88dd4abe65ac195
parenteee86eaf75eae8c8a443c498f6194ae069785874 (diff)
drm/i915: vm->ppgtt helper
is_active_vm is intentionally left alone as that should be handled separately. Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h11
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c26
2 files changed, 22 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9b24530a9770..640117476011 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2278,6 +2278,17 @@ static inline bool i915_is_ggtt(struct i915_address_space *vm)
return vm == ggtt;
}
+static inline struct i915_hw_ppgtt *
+vm_to_ppgtt_safe(struct i915_address_space *vm)
+{
+ struct i915_hw_ppgtt *ppgtt =
+ container_of(vm, struct i915_hw_ppgtt, base);
+
+ BUG_ON(i915_is_ggtt(vm));
+
+ return ppgtt;
+}
+
static inline bool i915_gem_obj_ggtt_bound(struct drm_i915_gem_object *obj)
{
return i915_gem_obj_bound(obj, obj_to_ggtt(obj));
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 4bcba2e72604..2cfd691b32e5 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -265,8 +265,9 @@ static void gen8_ppgtt_clear_range(struct i915_address_space *vm,
unsigned num_entries,
bool use_scratch)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+
+
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
gen8_gtt_pte_t *pt_vaddr, scratch_pte;
unsigned act_pt = first_entry / GEN8_PTES_PER_PAGE;
unsigned first_pte = first_entry % GEN8_PTES_PER_PAGE;
@@ -300,8 +301,7 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,
unsigned first_entry,
enum i915_cache_level cache_level)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
gen8_gtt_pte_t *pt_vaddr;
unsigned act_pt = first_entry / GEN8_PTES_PER_PAGE;
unsigned act_pte = first_entry % GEN8_PTES_PER_PAGE;
@@ -328,8 +328,7 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,
static void gen8_ppgtt_cleanup(struct i915_address_space *vm)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
int i, j;
list_del(&vm->global_link);
@@ -821,8 +820,7 @@ static void gen6_ppgtt_clear_range(struct i915_address_space *vm,
unsigned num_entries,
bool use_scratch)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
gen6_gtt_pte_t *pt_vaddr, scratch_pte;
unsigned act_pt = first_entry / GEN6_PTES_PER_PAGE;
unsigned first_pte = first_entry % GEN6_PTES_PER_PAGE;
@@ -853,8 +851,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
unsigned first_entry,
enum i915_cache_level cache_level)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
gen6_gtt_pte_t *pt_vaddr;
unsigned act_pt = first_entry / GEN6_PTES_PER_PAGE;
unsigned act_pte = first_entry % GEN6_PTES_PER_PAGE;
@@ -881,8 +878,7 @@ static void gen6_ppgtt_insert_entries(struct i915_address_space *vm,
static void gen6_ppgtt_cleanup(struct i915_address_space *vm)
{
- struct i915_hw_ppgtt *ppgtt =
- container_of(vm, struct i915_hw_ppgtt, base);
+ struct i915_hw_ppgtt *ppgtt = vm_to_ppgtt_safe(vm);
int i;
list_del(&vm->global_link);
@@ -1211,7 +1207,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
continue;
}
- gen6_write_pdes(container_of(vm, struct i915_hw_ppgtt, base));
+ gen6_write_pdes(vm_to_ppgtt_safe(vm));
}
i915_gem_chipset_flush(dev);
@@ -1223,7 +1219,7 @@ int i915_gem_vm_prepare_vma(struct i915_vma *vma)
struct i915_hw_ppgtt *ppgtt = NULL;
if (!i915_is_ggtt(vma->vm))
- ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
+ ppgtt = vm_to_ppgtt_safe(vma->vm);
if (ppgtt && ppgtt->promote)
ppgtt->promote(ppgtt, vma);
@@ -1503,7 +1499,7 @@ void i915_gem_vm_finish_vma(struct i915_vma *vma)
struct i915_hw_ppgtt *ppgtt = NULL;
if (!i915_is_ggtt(vma->vm))
- ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base);
+ ppgtt = vm_to_ppgtt_safe(vma->vm);
if (ppgtt && ppgtt->demote)
ppgtt->demote(ppgtt, vma);