Home | History | Annotate | only in /external/linux-kselftest/tools/testing/selftests/android/ion
Up to higher level directory
NameDateSize
config22-Oct-202072
ion.h22-Oct-20203.8K
ion_test.sh22-Oct-2020843
ionapp_export.c22-Oct-20203.1K
ionapp_import.c22-Oct-20202.1K
ionmap_test.c22-Oct-20202.3K
ionutils.c22-Oct-20205.3K
ionutils.h22-Oct-20201.4K
ipcsocket.c22-Oct-20204.7K
ipcsocket.h22-Oct-2020861
Makefile22-Oct-2020546
README22-Oct-20203.9K

README

      1 ION BUFFER SHARING UTILITY
      2 ==========================
      3 File: ion_test.sh : Utility to test ION driver buffer sharing mechanism.
      4 Author: Pintu Kumar <pintu.ping (a] gmail.com>
      5 
      6 Introduction:
      7 -------------
      8 This is a test utility to verify ION buffer sharing in user space
      9 between 2 independent processes.
     10 It uses unix domain socket (with SCM_RIGHTS) as IPC to transfer an FD to
     11 another process to share the same buffer.
     12 This utility demonstrates how ION buffer sharing can be implemented between
     13 two user space processes, using various heap types.
     14 The following heap types are supported by ION driver.
     15 ION_HEAP_TYPE_SYSTEM (0)
     16 ION_HEAP_TYPE_SYSTEM_CONTIG (1)
     17 ION_HEAP_TYPE_CARVEOUT (2)
     18 ION_HEAP_TYPE_CHUNK (3)
     19 ION_HEAP_TYPE_DMA (4)
     20 
     21 By default only the SYSTEM and SYSTEM_CONTIG heaps are supported.
     22 Each heap is associated with the respective heap id.
     23 This utility is designed in the form of client/server program.
     24 The server part (ionapp_export) is the exporter of the buffer.
     25 It is responsible for creating an ION client, allocating the buffer based on
     26 the heap id, writing some data to this buffer and then exporting the FD
     27 (associated with this buffer) to another process using socket IPC.
     28 This FD is called as buffer FD (which is different than the ION client FD).
     29 
     30 The client part (ionapp_import) is the importer of the buffer.
     31 It retrives the FD from the socket data and installs into its address space.
     32 This new FD internally points to the same kernel buffer.
     33 So first it reads the data that is stored in this buffer and prints it.
     34 Then it writes the different size of data (it could be different data) to the
     35 same buffer.
     36 Finally the buffer FD must be closed by both the exporter and importer.
     37 Thus the same kernel buffer is shared among two user space processes using
     38 ION driver and only one time allocation.
     39 
     40 Prerequisite:
     41 -------------
     42 This utility works only if /dev/ion interface is present.
     43 The following configs needs to be enabled in kernel to include ion driver.
     44 CONFIG_ANDROID=y
     45 CONFIG_STAGING=y
     46 CONFIG_ION=y
     47 CONFIG_ION_SYSTEM_HEAP=y
     48 
     49 This utility requires to be run as root user.
     50 
     51 
     52 Compile and test:
     53 -----------------
     54 This utility is made to be run as part of kselftest framework in kernel.
     55 To compile and run using kselftest you can simply do the following from the
     56 kernel top directory.
     57 linux$ make TARGETS=android kselftest
     58 Or you can also use:
     59 linux$ make -C tools/testing/selftests TARGETS=android run_tests
     60 Using the selftest it can directly execute the ion_test.sh script to test the
     61 buffer sharing using ion system heap.
     62 Currently the heap size is hard coded as just 10 bytes inside this script.
     63 You need to be a root user to run under selftest.
     64 
     65 You can also compile and test manually using the following steps:
     66 ion$ make
     67 These will generate 2 executable: ionapp_export, ionapp_import
     68 Now you can run the export and import manually by specifying the heap type
     69 and the heap size.
     70 You can also directly execute the shell script to run the test automatically.
     71 Simply use the following command to run the test.
     72 ion$ sudo ./ion_test.sh
     73 
     74 Test Results:
     75 -------------
     76 The utility is verified on Ubuntu-32 bit system with Linux Kernel 4.14.
     77 Here is the snapshot of the test result using kselftest.
     78 
     79 linux# make TARGETS=android kselftest
     80 heap_type: 0, heap_size: 10
     81 --------------------------------------
     82 heap type: 0
     83   heap id: 1
     84 heap name: ion_system_heap
     85 --------------------------------------
     86 Fill buffer content:
     87 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
     88 Sharing fd: 6, Client fd: 5
     89 <ion_close_buffer_fd>: buffer release successfully....
     90 Received buffer fd: 4
     91 Read buffer content:
     92 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0x0 0x0 0x0 0x0 0x0 0x0
     93 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
     94 Fill buffer content:
     95 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
     96 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd
     97 0xfd 0xfd
     98 <ion_close_buffer_fd>: buffer release successfully....
     99 ion_test.sh: heap_type: 0 - [PASS]
    100 
    101 ion_test.sh: done
    102