[PATCH v5 19/19] drm/i915: Save some page table setup on repeated binds

Michel Thierry
2015-07-16T09:33:56Z

Check if the required page tables are already allocated, if so, we can
skip altogether the inner loop of pdes, and move to the next page
directory.

If the new allocation is different than the existing one (i.e. new
allocation spans more ptes than already covered from earlier allocations),
the used_ptes bitmap may not get updated correctly, but none of the
code-checks rely on this.

Suggested-by: Akash Goel <akash.goel@intel.com>
Signed-off-by: Michel Thierry <michel.thierry@intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 446bd98..086c71d 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1194,6 +1194,16 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,
/* Every pd should be allocated, we just did that above. */
WARN_ON(!pd);

+ /* Check if the required page tables are already allocated /
+ * mapped; if so, we can skip altogether the inner loop of pdes,
+ * and move to the next page directory.
+ */
+ if (bitmap_subset(new_page_tables[pdpe], pd->used_pdes,
+ I915_PDES)) {
+ kunmap_px(ppgtt, page_directory);
+ continue;
+ }
+
gen8_for_each_pde(pt, pd, pd_start, pd_len, temp, pde) {
/* Same reasoning as pd */
WARN_ON(!pt);