678 Commits

Author SHA1 Message Date
Michel Dänzer
ebd32b1c07 dri2: Flush in dri2_create_buffer2 after calling glamor_set_pixmap_bo
To make sure the client can't use the shared pixmap storage for direct
rendering first, which could produce garbage.

Bugzilla: https://bugs.freedesktop.org/109235
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-16 18:38:40 +01:00
Michel Dänzer
d168532ee7 dri3: Flush if necessary in dri3_fd_from_pixmap
To make sure the client can't use the shared pixmap storage for direct
rendering first, which could produce garbage.

Bugzilla: https://bugs.freedesktop.org/109235
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-11 18:04:26 +01:00
Michel Dänzer
2058c4c469 Only call drmmode_validate_leases if RandR is enabled
It would crash if RandR is disabled, e.g. because Xinerama is enabled.

Bugzilla: https://bugs.freedesktop.org/109230
(Ported from radeon commit b1c01698f577577e4a88bad0ae08fb5d998e7ebb)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-10 17:25:05 +01:00
Michel Dänzer
f3c0939a0c Only call drmmode_uevent_init if RandR is enabled
There's no point in listening for hotplug events if RandR is disabled,
as there's no other mechanism for them to be propagated. We were already
mostly ignoring them in that case.

Inspired by
1a489142c8
(via https://bugs.freedesktop.org/109230#c11).
(Ported from radeon commit 38db1bbcfc019c92884c7819a6630c70e543f6b2)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-10 17:00:12 +01:00
Michel Dänzer
f3ddda618e gitlab-ci: Use kaniko instead of docker-in-docker for image generation
kaniko can also work in unprivileged runners.

Based on v2 of
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/92 .
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-20 10:28:32 +01:00
Michel Dänzer
b689dc5081 Remove superfluous vrr_flipping field and clean up related code
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-20 10:08:13 +01:00
Michel Dänzer
233a0be82d Don't clear info->flip_window in present_unflip
present_unflip can get called between present_check_flip and
present_flip, in which case the latter would pass a NULL WindowPtr to
the former, resulting in a crash.

present_flip should never get called for a window which has already been
destroyed, so there's no need to clear info->flip_window.

Bugzilla: https://bugs.freedesktop.org/109067
Fixes: 2d18b37159 "Check last flip window instead of screen root
                      before flipping"
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-19 18:56:37 +01:00
Mario Kleiner
d4eab5d108 Fix crash when page flipping in multi-X-Screen/Zaphod mode
amdgpu_do_pageflip() indexed the flipdata->fb[] array
indexing over config->num_crtc, but the flip completion
routines, e.g., drmmode_flip_handler(), index that array
via the crtc hw id from drmmode_get_crtc_id(crtc).

This is mismatched and causes indexing into the wrong
array slot at flip completion -> Server crash.

Always use drmmode_get_crtc_id(crtc) for indexing into
the array to fix this.

Tested on a dual-X-Screen setup with one video output
assigned to each X-Screen, page-flipping an OpenGL app
on either of both X-Screens. This used to crash when
flipping on X-Screen 1, now it doesn't anymore.

Fixes: 9b6782c821 "Store FB for each CRTC in drmmode_flipdata_rec"
(Ported from radeon commit 0058fd2ebf4c900b12f129984e98886a7ac84b2f)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-12-19 18:03:27 +01:00
Michel Dänzer
0d60233d26 Use two HW cursor buffers per CRTC
Switch to the other buffer when xf86_config->cursor changes. Avoids
these issues possible when re-using the same buffer:

* The HW may intermittently display a mix of the old and new cursor
  images.
* If the hotspot changes, the HW may intermittently display the new
  cursor image at the location corresponding to the old image's hotspot.

Bugzilla: https://bugs.freedesktop.org/108832
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:40:40 +01:00
Michel Dänzer
b04697de52 Update cursor position in drmmode_show_cursor if hotspot changed
The cursor position is updated to be consistent with the new hotspot in
the same ioctl call.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:40:03 +01:00
Michel Dänzer
b344e1559e Use drmIoctl in drmmode_show_cursor
This should be functionally equivalent to what drmModeSetCursor(2) do
behind the scenes, but allows for new tricks in following changes.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:39:16 +01:00
Michel Dänzer
e95044e453 Drop AMDGPUInfoRec::cursor_buffer array
Not needed or even useful for anything.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:38:40 +01:00
Michel Dänzer
13c85e8a13 Don't use GBM for allocating HW cursor BOs
GBM doesn't really buy us anything for the cursor BOs. This simplifies
the code and following changes.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:37:56 +01:00
Michel Dänzer
bcfa6c258f Automatically try re-enabling TearFree after a flip failed
Specifically, after both the page flip and vblank ioctls failed, but
then the vblank ioctl started working again. This can happen
intermittently e.g. when hotplugging a DP display. Previously, TearFree
would stay disabled in that case until a modeset was triggered somehow.

Bugzilla: https://bugs.freedesktop.org/103791
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:17:30 +01:00
Michel Dänzer
4e7a24ac5a Cancel pending scanout update in drmmode_crtc_scanout_update
drmmode_crtc_scanout_update does the equivalent of a scanout update,
so no need to do it again. This might also avoid issues if there's a
pending scanout update at this point.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:17:02 +01:00
Michel Dänzer
500fadb162 Perform scanout buffer update immediately if drmmode_wait_vblank fails
Otherwise the damaged screen contents may never be displayed in that
case.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13 12:16:27 +01:00
Michel Dänzer
be862ed459 Generate docker image as part of CI pipeline
This removes the dependency on an externally generated docker image, and
should make it easier to update the docker image or make other changes
related to it.

v2:
* If the image doesn't exist, try pulling it from the main repo's
  registry.
* Use debian:testing-slim as the base, might result in a slightly
  smaller image.

v3:
* Prevent installation of packages which are only recommended, for an
  even smaller image.
* Add recommendation to remove new image from source repository in
  favour of the main repository's.

Acked-by: Alex Deucher <alexander.deucher@amd.com> # v2
2018-12-11 11:47:16 +01:00
Nicholas Kazlauskas
b11ee02c45 Support CRTC variable refresh for windows using Present flips
This patch adds support for setting the CRTC variable refresh property
for suitable windows flipping via the Present extension.

The "VariableRefresh" Option is added to AMDGPU in this patch. This
option defaults to false, and must be set to "true" in an X conf
file for variable refresh support in the driver.

In order for a window to be suitable for variable refresh it must have
the _VARIABLE_REFRESH property with a 32-bit CARDINAL value of 1.

Then the window must pass the checks required to be suitable for
Present extension flips - it must cover the entire X screen and no
other window may already be flipping.

With these conditions met every CRTC for the X screen will have their
variable refresh property set to true.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2018-11-30 15:40:34 +00:00
Nicholas Kazlauskas
2d18b37159 Check last flip window instead of screen root before flipping
A significant amount of time can pass between the X call into
check_flip for a window and when amdgpu_present_flip actually occurs.
To ensure that flipping is still possible there was an additional check
performed on screen->root in amdgpu_present_flip - but what should
be checked instead is the window itself. This only really worked before
because X ensures that the window has the same dimensions as the screen
to allow for present extension flipping.

This patch tracks the flip window between calls to check_flip and flip
and uses that window instead of screen->root.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2018-11-30 15:40:34 +00:00
Michel Dänzer
13c94a373b Skip gamma correction of cursor data if premultiplied R/G/B > alpha
The un-premultiplied R/G/B values would overflow the gamma LUT, so just
pass through the data unchanged, and leave it up to the HW how to
interpret such weird premultiplied alpha pixels.

Bugzilla: https://bugs.freedesktop.org/108355
2018-11-20 10:14:37 +01:00
Michel Dänzer
51ba6dddee Move deferred vblank events to separate drm_vblank_deferred list
It was still possible for nested xorg_list_for_each_entry_safe loops
to occur over the drm_vblank_signalled list, which could mess up that
list. Moving deferred events to a separate list allows processing the
drm_vblank_signalled list without xorg_list_for_each_entry_safe.

v2:
* Refactor drm_handle_vblank_signalled helper function, less code
  duplication => better readability (Alex Deucher)

Bugzilla: https://bugs.freedesktop.org/108600
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-16 15:47:44 +00:00
Michel Dänzer
e2c7369cae Explicitly keep track of whether a DRM event is for a flip or not
When an async flip is performed, and TearFree is enabled on the CRTC
used for timing, we schedule a vblank event for completing the page
flip. The DRM event queuing code treated this event like a vblank event,
but it needs to be treated like a page flip event.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-16 15:47:44 +00:00
Michel Dänzer
eda571222f Use drm_abort_one in drm_queue_handler
At this point, we've already established that e->handler is NULL, no
need to check again in drm_queue_handle_one. This also makes it clearer
what's happening.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-16 15:47:44 +00:00
Michel Dänzer
426f9a4965 Relax detection of non-premultiplied alpha cursor data
The stricter detection broke the cursor in some games. Apparently those
use cursor data with premultiplied alpha, but with some pixels having
r/g/b values larger than the alpha value (which corresponds to original
r/g/b values > 1.0), triggering the workaround.

Relax the detection to match what's in the X server since 1.18.4, but
keep the workaround for older versions.

Bugzilla: https://bugs.freedesktop.org/108650
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-15 16:10:03 +01:00
Michel Dänzer
a9da219e13 Add README.md to EXTRA_DIST
Otherwise it isn't included in the generated tarballs.

Suggested-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-14 09:58:46 +01:00
Michel Dänzer
1cb338253a man: This driver supports colour depths 8, 15 and 16
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-29 11:04:55 +01:00
Michel Dänzer
0734cdf544 glamor: Can work at depth >= 15 with current xserver Git master
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-29 10:57:03 +01:00
Michel Dänzer
ad6dfb0124 Detect and fix up non-premultiplied cursor data
X server >= 1.18 already had code for this, but it only caught cases
where some pixels have 0 for alpha and non-0 for a non-alpha component.
Turns out some apps (e.g. the Civilization VI game) use
non-premultiplied cursor data which doesn't have such pixels, but can
still result in visual artifacts.

This uses the method suggested by Kamil in
https://bugs.freedesktop.org/92309#c19: check for pixels where any
colour component value is larger than the alpha value, which isn't
possible with premultiplied alpha.

There can still be non-premultiplied data which won't be caught by this,
but that should result in slightly incorrect colours and/or blending at
the worst, not wildly incorrect colours such as shown in the bug report
below.

v2:
* Disable the check with current xserver Git master, which already does
  the same check now.

Bugzilla: https://bugs.freedesktop.org/108355
Suggested-by: Kamil Páral <kamil.paral@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-25 09:15:56 +02:00
Michel Dänzer
c9d43c1deb Allow up to six instances in Zaphod mode
Corresponding to up to six CRTCs being available in the hardware.

v2:
* Move instance overflow check from PreInit to the probe hooks, in
  order to further minimize wasted effort.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2018-10-11 17:14:26 +02:00
Michel Dänzer
aa572683d8 Fix condition for calling set_pixmap_bo in drmmode_xf86crtc_resize
This matches CreateScreenResources_KMS.

Fixes crash when resizing the screen (e.g. using xrandr) with depth <
24.

Bugzilla: https://bugs.freedesktop.org/104914
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-10 17:28:35 +02:00
Michel Dänzer
05a1ba9abc Add GitLab CI configuration
Builds the driver against all supported versions of xserver, with both
gcc and clang for xserver >= 1.18 (older versions cause warnings with
clang). Compiler warnings are treated as errors.

The xserver 1.15 build uses standalone glamor, the xserver 1.13 & 1.14
builds use --disable-glamor.

With the latest xserver version, make install and make distcheck are
tested as well.
2018-10-02 18:01:14 +02:00
Michel Dänzer
babbd38057 Fix --disable-glamor build
We were still relying on the glamor.h header being picked up implicitly.
2018-10-02 17:55:03 +02:00
Michel Dänzer
b6ee7f92cf Cast return value of amdgpu_get_marketing_name to char*
Avoids compiler warning with xserver < 1.16:

../../src/amdgpu_kms.c: In function ‘AMDGPUPreInitChipType_KMS’:
../../src/amdgpu_kms.c:1203:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  pScrn->chipset = amdgpu_get_marketing_name(pAMDGPUEnt->pDev);
                 ^
2018-10-02 17:52:10 +02:00
Michel Dänzer
955373a3e6 Make wait_pending_flip / handle_deferred symmetric in set_mode_major
We were always calling the latter, but not always the former, which
could result in handling deferred DRM events prematurely.

Acked-by: Slava Abramov <slava.abramov@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-26 12:32:17 +02:00
Michel Dänzer
0cd2c337d2 Handle pending scanout update in drmmode_crtc_scanout_free
We have to wait for a pending scanout flip or abort a pending scanout
update, otherwise the corresponding event handler will likely crash
after drmmode_crtc_scanout_free cleaned up the data structures.

Fixes crash after VT switch while dedicated scanout pixmaps are enabled
for any CRTC.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-26 12:32:14 +02:00
Michel Dänzer
ac5b6f96e9 Convert README to markdown
And update it a little for the current Gitlab infrastructure.
2018-09-20 18:53:05 +02:00
Michel Dänzer
451fe96809 Post-release version bump 2018-09-20 18:50:01 +02:00
Michel Dänzer
d5e17dc4c7 Bump version for the 18.1.0 release xf86-video-amdgpu-18.1.0 2018-09-14 17:00:17 +02:00
Michel Dänzer
6572be49b7 Bail from drmmode_cm_init if there's no CRTC
We would crash due to dereferencing the NULL mode_res->crtc pointer.

Bugzilla: https://bugs.freedesktop.org/107913
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-13 11:44:21 +02:00
Michel Dänzer
ca5eb9894f Bail early from drm_wait_pending_flip if there's no pending flip
No need to process any events in that case.

v2:
* Re-check drmmode_crtc->flip_pending after processing each event
2018-09-05 10:54:56 +02:00
Michel Dänzer
a923bedfd9 Do not push the CM_GAMMA_LUT property values in drmmode_crtc_cm_init
The crtc->gamma_lut values aren't initialized yet at this point, and
the property values are pushed again from drmmode_setup_colormap
anyway.

Fixes intermittent flicker due to random gamma LUT values during server
startup.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-05 10:51:52 +02:00
Michel Dänzer
26770be44b Don't use xorg_list_for_each_entry_safe for signalled flips
drm_wait_pending_flip can get called from drm_handle_event, in which
case xorg_list_for_each_entry_safe can end up processing the same entry
in both. To avoid this, just process the first list entry until the list
is empty.
2018-08-31 17:52:22 +02:00
Michel Dänzer
7eea3e2cd7 Always delete entry from list in drm_queue_handler
We left entries without a handler hook in the list, so the list could
keep taking longer to process and use up more memory.
2018-08-31 17:51:43 +02:00
Michel Dänzer
b804d7f85d glamor: Handle ihandle == -1 in amdgpu_glamor_set_shared_pixmap_backing
(Ported from radeon commit de88ea2755611bdcb18d91d8234d2ab5be8ff2e9)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-30 09:45:48 +02:00
Michel Dänzer
ae2a450cb9 Handle ihandle == -1 in amdgpu_set_shared_pixmap_backing
It means to stop using the shared pixmap backing.

(Ported from radeon commit 1799680f7bd84e0618f34f4c7486799521ddaf83)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-29 17:31:49 +02:00
Michel Dänzer
34e851d1f2 Use AC_CONFIG_MACRO_DIR instead of AC_CONFIG_MACRO_DIRS
Older versions of autoconf only supported the former.

(Cherry picked from radeon commit cba8fe4d64819aaa8ba516aa68dbe6d2aa153046)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-24 18:22:15 +02:00
Michel Dänzer
afdfa2a1b6 Add m4 directory
Although normally it only warns about it, under some circumstances,
aclocal can error out if this directory doesn't exist.

Reported-by: John Lumby <johnlumby@hotmail.com>
(Cherry picked from radeon commit 7b01c10137aba24c8f61dd9b2a19ea257ad24371)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-24 17:17:43 +02:00
Michel Dänzer
f6cd72e64e Use correct FB handle in amdgpu_do_pageflip
We were always using the handle of the client provided FB, which
prevented RandR transforms from working, and could result in a black
screen.

Fixes: 9b6782c821 "Store FB for each CRTC in drmmode_flipdata_rec"
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 18:20:06 +02:00
Michel Dänzer
85cd8eef0c Remove drmmode_crtc_private_rec::present_vblank_* related code
Not needed anymore with the more robust mechanisms for preventing nested
drmHandleEvent calls introduced in the previous changes.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 17:11:24 +02:00
Michel Dänzer
e52872da69 Defer vblank event handling while waiting for a pending flip
This is to avoid submitting more flips while we are waiting for pending
ones to complete.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 17:11:24 +02:00