aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>2017-09-18 16:43:11 +0200
committerBenjamin Gaignard <benjamin.gaignard@linaro.org>2017-09-18 16:43:11 +0200
commit5c0e504f69e1c6053d542dc96b84c2190c7c92bd (patch)
treebfea110de40eba277f2e2e0ef9da52a422ef32d3
parente329311dd237b66767b7ad113c87b1fb4c981542 (diff)
downloadion_test_application-5c0e504f69e1c6053d542dc96b84c2190c7c92bd.tar.gz
[DRAFT] using one device entry per heap
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
-rw-r--r--test_ion.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/test_ion.c b/test_ion.c
index 6a46ff0..ddebbdb 100644
--- a/test_ion.c
+++ b/test_ion.c
@@ -8,8 +8,7 @@
#include <ion.h>
-#define ION_DEVICE "/dev/ion"
-#define MAX_HEAPS 8
+#define MAX_HEAPS 32
#define MAX_LEN 1024*16
int main(int argc, char ** argv)
@@ -19,8 +18,7 @@ int main(int argc, char ** argv)
struct ion_heap_data heaps_data[MAX_HEAPS];
struct ion_heap_query query;
- printf("Open ION memory manager\n");
- ion_fd = open(ION_DEVICE, O_RDONLY);
+ ion_fd = open("/dev/ion0", O_RDONLY);
if(!ion_fd) {
printf("Failed to open ION device - %s\n", strerror(errno));
return -errno;
@@ -28,8 +26,9 @@ int main(int argc, char ** argv)
memset(&query, 0, sizeof(query));
query.cnt = MAX_HEAPS;
- query.heaps = (__u64)&heaps_data;
+ query.heaps = &heaps_data;
err = ioctl(ion_fd, ION_IOC_HEAP_QUERY, &query);
+ close(ion_fd);
if (err) {
printf("Can't get ION heaps data %s\n", strerror(errno));
goto out;
@@ -40,10 +39,14 @@ int main(int argc, char ** argv)
int fd;
struct ion_allocation_data alloc;
void *buffer = NULL;
+ char filename[32];
+
+ sprintf(filename, "/dev/ion%d", heaps_data[i].heap_id);
+ ion_fd = open(filename, O_RDONLY);
memset(&alloc, 0, sizeof(alloc));
alloc.len = MAX_LEN;
- alloc.heap_id_mask = heaps_data[i].heap_id;
+ alloc.heap_id_mask = 1 << heaps_data[i].heap_id;
err = ioctl(ion_fd, ION_IOC_ALLOC, &alloc);
if (!err)
buffer = mmap(0, MAX_LEN, PROT_READ|PROT_WRITE, MAP_SHARED, alloc.fd, 0);
@@ -55,10 +58,9 @@ int main(int argc, char ** argv)
err ? "KO" : "OK",
buffer ? "OK": "KO");
close(fd);
+ close(ion_fd);
}
out:
- printf("close %s\n", ION_DEVICE);
- close(ion_fd);
return err;
}