openwrt/staging/blogic.git
6 years agodrm/nouveau/nvif: remove const attribute from nvif_mclass
Nick Desaulniers [Fri, 15 Jun 2018 23:00:42 +0000 (16:00 -0700)]
drm/nouveau/nvif: remove const attribute from nvif_mclass

Similar to commit 0bf8bf50eddc ("module: Remove
const attribute from alias for MODULE_DEVICE_TABLE")

Fixes many -Wduplicate-decl-specifier warnings due to the combination of
const typeof() of already const variables.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/hwmon: potential uninitialized variables
Dan Carpenter [Wed, 11 Jul 2018 08:02:28 +0000 (11:02 +0300)]
drm/nouveau/hwmon: potential uninitialized variables

Smatch complains that "value" can be uninitialized when kstrtol()
returns -ERANGE.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau: Fix runtime PM leak in drm_open()
Lyude Paul [Thu, 12 Jul 2018 17:02:52 +0000 (13:02 -0400)]
drm/nouveau: Fix runtime PM leak in drm_open()

Noticed this as I was skimming through, if we fail to allocate memory
for cli we'll end up returning without dropping the runtime PM ref we
got. Additionally, we'll even return the wrong return code! (ret most
likely will == 0 here, we want -ENOMEM).

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/debugfs: Wake up GPU before doing any reclocking
Karol Herbst [Sat, 14 Jul 2018 10:52:09 +0000 (12:52 +0200)]
drm/nouveau/debugfs: Wake up GPU before doing any reclocking

Fixes various reclocking related issues on prime systems.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/bios/vpstate: There are some fermi vbios with no boost or tdp entry
Karol Herbst [Sat, 14 Jul 2018 10:52:08 +0000 (12:52 +0200)]
drm/nouveau/bios/vpstate: There are some fermi vbios with no boost or tdp entry

If the entry size is too small, default to invalid values for both
boost_id and tdp_id, so as to default to the base clock in both cases.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: Allow vblank_disable_immediate
Mario Kleiner [Mon, 16 Jul 2018 06:47:50 +0000 (16:47 +1000)]
drm/nouveau/kms/nv50-: Allow vblank_disable_immediate

With instantaneous high precision vblank timestamping
that updates at leading edge of vblank, the emulated
"hw vblank counter" from vblank timestamping, which
increments at leading edge of vblank, and reliable
page flip execution and completion at leading edge of
vblank, we should meet the requirements for fast/
immediate vblank irq disable/enable.

This is only allowed on nv50+ gpu's, ie. the ones with
atomic modesetting. One requirement for immediate vblank
disable is that high precision vblank timestamping works
reliably all the time on all connectors. This is not the
case on all pre-nv50 parts for analog VGA outputs, where we
currently don't always have support for scanout position
queries and therefore fall back to vblank interrupt
timestamping. The implementation in nv04_head_state() does
not return valid values for vblanks, vtotal, hblanks, htotal
for VGA outputs on all cards, but those are needed for scanout
position queries.

Testing on Linux-4.12-rc5 + drm-next on a GeForce 9500 GT
(NV G96) with timing measurement equipment indicates this
works fine, so allow immediate vblank disable for power
saving.

For debugging in case of unexpected trouble, booting
with kernel cmdline option drm.vblankoffdelay=0
(or echo 0 > /sys/module/drm/parameters/vblankoffdelay)
would keep vblank irqs permanently on to approximate old
behavior.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: remove duplicate assignment
Ben Skeggs [Mon, 18 Jun 2018 07:53:12 +0000 (17:53 +1000)]
drm/nouveau/kms/nv50-: remove duplicate assignment

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/kms/nv50-: fix drm-get-put.cocci warnings
kbuild test robot [Fri, 18 May 2018 16:51:32 +0000 (18:51 +0200)]
drm/nouveau/kms/nv50-: fix drm-get-put.cocci warnings

 Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and
 drm_*_unreference() helpers.

Generated by: scripts/coccinelle/api/drm-get-put.cocci

Fixes: 30ed49b55b6e ("drm/nouveau/kms/nv50-: move code underneath dispnv50/")
Signed-off-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/disp/nv50-gp10x: fix coverity warning
Ben Skeggs [Thu, 14 Jun 2018 22:02:33 +0000 (08:02 +1000)]
drm/nouveau/disp/nv50-gp10x: fix coverity warning

Change values to u32, there's no need for them to be 64-bit.

Reported-by: Colin Ian King <colin.king@canonical.com>
Suggested-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info()
Ben Skeggs [Thu, 14 Jun 2018 21:59:28 +0000 (07:59 +1000)]
drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info()

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/mmu/gp10b: remove ghost file
Jérôme Glisse [Thu, 7 Jun 2018 18:18:24 +0000 (14:18 -0400)]
drm/nouveau/mmu/gp10b: remove ghost file

This ghost file have been haunting us.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/secboot/tegra: Enable gp20b/gp10b firmware tag when relevant
Nicolas Chauvet [Sun, 10 Jun 2018 11:01:31 +0000 (13:01 +0200)]
drm/nouveau/secboot/tegra: Enable gp20b/gp10b firmware tag when relevant

This allows to have the related MODULE_FIRMWARE tag only
on relevant arch (arm64).
This will saves about 400k on initramfs when not relevant

Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/fault/gv100: fix fault buffer initialisation
Ben Skeggs [Wed, 13 Jun 2018 05:33:16 +0000 (15:33 +1000)]
drm/nouveau/fault/gv100: fix fault buffer initialisation

Not sure how this happened, it worked last time I tested it!

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agodrm/nouveau/gr/gv100: handle multiple SM-per-TPC for shader exceptions
Ben Skeggs [Wed, 30 May 2018 05:36:42 +0000 (15:36 +1000)]
drm/nouveau/gr/gv100: handle multiple SM-per-TPC for shader exceptions

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6 years agoMerge tag 'vmwgfx-next-4.19-3' of git://people.freedesktop.org/~thomash/linux into...
Dave Airlie [Tue, 10 Jul 2018 01:13:36 +0000 (11:13 +1000)]
Merge tag 'vmwgfx-next-4.19-3' of git://people.freedesktop.org/~thomash/linux into drm-next

This introduces a header update and support for multisample surfaces.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d020efb8-776d-5e8f-9d9f-122591e074d6@vmware.com
6 years agoMerge tag 'vmwgfx-next-4.19-2' of git://people.freedesktop.org/~thomash/linux into...
Dave Airlie [Tue, 10 Jul 2018 01:05:46 +0000 (11:05 +1000)]
Merge tag 'vmwgfx-next-4.19-2' of git://people.freedesktop.org/~thomash/linux into drm-next

A series of cleanups / reorganizations and modesetting changes that
mostly target atomic state validation.

[airlied: conflicts with SPDX stuff in amdgpu tree]
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1a88485e-e509-b00e-8485-19194f074115@vmware.com
6 years agoMerge branch 'drm-next-4.19' of git://people.freedesktop.org/~agd5f/linux into drm...
Dave Airlie [Tue, 10 Jul 2018 00:57:02 +0000 (10:57 +1000)]
Merge branch 'drm-next-4.19' of git://people.freedesktop.org/~agd5f/linux into drm-next

More features for 4.19:
- Use core pcie functionality rather than duplicating our own for pcie
  gens and lanes
- Scheduler function naming cleanups
- More documentation
- Reworked DC/Powerplay interfaces to improve power savings
- Initial stutter mode support for RV (power feature)
- Vega12 powerplay updates
- GFXOFF fixes
- Misc fixes

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180705221447.2807-1-alexander.deucher@amd.com
6 years agoMerge tag 'tilcdc-4.19' of https://github.com/jsarha/linux into drm-next
Dave Airlie [Tue, 10 Jul 2018 00:46:42 +0000 (10:46 +1000)]
Merge tag 'tilcdc-4.19' of https://github.com/jsarha/linux into drm-next

tilcdc pull request for v4.19

Single fix to defer probing.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/a10f5b43-7711-6b80-1bc3-0dfce65c628f@ti.com
6 years agodrm/vmwgfx: Expose SM4_1 param to user space
Deepak Rawat [Wed, 20 Jun 2018 22:09:43 +0000 (15:09 -0700)]
drm/vmwgfx: Expose SM4_1 param to user space

A new param DRM_VMW_PARAM_SM4_1, is added for user space to determine
availability of SM4.1.

Minor version bump for SM4.1.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add support for multisampling
Deepak Rawat [Wed, 20 Jun 2018 22:24:05 +0000 (15:24 -0700)]
drm/vmwgfx: Add support for multisampling

Support for SVGA3D_SURFACE_MULTISAMPLE and surface mob size according
to sample count.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add new ioctl for GB surface create and reference
Deepak Rawat [Wed, 20 Jun 2018 21:48:35 +0000 (14:48 -0700)]
drm/vmwgfx: Add new ioctl for GB surface create and reference

New ioctls DRM_VMW_GB_SURFACE_CREATE_EXT and DRM_VMW_GB_SURFACE_REF_EXT
are added which support 64-bit wide svga device surface flags, quality
level and multisample pattern.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Support for SVGA3dSurfaceAllFlags in vmwgfx
Deepak Rawat [Wed, 20 Jun 2018 21:25:07 +0000 (14:25 -0700)]
drm/vmwgfx: Support for SVGA3dSurfaceAllFlags in vmwgfx

Since svga device introduced new 64bit SVGA3dSurfaceAllFlags, vmwgfx
now stores the surface flags internally as SVGA3dSurfaceAllFlags.
For legacy surface define commands, only lower 32-bit is used.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add support for SVGA3dCmdDefineGBSurface_v3
Deepak Rawat [Wed, 20 Jun 2018 21:20:23 +0000 (14:20 -0700)]
drm/vmwgfx: Add support for SVGA3dCmdDefineGBSurface_v3

SVGA device added new command SVGA3dCmdDefineGBSurface_v3 which allows
64-bit SVGA3dSurfaceAllFlags. This commit adds support for
SVGA3dCmdDefineGBSurface_v3 command in vmwgfx.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add SM4_1 flag
Deepak Rawat [Wed, 20 Jun 2018 20:52:32 +0000 (13:52 -0700)]
drm/vmwgfx: Add SM4_1 flag

A boolean flag in device private structure to specify if the device
support SM4_1.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add support for SVGA3dCmdIntraSurfaceCopy command
Neha Bhende [Tue, 19 Jun 2018 00:14:56 +0000 (17:14 -0700)]
drm/vmwgfx: Add support for SVGA3dCmdIntraSurfaceCopy command

A new command to support Intra-Surface-Copy.

Signed-off-by: Neha Bhende <bhenden@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agodrm/vmwgfx: Add CAP2 support in vmwgfx
Neha Bhende [Mon, 18 Jun 2018 23:44:48 +0000 (16:44 -0700)]
drm/vmwgfx: Add CAP2 support in vmwgfx

The device exposes a new capability register. Add support for it.

Signed-off-by: Neha Bhende <bhenden@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
6 years agoMerge commit 'refs/for-upstream/mali-dp' of git://linux-arm.org/linux-ld into drm...
Dave Airlie [Fri, 6 Jul 2018 00:02:10 +0000 (10:02 +1000)]
Merge commit 'refs/for-upstream/mali-dp' of git://linux-arm.org/linux-ld into drm-next

"mali-dp driver changes for drm-next, includes the driver implementation
for writeback, improvements for power management handling in the driver
and a debugfs entry for reporting possible internal errors. Please pull
at your earliest convenience.

Boris Brezillon is also interested in this pull as he is going to change
slightly the parameter for the writeback connector's atomic_commit() and
he needs to fix the mali-dp driver in his series."

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180705144408.GH15340@e110455-lin.cambridge.arm.com
6 years agoMerge tag 'drm-misc-next-2018-07-04' of git://anongit.freedesktop.org/drm/drm-misc...
Dave Airlie [Thu, 5 Jul 2018 22:52:45 +0000 (08:52 +1000)]
Merge tag 'drm-misc-next-2018-07-04' of git://anongit.freedesktop.org/drm/drm-misc into drm-next

drm-misc-next for 4.19:

UAPI Changes:
v3d: add fourcc modicfier for fourcc for the Broadcom UIF format (Eric Anholt)

Cross-subsystem Changes:
console/fbcon: Add support for deferred console takeover (Hans de Goede)

Core Changes:
dma-fence clean up, improvements and docs (Daniel Vetter)
add mask function for crtc, plane, encoder and connector DRM objects(Ville Syrjälä)

Driver Changes:
pl111: add Nomadik LCDC variant (Linus Walleij)

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180704234641.GA3981@juma
6 years agoMerge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm...
Dave Airlie [Thu, 5 Jul 2018 20:30:32 +0000 (06:30 +1000)]
Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm-next

A patchset worked out together with Peter Zijlstra. Ingo is OK with taking
it through the DRM tree:

This is a small fallout from a work to allow batching WW mutex locks and
unlocks.

Our Wound-Wait mutexes actually don't use the Wound-Wait algorithm but
the Wait-Die algorithm. One could perhaps rename those mutexes tree-wide to
"Wait-Die mutexes" or "Deadlock Avoidance mutexes". Another approach suggested
here is to implement also the "Wound-Wait" algorithm as a per-WW-class
choice, as it has advantages in some cases. See for example

http://www.mathcs.emory.edu/~cheung/Courses/554/Syllabus/8-recv+serial/deadlock-compare.html

Now Wound-Wait is a preemptive algorithm, and the preemption is implemented
using a lazy scheme: If a wounded transaction is about to go to sleep on
a contended WW mutex, we return -EDEADLK. That is sufficient for deadlock
prevention. Since with WW mutexes we also require the aborted transaction to
sleep waiting to lock the WW mutex it was aborted on, this choice also provides
a suitable WW mutex to sleep on. If we were to return -EDEADLK on the first
WW mutex lock after the transaction was wounded whether the WW mutex was
contended or not, the transaction might frequently be restarted without a wait,
which is far from optimal. Note also that with the lazy preemption scheme,
contrary to Wait-Die there will be no rollbacks on lock contention of locks
held by a transaction that has completed its locking sequence.

The modeset locks are then changed from Wait-Die to Wound-Wait since the
typical locking pattern of those locks very well matches the criterion for
a substantial reduction in the number of rollbacks. For reservation objects,
the benefit is more unclear at this point and they remain using Wait-Die.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180703105339.4461-1-thellstrom@vmware.com
6 years agodrm/amd: Add sphinx documentation for amd_ip_funcs
Darren Powell [Wed, 27 Jun 2018 21:05:20 +0000 (17:05 -0400)]
drm/amd: Add sphinx documentation for amd_ip_funcs

Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: update documentation for amdgpu_drv.c
Sonny Jiang [Tue, 26 Jun 2018 19:48:34 +0000 (15:48 -0400)]
drm/amdgpu: update documentation for amdgpu_drv.c

Signed-off-by: Sonny Jiang <sonny.jiang@amd.com>
Acked-by: Junwei Zhang <Jerry.Zhang@amd.com>
Acked-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/amd/display: add a check for display depth validity
Mikita Lipski [Tue, 3 Jul 2018 13:42:51 +0000 (09:42 -0400)]
drm/amd/display: add a check for display depth validity

[why]
HDMI 2.0 fails to validate 4K@60 timing with 10 bpc
[how]
Adding a helper function that would verify if the display depth
assigned would pass a bandwidth validation.
Drop the display depth by one level till calculated pixel clk
is lower than maximum TMDS clk.

Bugzilla: https://bugs.freedesktop.org/106959

Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: adding ycbcr420 pixel encoding for hdmi
Mikita Lipski [Wed, 4 Jul 2018 13:27:02 +0000 (09:27 -0400)]
drm/amd/display: adding ycbcr420 pixel encoding for hdmi

[why]
HDMI EDID's VSDB contains spectial timings for specifically
YCbCr 4:2:0 colour space. In those cases we need to verify
if the mode provided is one of the special ones has to use
YCbCr 4:2:0 pixel encoding for display info.
[how]
Verify if the mode is using specific ycbcr420 colour space with
the help of DRM helper function and assign the mode to use
ycbcr420 pixel encoding.

Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd: Remove errors from sphinx documentation
Darren Powell [Mon, 25 Jun 2018 23:04:03 +0000 (19:04 -0400)]
drm/amd: Remove errors from sphinx documentation

Eliminating the warnings produced by sphinx when processing the sphinx comments in
 amdgpu_device.c & amdgpu_mn.c

Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display/dc/dce: Fix multiple potential integer overflows
Gustavo A. R. Silva [Wed, 4 Jul 2018 13:22:11 +0000 (08:22 -0500)]
drm/amd/display/dc/dce: Fix multiple potential integer overflows

Add suffix ULL to constant 5 and cast variables target_pix_clk_khz and
feedback_divider to uint64_t in order to avoid multiple potential integer
overflows and give the compiler complete information about the proper
arithmetic to use.

Notice that such constant and variables are used in contexts that
expect expressions of type uint64_t (64 bits, unsigned). The current
casts to uint64_t effectively apply to each expression as a whole,
but they do not prevent them from being evaluated using 32-bit
arithmetic instead of 64-bit arithmetic.

Also, once the expressions are properly evaluated using 64-bit
arithmentic, there is no need for the parentheses that enclose
them.

Addresses-Coverity-ID: 1460245 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1460286 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1460401 ("Unintentional integer overflow")
Fixes: 4562236b3bc0 ("drm/amd/dc: Add dc display driver (v2)")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Use 2-factor allocator calls
Kees Cook [Wed, 4 Jul 2018 17:27:30 +0000 (10:27 -0700)]
drm/amd/display: Use 2-factor allocator calls

As already done treewide, switch from open-coded multiplication to
2-factor allocation helper.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agoRevert "drm/amd/display: Fix indentation in dcn10 resource constructor"
Harry Wentland [Wed, 4 Jul 2018 17:47:07 +0000 (13:47 -0400)]
Revert "drm/amd/display: Fix indentation in dcn10 resource constructor"

That change was a merge gone bad.

This reverts commit cb1d7eacb58f7d1b7d0e57b26dc02d45eada4a3c.

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: off by one in find_irq_source_info()
Dan Carpenter [Wed, 4 Jul 2018 09:46:15 +0000 (12:46 +0300)]
drm/amd/display: off by one in find_irq_source_info()

The ->info[] array has DAL_IRQ_SOURCES_NUMBER elements so this condition
should be >= instead of > or we could read one element beyond the end of
the array.

Fixes: 4562236b3bc0 ("drm/amd/dc: Add dc display driver (v2)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Remove the same struct define in powerplay
Rex Zhu [Wed, 20 Jun 2018 07:05:04 +0000 (15:05 +0800)]
drm/amd/pp: Remove the same struct define in powerplay

delete the same struct define in powerplay, share the struct
with display.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Fix copy error when set memory clocks
Rex Zhu [Tue, 3 Jul 2018 09:17:21 +0000 (17:17 +0800)]
drm/amd/display: Fix copy error when set memory clocks

Set memory clocks same as soc clocks

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Refine the implementation of dm_pp_get_funcs_rv
Rex Zhu [Tue, 3 Jul 2018 08:31:35 +0000 (16:31 +0800)]
drm/amd/display: Refine the implementation of dm_pp_get_funcs_rv

powerplay/dpm export all interfaces in struct amd_pm_funcs.
so call common exported interfaces instead of powerplay inner interfaces

Also not include header file hwmgr.h

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Export notify_smu_enable_pwe to display
Rex Zhu [Fri, 22 Jun 2018 06:12:59 +0000 (14:12 +0800)]
drm/amd/pp: Export notify_smu_enable_pwe to display

Display can notify smu to enable pwe after gpu suspend.
It is used in case when display resumes from S3 and wants to start
audio driver by enabling pwe

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm: drop drm_pcie_get_speed_cap_mask and drm_pcie_get_max_link_width
Alex Deucher [Mon, 25 Jun 2018 20:14:46 +0000 (15:14 -0500)]
drm: drop drm_pcie_get_speed_cap_mask and drm_pcie_get_max_link_width

These functions duplicated functionality which was ultimately added
to the pci core.

All users of these functions have been ported to using the newly
exposed pci functionality.  These functions are no longer used,
so drop them.

Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/radeon: use pcie functions for link width
Alex Deucher [Mon, 25 Jun 2018 19:37:45 +0000 (14:37 -0500)]
drm/radeon: use pcie functions for link width

This is the last user of drm_pcie_get_speed_cap_mask.  Use the pci
version so we can drop drm_pcie_get_speed_cap_mask.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: use pcie functions for link width and speed
Alex Deucher [Mon, 25 Jun 2018 18:07:50 +0000 (13:07 -0500)]
drm/amdgpu: use pcie functions for link width and speed

Use the newly exported pci functions to get the link width
and speed rather than using the drm duplicated versions.

Also query the GPU link caps directly rather than hardcoding
them.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: update amd_pcie.h to include gen4 speeds
Alex Deucher [Mon, 25 Jun 2018 18:03:51 +0000 (13:03 -0500)]
drm/amdgpu: update amd_pcie.h to include gen4 speeds

Internal header used by the driver to specify pcie gen
speeds of the asic and chipset.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agoPCI: Export pcie_get_speed_cap and pcie_get_width_cap
Alex Deucher [Mon, 25 Jun 2018 18:17:41 +0000 (13:17 -0500)]
PCI: Export pcie_get_speed_cap and pcie_get_width_cap

So drivers can use them.  This can be used to replace
duplicate code in the drm subsystem.

Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: switch firmware path for SI parts
Alex Deucher [Mon, 2 Jul 2018 19:35:36 +0000 (14:35 -0500)]
drm/amdgpu: switch firmware path for SI parts

Use separate firmware path for amdgpu to avoid conflicts
with radeon on SI parts.

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: switch firmware path for CIK parts (v2)
Alex Deucher [Mon, 2 Jul 2018 19:32:28 +0000 (14:32 -0500)]
drm/amdgpu: switch firmware path for CIK parts (v2)

Use separate firmware path for amdgpu to avoid conflicts
with radeon on CIK parts.

v2: squash in logic simplification (Alex)

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix user fence write race condition
Nicolai Hähnle [Fri, 29 Jun 2018 11:23:25 +0000 (13:23 +0200)]
drm/amdgpu: fix user fence write race condition

The buffer object backing the user fence is reserved using the non-user
fence, i.e., as soon as the non-user fence is signaled, the user fence
buffer object can be moved or even destroyed.

Therefore, emit the user fence first.

Both fences have the same cache invalidation behavior, so this should
have no user-visible effect.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Remove duplicate code in vega12_hwmgr.c
Rex Zhu [Wed, 20 Jun 2018 05:36:58 +0000 (13:36 +0800)]
drm/amd/pp: Remove duplicate code in vega12_hwmgr.c

use smu_helper function smu_set_watermarks_for_clocks_ranges
in vega12_set_watermarks_for_clocks_ranges.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Refine the interface exported to display
Rex Zhu [Fri, 22 Jun 2018 10:26:52 +0000 (18:26 +0800)]
drm/amd/pp: Refine the interface exported to display

use void * as function parameter type in order for extension.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Notify powerplay the display controller id
rex zhu [Mon, 2 Jul 2018 08:20:56 +0000 (16:20 +0800)]
drm/amd/display: Notify powerplay the display controller id

powerplay can recalculate the number of active display

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Notify powerplay the min_dcef clock
rex zhu [Mon, 2 Jul 2018 06:55:43 +0000 (14:55 +0800)]
drm/amd/display: Notify powerplay the min_dcef clock

powerplay can notify smu to recalculates the maximum deep-sleep
divider display allowed.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Switch the tolerable latency for display
rex zhu [Thu, 28 Jun 2018 05:55:46 +0000 (13:55 +0800)]
drm/amd/pp: Switch the tolerable latency for display

Select the lowest MCLK frequency that is within
the tolerable latency defined in DISPALY

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Memory Latency is always 25us on Vega10
Rex Zhu [Mon, 18 Jun 2018 10:49:07 +0000 (18:49 +0800)]
drm/amd/pp: Memory Latency is always 25us on Vega10

For HBM, 25us latency is enough for memory clock switch.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Convert clock unit to KHz as defined
Rex Zhu [Mon, 18 Jun 2018 10:15:15 +0000 (18:15 +0800)]
drm/amd/pp: Convert clock unit to KHz as defined

Convert clock unit 10KHz to KHz as the data sturct defined.
e.g.
struct pp_clock_with_latency {
uint32_t clocks_in_khz;
uint32_t latency_in_us;
};
Meanwhile revert the same conversion in display side.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: update uvd_v6_0_ring_vm_funcs to use new nop packet
Alex Deucher [Thu, 28 Jun 2018 17:32:27 +0000 (12:32 -0500)]
drm/amdgpu: update uvd_v6_0_ring_vm_funcs to use new nop packet

Was missed when updating the uvd 6 module.

Fixes: 1aac3c9180 (drm/amdgpu: fix insert nop for UVD6 ring)
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
6 years agodrm/amdgpu: fix the wrong type of gem object creation
Huang Rui [Thu, 28 Jun 2018 06:38:21 +0000 (14:38 +0800)]
drm/amdgpu: fix the wrong type of gem object creation

We still use legacy type of gem_object_create, it should update to ttm_bo_type
now.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/radeon: add SPDX identifier and clarify license
Dirk Hohndel (VMware) [Sun, 6 May 2018 23:16:23 +0000 (01:16 +0200)]
drm/radeon: add SPDX identifier and clarify license

This is dual licensed under GPL-2.0 or MIT.

Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dirk Hohndel (VMware) <dirk@hohndel.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd: add SPDX identifier and clarify license
Dirk Hohndel (VMware) [Sun, 6 May 2018 23:16:20 +0000 (01:16 +0200)]
drm/amd: add SPDX identifier and clarify license

This is dual licensed under GPL-2.0 or MIT.

Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dirk Hohndel (VMware) <dirk@hohndel.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd: Replace drm_dev_unref with drm_dev_put
Thomas Zimmermann [Thu, 28 Jun 2018 14:10:25 +0000 (16:10 +0200)]
drm/amd: Replace drm_dev_unref with drm_dev_put

This patch unifies the naming of DRM functions for reference counting
of struct drm_device. The resulting code is more aligned with the rest
of the Linux kernel interfaces.

Signed-off-by: Thomas Zimmermann <contact@tzimmermann.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/vce: simplify vce instance setup
Alex Deucher [Mon, 25 Jun 2018 17:41:21 +0000 (12:41 -0500)]
drm/amdgpu/vce: simplify vce instance setup

Set the me instance in early init and use that rather than
calculating the instance based on the ring pointer.

Reviewed-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Leo Liu <leo.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/sdma: simplify sdma instance setup
Alex Deucher [Mon, 25 Jun 2018 17:24:10 +0000 (12:24 -0500)]
drm/amdgpu/sdma: simplify sdma instance setup

Set the me instance in early init and use that rather than
calculating the instance based on the ring pointer.

Reviewed-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Leo Liu <leo.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/pp: fix copy paste typo in smu7_get_pp_table_entry_callback_func_v1
Alex Deucher [Thu, 28 Jun 2018 18:21:12 +0000 (13:21 -0500)]
drm/amdgpu/pp: fix copy paste typo in smu7_get_pp_table_entry_callback_func_v1

Should be using PCIELaneLow for the low clock level.

Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/pp: fix copy paste typo in smu7_init_dpm_defaults
Alex Deucher [Thu, 28 Jun 2018 17:52:43 +0000 (12:52 -0500)]
drm/amdgpu/pp: fix copy paste typo in smu7_init_dpm_defaults

Should be mclk rather than sclk.

Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/pp: fix endian swapping in atomctrl_get_voltage_range
Alex Deucher [Thu, 28 Jun 2018 17:51:06 +0000 (12:51 -0500)]
drm/amdgpu/pp: fix endian swapping in atomctrl_get_voltage_range

Need to swap before doing arthimetic on the values.

Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/pp: add missing byte swapping in process_pptables_v1_0.c
Alex Deucher [Thu, 28 Jun 2018 17:48:10 +0000 (12:48 -0500)]
drm/amdgpu/pp: add missing byte swapping in process_pptables_v1_0.c

Values need to be swapped on big endian.

Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu/pm: fix display count in non-DC path
Alex Deucher [Thu, 28 Jun 2018 17:44:25 +0000 (12:44 -0500)]
drm/amdgpu/pm: fix display count in non-DC path

new_active_crtcs is a bitmask, new_active_crtc_count is the
actual count.

Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: fix swapped emit_ib_size in vce3
Alex Deucher [Thu, 28 Jun 2018 17:38:53 +0000 (12:38 -0500)]
drm/amdgpu: fix swapped emit_ib_size in vce3

The phys and vm versions had the values swapped.

Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Remove amdgpu_gem_map_attach target_dev documentation
Michel Dänzer [Fri, 29 Jun 2018 09:27:11 +0000 (11:27 +0200)]
drm/amdgpu: Remove amdgpu_gem_map_attach target_dev documentation

The parameter was removed.

Fixes: a19741e5e5a9 "dma_buf: remove device parameter from attach
                     callback v2"
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Add AMDGPU_GPU_PAGES_IN_CPU_PAGE define
Michel Dänzer [Fri, 22 Jun 2018 16:54:03 +0000 (18:54 +0200)]
drm/amdgpu: Add AMDGPU_GPU_PAGES_IN_CPU_PAGE define

To hopefully make the code dealing with GPU vs CPU pages a little
clearer.

Suggested-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Use gmc_vram_full_visible in vram_mgr_bo_invisible_size
Michel Dänzer [Fri, 15 Jun 2018 14:37:03 +0000 (16:37 +0200)]
drm/amdgpu: Use gmc_vram_full_visible in vram_mgr_bo_invisible_size

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Dynamically probe for ATIF handle (v2)
Lyude Paul [Tue, 26 Jun 2018 01:09:07 +0000 (21:09 -0400)]
drm/amdgpu: Dynamically probe for ATIF handle (v2)

The other day I was testing one of the HP laptops at my office with an
i915/amdgpu hybrid setup and noticed that hotplugging was non-functional
on almost all of the display outputs. I eventually discovered that all
of the external outputs were connected to the amdgpu device instead of
i915, and that the hotplugs weren't being detected so long as the GPU
was in runtime suspend. After some talking with folks at AMD, I learned
that amdgpu is actually supposed to support hotplug detection in runtime
suspend so long as the OEM has implemented it properly in the firmware.

On this HP ZBook 15 G4 (the machine in question), amdgpu wasn't managing
to find the ATIF handle at all despite the fact that I could see acpi
events being sent in response to any hotplugging. After going through
dumps of the firmware, I discovered that this machine did in fact
support ATIF, but that it's ATIF method lived in an entirely different
namespace than this device's handle (the device handle was
\_SB_.PCI0.PEG0.PEGP, but ATIF lives in ATPX's handle at
\_SB_.PCI0.GFX0).

So, fix this by probing ATPX's ACPI parent's namespace if we can't find
ATIF elsewhere, along with storing a pointer to the proper handle to use
for ATIF and using that instead of the device's handle.

This fixes HPD detection while in runtime suspend for this ZBook!

v2: Update the comment to reflect how the namespaces are arranged
based on the system configuration. (Alex)

Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Add amdgpu_atpx_get_dhandle()
Lyude Paul [Tue, 26 Jun 2018 01:09:06 +0000 (21:09 -0400)]
drm/amdgpu: Add amdgpu_atpx_get_dhandle()

Since it seems that some vendors are storing the ATIF ACPI methods under
the same handle that ATPX lives under instead of the device's own
handle, we're going to need to be able to retrieve this handle later so
we can probe for ATIF there.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: s/disp_detetion_ports/disp_detection_ports/
Lyude Paul [Tue, 26 Jun 2018 01:09:05 +0000 (21:09 -0400)]
drm/amdgpu: s/disp_detetion_ports/disp_detection_ports/

Fix typo.

Reviewed-by: Jim Qu <Jim.Qu@amd.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Make struct amdgpu_atif private to amdgpu_acpi.c
Lyude Paul [Tue, 26 Jun 2018 01:09:04 +0000 (21:09 -0400)]
drm/amdgpu: Make struct amdgpu_atif private to amdgpu_acpi.c

Currently, there is nothing in amdgpu that actually uses these structs
other than amdgpu_acpi.c. Additionally, since we're about to start
saving the correct ACPI handle to use for calling ATIF in this struct
this saves us from having to handle making sure that the acpi_handle
(and by proxy, the type definition for acpi_handle and all of the other
acpi headers) doesn't need to be included within the amdgpu_drv struct
itself. This follows the example set by amdgpu_atpx_handler.c.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: cosmetic fix
Evan Quan [Mon, 11 Jun 2018 08:48:43 +0000 (16:48 +0800)]
drm/amd/powerplay: cosmetic fix

Fix coding style and drop unused variable.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: correct vega12 thermal support as true
Evan Quan [Mon, 11 Jun 2018 08:46:40 +0000 (16:46 +0800)]
drm/amd/powerplay: correct vega12 thermal support as true

Thermal support is enabled on vega12.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: set vega12 pre display configurations
Evan Quan [Mon, 11 Jun 2018 09:22:33 +0000 (17:22 +0800)]
drm/amd/powerplay: set vega12 pre display configurations

Set num_displays to 0 and force uclk high as part of the mode
set sequence.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: apply clocks adjust rules on power state change
Evan Quan [Mon, 11 Jun 2018 08:40:57 +0000 (16:40 +0800)]
drm/amd/powerplay: apply clocks adjust rules on power state change

This add the apply_clocks_adjust_rules callback which is used
to validate the clock settings on a power state change.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: correct vega12 max num of dpm level
Evan Quan [Mon, 11 Jun 2018 08:33:40 +0000 (16:33 +0800)]
drm/amd/powerplay: correct vega12 max num of dpm level

Use MAX_NUM_CLOCKS instead of VG12_PSUEDO* macros for
the max number of dpm levels.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: drop unnecessary uclk hard min setting
Evan Quan [Wed, 20 Jun 2018 04:28:10 +0000 (12:28 +0800)]
drm/amd/powerplay: drop unnecessary uclk hard min setting

We don't need to set uclk hard min here because this will
be set with other clocks on power state change.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: correct smc display config for multi monitor
Evan Quan [Wed, 20 Jun 2018 04:24:29 +0000 (12:24 +0800)]
drm/amd/powerplay: correct smc display config for multi monitor

Need to take into account multi-head with synced displays.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: initialize uvd/vce powergate status v4
Evan Quan [Mon, 11 Jun 2018 08:25:14 +0000 (16:25 +0800)]
drm/amd/powerplay: initialize uvd/vce powergate status v4

On UVD/VCE dpm enabled/disabled, the powergate status will be
set as false/true. So that we will not try to ungate/gate them(
enable/disable their dpm) again.

v2: added check for uvd/vce powergate status before gating
v3: fix typo in description
v4: warning fix (Alex)

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/amd/powerplay: revise clock level setup
Evan Quan [Mon, 11 Jun 2018 08:04:17 +0000 (16:04 +0800)]
drm/amd/powerplay: revise clock level setup

Make sure the clock level set only on dpm enabled. Also uvd/vce/soc
clock also changed correspondingly.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: retrieve all clock ranges on startup
Evan Quan [Mon, 11 Jun 2018 07:41:44 +0000 (15:41 +0800)]
drm/amd/powerplay: retrieve all clock ranges on startup

So that we do not need to use PPSMC_MSG_GetMin/MaxDpmFreq to
get the clock ranges on runtime. Since that causes some problems.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: revise default dpm tables setup
Evan Quan [Mon, 11 Jun 2018 07:25:37 +0000 (15:25 +0800)]
drm/amd/powerplay: revise default dpm tables setup

Initialize the soft/hard min/max level correctly and
handle the dpm disabled situation.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: drop the acg fix
Evan Quan [Mon, 11 Jun 2018 09:38:54 +0000 (17:38 +0800)]
drm/amd/powerplay: drop the acg fix

This workaround is not needed any more.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: smc_dpm_info structure change
Evan Quan [Mon, 11 Jun 2018 07:20:39 +0000 (15:20 +0800)]
drm/amd/powerplay: smc_dpm_info structure change

A new member Vr2_I2C_address is added.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/powerplay: correct vega12 bootup values settings
Evan Quan [Mon, 28 May 2018 00:59:16 +0000 (08:59 +0800)]
drm/amd/powerplay: correct vega12 bootup values settings

The vbios firmware structure changed between v3_1 and v3_2. So,
the code to setup bootup values needs different paths based
on header version.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Fix a typo in wm_min_memg_clk_in_khz
Rex Zhu [Wed, 20 Jun 2018 04:52:43 +0000 (12:52 +0800)]
drm/amd/display: Fix a typo in wm_min_memg_clk_in_khz

change wm_min_memg_clk_in_khz -> wm_min_mem_clk_in_khz

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/display: Ctrl stutter mode through module parameter
rex zhu [Wed, 27 Jun 2018 10:19:08 +0000 (18:19 +0800)]
drm/amd/display: Ctrl stutter mode through module parameter

use ppfeaturemask to enable/disable stutter mode.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Add stutter mode ctrl in module parameter
rex zhu [Wed, 27 Jun 2018 10:08:43 +0000 (18:08 +0800)]
drm/amdgpu: Add stutter mode ctrl in module parameter

Enable stutter mode can save power in low DRAM use cases
including but not limited to productivity application use,
web browsing, and video playback.

Currently this feature is disabled by default.

Make bit 17 in module parameter amdgpu_pp_feature_mask
as stutter mode mask, so user can enable/disable this feature easily.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Move CG/PG setting out of delay worker thread
Rex Zhu [Wed, 6 Jun 2018 05:42:42 +0000 (13:42 +0800)]
drm/amdgpu: Move CG/PG setting out of delay worker thread

Partially revert commit 2dc80b00652f
("drm/amdgpu: optimize amdgpu driver load & resume time")'

1. CG/PG enablement are part of gpu hw ip initialize, we should
wait for them complete. otherwise, there are some potential conflicts,
for example, Suspend and CG enablement concurrently.
2. better run ib test after hw initialize completely. That is to say,
   ib test should be after CG/PG enablement. otherwise, the test will
   not cover the cg/pg/poweroff enable case.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Split set_pg_state into separate function
Rex Zhu [Wed, 13 Jun 2018 11:30:40 +0000 (19:30 +0800)]
drm/amdgpu: Split set_pg_state into separate function

1. add amdgpu_device_ip_late_set_pg_state function for
   set pg state.
2. delete duplicate pg state setting on gfx_v8_0's late_init.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amdgpu: Add gfx_off support in smu through pp_set_powergating_by_smu
Rex Zhu [Tue, 5 Jun 2018 03:46:35 +0000 (11:46 +0800)]
drm/amdgpu: Add gfx_off support in smu through pp_set_powergating_by_smu

we can take gfx off feature as gfx power gate. gfx off feature is also
controled by smu. so add gfx_off support in pp_set_powergating_by_smu.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Add powergate_gfx backend function on Raven
Rex Zhu [Tue, 5 Jun 2018 05:55:04 +0000 (13:55 +0800)]
drm/amd/pp: Add powergate_gfx backend function on Raven

Raven support gfx off feature instand of gfx powergate,
so use smu10_gfx_off_control as the powergate_gfx backend function.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Add gfx pg support in smu through set_powergating_by_smu
Rex Zhu [Thu, 14 Jun 2018 05:07:19 +0000 (13:07 +0800)]
drm/amd/pp: Add gfx pg support in smu through set_powergating_by_smu

gfx ip block can call set_powergating_by_smu to set gfx pg state if
necessary.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
6 years agodrm/amd/pp: Unify powergate_uvd/vce/mmhub to set_powergating_by_smu
Rex Zhu [Tue, 5 Jun 2018 05:06:11 +0000 (13:06 +0800)]
drm/amd/pp: Unify powergate_uvd/vce/mmhub to set_powergating_by_smu

Some HW ip blocks need call SMU to enter/leave power gate state.
So export common set_powergating_by_smu interface.

1. keep consistent with set_clockgating_by_smu
2. scales easily to powergate other ip(gfx) if necessary

Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>