msm: kgsl: Increase the virtual GPU range for the IOMMU
Instead of a fixed 256MB virtual range for both the GPUMMU and IOMMU, make
the virtual range a property of the MMU engine and set the IOMMU range to
2GB. Technically we could go all the way up to 4G, but even 2G is far out
of the realm of possiblity in the current generation, and we wanted to
reserve some of the space for future enhancements.
Change-Id: Ic0dedbad2987beb162b6a1878dd65ffae8a78522
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
diff --git a/drivers/gpu/msm/kgsl_mmu.c b/drivers/gpu/msm/kgsl_mmu.c
index 319addb..ceb3212 100644
--- a/drivers/gpu/msm/kgsl_mmu.c
+++ b/drivers/gpu/msm/kgsl_mmu.c
@@ -148,9 +148,10 @@
pt = _get_pt_from_kobj(kobj);
- if (pt)
+ if (pt) {
ret += snprintf(buf, PAGE_SIZE, "0x%x\n",
- CONFIG_MSM_KGSL_PAGE_TABLE_SIZE);
+ kgsl_mmu_get_ptsize());
+ }
kgsl_put_pagetable(pt);
return ret;
@@ -268,6 +269,22 @@
return ret;
}
+unsigned int kgsl_mmu_get_ptsize(void)
+{
+ /*
+ * For IOMMU, we could do up to 4G virtual range if we wanted to, but
+ * it makes more sense to return a smaller range and leave the rest of
+ * the virtual range for future improvements
+ */
+
+ if (KGSL_MMU_TYPE_GPU == kgsl_mmu_type)
+ return CONFIG_MSM_KGSL_PAGE_TABLE_SIZE;
+ else if (KGSL_MMU_TYPE_IOMMU == kgsl_mmu_type)
+ return SZ_2G;
+ else
+ return 0;
+}
+
unsigned int kgsl_mmu_get_current_ptbase(struct kgsl_device *device)
{
struct kgsl_mmu *mmu = &device->mmu;
@@ -392,6 +409,7 @@
int status = 0;
struct kgsl_pagetable *pagetable = NULL;
unsigned long flags;
+ unsigned int ptsize;
pagetable = kzalloc(sizeof(struct kgsl_pagetable), GFP_KERNEL);
if (pagetable == NULL) {
@@ -403,9 +421,11 @@
kref_init(&pagetable->refcount);
spin_lock_init(&pagetable->lock);
+
+ ptsize = kgsl_mmu_get_ptsize();
+
pagetable->name = name;
- pagetable->max_entries = KGSL_PAGETABLE_ENTRIES(
- CONFIG_MSM_KGSL_PAGE_TABLE_SIZE);
+ pagetable->max_entries = KGSL_PAGETABLE_ENTRIES(ptsize);
pagetable->pool = gen_pool_create(PAGE_SHIFT, -1);
if (pagetable->pool == NULL) {
@@ -414,7 +434,7 @@
}
if (gen_pool_add(pagetable->pool, KGSL_PAGETABLE_BASE,
- CONFIG_MSM_KGSL_PAGE_TABLE_SIZE, -1)) {
+ ptsize, -1)) {
KGSL_CORE_ERR("gen_pool_add failed\n");
goto err_pool;
}
@@ -697,10 +717,10 @@
}
EXPORT_SYMBOL(kgsl_mmu_ptpool_destroy);
-void *kgsl_mmu_ptpool_init(int ptsize, int entries)
+void *kgsl_mmu_ptpool_init(int entries)
{
if (KGSL_MMU_TYPE_GPU == kgsl_mmu_type)
- return kgsl_gpummu_ptpool_init(ptsize, entries);
+ return kgsl_gpummu_ptpool_init(entries);
else
return (void *)(-1);
}