staging: etnaviv: add gem get_pages() method

Provide a get_pages() method for gem objects, which allows our objects
to provide their own method to obtain the struct page array and
scatterlist.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: clean up etnaviv_gem_free_object()

As the tail of etnaviv_free_obj() is identical to etnaviv_free_cmd(),
we can eliminate etnaviv_free_obj() entirely by moving it into
etnaviv_gem_free_object().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
staging: etnaviv: move scatterlist creation to etnaviv_gem_get_pages()

Move the scatterlist creation from etnaviv_gem_shmem_get_pages() into
etnaviv_gem_get_pages() as we always want a scatterlist internally for
the IOMMU code.  It makes little sense to have each get_pages() method
re-implement this code.

However, we still allow a get_pages() method to override this by doing
their own initialisation of the etnaviv_obj->sgt pointer.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
make drm_ioctl_desc array more readable

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: add userptr mapping support

Add support for mapping userspace memory to the GPU.  This is useful for
cases where we have some malloc()'d memory which we wish to pass to the
GPU or shmem memory via Xv, and wish to avoid the overhead of an
additional memcpy(), especially as is is expensive to memcpy()ing a 1080p
frame.

This is mostly taken from the 3.17 i915 userptr implementation, except
we solve the held-mm problem in (imho) a nicer way, and we also avoid
excessive spinning with -EAGAIN waiting for the queued work to run.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: move scatterlist map/unmap

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: "better" DMA API usage

The DMA API usage by etnaviv is really not up to scratch.  It does not
respect the buffer ownership rules, which are vitally necessary when
using DMA_BIDIRECTIONAL, as mapping /only/ cleans the cache lines,
causing dirty data to be written back to RAM and an unmap /only/
invalidates them, causing any data in the cache to be discarded.  Given
the length of time which these objects remain mapped, we can't hold
them in the mapped state while hoping that no other CPU accesses to the
buffer occur.

This has lead to visible pixmap corruption in the X server.  Work around
this by mapping and then immediately unmapping the buffers.  This causes
data in the buffers to be written back and then purged from the caches.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
keep track of the used bo backend

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>