add to_prefetch(..) helper

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
fix almost all checkpatch warnings and errors

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
add flag to trigger mmu flush

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

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
add command sequence to flush mmu for IOMMUv2 (untested)

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: package up events into etnaviv_event struct

Combine the event data into an array of etnaviv_event structures,
rather than individual arrays.

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

get_pages() tries to convert a page array into a scatterlist.  If this
fails, we bail out without freeing the page array.  Add a call to
drm_gem_put_pages() to drop the reference gained in drm_gem_get_pages(),
indicating that we didn't access the pages.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: add gem operations structure to etnaviv objects

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: convert prime import to use etnaviv_gem_ops

Convert the prime import code to use etnaviv_gem_ops release method
to clean up the object.  This removes the prime specific code from
the generic object cleanup path.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: convert shmem release to use etnaviv_gem_ops

Convert the shmem object release to use the etnaviv_gem_ops release
method.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: convert cmdbuf release to use etnaviv_gem_ops

Convert the command buffer release handling to use the etnaviv_gem_ops
release method.

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

We always call drm_gem_object_release() from both etnaviv_free_cmd()
and etnaviv_free_obj().  Move this to the parent function so it is
done at one place only.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: ensure cleanup of reservation object

The embedded reservation object is always initialised whenever we create
an etnaviv buffer object, but it is not always cleaned up.  Arrange this
to be clearer: always initialise the embedded reservation object
directly, and always clean the embedded reservation object up when
removing a buffer object.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: move GPU memory management into MMU

The GPU memory management (managed by a drm_mm object) is used to
track which areas of the MMU address space are in-use.  Therefore,
this should be tied to the MMU object, rather than the GPU object.

This means we could (as comments suggest) have multiple MMU objects,
one for each context, and switch between them.  Each would need to
be managed by its own drm_mm object.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: publish and use mmu geometry

We model the GPU MMU using the iommu layer, which supports exporting
the iommu domain geometry.  Use this feature to publish the size of
the MMU window, and initialise the MMU drm_mm object according to
the available MMU window size.

As we only allocate a MMU page table which covers 256MB, yet we
initialised the drm_mm object to cover 1GB, this fixes an overflow
of the MMU page table array.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: mmuv1: ensure we unmap all entries

Ensure that we unmap all MMU entries when unmapping a region.  We
fail to do this because we assume that the return value from the
unmap method should be zero.  It should be the size of entry which
has been unmapped.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: remove presumption of BO addresses

We never pass the GPU addresses of BOs to userspace, so userspace can
never specify the correct address.  Hence, this code serves no useful
purpose, and can be removed.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: call the DRM device 'drm'

Call the DRM device 'drm' in the etnaviv_gpu structure, so that we can
add a struct device pointer.

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

Report messages against the component device rather than the subsystem
device, so that the component responsible for the message is identified
rather than having to be separately formatted in the string.  This
ensures that many of the debug messages are properly attributed to their
appropriate component, which is especially important when we have
multiple GPU cores in a SoC.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
staging: etnaviv: safely take down hangcheck

We need to synchronously take down the hangcheck timer, and then cancel
the recovery work when we're unbinding the GPU to avoid these timers and
workers running after we clean up.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>