Commit Graph

161 Commits

Author SHA1 Message Date
Michel Dänzer
5ba95c3abe Identify DRM event queue entries by sequence number instead of by pointer
If the memory for an entry was allocated at the same address as that for
a previously cancelled entry, the handler could theoretically be called
prematurely, triggered by the DRM event which was submitted for the
cancelled entry.

(Ported from radeon commit 4693b1bd5b5c381e8b7b68a6f7f0c6696d6a68df)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-01 15:29:26 +09:00
Michel Dänzer
8ecfa69b5a DRI3: Refuse to open DRM file descriptor for ssh clients
Fixes hangs when attempting to use DRI3 on display connections forwarded
via SSH.

Don't do this for Xorg > 1.18.99.1 since the corresponding xserver
change has landed in Git master.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93261

(Ported from radeon commit 0b3aac1de9db42bfca545fa331e4985836682ec7)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-30 18:33:00 +09:00
Michel Dänzer
b2a2e114ee Revert "Use render node for DRI3 if available"
This reverts commit ea558e6457.

It broke VDPAU<->GL interop with DRI3 enabled, because the Gallium VDPAU
code doesn't support DRI3 yet. We can consider re-enabling this once
there is a Mesa release where the Gallium VDPAU code supports DRI3.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94675

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 12:01:36 +09:00
Flora Cui
e31a2d668a add polaris10 pci id
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Flora Cui <Flora.Cui@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
2016-03-24 22:44:33 -04:00
Flora Cui
6e09b8deb7 add polaris11 pci id
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Flora Cui <Flora.Cui@amd.com>
Reviewed-By: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 22:44:28 -04:00
Alex Deucher
7d32c43fff add Polaris chip families
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 22:44:16 -04:00
Michel Dänzer
fbf9ae18cd Require xserver 1.9 or newer
1.9.0 was released in August 2010.

We were already unintentionally relying on things not available in 1.8
for at least a year, and nobody has complained.

(Ported from radeon commit e592f32f8b5f5873fcc18b10a69dd5e4ccf11073)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 10:38:52 +09:00
Michel Dänzer
912db5fbbc Fix build against older versions of xserver
Also slightly clean up the error handling in amdgpu_scanout_do_update.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94614

(Ported from radeon commit bde466e5d44cad64b4e4eceaa5de80fdbf86356e)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 10:38:26 +09:00
Michel Dänzer
3fb6280ab3 DRI3 only works with acceleration
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94214

(Ported from radeon commit d21ac4669a8b2cdd4eec5e5a94d1950b7423b8b5)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 10:38:05 +09:00
Michel Dänzer
3177fe817a Check for xf86CursorResetCursor
If it's available, Xorg calls it on each mode configuration change. It
does what xf86_reload_cursors does (and more), so we don't need to call
the latter anymore.

(Ported from radeon commit d670c5c9851b4eff21c845d26c7d7e4eb5ee0fa9)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 10:37:44 +09:00
Michel Dänzer
a3dfce7b24 Don't try DRI2/Present flipping while the HW cursor can't be used
Flipping doesn't interact correctly with SW cursor: A flip makes the SW
cursor disappear. It will only appear again when the cursor is moved,
but it will be surrounded by corruption, because the SW cursor code
will restore stale screen contents at the old cursor location before
drawing the cursor at the new location.

(Ported from radeon commit 7f3d0780ca65a90117c2a61362dbc0899bd9c0b0)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 10:37:17 +09:00
Michel Dänzer
ba9be8f32f Factor out HW cursor checking code into drmmode_can_use_hw_cursor
And add a check for RandR 1.4 multihead.

(Ported from radeon commit 3de480e83c0a1824838d662d6d67c9fe85277298)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 18:44:30 +09:00
Michel Dänzer
4a60b4b185 Call AMDGPUBlockHandler_KMS before setting initial modes
Doing it the other way around meant that there was still a possibility
for the front buffer contents to be uninitialized when they start being
scanned out.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 12:14:58 +09:00
Michel Dänzer
37bd79652a present: Return rotated CRTCs from amdgpu_present_get_crtc
Sync-to-vblank works fine with rotation. We're still checking for
rotation in amdgpu_present_check_flip.

Returning NULL from here resulted in the xserver present code falling
back to the fake CRTC running at 1 fps.

(Ported from radeon commit a03271de5ecdaa7790d1316e993c4450b91fe936)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:59:29 +09:00
Michel Dänzer
6b930fb328 present: Clear drmmode->fb_id before calling set_mode_major for unflip
Without this, drmmode_set_mode_major may just re-set the FB for the
last flipped BO, in which case the display will probably freeze.

Reproduction recipe: Enable rotation while a fullscreen client is
flipping.

(Ported from radeon commit 40191d82370eb7e58bd34c44966cbf44c3703229)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:59:20 +09:00
Michel Dänzer
6889e09144 Make Option "TearFree" effective for rotated/reflected outputs as well
Support varies by xserver version:

< 1.12:    No support for the driver handling rotation/reflection
1.12-1.15: Support for driver handling rotation/reflection, but there's
           a bug preventing the HW cursor from being visible everywhere
           it should be on rotated outputs, so we can only support
           TearFree for reflection.
>= 1.16:   While the bug above is still there (fixes pending review),
           the driver can force SW cursor for rotated outputs, so we
           can support TearFree for rotation as well.

(Ported from radeon commit 798c4fd16d339b1ad5fd729cc884be084c60e38b)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:59:02 +09:00
Michel Dänzer
da4e0c66fc Consolidate pScreen usage in drmmode_set_mode_major
We were already relying on pScrn->pScreen being non-NULL in some cases,
which is supposedly always true ever since this function is no longer
getting called from ScreenInit.

(Ported from radeon commit eb611a2e4ecce7a1ab85fd72b9b78e3269311dd5)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:54 +09:00
Michel Dänzer
0bbf09dd7e Remove check for XF86_CRTC_VERSION 3
We require xserver >= 1.8, which was already at version 3.

(Ported from radeon commit 06602171386e538081c298645fb7ca1a70fe80cc)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:44 +09:00
Michel Dänzer
3485ca0051 Deal with modesets and page flips crossing on a CRTC
If we set a mode while a flip is pending, the kernel driver may program
the flip to the hardware after the modeset. If that happens, the hardware
will display the BO from the flip, whereas we will assume it displays the
BO from the modeset. In other words, the display will most likely freeze,
at least until another modeset.

Prevent this condition by waiting for a pending flip to finish before
setting a mode.

Fixes display freezing when setting rotation or a transform with
TearFree enabled.

(Ported from radeon commit a88985f5d1e39caca49ceb65678aaa9cb622a0d2)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:35 +09:00
Michel Dänzer
b9d00fa7aa Make DRM event queue xf86CrtcPtr based instead of ScrnInfoPtr based
This allows for a minor simplification of the code.

(Ported from radeon commit f5d968cbba3c9b7ec202161f2157d8d64778c817)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:26 +09:00
Michel Dänzer
e0ed26151b Remove amdgpu_scanout_flip_handler
No longer necessary now that amdgpu_drm_queue_handler can handle
e->handler == NULL.

(Ported from radeon commit d5dbb07db22d5420c81dfebc060f0dd86e7b8a20)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:19 +09:00
Michel Dänzer
acd5da56f5 DRI2: Also clear dri2_flipping when client disconnects before event
Fixes the following problem:

With DRI3 enabled, run glxgears with LIBGL_DRI3_DISABLE=1, make it
fullscreen and press Escape while it's still fullscreen. This could
result in dri2_flipping not getting cleared, spuriously preventing apps
using DRI3 from flipping.

(Ported from radeon commit e87365117acbd80b7d80fbb5eb30890ef7153291)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:12 +09:00
Michel Dänzer
a58bfa9820 drm_queue: Don't abort events immediately from amdgpu_drm_abort_client
Keep them around until the DRM event arrives, but then call the abort
functions instead of the handler functions.

This is a prerequisite for the following fix.

(Ported from radeon commit 3989766edde85d1abe7024577b98fc9b007bc02a)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:05 +09:00
Michel Dänzer
e4888df6e3 Fix RandR CRTC transforms
Currently, Xorg will only transform the cursor as of the first time the
cursor image changes after a transform is set.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80678

(Ported from radeon commit 9483a3d777919b224f70c3b4d01e4b320a57db31)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:57:57 +09:00
Michel Dänzer
43af92ede0 Build RandR 1.4 provider name from chipset name and bus ID
Instead of just "amdgpu", it's now e.g. "TONGA @ pci:0000:01:00.0".

(Ported from radeon commit c7cf00487cd6d4a5d0f39d5b92ff04f6420d6a32)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-18 16:58:07 +09:00
Michel Dänzer
5ec1797a28 DRI2: Use amdgpu_pixmap_get_handle
Now we can share pixmaps with no struct amdgpu_buffer via DRI2.

Fixes VDPAU video playback freezing when using an OpenGL compositor with
DRI3 enabled and mpv VAAPI hardware decoding with OpenGL output.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89755
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93804

(ported from radeon commit f8b0f23e9f4af9f9097ee5e72d53b45173163c41)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:25:58 +09:00
Michel Dänzer
df60c635e1 glamor: Avoid generating GEM flink names for BOs shared via DRI3 (v2)
We can't create our own struct amdgpu_buffer representation in this case
because destroying that would make the GEM handle inaccessible to glamor
as well. So just get the handle directly via dma-buf.

(ported from radeon commit 391900a670addec39515f924265bfa9f8bfa9ec0,
 extended to cache BO handles in the private for non-DRI3 pixmaps as
 well)

v2: Swap whole pixmap privates instead of just BOs in
    amdgpu_dri2_exchange_buffers to avoid invalidating cached BO handles

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:24:51 +09:00
Michel Dänzer
e463b849f3 Make amdgpu_do_pageflip take a pixmap instead of a BO
(inspired by radeon commit 7b4fc4a677d252d01c2bf80d162bc35814059eaa)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:24:25 +09:00
Michel Dänzer
1ee341f9d9 Add amdgpu_pixmap_get_handle helper
(inspired by radeon commits dfad91fffb5bd013785223b42d78886df839eacf
 and ccbda955ebae1d457d35293833f12791e0f9fb0b)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-24 18:09:18 +09:00
Michel Dänzer
a36bbfd98b HAS_DIRTYTRACKING_ROTATION also supports multiple CRTCs
(ported from radeon commit ff9a6b6f079a8419f4e6fadfee778060618bf735)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-16 16:33:48 +09:00
Michel Dänzer
a37746ffce Load fb module before glamoregl/shadow modules
Fixes unresolved symbols on some systems.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93105
(ported from radeon commit 78fbca095ae9887a2d3de48bb07975e2d1126e68)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-16 16:33:14 +09:00
Michel Dänzer
59c0a68071 Don't advertise any PRIME offloading capabilities without acceleration
Acceleration is required even for display offloading. Trying to enable
display offloading without acceleration resulted in a crash.

(ported from radeon commit b19417e2fddf4df725951aea5ad5e9558338f59e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-15 18:28:13 +09:00
Michel Dänzer
a3eac85d81 Only map front buffer if glamor acceleration is disabled (v2)
Otherwise the front buffer may not be accessible by the CPU, because Mesa
sets the AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag for tiled buffers, because
accessing tiled buffers with the CPU makes little sense.

v2: Also handle Option "AccelMethod" "none"

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-29 16:05:08 +09:00
jimqu
2fcb7dadd3 glamor: Return NullPixmap on failure to create shareable pixmap
If we were asked to create a shareable pixmap, it doesn't make sense
to return a pixmap which isn't shareable. Doing so caused trouble down
the line such as a crash with older versions of glamor when trying to
use GLX pixmaps of bpp < 32 via DRI2.

Signed-off-by: JimQu <jim.qu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-28 18:15:45 +09:00
jimqu
5269a2228b Move amdgpu_glamor_destroy_pixmap before amdgpu_glamor_create_pixmap
The next commit will call the former from the latter. No functional
change.

Signed-off-by: JimQu <jim.qu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-28 18:06:33 +09:00
Tom St Denis
54c959c163 Move memset() after variable declarations
To make the code more "C" like move the function calls
after the variable declarations.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-21 12:54:11 +09:00
Michel Dänzer
8853b07ae8 Set the RandR primary output on startup if Xorg hasn't
Fixes xrandr (XRRGetOutputPrimary) not reporting any output as primary
after startup.

(Ported from radeon commit b16856b25086ffb27365ac2249b8da921066ce62)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-19 17:35:11 +09:00
Michel Dänzer
bd5c65dace Only call amdgpu_bus_id once in each probe path (v2)
Instead of up to twice as before.

v2: Remove free(busIdString) call from amdgpu_kernel_mode_enabled, the
    bus ID string is now managed by its callers.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
2016-01-13 18:48:02 +09:00
Michel Dänzer
6e42c58375 Remove pci_dev test from amdgpu_get_scrninfo
The pci_dev parameter can never be NULL since we only support KMS.

Reported-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-13 18:47:17 +09:00
Michel Dänzer
8e09180798 Re-use PCI bus ID code from kernel_open_fd in kernel_mode_enabled
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-13 18:46:46 +09:00
Mykola Lysenko
4eb9cedca0 Initialize drmmode_crtc dpms_mode to DPMSModeOff
This disables query of disabled pipes for drmWaitVBlank on X start

Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-13 18:42:22 +09:00
Michel Dänzer
1d0b0c1794 sync: Check if miSyncShmScreenInit symbol is resolved at runtime
It may be disabled in the Xorg build, either explicitly or because the
xshmfence library isn't available.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-05 12:02:04 +09:00
Mykola Lysenko
f4107f67f1 Check for NULL koutput in drmmode_output_dpms
This situation happens whit start of usage of DRM DP MST framework,
when connectors created and destroyed dynamically.

Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-24 10:17:13 +09:00
Jammy Zhou
ea558e6457 Use render node for DRI3 if available
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-11-20 17:44:55 +09:00
Michel Dänzer
43c2dc1aab glamor: Deal with glamor_egl_destroy_textured_pixmap being removed
When it's not available, it's safe to call down to the glamor
DestroyPixmap hook instead.

(ported from radeon commit 10b7c3def58bb34acc38f076bc230e25b454ab79)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-20 12:14:03 +09:00
Michel Dänzer
84cab5738a glamor: Restore all ScreenRec hooks during CloseScreen
(ported from radeon commit 535e5438b2c32f774b9c8c27ee0289b4749548ef)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:56:36 +09:00
Michel Dänzer
a00c050c2e Post 1.0.0 release version bump 2015-11-19 17:55:53 +09:00
Michel Dänzer
755e6ff233 Bump version for 1.0.0 release xf86-video-amdgpu-1.0.0 2015-11-19 17:28:19 +09:00
Michel Dänzer
49c7d2be99 Add amdgpu_pixmap.h to src/Makefile.am's EXTRA_DIST
Fixes make distcheck.
2015-11-19 17:20:39 +09:00
Stephen Chandler Paul
d069ec5d27 Handle failures in setting a CRTC to a DRM mode properly
This fixes a bug where running the card out of PPLL's when hotplugging
another monitor would result in all of the displays going blank and
failing to work properly until X was restarted or the user switched to
another VT.

[Michel Dänzer: Pass errno instead of -ret to strerror()]

Signed-off-by: Stephen Chandler Paul <cpaul@redhat.com>
(ported from radeon commit 7186a8713ba004de4991f21c1a9fc4abc62aeff4)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:20:23 +09:00