summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/etnaviv
AgeCommit message (Collapse)Author
2018-03-09drm/etnaviv: add PTA handling to MMUv2Lucas Stach
The Page Table Array is a new first level structure above the MTLB availabale on GPUs with the security feature. Use the PTa to set up the MMU when the security related states are handled by the kernel driver. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: add function to load the initial PTA stateLucas Stach
On GPUs with the security feature the MTLB config is stored in the PTA. Add a function to trigger the initial PTA load through the FE. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: handle security statesLucas Stach
GPUs with support for the security features need some additional setup to get the frontend started. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: add security handling mode enumLucas Stach
With the introduction of GPU security we have 3 different modes of GPU operation: - GPU core doesn't have security features -> no handling required - the security related states are handled by the kernel driver - the security related states are handled by a TrustZone application Add a enum to differentiate between the different operation modes. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: add hardware databaseLucas Stach
New versions of the Vivante kernel driver don't trust the hardware feature bits anymore, but use an internal hardware database. This also includes more feature fields than are available in hardware. As we can't trust the hardware feature bits to be correct anymore, we need to replicate the HWDB in etanviv. For now only the GC7000L as found on the i.MX8M is supported. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: add more minor features fieldsLucas Stach
Newer GPU cores added yet more feature bits. Make room for them and let userspace query them. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: update hardware headers from rnndbLucas Stach
Update the state HI and common header from rnndb commit 8478eef32fd9 (rnndb: document secure GPU reset bit). Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: add support for slave interface clockLucas Stach
The slave interface clock is a clock input found on newer cores to gate the register interface. For now we simply ungate it when the GPU is in active state. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-03-09drm/etnaviv: split out and optimize MMU fault dumpingLucas Stach
Split out the fault dumping, as this will get more complex in the future. Also there is no need to read and dump the fault address from MMUs that didn't signal a fault. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: remove the need for a gpu-subsystem DT nodeLucas Stach
The module autoloading can be triggered through the GPU core nodes and the necessary platform device for the DRM toplevel device will be instantiated on module init. Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Rob Herring <robh@kernel.org>
2018-02-12drm/etnaviv: use correct format specifier for size_tLucas Stach
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: replace hangcheck with scheduler timeoutLucas Stach
This replaces the etnaviv internal hangcheck logic with the job timeout handling provided by the DRM scheduler. This simplifies the driver further and allows to replay jobs after a GPU reset, so only minimal state is lost. This introduces a user-visible change in that we don't allow jobs to run indefinitely as long as they make progress anymore, as this introduces quality of service issues when multiple processes are using the GPU. Userspace is now responsible to flush jobs in a way that the finish in a reasonable time, where reasonable is currently defined as less than 500ms. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: lock BOs after all other submit work is doneLucas Stach
Populating objects, adding them to the GPU VM and patching/validating the command stream might take a lot of CPU time. There is no reason to hold all object reservations during that time. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: move dependency handling to schedulerLucas Stach
Move the fence dependency handling to the scheduler where it belongs. Jobs with unsignaled dependencies just get to sit in the scheduler queue without holding any locks. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: hook up DRM GPU schedulerLucas Stach
This hooks in the DRM GPU scheduler. No improvement yet, as all the dependency handling is still done in etnaviv_gem_submit. This just replaces the actual GPU submit by passing through the scheduler. Allows to get rid of the retire worker, as this is now driven by the scheduler. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: track fences by IDR instead of seqnoLucas Stach
This moves away from using the internal seqno as the userspace fence reference. By moving to a generic ID, we can later replace the internal fence by something different than the etnaviv seqno fence. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-02-12drm/etnaviv: add missing major features field to debugfsLucas Stach
This can be useful when dealing with a new GPU core. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: don't fail to build on arches without PHYS_OFFSETLucas Stach
Some architecture ports like ARC don't provide the PHYS_OFFSET symbol. Define it to 0 in that case, which is the most conservative default in the usage context of the etnaviv driver. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-02-12drm/etnaviv: make local symbols staticWei Yongjun
Fixes the following sparse warnings: drivers/gpu/drm/etnaviv/etnaviv_iommu.c:161:39: warning: symbol 'etnaviv_iommuv1_ops' was not declared. Should it be static? drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c:239:39: warning: symbol 'etnaviv_iommuv2_ops' was not declared. Should it be static? Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: use memset32 to init pagetableLucas Stach
Now that memset32 is available, the open-coded pagetable initialization loop can be replaced. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move submit free out of critical sectionLucas Stach
There is no need to hold the GPU lock while freeing the submit object. Only move the retired submits from the GPU active list to a temporary retire list under the GPU lock. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: re-enable perfmon supportLucas Stach
Now that the PMR lifetime issues are solved we can safely re-enable performance counter profiling support. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: couple runtime PM management to submit object lifetimeLucas Stach
As long as there is an active submit, we want the GPU to stay awake. This is slightly complicated by the fact that we really want to wake the GPU at the last possible moment to achieve maximum power savings. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move GPU active handling to bo pin/unpinLucas Stach
The active count is used to check if the BO is idle, where idle is defined as not active on the GPU and all VM mappings and reference counts dropped to the initial state. As the idling of the mappings and references now only happens in the submit cleanup, the active state handling must be moved to the same location in order to keep the userspace semantics. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move cmdbuf into submit objectLucas Stach
Less dynamic allocations and slims down the cmdbuf object to only the required information, as everything else is already available in the submit object. This also simplifies buffer and mappings lifetime management, as they are now exlusively attached to the submit object and not additionally to the cmdbuf. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: use submit exec_state for perfmon samplingLucas Stach
The GPU exec state may have changed at the time when the perfmon sampling is done, as it reflects the state of the last submission, not the current GPU execution state. So for proper sampling we must use the submit exec_state. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move exec_state to submit objectLucas Stach
We'll need this in some places where only the submit is available. Also this is a first step at slimming down the cmdbuf object. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move PMRs to submit objectLucas Stach
To make them available to the event worker even after the actual command stream execution has finished. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: refcount the submit objectLucas Stach
The submit object lifetime will get extended to the actual GPU execution. As multiple users will depend on this, add a kref to properly control destruction of the object. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: move ww_acquire_ctx out of submit objectLucas Stach
The acquire_ctx is special in that it needs to be released from the same thread as has been used to initialize it. This collides with the intention to extend the submit lifetime beyond the gem_submit function with potentially other threads doing the final cleanup. Move the ww_acquire_ctx to the function local stack as suggested in the documentation. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: move object unpinning to submit cleanupLucas Stach
This is safe to call in all paths, as the BO_PINNED flag tells us if the BO needs unpinning. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: attach in fence to submit and move fence wait to fence_syncLucas Stach
Simplifies the cleanup path and moves fence waiting to a central location. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: rename submit fence to out_fenceLucas Stach
This is the fence passed out on a sucessful GPU submit. Make the name more clear. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: move object fence attachment to gem_submit pathLucas Stach
The object fencing has nothing to do with the actual GPU buffer submit, so move it to the gem submit path to have a cleaner split. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: simplify submit_createLucas Stach
Use kzalloc so other code doesn't need to worry about uninitialized members. Drop the non-standard GFP flags, as we really don't want to fail the submit when under slight memory pressure. Remove one level of indentation by using an early return if the allocation failed. Also remove the unused drm device member. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: add lockdep annotations to buffer manipulation functionsLucas Stach
When manipulating the kernel command buffer the GPU mutex must be held, as otherwise different callers might try to replace the same part of the buffer, wreacking havok in the GPU execution. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: hold GPU lock while inserting END commandLucas Stach
Inserting the END command when suspending the GPU is changing the command buffer state, which requires the GPU to be held. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-01-02drm/etnaviv: move workqueue to be per GPULucas Stach
While the etnaviv workqueue needs to be ordered, as we rely on work items being executed in queuing order, this is only true for a single GPU. Having a shared workqueue for all GPUs in the system limits concurrency artificially. Getting each GPU its own ordered workqueue still meets our ordering expectations and enables retire workers to run concurrently. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: remove switch_context member from etnaviv_gpuLucas Stach
There is no need to store this in the gpu struct. MMU flushes are triggered correctly in reaction to MMU maps and unmaps, independent of the current ctx. Any required pipe switches can be infered from the current and the desired GPU exec state. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-01-02drm/etnaviv: don't flush workqueue in etnaviv_gpu_wait_obj_inactiveLucas Stach
There is no need to synchronize with oustanding retire jobs if the object has gone idle. Retire jobs only ever change the object state from active to idle, not the other way around. The IOVA put race is uncritical, as the GEM_WAIT ioctl itself is holding a reference to the GEM object, so the retire worker will not pull the object into the CPU domain, which is the thing we are trying to guard against with etnaviv_gpu_wait_obj_inactive. The ordering of the various counts and waits may change a bit, but the userspace visible behavior at the bounds of the syscall are unchanged. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: remove stale TODO in etnaviv_gpu_submitLucas Stach
Flush and prefetch are properly handled in the buffer code, data endianess would need much wider changes than adding something to this single function. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-01-02drm/etnaviv: remove -EAGAIN handling from submit pathLucas Stach
Now that the userptr BO handling doesn't rely on the userspace restarting the submit after object population, there is no need to special case the -EAGAIN return value anymore. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: get rid of userptr workerLucas Stach
All code paths which populate userptr BOs are fine with the get_pages function taking the mmap_sem lock. This allows to get rid of the pretty involved architecture with a worker being scheduled if the mmap_sem needs to be taken, but instead call GUP directly and allow it to take the lock if necessary. This simplifies the code a lot and removes the possibility of this function returning -EAGAIN, which complicates object population handling at the callers. A notable change in behavior is that we don't allow a process to populate objects with user pages from a foreign MM anymore. This would have been an invalid use before, as it breaks the assumptions made in the etnaviv kernel driver to enfore cache coherence. We now disallow this by rejecting the request to populate those objects. Well behaving userspace is unaffected by this change. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2018-01-02drm/etnaviv: change return type of etnaviv_gem_obj_add to voidLucas Stach
This function never fails, as it does nothing more than adding the GEM object to the global device list. Making this explicit through the void return type allows to drop some unnecessary error handling. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: fold __etnaviv_gem_new into callerLucas Stach
This function has only one caller and it isn't expected that there will be any more in the future. Folding this function into the caller is helping the readability. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-01-02drm/etnaviv: add lockdep annotation for userptr object populationLucas Stach
The current userptr page population will defer work to a work item if needed to avoid ever taking the mmap_sem in the direct call path. With the more fine-grained locking in etnaviv this isn't needed anymore, so a future commit will simplify this code. Add a lockdep annotation to validate the assumption that the mmap_sem can be taken in the direct call path. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2018-01-02drm/etnaviv: split obj locks in different classes depending on the obj typeLucas Stach
Userptr, prime and shmem buffer objects have different lock ordering requirements. This is mostly due to the fact that we don't allow to mmap userptr buffers, so we won't ever end up in our fault handler for those, so some of the code paths are never called with the mmap_sem held. To avoid lockdep false positives, split them up into different lock classes. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
2018-01-02drm/etnaviv: fix GPU vs sync point raceLucas Stach
If the FE is restarted before the sync point event is cleared, the GPU might trigger a completion IRQ for the next sync point, corrupting the state of the currently running worker. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2017-12-01drm/etnaviv: make THERMAL selectablePhilipp Zabel
The etnaviv driver causes a link failure if it is built-in but THERMAL is built as a module: drivers/gpu/drm/etnaviv/etnaviv_gpu.o: In function `etnaviv_gpu_bind': etnaviv_gpu.c:(.text+0x4c4): undefined reference to `thermal_of_cooling_device_register' etnaviv_gpu.c:(.text+0x600): undefined reference to `thermal_cooling_device_unregister' drivers/gpu/drm/etnaviv/etnaviv_gpu.o: In function `etnaviv_gpu_unbind': etnaviv_gpu.c:(.text+0x2aac): undefined reference to `thermal_cooling_device_unregister' Adding a Kconfig dependency on THERMAL || !THERMAL to avoid this causes a dependency loop on x86_64: drivers/gpu/drm/tve200/Kconfig:1:error: recursive dependency detected! For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/gpu/drm/tve200/Kconfig:1: symbol DRM_TVE200 depends on CMA For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" mm/Kconfig:489: symbol CMA is selected by DRM_ETNAVIV For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/gpu/drm/etnaviv/Kconfig:2: symbol DRM_ETNAVIV depends on THERMAL For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/thermal/Kconfig:5: symbol THERMAL is selected by ACPI_VIDEO For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/acpi/Kconfig:189: symbol ACPI_VIDEO is selected by BACKLIGHT_CLASS_DEVICE For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/video/backlight/Kconfig:158: symbol BACKLIGHT_CLASS_DEVICE is selected by DRM_PARADE_PS8622 For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/gpu/drm/bridge/Kconfig:62: symbol DRM_PARADE_PS8622 depends on DRM_BRIDGE For a resolution refer to Documentation/kbuild/kconfig-language.txt subsection "Kconfig recursive dependency limitations" drivers/gpu/drm/bridge/Kconfig:1: symbol DRM_BRIDGE is selected by DRM_TVE200 To work around this, add a new option DRM_ETNAVIV_THERMAL to optionally enable thermal throttling support and make DRM_ETNAVIV select THERMAL at the same time. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
2017-12-01drm/etnaviv: Improve unlocking of a mutex in etnaviv_iommu_map_gem()Markus Elfring
Add a jump target so that a call of the function "mutex_unlock" is stored only once at the end of this function implementation. Replace three calls by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>