Re: [PATCH v2] staging: android: ion: Allocate from heap ID directly without mask

From: John Stultz
Date: Fri Feb 15 2019 - 16:15:19 EST

On Fri, Feb 15, 2019 at 12:52 PM Andrew F. Davis <afd@xxxxxx> wrote:
> On 2/15/19 1:58 PM, John Stultz wrote:
> > So yea, I don't think we should tie our hands in reworking the
> > interfaces, but it would be nice to avoid having subtle ABI changes
> > that don't have clear ways for userland to detect which interface
> > version its using.
> >
> Let me preference this by pointing out I've dealt with the same pain
> internally with our Android and soon to also in AOSP for the Beagle x15
> boards[0].. But my stance matches Christoph's in the other ION thread:
> The more freely we can make ABI changes here in staging the quicker we
> can get this out of staging where the ABI can be locked down.
> ION_IOC_VERSION should solve this anyway.

If there is real momentum to destaging and locking the ABI down,
that's great! I just want to avoid lots of little incompatible changes
that don't get us fully out of staging and cause tons of pain for
folks trying to make it work (because at that point, its easier for
folks to stick to their own out of tree solutions).

> > So my initial thought is we simply use a /dev/ion_heaps/ dir which has
> > a list of heap devicenodes. /dev/ion goes away.
> >
> > Currently ION_IOC_HEAP_QUERY returns:
> > char name[MAX_HEAP_NAME];
> > __u32 type;
> > __u32 heap_id;
> >
> > The names are discoverable via "ls /dev/ion_heaps/"
> >
> > The heap_id is really only useful as a handle, and after opening the
> > heap device, we'll have the fd to use.
> >
> So why have heap_id at all then?

Good question! I'm hoping we can yank them, though internally I
didn't quite get there with my first patchset. :)

> > But to match the use case you describe:
> > 1) ls /dev/ion_heaps/ for a list of heaps
> Yuk, dirent.h and friends :(

Yea, its not super fun, but its a standard interface, and the ugly
bits can be done once in the helper library.

> > Does that sound reasonable? And I don't really mean to dismiss the
> > dynamic picking of the best heap part, and having something like a
> > opaque constraints bitfield that each device and each heap export so
> > userland can match things up would be great. But since we don't have
> > any real solutions there yet(still!), it seems like most gralloc
> > implementations are likely to be fully knowing which heap they want at
> > allocation time.
> >
> I think you already touched on my main issue with this, the dynamic
> picking not supported. Well, like you said it doesn't really exist now
> either. And this doesn't look to stop one from adding it as some ioctl
> extensions..
> Okay, looks like you posted an RFC, lets move the discussion over to
> that thread.

Sounds good. I look forward to your input!