summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2019-03-04present: Don't check tiling parameters with DC & DRM minor version >= 31Michel Dänzer1-5/+11
Current DC handles any changes of tiling parameters for flips. v2: * Just check all tiling bits if DRM minor < 31 or DC is disabled. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-03-04Make drmmode_cm_enabled an inline functionMichel Dänzer2-8/+9
So that it can be used outside of drmmode_display.c as well. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-03-04Revert "Remove set but unused amdgpu_dri2::pKernelDRMVersion"Michel Dänzer2-0/+7
This reverts commit 720a61000aeb139005bd8125908cec66a6e69554. We're going to make use of it now. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-03-01dri2: Call drm_queue_handle_deferred in dri2_deferred_eventMichel Dänzer1-4/+15
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: 739181c8d3334 "Add amdgpu_drm_handle_event wrapper for drmHandleEvent" Reviewed-by: Aaron Liu <aaron.liu@amd.com> Tested-by: Aaron Liu <aaron.liu@amd.com>
2019-02-27present: Check that flip and screen pixmap pitches matchMichel Dänzer1-1/+7
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. Tested-by: Jax Lin <jax.lin@amd.com>
2019-02-22Call amdgpu_present_set_screen_vrr from amdgpu_vrr_property_updateMichel Dänzer3-1/+9
If the window is currently flipping. This might make a difference when the property gets disabled: Variable refresh will now be disabled immediately in that case, instead of only when the window can no longer use page flipping at all. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-02-22Make use of property request wrappers for VRR propertyMichel Dänzer1-60/+55
Instead of scanning for PropertyNotify events. Reasons: * Works even if no client listens to PropertyNotify events for the window. * No overhead on delivery of unrelated events, and no overhead at all if Option "VariableRefresh" is disabled. v2: * Use shorter variable name amdgpu_vrr_atom. * Call MakeAtom regardless of info->instance_id, for robustness vs VRR being enabled in some but not all AMDGPU screens. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-02-20Wrap change/delete window property request handlersMichel Dänzer1-1/+90
Preparation for the following change. v2: * Add comments explaining what the wrappers are wrapping. * Use global amdgpu_property_vectors_wrapped to keep track of whether the vectors need to be (un)wrapped, for robustness against VRR being enabled in some but not all AMDGPU screens. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-02-20Don't enable the VRR support code for GPU screensMichel Dänzer1-4/+6
Windows aren't associated with GPU screens, and amdgpu_present_flip is never called for them, so VRR can never actually be enabled for them. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-02-12Don't register a window private if VRR is disabledMichel Dänzer1-1/+2
It's not used in that case. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-01-25Keep waiting for a pending flip if drm_handle_event returns 0Michel Dänzer1-1/+1
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. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-25Call drmHandleEvent again if it was interrupted by a signalMichel Dänzer1-1/+16
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. v2: * Use ErrorF instead of xf86DrvMsg with hard-coded screen 0. Bugzilla: https://bugs.freedesktop.org/109364 Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2019-01-17Only update drmmode_crtc->flip_pending after actually submitting a flipMichel Dänzer2-38/+43
And only clear it if it matches the framebuffer of the completed flip being processed. Fixes (WW) AMDGPU(0): flip queue failed: Device or resource busy (WW) AMDGPU(0): Page flip failed: Device or resource busy (EE) AMDGPU(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 . Acked-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-16Don't allow TearFree scanout flips to complete in the same vblank periodMichel Dänzer1-2/+2
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 . Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-16glamor: Avoid glamor_create_pixmap for pixmaps backing windowsMichel Dänzer1-1/+1
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. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-16dri2: Flush in dri2_create_buffer2 after calling glamor_set_pixmap_boMichel Dänzer1-0/+6
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-11dri3: Flush if necessary in dri3_fd_from_pixmapMichel Dänzer1-2/+29
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-10Only call drmmode_validate_leases if RandR is enabledMichel Dänzer1-1/+2
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-10Only call drmmode_uevent_init if RandR is enabledMichel Dänzer2-3/+3
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 https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/commit/1a489142c8e6a4828348cc9afbd0f430d3b1e2d8 (via https://bugs.freedesktop.org/109230#c11). (Ported from radeon commit 38db1bbcfc019c92884c7819a6630c70e543f6b2) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-20Remove superfluous vrr_flipping field and clean up related codeMichel Dänzer2-18/+14
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-19Don't clear info->flip_window in present_unflipMichel Dänzer1-1/+0
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: 2d18b37159edc "Check last flip window instead of screen root before flipping" Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-19Fix crash when page flipping in multi-X-Screen/Zaphod modeMario Kleiner1-7/+9
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: 9b6782c821e0 "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-13Use two HW cursor buffers per CRTCMichel Dänzer3-16/+38
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-13Update cursor position in drmmode_show_cursor if hotspot changedMichel Dänzer2-32/+48
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-13Use drmIoctl in drmmode_show_cursorMichel Dänzer1-9/+14
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-13Drop AMDGPUInfoRec::cursor_buffer arrayMichel Dänzer4-24/+9
Not needed or even useful for anything. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13Don't use GBM for allocating HW cursor BOsMichel Dänzer2-54/+14
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-13Automatically try re-enabling TearFree after a flip failedMichel Dänzer2-11/+71
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-13Cancel pending scanout update in drmmode_crtc_scanout_updateMichel Dänzer1-5/+11
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-13Perform scanout buffer update immediately if drmmode_wait_vblank failsMichel Dänzer1-10/+19
Otherwise the damaged screen contents may never be displayed in that case. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-30Support CRTC variable refresh for windows using Present flipsNicholas Kazlauskas5-0/+181
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-30Check last flip window instead of screen root before flippingNicholas Kazlauskas2-2/+6
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-20Skip gamma correction of cursor data if premultiplied R/G/B > alphaMichel Dänzer1-13/+21
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-16Move deferred vblank events to separate drm_vblank_deferred listMichel Dänzer1-11/+46
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-16Explicitly keep track of whether a DRM event is for a flip or notMichel Dänzer6-37/+25
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-16Use drm_abort_one in drm_queue_handlerMichel Dänzer1-14/+14
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-15Relax detection of non-premultiplied alpha cursor dataMichel Dänzer1-2/+2
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-10-29glamor: Can work at depth >= 15 with current xserver Git masterMichel Dänzer2-1/+9
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-25Detect and fix up non-premultiplied cursor dataMichel Dänzer1-31/+60
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-11Allow up to six instances in Zaphod modeMichel Dänzer5-39/+59
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-10Fix condition for calling set_pixmap_bo in drmmode_xf86crtc_resizeMichel Dänzer1-2/+1
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-02Fix --disable-glamor buildMichel Dänzer4-4/+44
We were still relying on the glamor.h header being picked up implicitly.
2018-10-02Cast return value of amdgpu_get_marketing_name to char*Michel Dänzer1-1/+1
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-09-26Make wait_pending_flip / handle_deferred symmetric in set_mode_majorMichel Dänzer1-1/+5
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-26Handle pending scanout update in drmmode_crtc_scanout_freeMichel Dänzer3-11/+18
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-13Bail from drmmode_cm_init if there's no CRTCMichel Dänzer1-0/+3
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-05Bail early from drm_wait_pending_flip if there's no pending flipMichel Dänzer1-1/+2
No need to process any events in that case. v2: * Re-check drmmode_crtc->flip_pending after processing each event
2018-09-05Do not push the CM_GAMMA_LUT property values in drmmode_crtc_cm_initMichel Dänzer1-1/+1
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-08-31Don't use xorg_list_for_each_entry_safe for signalled flipsMichel Dänzer1-3/+9
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-31Always delete entry from list in drm_queue_handlerMichel Dänzer1-1/+1
We left entries without a handler hook in the list, so the list could keep taking longer to process and use up more memory.