linux-2.6-microblaze.git
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_dynamic_mg_power_gating()
Tom St Denis [Thu, 31 Aug 2017 13:31:23 +0000 (09:31 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_dynamic_mg_power_gating()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_static_mg_power_gating()
Tom St Denis [Thu, 31 Aug 2017 13:31:01 +0000 (09:31 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_static_mg_power_gating()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_pipeline_powergating()
Tom St Denis [Thu, 31 Aug 2017 13:27:22 +0000 (09:27 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_pipeline_powergating()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_cg_power_gating()
Tom St Denis [Thu, 31 Aug 2017 13:14:41 +0000 (09:14 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_gfx_cg_power_gating()

Make it consistent in style with the other CG/PG enable functions...

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_cp_power_gating()
Tom St Denis [Thu, 31 Aug 2017 13:12:47 +0000 (09:12 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_cp_power_gating()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_sck_slow_down_on_power_down()
Tom St Denis [Thu, 31 Aug 2017 13:02:33 +0000 (09:02 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_sck_slow_down_on_power_down()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_sck_slow_down_on_power_up()
Tom St Denis [Thu, 31 Aug 2017 13:01:11 +0000 (09:01 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_sck_slow_down_on_power_up()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_enable_save_restore_machine()
Tom St Denis [Thu, 31 Aug 2017 12:59:00 +0000 (08:59 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_enable_save_restore_machine()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up gfx_v9_0_ngg_en()
Tom St Denis [Thu, 31 Aug 2017 12:50:23 +0000 (08:50 -0400)]
drm/amd/amdgpu: Tidy up gfx_v9_0_ngg_en()

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Tidy up register list formatting.
Tom St Denis [Thu, 31 Aug 2017 12:41:54 +0000 (08:41 -0400)]
drm/amd/amdgpu: Tidy up register list formatting.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: bump version for support of local BOs
Christian König [Tue, 29 Aug 2017 14:14:32 +0000 (16:14 +0200)]
drm/amdgpu: bump version for support of local BOs

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: add IOCTL interface for per VM BOs v3
Christian König [Fri, 25 Aug 2017 07:14:43 +0000 (09:14 +0200)]
drm/amdgpu: add IOCTL interface for per VM BOs v3

Add the IOCTL interface so that applications can allocate per VM BOs.

Still WIP since not all corner cases are tested yet, but this reduces average
CS overhead for 10K BOs from 21ms down to 48us.

v2: add some extra checks, remove the WIP tag
v3: rename new flag to AMDGPU_GEM_CREATE_VM_ALWAYS_VALID

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: add support for per VM BOs v2
Christian König [Wed, 16 Aug 2017 09:13:48 +0000 (11:13 +0200)]
drm/amdgpu: add support for per VM BOs v2

Per VM BOs are handled like VM PDs and PTs. They are always valid and don't
need to be specified in the BO lists.

v2: validate PDs/PTs first

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: restrict userptr even more
Christian König [Tue, 29 Aug 2017 14:07:31 +0000 (16:07 +0200)]
drm/amdgpu: restrict userptr even more

Don't allow them to be GEM imported into another process.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix new PD update code for Vega10 v2
Christian König [Thu, 31 Aug 2017 08:46:20 +0000 (10:46 +0200)]
drm/amdgpu: fix new PD update code for Vega10 v2

We need to refer to the parent instead of the root BO for multi
level page tables on Vega10. Also don't set the PDE_PTE bit.

v2: Don't set the PDE_PTE bit either.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: move hw generation check into amdgpu_doorbell_init v2
Christian König [Thu, 8 Jun 2017 09:15:16 +0000 (11:15 +0200)]
drm/amdgpu: move hw generation check into amdgpu_doorbell_init v2

This way we can safely call it on SI as well.

v2: fix type in commit message

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: cleanup the VM code a bit more
Christian König [Wed, 30 Aug 2017 13:38:45 +0000 (15:38 +0200)]
drm/amdgpu: cleanup the VM code a bit more

The src isn't used any more after GART hack removal.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: rework page directory filling v2
Christian König [Wed, 9 Aug 2017 12:15:46 +0000 (14:15 +0200)]
drm/amdgpu: rework page directory filling v2

Keep track off relocated PDs/PTs instead of walking and checking all PDs.

v2: fix root PD handling

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay/hwmgr: Remove null check before kfree
Himanshu Jha [Tue, 29 Aug 2017 13:12:27 +0000 (18:42 +0530)]
drm/amd/powerplay/hwmgr: Remove null check before kfree

kfree on NULL pointer is a no-op and therefore checking is redundant.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd: Remove null check before kfree
Himanshu Jha [Tue, 29 Aug 2017 13:21:27 +0000 (18:51 +0530)]
drm/amd: Remove null check before kfree

Kfree on NULL pointer is a no-op and therefore checking is redundant.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: track evicted page tables v2
Christian König [Thu, 3 Aug 2017 12:02:13 +0000 (14:02 +0200)]
drm/amdgpu: track evicted page tables v2

Instead of validating all page tables when one was evicted,
track which one needs a validation.

v2: simplify amdgpu_vm_ready as well

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix comment on amdgpu_bo_va
Christian König [Mon, 28 Aug 2017 12:46:40 +0000 (14:46 +0200)]
drm/amdgpu: fix comment on amdgpu_bo_va

Except for the reference count all other members are protected
by the VM PD being reserved.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: add bo_va cleared flag again v2
Christian König [Tue, 15 Aug 2017 15:08:12 +0000 (17:08 +0200)]
drm/amdgpu: add bo_va cleared flag again v2

We changed this to use an extra list a while back, but for the next
series I need a separate flag again.

v2: reorder to avoid unlocked list access

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: rework moved handling in the VM v2
Christian König [Wed, 23 Aug 2017 14:13:33 +0000 (16:13 +0200)]
drm/amdgpu: rework moved handling in the VM v2

Instead of using the vm_state use a separate flag to note
that the BO was moved.

v2: reorder patches to avoid temporary lockless access

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Add write() method to VRAM debugfs entry (v2)
Tom St Denis [Tue, 29 Aug 2017 12:36:52 +0000 (08:36 -0400)]
drm/amd/amdgpu: Add write() method to VRAM debugfs entry (v2)

Allows writing data to vram via debugfs.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
(v2):  Call get_user before holding spinlock.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: notify smu once display changed on Rv.
Rex Zhu [Fri, 25 Aug 2017 08:58:10 +0000 (16:58 +0800)]
drm/amd/powerplay: notify smu once display changed on Rv.

when User turn off display or screen idle timeout,
smu need this message to start S0i2 entry.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: add dummy pp table for raven. (v2)
Rex Zhu [Thu, 24 Aug 2017 05:29:52 +0000 (13:29 +0800)]
drm/amd/powerplay: add dummy pp table for raven. (v2)

As there is no PPTable in RV, it is difficult to
cleanly decouple PPTABLE functionality in existing
codes.

v2: agd: squash in clean build fix

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: refine pp code for raven
Rex Zhu [Fri, 25 Aug 2017 07:51:03 +0000 (15:51 +0800)]
drm/amd/powerplay: refine pp code for raven

delete useless code.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/gfx9: adjust mqd allocation size
Alex Deucher [Sat, 19 Aug 2017 03:52:37 +0000 (23:52 -0400)]
drm/amdgpu/gfx9: adjust mqd allocation size

To allocate additional space for the dynamic cu masks.
Confirmed with the hw team that we only need 1 dword
for the mask.  The mask is the same for each SE so
you only need 1 dword.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/gfx9: update mqd to include dynamic CU mask
Alex Deucher [Sat, 19 Aug 2017 03:36:08 +0000 (23:36 -0400)]
drm/amdgpu/gfx9: update mqd to include dynamic CU mask

Necessary for proper operation with KIQ.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/gfx8: drop cz mqd
Alex Deucher [Thu, 24 Aug 2017 20:47:15 +0000 (16:47 -0400)]
drm/amdgpu/gfx8: drop cz mqd

It was unused and according to hw team, it's the same for
all asics in a gfx family so remove it.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/gfx8: apply dynamic cu mask to APUs as well
Alex Deucher [Thu, 24 Aug 2017 20:46:29 +0000 (16:46 -0400)]
drm/amdgpu/gfx8: apply dynamic cu mask to APUs as well

Confirmed with the hw team.  It's the same for all asics.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/powerplay/vega10: fix typo in register base index
Alex Deucher [Thu, 24 Aug 2017 20:04:50 +0000 (16:04 -0400)]
drm/amdgpu/powerplay/vega10: fix typo in register base index

Probably a copy pasta.  No functional difference, both have
the same value.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reported-by: Michael von Khurja <mvonkhurja@techpowerup.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: cleanup GWS, GDS and OA allocation
Christian König [Wed, 23 Aug 2017 18:11:25 +0000 (20:11 +0200)]
drm/amdgpu: cleanup GWS, GDS and OA allocation

Those are certainly not kernel allocations, instead set the NO_CPU_ACCESS flag.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix and cleanup VM ready check
Christian König [Thu, 24 Aug 2017 10:32:55 +0000 (12:32 +0200)]
drm/amdgpu: fix and cleanup VM ready check

Stop checking the mapped BO itself, cause that one is
certainly not a page table.

Additional to that move the code into amdgpu_vm.c

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix amdgpu_vm_bo_map trace point
Christian König [Wed, 23 Aug 2017 12:05:48 +0000 (14:05 +0200)]
drm/amdgpu: fix amdgpu_vm_bo_map trace point

That somehow got lost.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Move VBIOS version to sysfs
Kent Russell [Tue, 22 Aug 2017 16:31:43 +0000 (12:31 -0400)]
drm/amdgpu: Move VBIOS version to sysfs

sysfs is more stable, and doesn't require root to access

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Add debugfs file for VBIOS and version
Kent Russell [Tue, 22 Aug 2017 16:31:43 +0000 (12:31 -0400)]
drm/amdgpu: Add debugfs file for VBIOS and version

Add 2 debugfs files, one that contains the VBIOS version, and one that
contains the VBIOS itself. These won't change after initialization,
so we can add the VBIOS version when we parse the atombios information.

This ensures that we can find out the VBIOS version, even when the dmesg
buffer fills up, and makes it easier to associate which VBIOS version is
for which GPU on mGPU configurations. Set the size to 20 characters in
case of some weird VBIOS version that exceeds the expected 17 character
format (3-8-3\0). The VBIOS dump also allows for easy debugging

    v2: Move to debugfs, clarify commit message, add VBIOS dump file

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/ttm: Remove needless 'extern' on functions in header.
Tom St Denis [Thu, 24 Aug 2017 10:46:39 +0000 (06:46 -0400)]
drm/ttm: Remove needless 'extern' on functions in header.

Minor tidy up.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/radeon: use new TTM populate/dma map helper functions
Tom St Denis [Fri, 18 Aug 2017 14:06:34 +0000 (10:06 -0400)]
drm/radeon: use new TTM populate/dma map helper functions

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Use new TTM populate/map helper function
Tom St Denis [Fri, 18 Aug 2017 14:05:48 +0000 (10:05 -0400)]
drm/amd/amdgpu: Use new TTM populate/map helper function

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/ttm: Add helper functions to populate/map in one call (v2)
Tom St Denis [Fri, 18 Aug 2017 14:04:57 +0000 (10:04 -0400)]
drm/ttm: Add helper functions to populate/map in one call (v2)

These functions replace a section of common code found
in radeon/amdgpu drivers (and possibly others) as part
of the ttm_tt_*populate() callbacks.

v2: squash in fix for sw iommu from Tom

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/include: Add hdmi_redriver_set to atomfirmware
Harry Wentland [Mon, 21 Aug 2017 19:43:32 +0000 (15:43 -0400)]
drm/amd/include: Add hdmi_redriver_set to atomfirmware

We'll need this for a some upcoming display changes

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: Remove AMDGPU tracepoint and use new TTM tracepoint (v2)
Tom St Denis [Wed, 23 Aug 2017 19:33:40 +0000 (15:33 -0400)]
drm/amd/amdgpu: Remove AMDGPU tracepoint and use new TTM tracepoint (v2)

Switches the AMDGPU driver over to the TTM tracepoint and removes
our old one.  Now you can enable traces before loading the module
and trace all mappings.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(v2): Use struct device instead of pci in trace.

6 years agodrm/ttm: Add DMA map/unmap tracepoint (v3)
Tom St Denis [Wed, 23 Aug 2017 19:17:47 +0000 (15:17 -0400)]
drm/ttm: Add DMA map/unmap tracepoint (v3)

Also exports two functions that vendor drivers can call
to trace DMA mappings.  This is meant to help translate
IOMMU mappings of bus addresses back to physical pages.

Used by the umr amdgpu debugger for instance.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(v2): Use dev_name() to get PCI path instead.
(v3): Use correct types for dma/phys addresses

6 years agodrm/amdgpu: support polaris10/11/12 new cp firmwares
Evan Quan [Fri, 18 Aug 2017 08:46:47 +0000 (16:46 +0800)]
drm/amdgpu: support polaris10/11/12 new cp firmwares

Newer versions of the CP firmware require changes in how the driver
initializes the hw block.
Change the firmware name for new firmware to maintain compatibility with
older kernels.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: remove duplicate return statement
Colin Ian King [Wed, 23 Aug 2017 13:17:40 +0000 (14:17 +0100)]
drm/amdgpu: remove duplicate return statement

Remove a redundant identical return statement, it has no use.

Detected by CoverityScan, CID#1454586 ("Structurally dead code")

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: check memory allocation failure
Christophe JAILLET [Wed, 23 Aug 2017 05:52:36 +0000 (07:52 +0200)]
drm/amdgpu: check memory allocation failure

Check memory allocation failure and return -ENOMEM in such a case.

'num_post_dep_syncobjs' still has to be set to 0 before the test in order
to have it initialized if 'amdgpu_cs_parser_fini()' is called to free
resources.

The calling graph would be, in such a case!
   failure in amdgpu_cs_process_syncobj_out_dep()
      ---> error code returned by amdgpu_cs_dependencies()
         --> amdgpu_cs_parser_fini() is called

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/amdgpu: fix BANK_SELECT on Vega10 (v2)
Roger He [Thu, 24 Aug 2017 06:57:57 +0000 (14:57 +0800)]
drm/amd/amdgpu: fix BANK_SELECT on Vega10 (v2)

BANK_SELECT should always be FRAGMENT_SIZE + 3 due to 8-entry (2^3)
per cache line in L2 TLB for Vega10.

v2: agd: fix warning

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: inline amdgpu_ttm_do_bind again
Christian König [Tue, 22 Aug 2017 19:04:47 +0000 (21:04 +0200)]
drm/amdgpu: inline amdgpu_ttm_do_bind again

The function is called only once and doesn't do anything special.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix amdgpu_ttm_bind
Christian König [Tue, 22 Aug 2017 14:58:07 +0000 (16:58 +0200)]
drm/amdgpu: fix amdgpu_ttm_bind

Use ttm_bo_mem_space instead of manually allocating GART space.

This allows us to evict BOs when there isn't enought GART space any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: remove the GART copy hack
Christian König [Tue, 22 Aug 2017 10:50:46 +0000 (12:50 +0200)]
drm/amdgpu: remove the GART copy hack

This isn't used since we don't map evicted BOs to GART any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/ttm:fix wrong decoding of bo_count
Monk Liu [Thu, 10 Aug 2017 12:38:41 +0000 (20:38 +0800)]
drm/ttm:fix wrong decoding of bo_count

we observe abnormal number from:
/sys/devices/virtual/drm/amdttm/buffer_objects/bo_count

bo_count is atomic_inc which is "int" type,
shouldn't explicitly turn it to unsigned long.

Signed-off-by: Monk Liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/ttm: fix missing inc bo_count
Monk Liu [Fri, 11 Aug 2017 05:50:51 +0000 (13:50 +0800)]
drm/ttm: fix missing inc bo_count

Signed-off-by: Monk Liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: set sched_hw_submission higher for KIQ (v3)
Alex Deucher [Tue, 22 Aug 2017 20:39:30 +0000 (16:39 -0400)]
drm/amdgpu: set sched_hw_submission higher for KIQ (v3)

KIQ doesn't really use the GPU scheduler.  The base
drivers generally use the KIQ ring directly rather than
submitting IBs.  However, amdgpu_sched_hw_submission
(which defaults to 2) limits the number of outstanding
fences to 2.  KFD uses the KIQ for TLB flushes and the
2 fence limit hurts performance when there are several KFD
processes running.

v2: move some expressions to one line
    change KIQ sched_hw_submission to at least 16
v3: bump to 256

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: move default gart size setting into gmc modules
Alex Deucher [Tue, 22 Aug 2017 17:06:30 +0000 (13:06 -0400)]
drm/amdgpu: move default gart size setting into gmc modules

Move the asic specific code into the IP modules.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: refine default gart size
Alex Deucher [Tue, 22 Aug 2017 16:21:07 +0000 (12:21 -0400)]
drm/amdgpu: refine default gart size

Be more explicit and add comments explaining each case.
Also s/gart/GART/ in the parameter string as per Felix'
suggestion.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: ACG frequency added in PPTable
Evan Quan [Tue, 22 Aug 2017 03:19:10 +0000 (11:19 +0800)]
drm/amd/powerplay: ACG frequency added in PPTable

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: discard commands of killed processes
Christian König [Mon, 21 Aug 2017 12:27:51 +0000 (14:27 +0200)]
drm/amdgpu: discard commands of killed processes

When a process is killed we shouldn't submit all waiting jobs, but instead
clean up as fast as possible.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix and cleanup shadow handling
Christian König [Fri, 18 Aug 2017 13:50:17 +0000 (15:50 +0200)]
drm/amdgpu: fix and cleanup shadow handling

Set the shadow flag on the shadow and not the parent, always bind shadow BOs
during allocation instead of manually, use the reservation_object wrappers
to grab the lock.

This fixes a couple of issues with binding the shadow BOs as well as correctly
evicting them when memory becomes tight.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: add automatic per asic settings for gart_size
Alex Deucher [Mon, 21 Aug 2017 15:58:25 +0000 (11:58 -0400)]
drm/amdgpu: add automatic per asic settings for gart_size

We need a larger gart for asics that do not support GPUVM on all
engines (e.g., MM) to make sure we have enough space for all
gtt buffers in physical mode.  Change the default size based on
the asic type.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/gfx8: fix spelling typo in mqd allocation
Alex Deucher [Sat, 19 Aug 2017 03:39:52 +0000 (23:39 -0400)]
drm/amdgpu/gfx8: fix spelling typo in mqd allocation

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: unhalt mec after loading
Evan Quan [Thu, 17 Aug 2017 07:25:04 +0000 (15:25 +0800)]
drm/amd/powerplay: unhalt mec after loading

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/virtual_dce: Virtual display doesn't support disable vblank immediately
Emily Deng [Mon, 21 Aug 2017 01:51:10 +0000 (09:51 +0800)]
drm/amdgpu/virtual_dce: Virtual display doesn't support disable vblank immediately

For virtual display, it uses software timer to emulate the vsync interrupt,
it doesn't have high precision, so doesn't support disable vblank immediately.

BUG: SWDEV-129274

Signed-off-by: Emily Deng <Emily.Deng@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Fix huge page updates with CPU
Felix Kuehling [Thu, 17 Aug 2017 20:37:49 +0000 (16:37 -0400)]
drm/amdgpu: Fix huge page updates with CPU

Correctly detect system memory mappings when using CPU and don't use
huge pages for them.

Avoid incorrectly translating a physical page table GPU address when
splitting a huge page while mapping system memory.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agoMerge branch 'drm-vmwgfx-next' of git://people.freedesktop.org/~syeh/repos_linux...
Dave Airlie [Tue, 29 Aug 2017 00:38:14 +0000 (10:38 +1000)]
Merge branch 'drm-vmwgfx-next' of git://people.freedesktop.org/~syeh/repos_linux into drm-next

vmwgfx add fence fd support.

* 'drm-vmwgfx-next' of git://people.freedesktop.org/~syeh/repos_linux:
  drm/vmwgfx: Bump the version for fence FD support
  drm/vmwgfx: Add export fence to file descriptor support
  drm/vmwgfx: Add support for imported Fence File Descriptor
  drm/vmwgfx: Prepare to support fence fd
  drm/vmwgfx: Fix incorrect command header offset at restart
  drm/vmwgfx: Support the NOP_ERROR command
  drm/vmwgfx: Restart command buffers after errors
  drm/vmwgfx: Move irq bottom half processing to threads
  drm/vmwgfx: Don't use drm_irq_[un]install

6 years agoMerge tag 'exynos-drm-next-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel...
Dave Airlie [Tue, 29 Aug 2017 00:37:36 +0000 (10:37 +1000)]
Merge tag 'exynos-drm-next-for-v4.14' of git://git./linux/kernel/git/daeinki/drm-exynos into drm-next

Summary:
- Provide NV12MT pixel format support of Mixer driver in generic way.
- Refactor Exynos KMS drivers
  . Refactoring to panel detection way
  . Refactoring to setting up possible_crtcs
  . Refactoring to video and command mode support
- Some cleanups

* tag 'exynos-drm-next-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos:
  drm/exynos: simplify set_pixfmt() in DECON and FIMD drivers
  drm/exynos: consistent use of cpp
  drm/exynos: mixer: remove src offset from mixer_graph_buffer()
  drm/exynos: mixer: simplify mixer_graph_buffer()
  drm/exynos: mixer: simplify vp_video_buffer()
  drm/exynos: mixer: enable NV12MT support for the video plane
  drm/exynos: mixer: fix chroma comment in vp_video_buffer()
  arm64: dts: exynos: remove i80-if-timings nodes
  dt-bindings: exynos5433-decon: remove i80-if-timings property
  drm/exynos/decon5433: use mode info stored in CRTC to detect i80 mode
  drm/exynos: add mode_valid callback to exynos_drm
  drm/exynos/decon5433: refactor irq requesting code
  drm/exynos/mic: use mode info stored in CRTC to detect i80 mode
  drm/exynos/dsi: propagate info about command mode from panel
  drm/exynos/dsi: refactor panel detection logic
  drm/exynos: use helper to set possible crtcs
  drm/exynos/decon5433: use readl_poll_timeout helpers

6 years agoMerge tag 'drm-misc-next-fixes-2017-08-28' of git://anongit.freedesktop.org/git/drm...
Dave Airlie [Tue, 29 Aug 2017 00:36:06 +0000 (10:36 +1000)]
Merge tag 'drm-misc-next-fixes-2017-08-28' of git://anongit.freedesktop.org/git/drm-misc into drm-next

UAPI Changes:
- Rename u32 to __u32 in struct drm_format_modifier_blob (Lionel)

Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
* tag 'drm-misc-next-fixes-2017-08-28' of git://anongit.freedesktop.org/git/drm-misc:
  drm: rename u32 in __u32 in uapi

6 years agodrm/syncobj: Add a signal ioctl (v3)
Jason Ekstrand [Mon, 28 Aug 2017 21:10:28 +0000 (14:10 -0700)]
drm/syncobj: Add a signal ioctl (v3)

This IOCTL provides a mechanism for userspace to trigger a sync object
directly.  There are other ways that userspace can trigger a syncobj
such as submitting a dummy batch somewhere or hanging on to a triggered
sync_file and doing an import.  This just provides an easy way to
manually trigger the sync object without weird hacks.

The motivation for this IOCTL is Vulkan fences.  Vulkan lets you create
a fence already in the signaled state so that you can wait on it
immediatly without stalling.  We could also handle this with a new
create flag to ask the driver to create a syncobj that is already
signaled but the IOCTL seemed a bit cleaner and more generic.

v2:
 - Take an array of sync objects (Dave Airlie)
v3:
 - Throw -EINVAL if pad != 0

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Add a reset ioctl (v3)
Jason Ekstrand [Mon, 28 Aug 2017 21:10:27 +0000 (14:10 -0700)]
drm/syncobj: Add a reset ioctl (v3)

This just resets the dma_fence to NULL so it looks like it's never been
signaled.  This will be useful once we add the new wait API for allowing
wait on "submit and signal" behavior.

v2:
 - Take an array of sync objects (Dave Airlie)
v3:
 - Throw -EINVAL if pad != 0

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Christian König <christian.koenig@amd.com> (v1)
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Add a syncobj_array_find helper
Jason Ekstrand [Fri, 25 Aug 2017 17:52:26 +0000 (10:52 -0700)]
drm/syncobj: Add a syncobj_array_find helper

The wait ioctl has a bunch of code to read an syncobj handle array from
userspace and turn it into an array of syncobj pointers.  We're about to
add two new IOCTLs which will need to work with arrays of syncobj
handles so let's make some helpers.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Allow wait for submit and signal behavior (v5)
Jason Ekstrand [Fri, 25 Aug 2017 17:52:24 +0000 (10:52 -0700)]
drm/syncobj: Allow wait for submit and signal behavior (v5)

Vulkan VkFence semantics require that the application be able to perform
a CPU wait on work which may not yet have been submitted.  This is
perfectly safe because the CPU wait has a timeout which will get
triggered eventually if no work is ever submitted.  This behavior is
advantageous for multi-threaded workloads because, so long as all of the
threads agree on what fences to use up-front, you don't have the extra
cross-thread synchronization cost of thread A telling thread B that it
has submitted its dependent work and thread B is now free to wait.

Within a single process, this can be implemented in the userspace driver
by doing exactly the same kind of tracking the app would have to do
using posix condition variables or similar.  However, in order for this
to work cross-process (as is required by VK_KHR_external_fence), we need
to handle this in the kernel.

This commit adds a WAIT_FOR_SUBMIT flag to DRM_IOCTL_SYNCOBJ_WAIT which
instructs the IOCTL to wait for the syncobj to have a non-null fence and
then wait on the fence.  Combined with DRM_IOCTL_SYNCOBJ_RESET, you can
easily get the Vulkan behavior.

v2:
 - Fix a bug in the invalid syncobj error path
 - Unify the wait-all and wait-any cases
v3:
 - Unify the timeout == 0 case a bit with the timeout > 0 case
 - Use wait_event_interruptible_timeout
v4:
 - Use proxy fence
v5:
 - Revert to a combination of v2 and v3
 - Don't use proxy fences
 - Don't use wait_event_interruptible_timeout because it just adds an
   extra layer of callbacks

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Add a CREATE_SIGNALED flag
Jason Ekstrand [Fri, 25 Aug 2017 17:52:25 +0000 (10:52 -0700)]
drm/syncobj: Add a CREATE_SIGNALED flag

This requests that the driver create the sync object such that it
already has a signaled dma_fence attached.  Because we don't need
anything in particular (just something signaled), we use a dummy null
fence.  This is useful for Vulkan which has a similar flag that can be
passed to vkCreateFence.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Add a callback mechanism for replace_fence (v3)
Jason Ekstrand [Mon, 28 Aug 2017 14:39:25 +0000 (07:39 -0700)]
drm/syncobj: Add a callback mechanism for replace_fence (v3)

It is useful in certain circumstances to know when the fence is replaced
in a syncobj.  Specifically, it may be useful to know when the fence
goes from NULL to something valid.  This does make syncobj_replace_fence
a little more expensive because it has to take a lock but, in the common
case where there is no callback list, it spends a very short amount of
time inside the lock.

v2:
 - Don't lock in drm_syncobj_fence_get.  We only really need to lock
   around fence_replace to make the callback work.
v3:
 - Fix the cb_list comment to make kbuild happy

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: add sync obj wait interface. (v8)
Dave Airlie [Fri, 25 Aug 2017 17:52:22 +0000 (10:52 -0700)]
drm/syncobj: add sync obj wait interface. (v8)

This interface will allow sync object to be used to back
Vulkan fences. This API is pretty much the vulkan fence waiting
API, and I've ported the code from amdgpu.

v2: accept relative timeout, pass remaining time back
to userspace.
v3: return to absolute timeouts.
v4: absolute zero = poll,
    rewrite any/all code to have same operation for arrays
    return -EINVAL for 0 fences.
v4.1: fixup fences allocation check, use u64_to_user_ptr
v5: move to sec/nsec, and use timespec64 for calcs.
v6: use -ETIME and drop the out status flag. (-ETIME
is suggested by ickle, I can feel a shed painting)
v7: talked to Daniel/Arnd, use ktime and ns everywhere.
v8: be more careful in the timeout calculations
    use uint32_t for counter variables so we don't overflow
    graciously handle -ENOINT being returned from dma_fence_wait_timeout

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agoi915: Use drm_syncobj_fence_get
Jason Ekstrand [Fri, 25 Aug 2017 17:52:21 +0000 (10:52 -0700)]
i915: Use drm_syncobj_fence_get

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Add a race-free drm_syncobj_fence_get helper (v2)
Jason Ekstrand [Fri, 25 Aug 2017 17:52:20 +0000 (10:52 -0700)]
drm/syncobj: Add a race-free drm_syncobj_fence_get helper (v2)

The atomic exchange operation in drm_syncobj_replace_fence is sufficient
for the case where it races with itself.  However, if you have a race
between a replace_fence and dma_fence_get(syncobj->fence), you may end
up with the entire replace_fence happening between the point in time
where the one thread gets the syncobj->fence pointer and when it calls
dma_fence_get() on it.  If this happens, then the reference may be
dropped before we get a chance to get a new one.  The new helper uses
dma_fence_get_rcu_safe to get rid of the race.

This is also needed because it allows us to do a bit more than just get
a reference in drm_syncobj_fence_get should we wish to do so.

v2:
 - RCU isn't that scary
 - Call rcu_read_lock/unlock
 - Don't rename fence to _fence
 - Make the helper static inline

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Christian König <christian.koenig@amd.com> (v1)
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/syncobj: Rename fence_get to find_fence
Jason Ekstrand [Fri, 25 Aug 2017 17:52:19 +0000 (10:52 -0700)]
drm/syncobj: Rename fence_get to find_fence

The function has far more in common with drm_syncobj_find than with
any in the get/put functions.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Christian König <christian.koenig@amd.com> (v1)
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm: kirin: Add mode_valid logic to avoid mode clocks we can't generate
John Stultz [Tue, 22 Aug 2017 18:42:26 +0000 (11:42 -0700)]
drm: kirin: Add mode_valid logic to avoid mode clocks we can't generate

Currently the hikey dsi logic cannot generate accurate byte
clocks values for all pixel clock values. Thus if a mode clock
is selected that cannot match the calculated byte clock, the
device will boot with a blank screen.

This patch uses the new mode_valid callback (many thanks to
Jose Abreu for upstreaming it!) to ensure we don't select
modes we cannot generate.

Also, since the ade crtc code will adjust the mode in mode_set,
this patch also adds a mode_fixup callback which we use to make
sure we are validating the mode clock that will eventually be
used.

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
Cc: Rongrong Zou <zourongrong@gmail.com>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agodrm/vmwgfx: Bump the version for fence FD support
Sinclair Yeh [Wed, 5 Jul 2017 08:51:42 +0000 (01:51 -0700)]
drm/vmwgfx: Bump the version for fence FD support

Minor version bump to indicate support for fence FD

Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Singh Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add export fence to file descriptor support
Sinclair Yeh [Wed, 5 Jul 2017 08:49:32 +0000 (01:49 -0700)]
drm/vmwgfx: Add export fence to file descriptor support

Added code to link a fence to a out_fence_fd file descriptor and
thread out_fence_fd down to vmw_execbuf_copy_fence_user() so it can be
copied into the IOCTL reply and be passed back up the the user.

v2:
Make sure to sync and clean up in case of failure

Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Singh Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add support for imported Fence File Descriptor
Sinclair Yeh [Wed, 5 Jul 2017 08:45:40 +0000 (01:45 -0700)]
drm/vmwgfx: Add support for imported Fence File Descriptor

This allows vmwgfx to wait on a fence created by another
device.

v2:
* Remove special handling for vmwgfx fence and just use dma_fence_wait()
* Use interruptible waits
* Added function documentation

Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Singh Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Prepare to support fence fd
Sinclair Yeh [Wed, 5 Jul 2017 08:37:55 +0000 (01:37 -0700)]
drm/vmwgfx: Prepare to support fence fd

Make the fields and flags available.

Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Singh Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Fix incorrect command header offset at restart
Thomas Hellstrom [Thu, 24 Aug 2017 06:06:31 +0000 (08:06 +0200)]
drm/vmwgfx: Fix incorrect command header offset at restart

Sometimes it appears like the device modifies the command header offset
member. So explicitly clear it when restarting after an error.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
6 years agodrm/vmwgfx: Support the NOP_ERROR command
Thomas Hellstrom [Thu, 24 Aug 2017 06:06:30 +0000 (08:06 +0200)]
drm/vmwgfx: Support the NOP_ERROR command

Can be used by user-space applications to test and verify the kernel
command buffer error recovery functionality.

Malicious user-space apps could potentially use this command to slow down
graphics processing somewhat, but they could also accomplish the same thing
using a random malformed command so this should be considered safe.
At least as safe as it gets.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
6 years agodrm/vmwgfx: Restart command buffers after errors
Thomas Hellstrom [Thu, 24 Aug 2017 06:06:29 +0000 (08:06 +0200)]
drm/vmwgfx: Restart command buffers after errors

Previously we skipped the command buffer and added an extra fence to
avoid hangs due to skipped fence commands.
Now we instead restart the command buffer after the failing command,
if there are any commands left.
In addition we print out some information about the failing command
and its location in the command buffer.

Testing Done: ran glxgears using mesa modified to send the NOP_ERROR
command before each 10th clear and verified that we detected the device
error properly and that there were no other device errors caused by
incorrectly ordered command buffers. Also ran the piglit "quick" test
suite which generates a couple of device errors and verified that
they were handled as intended.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
6 years agodrm/vmwgfx: Move irq bottom half processing to threads
Thomas Hellstrom [Thu, 24 Aug 2017 06:06:28 +0000 (08:06 +0200)]
drm/vmwgfx: Move irq bottom half processing to threads

This gets rid of the irq bottom half tasklets and instead performs the
work needed in process context. We also convert irq-disabling spinlocks to
ordinary spinlocks.

This should decrease system latency for other system components, like
sound for example but has the potential to increase latency for processes
that wait on the GPU.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
6 years agodrm/vmwgfx: Don't use drm_irq_[un]install
Thomas Hellstrom [Thu, 24 Aug 2017 06:06:27 +0000 (08:06 +0200)]
drm/vmwgfx: Don't use drm_irq_[un]install

We're not allowed to change the upstream version of the drm_irq_install
function to be able to incorporate threaded irqs. So roll our own irq
install- and uninstall functions instead of relying on the drm core ones.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm: rename u32 in __u32 in uapi
Lionel Landwerlin [Thu, 24 Aug 2017 15:08:14 +0000 (16:08 +0100)]
drm: rename u32 in __u32 in uapi

All other fields use __

Cc: Ben Widawsky <ben@bwidawsk.net>
Fixes: db1689aa61b ("drm: Create a format/modifier blob")
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170824150814.5878-1-lionel.g.landwerlin@intel.com
6 years agodrm/exynos: simplify set_pixfmt() in DECON and FIMD drivers
Tobias Jakobi [Tue, 22 Aug 2017 14:19:44 +0000 (16:19 +0200)]
drm/exynos: simplify set_pixfmt() in DECON and FIMD drivers

DRM core already checks the validity of the pixelformat.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos: consistent use of cpp
Tobias Jakobi [Tue, 22 Aug 2017 14:19:43 +0000 (16:19 +0200)]
drm/exynos: consistent use of cpp

A recent commit (272725c7db4da1fd3229d944fc76d2e98e3a144e) has removed
the use of 'bits_per_pixel' in DRM. However the corresponding Exynos
driver code still uses the ambiguous 'bpp', even though it is now
initialized from fb->cpp[0].

Consistenly use 'cpp' in FIMD, DECON7 and DECON5433 drivers.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
6 years agodrm/exynos: mixer: remove src offset from mixer_graph_buffer()
Tobias Jakobi [Tue, 22 Aug 2017 14:19:40 +0000 (16:19 +0200)]
drm/exynos: mixer: remove src offset from mixer_graph_buffer()

We always translate the dma address such that the offsets of
the source image are zero. Hence we can remove manipulation of
the MXR_GRAPHIC_SXY(win) register and just zero them once
in mixer_win_reset().

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos: mixer: simplify mixer_graph_buffer()
Tobias Jakobi [Tue, 22 Aug 2017 14:19:39 +0000 (16:19 +0200)]
drm/exynos: mixer: simplify mixer_graph_buffer()

DRM core already checks in drm_atomic_plane_check() if the
pixelformat is valid. Hence we can collapse the default case
of the switch statement with the XRGB8888 case.

No functional change.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos: mixer: simplify vp_video_buffer()
Tobias Jakobi [Tue, 22 Aug 2017 14:19:38 +0000 (16:19 +0200)]
drm/exynos: mixer: simplify vp_video_buffer()

DRM core already checks in drm_atomic_plane_check() if the
pixelformat is valid. Hence we can drop the default case of
the switch statement and collapse most of the code.

Also rename the two booleans to reflect what true/false
actually means, and to avoid mixing CrCb/NV21 descriptions.

No functional change.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos: mixer: enable NV12MT support for the video plane
Tobias Jakobi [Tue, 22 Aug 2017 14:19:37 +0000 (16:19 +0200)]
drm/exynos: mixer: enable NV12MT support for the video plane

The video processor supports a tiled version of the NV12 format,
known as NV12MT in V4L2 terms. The support was removed in commit
083500baefd5f4c215a5a93aef2492c1aa775828 due to not being a real
pixel format, but rather NV12 with a special memory layout.

With the introduction of FB modifiers, we can now properly support
this format again.

Tested with a hacked up modetest from libdrm's test suite on
an ODROID-X2 (Exynos4412).

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos: mixer: fix chroma comment in vp_video_buffer()
Tobias Jakobi [Tue, 22 Aug 2017 14:19:36 +0000 (16:19 +0200)]
drm/exynos: mixer: fix chroma comment in vp_video_buffer()

The current comment sounds like the division op is done to
compensate for some hardware erratum. But the chroma plane
having half the height of the luma plane is just the way
NV12/NV21 is defined, so clarify this behaviour.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agoarm64: dts: exynos: remove i80-if-timings nodes
Andrzej Hajda [Thu, 24 Aug 2017 13:33:59 +0000 (15:33 +0200)]
arm64: dts: exynos: remove i80-if-timings nodes

Since i80/command mode is determined in runtime by propagating info
from panel this property can be removed.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodt-bindings: exynos5433-decon: remove i80-if-timings property
Andrzej Hajda [Thu, 24 Aug 2017 13:33:58 +0000 (15:33 +0200)]
dt-bindings: exynos5433-decon: remove i80-if-timings property

Since i80/command mode is determined in runtime by propagating info
from panel this property can be removed.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
6 years agodrm/exynos/decon5433: use mode info stored in CRTC to detect i80 mode
Andrzej Hajda [Thu, 24 Aug 2017 13:33:57 +0000 (15:33 +0200)]
drm/exynos/decon5433: use mode info stored in CRTC to detect i80 mode

Since panel's mode of work is propagated properly from panel to DECON,
there is no need to use redundant private device tree property.
The only issue with such approach is that check for required interrupts
should be postponed until panel communicate its requirements, ie to
mode validation phase - mode_valid callback.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
6 years agodrm/exynos: add mode_valid callback to exynos_drm
Andrzej Hajda [Thu, 24 Aug 2017 13:33:56 +0000 (15:33 +0200)]
drm/exynos: add mode_valid callback to exynos_drm

crtc::mode_valid callback is required to implement proper pipeline
validation for command/video modes. Since Exynos uses private
framework such callback should be added to it.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>