[Intel-gfx] [PATCH v4 08/24] drm/i915: Plumb drm_device through page tables operations
Michel Thierry
michel.thierry at intel.com
Thu Jan 22 09:01:30 PST 2015
The next patch in the series will require it for alloc_pt_single.
Signed-off-by: Michel Thierry <michel.thierry at intel.com>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 85ea535..e2bcd10 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -138,7 +138,6 @@ static int sanitize_enable_ppgtt(struct drm_device *dev, int enable_ppgtt)
return has_aliasing_ppgtt ? 1 : 0;
}
-
static void ppgtt_bind_vma(struct i915_vma *vma,
enum i915_cache_level cache_level,
u32 flags);
@@ -275,7 +274,7 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
return pte;
}
-static void unmap_and_free_pt(struct i915_page_table_entry *pt)
+static void unmap_and_free_pt(struct i915_page_table_entry *pt, struct drm_device *dev)
{
if (WARN_ON(!pt->page))
return;
@@ -283,7 +282,7 @@ static void unmap_and_free_pt(struct i915_page_table_entry *pt)
kfree(pt);
}
-static struct i915_page_table_entry *alloc_pt_single(void)
+static struct i915_page_table_entry *alloc_pt_single(struct drm_device *dev)
{
struct i915_page_table_entry *pt;
@@ -313,7 +312,9 @@ static struct i915_page_table_entry *alloc_pt_single(void)
*
* Return: 0 if allocation succeeded.
*/
-static int alloc_pt_range(struct i915_page_directory_entry *pd, uint16_t pde, size_t count)
+static int alloc_pt_range(struct i915_page_directory_entry *pd, uint16_t pde, size_t count,
+ struct drm_device *dev)
+
{
int i, ret;
@@ -323,7 +324,7 @@ static int alloc_pt_range(struct i915_page_directory_entry *pd, uint16_t pde, si
BUG_ON(pde + count > GEN6_PPGTT_PD_ENTRIES);
for (i = pde; i < pde + count; i++) {
- struct i915_page_table_entry *pt = alloc_pt_single();
+ struct i915_page_table_entry *pt = alloc_pt_single(dev);
if (IS_ERR(pt)) {
ret = PTR_ERR(pt);
@@ -339,7 +340,7 @@ static int alloc_pt_range(struct i915_page_directory_entry *pd, uint16_t pde, si
err_out:
while (i--)
- unmap_and_free_pt(pd->page_tables[i]);
+ unmap_and_free_pt(pd->page_tables[i], dev);
return ret;
}
@@ -518,7 +519,7 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,
}
}
-static void gen8_free_page_tables(struct i915_page_directory_entry *pd)
+static void gen8_free_page_tables(struct i915_page_directory_entry *pd, struct drm_device *dev)
{
int i;
@@ -529,7 +530,7 @@ static void gen8_free_page_tables(struct i915_page_directory_entry *pd)
if (WARN_ON(!pd->page_tables[i]))
continue;
- unmap_and_free_pt(pd->page_tables[i]);
+ unmap_and_free_pt(pd->page_tables[i], dev);
pd->page_tables[i] = NULL;
}
}
@@ -542,7 +543,7 @@ static void gen8_ppgtt_free(struct i915_hw_ppgtt *ppgtt)
if (WARN_ON(!ppgtt->pdp.page_directory[i]))
continue;
- gen8_free_page_tables(ppgtt->pdp.page_directory[i]);
+ gen8_free_page_tables(ppgtt->pdp.page_directory[i], ppgtt->base.dev);
unmap_and_free_pd(ppgtt->pdp.page_directory[i]);
}
}
@@ -594,7 +595,7 @@ static int gen8_ppgtt_allocate_page_tables(struct i915_hw_ppgtt *ppgtt)
for (i = 0; i < ppgtt->num_pd_pages; i++) {
ret = alloc_pt_range(ppgtt->pdp.page_directory[i],
- 0, GEN8_PDES_PER_PAGE);
+ 0, GEN8_PDES_PER_PAGE, ppgtt->base.dev);
if (ret)
goto unwind_out;
}
@@ -603,7 +604,7 @@ static int gen8_ppgtt_allocate_page_tables(struct i915_hw_ppgtt *ppgtt)
unwind_out:
while (i--)
- gen8_free_page_tables(ppgtt->pdp.page_directory[i]);
+ gen8_free_page_tables(ppgtt->pdp.page_directory[i], ppgtt->base.dev);
return -ENOMEM;
}
@@ -1075,7 +1076,7 @@ static void gen6_ppgtt_free(struct i915_hw_ppgtt *ppgtt)
int i;
for (i = 0; i < ppgtt->num_pd_entries; i++)
- unmap_and_free_pt(ppgtt->pd.page_tables[i]);
+ unmap_and_free_pt(ppgtt->pd.page_tables[i], ppgtt->base.dev);
unmap_and_free_pd(&ppgtt->pd);
}
@@ -1140,7 +1141,9 @@ static int gen6_ppgtt_alloc(struct i915_hw_ppgtt *ppgtt)
if (ret)
return ret;
- ret = alloc_pt_range(&ppgtt->pd, 0, ppgtt->num_pd_entries);
+ ret = alloc_pt_range(&ppgtt->pd, 0, ppgtt->num_pd_entries,
+ ppgtt->base.dev);
+
if (ret) {
drm_mm_remove_node(&ppgtt->node);
return ret;
--
2.1.1
More information about the Intel-gfx
mailing list