[Intel-gfx] [PATCH 14/66] drm/i915: Move ppgtt initialization down

Ben Widawsky ben at bwidawsk.net
Fri Jun 28 01:30:15 CEST 2013


This will allows us to be able to check whether PPGTT was initialized
not by the pointer, but by the values of it's function pointers.

This will be used in the next patch in order to determine at context
destruction if the PPGTT needs cleanup. It should only occur in error
cases.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 16a8486..f56e75b 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -295,30 +295,26 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
 	} else {
 		ppgtt->pte_encode = gen6_pte_encode;
 	}
-	ppgtt->num_pd_entries = GEN6_PPGTT_PD_ENTRIES;
-	ppgtt->enable = gen6_ppgtt_enable;
-	ppgtt->clear_range = gen6_ppgtt_clear_range;
-	ppgtt->insert_entries = gen6_ppgtt_insert_entries;
-	ppgtt->cleanup = gen6_ppgtt_cleanup;
-	ppgtt->pt_pages = kzalloc(sizeof(struct page *)*ppgtt->num_pd_entries,
+
+	ppgtt->pt_pages = kzalloc(sizeof(struct page *)*GEN6_PPGTT_PD_ENTRIES,
 				  GFP_KERNEL);
 	if (!ppgtt->pt_pages) {
 		drm_mm_remove_node(&ppgtt->node);
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < ppgtt->num_pd_entries; i++) {
+	for (i = 0; i < GEN6_PPGTT_PD_ENTRIES; i++) {
 		ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL);
 		if (!ppgtt->pt_pages[i])
 			goto err_pt_alloc;
 	}
 
-	ppgtt->pt_dma_addr = kzalloc(sizeof(dma_addr_t) *ppgtt->num_pd_entries,
+	ppgtt->pt_dma_addr = kzalloc(sizeof(dma_addr_t) * GEN6_PPGTT_PD_ENTRIES,
 				     GFP_KERNEL);
 	if (!ppgtt->pt_dma_addr)
 		goto err_pt_alloc;
 
-	for (i = 0; i < ppgtt->num_pd_entries; i++) {
+	for (i = 0; i < GEN6_PPGTT_PD_ENTRIES; i++) {
 		dma_addr_t pt_addr;
 
 		pt_addr = pci_map_page(dev->pdev, ppgtt->pt_pages[i], 0, 4096,
@@ -332,6 +328,12 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
 		ppgtt->pt_dma_addr[i] = pt_addr;
 	}
 
+	ppgtt->num_pd_entries = GEN6_PPGTT_PD_ENTRIES;
+	ppgtt->enable = gen6_ppgtt_enable;
+	ppgtt->clear_range = gen6_ppgtt_clear_range;
+	ppgtt->insert_entries = gen6_ppgtt_insert_entries;
+	ppgtt->cleanup = gen6_ppgtt_cleanup;
+
 	ppgtt->clear_range(ppgtt, 0,
 			   ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES);
 
-- 
1.8.3.1




More information about the Intel-gfx mailing list