2017-10-09 21:20:23

by Laura Abbott

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

On 10/09/2017 07:17 AM, Pintu Kumar wrote:
> On Fri, Oct 6, 2017 at 7:58 PM, Pintu Kumar <[email protected]> wrote:
>>>> +
>>>> + 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?
>
> Dear Laura,
> I figured out myself.
> Now I am able to query heap_id from the new QUERY ioctl.
> Also I have added a script to test all the heaps from single terminal.
> Things are working fine.
> I will post the new patch set soon.
> However I have few questions to be clarified.
> 1) I have moved the test setup under: tools/testing/selftests/android/ion/
> So that it can be included easily in selftests framework later.
> Hope this is fine.
>

Is it actually hooked up to the selftest framework? Please make sure
it actually runs under the kselftest framework.

> 2) I observed that ION_HEAP_TYPE_DMA heap type is returned as
> "reserved" heap name.
> However allocation goes through CMA area. Hope this is expected behavior.
>
> 3) For me CHUNK & CARVEDOUT heap is not working, on my Ubuntu PC.
> So I could not check it.
> I know these heaps needs to be declared first, may be in device
> tree or somewhere else.
> Do you know how to verify this on Ubuntu x86 PC?
>

The answer to both of these is that Ion is now doing heap enumeration
differently. Using heap types as arguments to heap ids never really
made much sense since it was conflating heap types with actual
instances of heaps. The ion test module which tried to set up one
of each type of heap was deleted.

There really isn't any need to test multiple heap types anyway.
This is a buffer sharing test and the underlying allocation
doesn't have anything to do with that. Let's just get rid of the
different heap types and just use the system heap which should
always be available. While we're at it, just drop specifying the
allocation size on the command line as well and use something
hardcoded.

Thanks,
Laura

> 4) Please see the snapshots of output from the test results.
>
> linux/tools/testing/selftests/android/ion$ sudo ./ion_test.sh
> heap_type: 0, heap_size: 10
> --------------------------------------
> heap type: 0
> heap id: 1
> heap name: ion_system_heap
> --------------------------------------
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> Sharing fd: 6, Client fd: 5
> <ion_close_buffer_fd>: buffer release successfully....
> Received buffer fd: 4
> Read buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0x0 0x0 0x0 0x0 0x0
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd
> <ion_close_buffer_fd>: buffer release successfully....
> ion_test.sh: heap_type: 0 - [PASS]
>
> heap_type: 1, heap_size: 10
> --------------------------------------
> heap type: 1
> heap id: 0
> heap name: ion_system_contig_heap
> --------------------------------------
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> Sharing fd: 6, Client fd: 5
> <ion_close_buffer_fd>: buffer release successfully....
> Received buffer fd: 4
> Read buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0x0 0x0 0x0 0x0 0x0
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd
> <ion_close_buffer_fd>: buffer release successfully....
> ion_test.sh: heap_type: 1 - [PASS]
>
> heap_type: 2, heap_size: 10
> <ion_export_buffer_fd>: ERROR: heap type does not exists
> FAILED: ion_get_buffer_fd
> <ion_close_buffer_fd>: buffer release successfully....
> Received buffer fd: 0
> ERROR: improper buf fd
> ion_test.sh: heap_type: 2 - [FAIL]
>
> heap_type: 3, heap_size: 10
> <ion_export_buffer_fd>: ERROR: heap type does not exists
> FAILED: ion_get_buffer_fd
> <ion_close_buffer_fd>: buffer release successfully....
> Received buffer fd: 0
> ERROR: improper buf fd
> ion_test.sh: heap_type: 3 - [FAIL]
>
> heap_type: 4, heap_size: 10
> --------------------------------------
> heap type: 4
> heap id: 2
> heap name: reserved
> --------------------------------------
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> Sharing fd: 6, Client fd: 5
> <ion_close_buffer_fd>: buffer release successfully....
> Received buffer fd: 4
> Read buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd
> Fill buffer content:
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
> 0xfd 0xfd 0xfd 0xfd
> <ion_close_buffer_fd>: buffer release successfully....
> ion_test.sh: heap_type: 4 - [PASS]
>
> done....
>
>
>
>
> Thanks,
> Pintu
>


From 1580789856373126670@xxx Mon Oct 09 14:18:05 +0000 2017
X-GM-THRID: 1579656416160844925
X-Gmail-Labels: Inbox,Category Forums