Skip to content

Commit 5f342a7

Browse files
Rebecca Schultz Zavingregkh
authored andcommitted
gpu: ion: Modify reserve function for carveouts with no start address
This patch allows you to specify a heap that requires carveout memory but that doesn't specify a start address. Memblock_alloc will be called to find a location for these heaps. Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com> [jstultz: modified patch to apply to staging directory] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f4175af commit 5f342a7

File tree

1 file changed

+26
-7
lines changed
  • drivers/staging/android/ion

1 file changed

+26
-7
lines changed

drivers/staging/android/ion/ion.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,16 +1343,35 @@ void ion_device_destroy(struct ion_device *dev)
13431343

13441344
void __init ion_reserve(struct ion_platform_data *data)
13451345
{
1346-
int i, ret;
1346+
int i;
13471347

13481348
for (i = 0; i < data->nr; i++) {
13491349
if (data->heaps[i].size == 0)
13501350
continue;
1351-
ret = memblock_reserve(data->heaps[i].base,
1352-
data->heaps[i].size);
1353-
if (ret)
1354-
pr_err("memblock reserve of %x@%lx failed\n",
1355-
data->heaps[i].size,
1356-
data->heaps[i].base);
1351+
1352+
if (data->heaps[i].base == 0) {
1353+
phys_addr_t paddr;
1354+
paddr = memblock_alloc_base(data->heaps[i].size,
1355+
data->heaps[i].align,
1356+
MEMBLOCK_ALLOC_ANYWHERE);
1357+
if (!paddr) {
1358+
pr_err("%s: error allocating memblock for "
1359+
"heap %d\n",
1360+
__func__, i);
1361+
continue;
1362+
}
1363+
data->heaps[i].base = paddr;
1364+
} else {
1365+
int ret = memblock_reserve(data->heaps[i].base,
1366+
data->heaps[i].size);
1367+
if (ret)
1368+
pr_err("memblock reserve of %x@%lx failed\n",
1369+
data->heaps[i].size,
1370+
data->heaps[i].base);
1371+
}
1372+
pr_info("%s: %s reserved base %lx size %d\n", __func__,
1373+
data->heaps[i].name,
1374+
data->heaps[i].base,
1375+
data->heaps[i].size);
13571376
}
13581377
}

0 commit comments

Comments
 (0)