Re: [PATCHv2 1/1] [tools]: android/ion: userspace test utility for ion buffer sharing

From: Pintu Kumar
Date: Fri Oct 06 2017 - 10:29:05 EST


>> +
>> + heap_type = ion_info->heap_type;
>> + heap_size = ion_info->heap_size;
>> + flag_type = ion_info->flag_type;
>> + alloc_data.len = heap_size;
>> + alloc_data.heap_id_mask = heap_type;
>
> The heap type and heap ID are not the same thing. You need
> to determine the heap id from using the new query ioctl.
>

Hello Laura,
Can you point out some example on how to retrieve heap_id from query ioctl.
Sorry, I am not able to figure out, how can I get a specific heap_id
if I know the heap_type.
Do, I need to query all the heaps? Then how do I map to heap_data for each heap?
Here is what I am doing.

struct ion_heap_query query;
struct ion_heap_data heap_data[5];

query.cnt = 5;
/* Query ION heap_id_mask from ION heap */
ret = ioctl(ionfd, ION_IOC_HEAP_QUERY, &query);
if (ret < 0) {
fprintf(stderr, "<%s>: Failed: ION_IOC_HEAP_QUERY: %s\n",
__func__, strerror(errno));
goto err_heap;
}

After this how to map each heap_data[..] to query.heaps?
Do you have any examples?