[PATCH 5/6] drm/i915/gtt: Generalize alloc_pd
Mika Kuoppala
mika.kuoppala at linux.intel.com
Mon Jun 3 12:04:09 UTC 2019
Allocate all page directory variants with alloc_pd
v2: zero used
Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 48 ++++-------------------------
1 file changed, 6 insertions(+), 42 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index d5dbb5f39bf2..38fa0772cff4 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -711,42 +711,6 @@ static void init_pd_with_page(struct i915_address_space *vm,
memset_p((void **)pd->entry, pt, 512);
}
-static struct i915_page_directory *
-alloc_pdp(struct i915_address_space *vm)
-{
- struct i915_page_directory *pdp;
- int ret = -ENOMEM;
-
- GEM_BUG_ON(!i915_vm_is_4lvl(vm));
-
- pdp = kmalloc(sizeof(*pdp), GFP_KERNEL);
- if (!pdp)
- return ERR_PTR(-ENOMEM);
-
- ret = setup_px(vm, pdp);
- if (ret)
- goto fail_setup;
-
- pdp->used = 0;
-
- return pdp;
-
-fail_setup:
- kfree(pdp);
-
- return ERR_PTR(ret);
-}
-
-static void free_pdp(struct i915_address_space *vm,
- struct i915_page_directory *pdp)
-{
- if (!i915_vm_is_4lvl(vm))
- return;
-
- cleanup_px(vm, pdp);
- kfree(pdp);
-}
-
static void init_pd(struct i915_address_space *vm,
struct i915_page_directory * const pd,
struct i915_page_directory * const to)
@@ -909,7 +873,7 @@ static void gen8_ppgtt_clear_4lvl(struct i915_address_space *vm,
gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
- free_pdp(vm, pdp);
+ free_pd(vm, pdp);
}
}
@@ -1211,7 +1175,7 @@ static int gen8_init_scratch(struct i915_address_space *vm)
}
if (i915_vm_is_4lvl(vm)) {
- vm->scratch_pdp = alloc_pdp(vm);
+ vm->scratch_pdp = alloc_pd(vm);
if (IS_ERR(vm->scratch_pdp)) {
ret = PTR_ERR(vm->scratch_pdp);
goto free_pd;
@@ -1273,7 +1237,7 @@ static void gen8_free_scratch(struct i915_address_space *vm)
return;
if (i915_vm_is_4lvl(vm))
- free_pdp(vm, vm->scratch_pdp);
+ free_pd(vm, vm->scratch_pdp);
free_pd(vm, vm->scratch_pd);
free_pt(vm, vm->scratch_pt);
cleanup_scratch_page(vm);
@@ -1293,7 +1257,7 @@ static void gen8_ppgtt_cleanup_3lvl(struct i915_address_space *vm,
free_pd(vm, pdp->entry[i]);
}
- free_pdp(vm, pdp);
+ free_pd(vm, pdp);
}
static void gen8_ppgtt_cleanup_4lvl(struct i915_hw_ppgtt *ppgtt)
@@ -1426,7 +1390,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
gen8_for_each_pml4e(pdp, pml4, start, length, pml4e) {
if (i915_pdp_entry(pml4, pml4e) == vm->scratch_pdp) {
- pdp = alloc_pdp(vm);
+ pdp = alloc_pd(vm);
if (IS_ERR(pdp))
goto unwind;
@@ -1444,7 +1408,7 @@ static int gen8_ppgtt_alloc_4lvl(struct i915_address_space *vm,
unwind_pdp:
if (!pdp->used) {
gen8_ppgtt_set_pml4e(pml4, vm->scratch_pdp, pml4e);
- free_pdp(vm, pdp);
+ free_pd(vm, pdp);
}
unwind:
gen8_ppgtt_clear_4lvl(vm, from, start - from);
--
2.17.1
More information about the Intel-gfx-trybot
mailing list