mbox series

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

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

Message

Benjamin Gaignard Sept. 20, 2017, 8:45 a.m. UTC
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.

That really change ion ABI because:
- device name change
- allocation must be done on the correct device/heap.
- device major number will not be the same and that could impact init scripts.

Even if splitting ion device in multiple node was one of the item of the
de-staging TODO list this must be agreed by a larger audience because it is
(again) an ion ABI bing bang. Hopefully that could be discussed at next XDC
to get a decission on this particular point.

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/ion-ioctl.c | 20 +++++++++++++-------
 drivers/staging/android/ion/ion.c       | 27 ++++++++++++++++++++-------
 drivers/staging/android/ion/ion.h       | 12 ++++++++----
 4 files changed, 41 insertions(+), 19 deletions(-)

-- 
2.7.4

Comments

Daniel Vetter Sept. 26, 2017, 5:09 a.m. UTC | #1
On Mon, Sep 25, 2017 at 11:26:27AM -0700, Laura Abbott wrote:
> On 09/20/2017 01:45 AM, Benjamin Gaignard wrote:

> > Instead a getting one common device "/dev/ion" for

> > all the heaps this patch allow to create one device

> > entry ("/dev/ionX") per heap.

> > Getting an entry per heap could allow to set security rules

> > per heap and global ones for all heaps.

> > 

> > Allocation requests will be only allowed if the mask_id

> > match with device minor.

> > Query request could be done on any of the devices.

> > Deivce node major will also change and that may impact init scripts.

> > 

> 

> We should start Cc linux-api for future changes since we're going

> to have more than just /dev/ion.

> 

> Thinking about this some more, I think we need to allow backwards

> compatibility. It's just not feasible to keep throwing workarounds

> into userspace if we can avoid it. I'd propose keeping the old /dev/ion

> misc interface available under a Kconfig and then creating the new

> split heaps in parallel.

> 

> On a somewhat related note, there was some interest in possibly

> having a sysfs interface for Ion long term. I don't think this

> needs to happen right now but I'd like whatever we do to not

> make adding that harder.


Not sure sysfs is a good idea for allocating buffers. The backlight
interface is in sysfs, which defacto makes it a root-only interface.
Distros really hate that, because it makes unpriviledged X/wayland really
hard to pull of. Passing a device file otoh from logind to the compositor
is dead simple (and how X et al get at e.g. the drm/input devices
already).

Adding some links from devices to corresponding ion heaps somewhere in
sysfs makes sense, and those could be read by anyone.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Greg Kroah-Hartman Sept. 26, 2017, 6:56 a.m. UTC | #2
On Tue, Sep 26, 2017 at 07:09:14AM +0200, Daniel Vetter wrote:
> On Mon, Sep 25, 2017 at 11:26:27AM -0700, Laura Abbott wrote:

> > On 09/20/2017 01:45 AM, Benjamin Gaignard wrote:

> > > Instead a getting one common device "/dev/ion" for

> > > all the heaps this patch allow to create one device

> > > entry ("/dev/ionX") per heap.

> > > Getting an entry per heap could allow to set security rules

> > > per heap and global ones for all heaps.

> > > 

> > > Allocation requests will be only allowed if the mask_id

> > > match with device minor.

> > > Query request could be done on any of the devices.

> > > Deivce node major will also change and that may impact init scripts.

> > > 

> > 

> > We should start Cc linux-api for future changes since we're going

> > to have more than just /dev/ion.

> > 

> > Thinking about this some more, I think we need to allow backwards

> > compatibility. It's just not feasible to keep throwing workarounds

> > into userspace if we can avoid it. I'd propose keeping the old /dev/ion

> > misc interface available under a Kconfig and then creating the new

> > split heaps in parallel.

> > 

> > On a somewhat related note, there was some interest in possibly

> > having a sysfs interface for Ion long term. I don't think this

> > needs to happen right now but I'd like whatever we do to not

> > make adding that harder.

> 

> Not sure sysfs is a good idea for allocating buffers. The backlight

> interface is in sysfs, which defacto makes it a root-only interface.

> Distros really hate that, because it makes unpriviledged X/wayland really

> hard to pull of. Passing a device file otoh from logind to the compositor

> is dead simple (and how X et al get at e.g. the drm/input devices

> already).


sysfs is not a good idea for allocating buffers.  We already have some
out-of-tree drm drivers doing horrid things in sysfs in ways that
totally abuse that api, and vendors have to do crazy things with selinux
rules to try to lock it down because of that.  A device node is fine, we
are used to that for graphics stuff :)

thanks,

greg k-h