Commit Graph

3632 Commits

Author SHA1 Message Date
Michel Dänzer
4d84cf438e Handle NULL fb_ptr in pixmap_get_fb
This can happen when HW acceleration is disabled.

Fixes https://gitlab.freedesktop.org/xorg/driver/xf86-video-ati/issues/188
2020-02-10 15:53:48 +00:00
Adam Jackson
f223035f4f Fix link failure with gcc 10
Without the 'extern' this looks like a definition not just a
declaration, in every file that includes the header. gcc 10 is stricter
about this kind of multiple definition.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-02-05 11:39:53 -05:00
Michel Dänzer
b9bd8097e1 Bump version for 19.1.0 release xf86-video-ati-19.1.0 2019-10-15 17:54:12 +02:00
Michel Dänzer
2faaecc69b Don't unreference FBs of pixmaps from different screens in LeaveVT
FindClientResourcesByType finds pixmaps from all screens, but trying to
process ones from other screens here makes no sense and likely results
in a crash or memory corruption.

Fixes: 06a4654841 ("Make all active CRTCs scan out an all-black
                      framebuffer in LeaveVT")
2019-09-25 09:23:25 +02:00
Michel Dänzer
2cbbd8648c Don't set up black scanout buffer if LeaveVT is called from CloseScreen
Avoids a crash described in
https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/merge_requests/43#note_223718

(Ported from amdgpu commit 5b8bc9fc505c551dcd9b0ed5ab835a49fa4f9fda)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-09-20 18:47:02 +02:00
Michel Dänzer
c7ed12cb2e Don't disable page flipping completely with SW cursor
Even with SW cursor, page flipping can be used while no X cursor is
visible.

Occurred to me in the context of xorg/xserver#828.
(Ported from amdgpu commit 87f41ace4920fd2069794211683659eb25b025a6)
2019-07-18 18:14:48 +02:00
Michel Dänzer
33803c85f7 present: Check that we can get a KMS FB for flipping
This can legitimately fail if the pixmap's storage is shared from
another device, e.g. when using PRIME render offloading.

(Ported from amdgpu commit 7d3fef72e0c871e1677e9e544f4cae5e238b5c52)
2019-06-25 17:46:23 +02:00
Michel Dänzer
fee737e828 Remove dri2_drawable_crtc parameter consider_disabled
All callers were passing TRUE.

(Ported from amdgpu commit ea19a5207054bb159fc7fb6d88e0ceb10c3da010)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-06-14 16:03:45 +02:00
Michel Dänzer
2a3f2d2089 dri2: Re-use previous CRTC when possible if pick_best_crtc returns NULL
This way, the MSC will continue ticking at the rate of (the last mode
which was enabled for) that CRTC, instead of the client running
unthrottled.

(Ported from amdgpu commit 3109f088fdbd89c2ee8078625d4f073852492656)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-06-14 16:03:38 +02:00
Flora Cui
d5f5bc5846 dri2: reply to client for WaitMSC request in any case
otherwise client would wait for reply forever and desktop appears hang.

Signed-off-by: Flora Cui <flora.cui@amd.com>
(Ported from amdgpu commit fb06fb814700a47464abd756e1111dcc76d0d776)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-06-14 11:20:12 +02:00
Michel Dänzer
f758908db4 dri3: Always flush glamor before sharing pixmap storage with clients
Even if glamor_gbm_bo_from_pixmap / glamor_fd_from_pixmap themselves
don't trigger any drawing, there could already be unflushed drawing to
the pixmap whose storage we share with a client.

(Ported from amdgpu commit 4b17533fcb30842caf0035ba593b7d986520cc85)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2019-05-09 12:35:37 +02:00
Michel Dänzer
d1d8e3c8d0 Retry get_fb_ptr in get_fb
If get_fb_ptr returns NULL, try again after pixmap_get_handle, it should
work then.

Fixes spurious Present page flipping failures using "normal" pixmaps
which aren't shared with direct rendering clients, e.g. with a
compositor using the RENDER extension.

Bugzilla: https://bugs.freedesktop.org/110417
(Ported from amdgpu commit bf61e6d7ac1a5754b1026d7f80acf25ef622c491)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-04-24 12:25:39 +02:00
Michel Dänzer
36703f66c3 Bump version for 19.0.1 release xf86-video-ati-19.0.1 2019-03-19 18:01:02 +01:00
Dave Airlie
4407c78bd8 modesetting: add tile property support
This adds tiling support to the driver, it retrieves the tile info from
the kernel and translates it into the server format and exposes the
property.

(Ported from xserver commits 8fb8bbb3062f1a06621ab7030a9e89d5e8367b35
 and 6abdb54a11dac4e8854ff94ecdcb90a14321ab31)
(Ported from amdgpu commit 6ee857726166f495abcd68e4ff60e3a09593d079)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-15 12:42:04 +01:00
Michel Dänzer
79bc0e054f Use radeon_finish in drmmode_crtc_scanout_update
radeon_glamor_finish only works if we're using glamor, otherwise it'll
crash.

Fixes: ce7db51020 "Cancel pending scanout update in drmmode_crtc_scanout_update"
Bug: https://bugs.debian.org/924540
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-14 11:10:51 +01:00
Michel Dänzer
f6cd4a67d7 Revert "glamor: Avoid glamor_create_pixmap for pixmaps backing windows"
This reverts commit 274703087f.

Reports of visual corruption were bisected to this, e.g.
https://bugs.archlinux.org/task/61941 . I can reproduce this with Turks,
but not with Bonaire. I assume it's a Mesa/glamor bug, but let's revert
for now.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-08 11:48:10 +01:00
Michel Dänzer
0d132d99e0 Bump version for 19.0.0 release xf86-video-ati-19.0.0 2019-03-06 17:48:42 +01:00
Michel Dänzer
c301b8af25 dri2: Call drm_queue_handle_deferred in dri2_deferred_event
drm_queue_handler just puts the event on the signalled list; without
calling drm_queue_handle_deferred, actual processing of the event may be
delayed indefinitely, e.g. until another event arrives from the kernel.

This could result in DRI2 clients hanging during DPMS off.

Fixes: ba83a866af "Add radeon_drm_handle_event wrapper for
                     drmHandleEvent"
(Ported from amdgpu commit 09be74a3d1dd9604336d9a27f98d132b262dcbaf)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-04 17:07:14 +01:00
Michel Dänzer
705020b624 present: Check that flip and screen pixmap pitches match
If they don't, flipping will result in corrupted display.

Test case:

* Run Xorg at 1920x1080 with no window manager
* glxgears -geometry 2048x1080

The Present extension code in xserver 1.21 will check for this.

(Ported from amdgpu commit a636f42b496b0604ca00a144690ece61d1a88a27)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-01 18:23:30 +01:00
Michel Dänzer
15697ee242 Keep waiting for a pending flip if drm_handle_event returns 0
drm_wait_pending_flip stopped waiting if drm_handle_event returned 0,
but that might have processed only some unrelated DRM events. As long as
the flip is pending, we have to keep waiting for its completion event.

Noticed while working on the previous fix.

(Ported from amdgpu commit 9045fb310f88780e250e60b80431ca153330e61b)
2019-02-11 12:12:34 +01:00
Michel Dänzer
227123de3d Call drmHandleEvent again if it was interrupted by a signal
drmHandleEvent can be interrupted by a signal in read(), in which case
it doesn't process any events but returns -1, which
drm_handle_event propagated to its callers. This could cause the
following failure cascade:

1. drm_wait_pending_flip stopped waiting for a pending flip.
2. Its caller cleared drmmode_crtc->flip_pending before the flip
   completed.
3. Another flip was attempted but got an unexpected EBUSY error because
   the previous flip was still pending.
4. TearFree was disabled due to the error.

The solution is to call drmHandleEvent if it was interrupted by a
signal. We can do that in drm_handle_event, because when that is called,
either it is known that there are events ready to be processed, or the
caller has to wait for events to arrive anyway.

Bugzilla: https://bugs.freedesktop.org/109364
(Ported from amdgpu commit 3ff2cc225f6bc08364ee007fa54e9d0150adaf11)
2019-01-28 18:24:41 +01:00
Michel Dänzer
1bfdccf763 Only update drmmode_crtc->flip_pending after actually submitting a flip
And only clear it if it matches the framebuffer of the completed flip
being processed.

Fixes

 (WW) RADEON(0): flip queue failed: Device or resource busy
 (WW) RADEON(0): Page flip failed: Device or resource busy
 (EE) RADEON(0): present flip failed

due to clobbering drmmode_crtc->flip_pending.

Reproducer: Enable TearFree, run warzone2100 fullscreen, toggle
Vertical sync on/off under Video Options. Discovered while investigating
https://bugs.freedesktop.org/109364 .

(Ported from amdgpu commit e72a02ba1d35743fefd939458b9d8cddce86e7f5)
2019-01-28 18:11:10 +01:00
Michel Dänzer
dcd3527299 Don't allow TearFree scanout flips to complete in the same vblank period
We were using a relative target of 0, meaning "complete the flip ASAP".
This could result in the flip sometimes, but not always completing in
the same vertical blank period where the corresponding drawing occurred,
potentially causing judder artifacts with applications updating their
window contents synchronized to the display refresh. A good way to test
this is the vsynctester.com site in a windowed browser, where the judder
results in the large "VSYNC" text intermittently appearing red or cyan
instead of the expected gray.

To avoid this, use a relative target MSC of 1, meaning that if a
vertical blank period is in progress, the flip will only complete in the
next one.

Reported by Julian Tempel and Brandon Wright in
https://bugs.freedesktop.org/106175 .

(Ported from amdgpu commit a1b479c7d0066c481af920f297d6af9009dda11e)
2019-01-28 18:08:35 +01:00
Michel Dänzer
274703087f glamor: Avoid glamor_create_pixmap for pixmaps backing windows
If the compositing manager uses direct rendering (as is usually the case
these days), the storage of a pixmap allocated by glamor_create_pixmap
needs to be reallocated for sharing it with the compositing manager.
Instead, allocate pixmap storage which can be shared directly.

(Ported from amdgpu commit bf326f2ea19daa6c8da23d6788ff301ae70b8e69)
2019-01-28 18:06:50 +01:00
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