mbox series

[v5,0/2] staging: ion: get one device per heap

Message ID 1506518409-16887-1-git-send-email-benjamin.gaignard@linaro.org
Headers show
Series staging: ion: get one device per heap | expand

Message

Benjamin Gaignard Sept. 27, 2017, 1:20 p.m. UTC
version 5:
- create a configuration flag to keep legacy Ion misc device

version 4:
- add a configuration flag to switch between legacy Ion misc device
  and one device per heap version.
  This change has been suggested after Laura talks at XDC 2017.

version 3:
- change ion_device_add_heap prototype to return a possible error.

version 2:
- simplify ioctl check like propose by Dan
- make sure that we don't register more than ION_DEV_MAX heaps.

Until now all ion heaps are addressing using the same device "/dev/ion".
This way of working doesn't allow to give access rights (for example with
SElinux rules) per heap.
This series propose to have one device "/dev/ionX" per heap.
Query heaps informations will be possible on each device node but
allocation request will only be possible if heap_mask_id match with device minor number.

Using legacy Ion misc device is still by setting ION_LEGACY_DEVICE_API
configuration flag.

Benjamin Gaignard (2):
  staging: ion: simplify ioctl args checking function
  staging: ion: create one device entry per heap

 drivers/staging/android/TODO            |  1 -
 drivers/staging/android/ion/Kconfig     |  7 +++++++
 drivers/staging/android/ion/ion-ioctl.c | 29 +++++++++++++++++++++--------
 drivers/staging/android/ion/ion.c       | 31 ++++++++++++++++++++++++++++++-
 drivers/staging/android/ion/ion.h       | 15 +++++++++++++--
 5 files changed, 71 insertions(+), 12 deletions(-)

Comments

Laura Abbott Oct. 9, 2017, 4:45 p.m. UTC | #1
On 10/09/2017 02:21 AM, Benjamin Gaignard wrote:
> 2017-09-27 15:20 GMT+02:00 Benjamin Gaignard <benjamin.gaignard@linaro.org>:
>> Make arguments checking more easy to read.
>>
> 
> Hi Laura,
> 
> Even if we don't have found a solution for the second patch I believe
> this one could be useful.
> May I ask you your point of view on those few lines ?
> 
> Benjamin
> 

Yes, this looks better.

Acked-by: Laura Abbott <labbott@redhat.com>

>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>> ---
>>  drivers/staging/android/ion/ion-ioctl.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
>> index d9f8b14..e26b786 100644
>> --- a/drivers/staging/android/ion/ion-ioctl.c
>> +++ b/drivers/staging/android/ion/ion-ioctl.c
>> @@ -27,19 +27,18 @@ union ion_ioctl_arg {
>>
>>  static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
>>  {
>> -       int ret = 0;
>> -
>>         switch (cmd) {
>>         case ION_IOC_HEAP_QUERY:
>> -               ret = arg->query.reserved0 != 0;
>> -               ret |= arg->query.reserved1 != 0;
>> -               ret |= arg->query.reserved2 != 0;
>> +               if (arg->query.reserved0 ||
>> +                   arg->query.reserved1 ||
>> +                   arg->query.reserved2)
>> +                       return -EINVAL;
>>                 break;
>>         default:
>>                 break;
>>         }
>>
>> -       return ret ? -EINVAL : 0;
>> +       return 0;
>>  }
>>
>>  /* fix up the cases where the ioctl direction bits are incorrect */
>> --
>> 2.7.4
>>
> 
> 
>