[v6,19/19] drm/i915: Save some page table setup on repeated binds

Submitted by Michel Thierry on July 29, 2015, 4:24 p.m.

Details

Message ID 1438187043-34267-20-git-send-email-michel.thierry@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Michel Thierry July 29, 2015, 4:24 p.m.
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(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index a7d3c07..13cf23c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1249,6 +1249,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);