Commit Graph

3608 Commits

Author SHA1 Message Date
Michel Dänzer
6d1dfe2523 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
(Ported from amdgpu commit ebd32b1c07208f8dbe853e089f5e4b7c6a7a658a)
2019-01-28 18:04:41 +01:00
Michel Dänzer
77d7abf464 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
(Ported from amdgpu commit d168532ee739f7e33a2798051e64ba445dd3859f)
2019-01-28 18:00:20 +01:00
Michel Dänzer
b1c01698f5 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
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-09 16:09:16 +01:00
Michel Dänzer
38db1bbcfc 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).
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-09 11:39:56 +01:00
Michel Dänzer
803f872f7d 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
(Ported from amdgpu commit 0d60233d26ec70d4e1faa343b438e33829c6d5e4)
2018-12-28 12:10:19 +01:00
Michel Dänzer
91e557f78a 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.

(Ported from amdgpu commit b04697de5270e8e45744a7025c24df1f454a4cf0)
2018-12-28 12:09:25 +01:00
Michel Dänzer
92df709786 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.

(Ported from amdgpu commit b344e1559e936046ef02c777fc4f6bcefa3830bc)
2018-12-28 12:09:09 +01:00
Michel Dänzer
e14c3d2f86 Drop RADEONInfoRec::cursor_bo array
Not needed or even useful for anything.

(Ported from amdgpu commit e95044e45350870fa7e237860e89ade91ac03550)
2018-12-28 12:08:41 +01:00
Michel Dänzer
f66254c171 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
(Ported from amdgpu commit bcfa6c258fdf41a9928f8a3c78fc528d0fafee25)
2018-12-28 12:07:49 +01:00
Michel Dänzer
ce7db51020 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.

(Ported from amdgpu commit 4e7a24ac5a64e402146953ec5850d13c05742116)
2018-12-28 12:07:24 +01:00
Michel Dänzer
21d65e5b78 Perform scanout buffer update immediately if drmmode_wait_vblank fails
Otherwise the damaged screen contents may never be displayed in that
case.

(Ported from amdgpu commit 500fadb16285146e91f62fce3a0ce1360ca684ba)
2018-12-28 12:07:03 +01:00
Michel Dänzer
64942d2c49 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.

Bugzilla: https://bugs.freedesktop.org/108600
(Ported from amdgpu commit 51ba6dddee40c3688d4c7b12eabeab516ed153b7)
2018-12-28 12:05:35 +01:00
Michel Dänzer
f450632077 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.

(Ported from amdgpu commit e2c7369cae65069aa93eed1c0b678f975ce5c274)
2018-12-28 12:04:35 +01:00
Michel Dänzer
189b6facb3 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.

(Ported from amdgpu commit eda571222f5a6be47f8897e82d85199bb9d95251)
2018-12-28 12:03:59 +01:00
Michel Dänzer
06957e3067 glamor: Can work at depth >= 15 with current xserver Git master
(Ported from amdgpu commit 0734cdf544ffd3f2ac8749ad0e4bf43f8a5cea50)
2018-12-28 11:58:47 +01:00
Michel Dänzer
99ac121770 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
(Ported from amdgpu commit 13c94a373b4858a2d2aa14c22b5f98d53c84c0d9)
2018-12-28 11:58:12 +01:00
Michel Dänzer
0c40a76d1c Detect and fix up non-premultiplied cursor data
X server >= 1.18 already has code for this, but handle it with older X
servers as well.

(Ported from amdgpu commits ad6dfb0124860cf67730bde85867f81d9258c84d &
 426f9a49655f01863cf4d898f525e5f95984e0c4)
2018-12-20 18:25:21 +01:00
Mario Kleiner
0058fd2ebf Fix crash when page flipping in multi-X-Screen/Zaphod mode
radeon_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: 740f0850f1 "Store FB for each CRTC in drmmode_flipdata_rec"
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-12-18 15:28:42 +01:00
Michel Dänzer
b559fd83b2 Post-release version bump 2018-11-19 11:38:22 +01:00
Alan Coopersmith
33cbd449b5 Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-19 11:34:22 +01:00
Michel Dänzer
5e6fa5c17a Allow up to six instances in Zaphod mode
Corresponding to up to six CRTCs being available in the hardware.

(Ported from amdgpu commit c9d43c1deb9a9cfc41a8d6439caf46d12d220853)
2018-10-24 18:22:05 +02:00
Michel Dänzer
c480fd066f 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.

(Ported from amdgpu commit 955373a3e69baa241a1f267e96d04ddb902f689f)
2018-10-24 18:19:42 +02:00
Michel Dänzer
86fe8d27b9 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.

(Ported from amdgpu commit 0cd2c337d2c02b8ec2bd994d6124b4aaaad10741)
2018-10-24 18:14:02 +02:00
Michel Dänzer
f892d37912 dri3: Handle radeon_get_pixmap_bo returning NULL
We were trying to already, but testing the wrong pointer.

Fixes: b85b7b11f5 "Add struct radeon_buffer"
Bug: https://bugs.debian.org/910846
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-15 17:14:41 +02:00
Michel Dänzer
80514b7b1b Bump version for 18.1.0 release xf86-video-ati-18.1.0 2018-09-14 17:48:49 +02:00
Michel Dänzer
2d58830c3f Fix uninitialized use of local variable pitch in radeon_setup_kernel_mem
Fixes server reset.

Pointed out by clang:

../../src/radeon_kms.c:2721:9: warning: variable 'pitch' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    if (!info->front_buffer) {
        ^~~~~~~~~~~~~~~~~~~
../../src/radeon_kms.c:2765:27: note: uninitialized use occurs here
    pScrn->displayWidth = pitch / cpp;
                          ^~~~~
2018-09-11 15:16:38 +02:00
Michel Dänzer
5d5d883496 Bail early from drm_wait_pending_flip if there's no pending flip
No need to process any events in that case.

(Ported from amdgpu commit ca5eb9894fff153c0a1df7bdc4a4745713309e27)
2018-09-07 18:19:05 +02:00
Michel Dänzer
4c7d5e50a5 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.

(Ported from amdgpu commit 26770be44b89b83bf39c28f2fe284c8cb92ed0c0)
2018-09-05 11:29:43 +02:00
Michel Dänzer
87b9a3e516 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.

(Ported from amdgpu commit 7eea3e2cd74eed22e982319144e18ae5b1087b78)
2018-09-05 11:27:25 +02:00
Michel Dänzer
de88ea2755 glamor: Handle ihandle == -1 in radeon_glamor_set_shared_pixmap_backing 2018-08-29 17:23:34 +02:00
Michel Dänzer
84bde2df5b EXA: Handle ihandle == -1 in RADEONEXASharePixmapBacking 2018-08-29 17:23:30 +02:00
Michel Dänzer
1799680f7b Handle ihandle == -1 in radeon_set_shared_pixmap_backing
It means to stop using the shared pixmap backing.

Fixes crash when changing PRIME slave output configuration.
2018-08-29 17:23:26 +02:00
Michel Dänzer
3c42bd0480 EXA: Handle NULL BO pointer in radeon_set_pixmap_bo 2018-08-29 17:19:24 +02:00
Michel Dänzer
cba8fe4d64 Use AC_CONFIG_MACRO_DIR instead of AC_CONFIG_MACRO_DIRS
Older versions of autoconf only supported the former.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-24 17:05:06 +02:00
Michel Dänzer
7b01c10137 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>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-23 18:48:45 +02:00
Michel Dänzer
60cd28bbbe 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.

(Ported from amdgpu commit 85cd8eef0cbed7b409b07f58d76dacd34aa3ddea)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17 10:06:43 +02:00
Michel Dänzer
c42f6e2e61 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.

(Ported from amdgpu commit e52872da69ecc84dafb3355839e35b0383f0d228)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17 10:02:08 +02:00
Michel Dänzer
ba83a866af Add radeon_drm_handle_event wrapper for drmHandleEvent
Instead of processing DRM events directly from drmHandleEvent's
callbacks, there are three phases:

1. drmHandleEvent is called, and signalled events are re-queued to
   _signalled lists from its callbacks.
2. Signalled page flip completion events are processed.
3. Signalled vblank events are processed.

This should make sure that we never call drmHandleEvent from one of its
callbacks, which would usually result in blocking forever.

(Ported from amdgpu commit 739181c8d3334ff14b5a607895dfdeb29b0d9020)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17 09:59:42 +02:00
Michel Dänzer
93621e408c Add radeon_drm_wait_pending_flip function
Replacing the drmmode_crtc_wait_pending_event macro.

(Ported from amdgpu commit 6029794e8a35417faf825491a89b85f713c77fc1)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17 09:58:57 +02:00
Michel Dänzer
ecdf0b7ec9 Move DRM event queue related initialization to radeon_drm_queue_init
And make radeon_drm_queue_handler not directly accessible outside of
radeon_drm_queue.c.

(Ported from amdgpu commit 0148283984c77f7a6e97026edc3093497547e0a4)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17 09:57:33 +02:00
Michel Dänzer
824189b3da Use correct FB handle in radeon_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.

Bugzilla: https://bugs.freedesktop.org/107519
Fixes: 740f0850f1 "Store FB for each CRTC in drmmode_flipdata_rec"
(Ported from amdgpu commit f6cd72e64e85896b6d155bee0930e59771dcb701)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 18:22:27 +02:00
Michel Dänzer
740f0850f1 Store FB for each CRTC in drmmode_flipdata_rec
We were only storing the FB provided by the client, but on CRTCs with
TearFree enabled, we use a separate FB. This could cause
drmmode_flip_handler to fail to clear drmmode_crtc->flip_pending, which
could result in a hang when waiting for the pending flip to complete. We
were trying to avoid that by always clearing drmmode_crtc->flip_pending
when TearFree is enabled, but that wasn't reliable, because
drmmode_crtc->tear_free can already be FALSE at this point when
disabling TearFree.

Now that we're keeping track of each CRTC's flip FB separately,
drmmode_flip_handler can reliably clear flip_pending, and we no longer
need the TearFree hack.

(Ported from amdgpu commit 9b6782c821e0bdc53336d98f87ddde752faf7902)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-03 18:24:01 +02:00
Michel Dänzer
ef2a6b818f glamor: Set RADEON_CREATE_PIXMAP_DRI2 for DRI3 pixmaps
Not doing this resulted in falling back to software for DRI3 client
presentation operations with ShadowPrimary.

(Ported from amdgpu commit 2989d40ef74d9966e8e8df2ef7727b2cc48d4960)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-02 18:48:04 +02:00
Michel Dänzer
db28d35ce9 glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible
Inspired by the modesetting driver.

Fixes screen pixmap corruption with Xorg < 1.20, and as a bonus,
simplifies the code slightly.

Bugzilla: https://bugs.freedesktop.org/107385
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-27 11:30:57 +02:00
Michel Dänzer
7de4ea1588 Bump version to 18.0.99
Forgot to do this after the 18.0.1 release.
2018-07-27 09:13:12 +02:00
Michel Dänzer
fed411290b Use strcpy for RandR output property names
Instead of strncpy with the string length. Avoids new warnings with GCC
8:

../../src/drmmode_display.c: In function ‘drmmode_output_create_resources’:
../../src/drmmode_display.c:2240:2: warning: ‘strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(tearfree_prop->name, "TearFree", 8);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2244:2: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(tearfree_prop->enums[0].name, "off", 3);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2245:2: warning: ‘strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(tearfree_prop->enums[1].name, "on", 2);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/drmmode_display.c:2247:2: warning: ‘strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(tearfree_prop->enums[2].name, "auto", 4);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(Ported from amdgpu commit f3b2ed37d683f8616a0a31ff63133ddb8fe1a4a3)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-24 17:28:46 +02:00
Michel Dänzer
d258413c95 Remove drmmode_terminate_leases
The RandR screen private is already freed when our CloseScreen runs, so
this can't do anything useful. This cleanup has to be done by the X
server itself.

(Ported from amdgpu commit 5f06d6b8ba570b500956ad26fee711d5ac427818)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-23 18:54:40 +02:00
Michel Dänzer
ffdbd46b0a Hardcode "non-desktop" RandR property name
It's a bit silly to require current randrproto just for this definition,
which can't really change anyway.

Suggested-by: Qiang Yu <qiang.yu@amd.com>
(Ported from amdgpu commit ae8e02c6fc4ef5d5340b8cd4739e66b19b9e3386)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-23 11:02:32 +02:00
Michel Dänzer
64bd009d17 Don't allocate drmmode_output->props twice
This was accidentally duplicated when porting RandR lease support from
amdgpu.

Trivial.
2018-07-19 11:33:42 +02:00
Michel Dänzer
499d2f9d5d glamor: Invalidate cached GEM handle in radeon_set_pixmap_bo
We continued using the stale cached handle, causing issues e.g. when
resizing the screen via RandR.

Reported-by: iive on IRC
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-17 11:43:12 +02:00