summaryrefslogtreecommitdiff
path: root/src/radeon_kms.c
AgeCommit message (Collapse)Author
2020-07-13ati: cleanup terminology to use primary/secondaryDave Airlie
The X server changed some API/ABIs here. Based on amdgpu patch by Michel
2019-09-25Don't unreference FBs of pixmaps from different screens in LeaveVTMichel Dänzer
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: 06a465484101 ("Make all active CRTCs scan out an all-black framebuffer in LeaveVT")
2019-09-20Don't set up black scanout buffer if LeaveVT is called from CloseScreenMichel Dänzer
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-07-18Don't disable page flipping completely with SW cursorMichel Dänzer
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-01-28Only update drmmode_crtc->flip_pending after actually submitting a flipMichel Dänzer
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-28Don't allow TearFree scanout flips to complete in the same vblank periodMichel Dänzer
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-09Only call drmmode_uevent_init if RandR is enabledMichel Dänzer
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). Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-28Use two HW cursor buffers per CRTCMichel Dänzer
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-28Drop RADEONInfoRec::cursor_bo arrayMichel Dänzer
Not needed or even useful for anything. (Ported from amdgpu commit e95044e45350870fa7e237860e89ade91ac03550)
2018-12-28Automatically try re-enabling TearFree after a flip failedMichel Dänzer
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-28Perform scanout buffer update immediately if drmmode_wait_vblank failsMichel Dänzer
Otherwise the damaged screen contents may never be displayed in that case. (Ported from amdgpu commit 500fadb16285146e91f62fce3a0ce1360ca684ba)
2018-12-28Explicitly keep track of whether a DRM event is for a flip or notMichel Dänzer
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-10-24Allow up to six instances in Zaphod modeMichel Dänzer
Corresponding to up to six CRTCs being available in the hardware. (Ported from amdgpu commit c9d43c1deb9a9cfc41a8d6439caf46d12d220853)
2018-10-24Handle pending scanout update in drmmode_crtc_scanout_freeMichel Dänzer
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-09-11Fix uninitialized use of local variable pitch in radeon_setup_kernel_memMichel Dänzer
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-08-17Remove drmmode_crtc_private_rec::present_vblank_* related codeMichel Dänzer
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-17Move DRM event queue related initialization to radeon_drm_queue_initMichel Dänzer
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-07-23Remove drmmode_terminate_leasesMichel Dänzer
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-12Add RandR leases supportKeith Packard
Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit e4e3447603b5fd3a38a92c3f972396d1f81168ad) Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (Ported from amdgpu commit 61040bdfa360975614fb47aa7ea1b3a1abac3427) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Replace 'foo == NULL' with '!foo'Michel Dänzer
Shorter and sweeter. :) (Ported from amdgpu commit e8e688f3852fb06b0c34ed5bce47c9493bcd1613) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Don't call scanout_flip/update with a legacy RandR scanout bufferMichel Dänzer
It means we are not using our own scanout buffers. Fixes crash when TearFree is supposed to be enabled, but drmmode_handle_transform doesn't set crtc->driverIsPerformingTransform. Bugzilla: https://bugs.freedesktop.org/105736 (Ported from amdgpu commit 463477661c88cab3a87746499e5838c5b9f9a13b) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Track DRM event queue sequence number in scanout_update_pendingMichel Dänzer
Preparation for next change, no behaviour change intended. (Ported from amdgpu commit 04a5c5f7cfacad8d9ccffe81e388cc3da2036cb5) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09glamor: Use GBM for BO allocation when possibleMichel Dänzer
Inspired by amdgpu. This avoids various issues due to a GEM handle lifetime conflict between us and Mesa with current glamor. Bugzilla: https://bugs.freedesktop.org/105381 Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Add struct radeon_bufferMichel Dänzer
Inspired by amdgpu, preparation for the following change. For now, this is mostly a wrapper around struct radeon_bo, no functional change intended. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Refactor radeon_finish helperMichel Dänzer
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Move flush from radeon_scanout_do_update to its callersMichel Dänzer
No functional change intended. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Factor out radeon_surface_initialize helperMichel Dänzer
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09glamor: Don't store radeon_surfaces in pixmapsMichel Dänzer
Only EXA needs them. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Only initialize libdrm_radeon surface manager for >= R600Michel Dänzer
Not used with older GPUs. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-14Pass extents to radeon_scanout_do_update by valueMichel Dänzer
radeon_scanout_extents_intersect could leave the scanout damage region in an invalid state, triggering debugging checks in pixman: *** BUG *** In pixman_region_append_non_o: The expression r->x1 < r->x2 was false Set a breakpoint on '_pixman_log_error' to debug (Ported from amdgpu commit 8af989546907ad9fb491d940e1936d3bfc89276b)
2018-03-07Wrap the whole miPointerScreenFuncRec, instead of only Set/MoveCursorMichel Dänzer
We were clobbering entries in mi's global miSpritePointerFuncs struct, which cannot work correctly with multiple primary screens. Instead, assign a pointer to our own wrapper struct to PointPriv->spriteFuncs. Fixes crashes with multiple primary screens. Fixes: 1fe8ca75974c ("Keep track of how many SW cursors are visible on each screen") Reported-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-03-05Only change Set/MoveCursor hooks from what we expectMichel Dänzer
Since xf86CursorCloseScreen runs after RADEONCloseScreen_KMS, PointPriv->spriteFuncs doesn't point to the same struct in the latter as in RADEONCursorInit_KMS. So we were restoring info->Set/MoveCursor to the wrong struct. Then in the next server generation, info->Set/MoveCursor would end up pointing to drmmode_sprite_set/move_cursor, resulting in an infinite loop if one of them was called. To avoid this, only change the Set/MoveCursor hooks if their values match our expectations, otherwise leave them as is. This is kind of a hack, but the alternative would be invasive and thus risky changes to the way we're wrapping CloseScreen, and it's not even clear that can work without changing xserver code. Fixes: 1fe8ca75974c ("Keep track of how many SW cursors are visible on each screen") Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15Simplify depth 30 "kernel too old" error messageMichel Dänzer
We know it's depth 30, no need to have xf86DrvMsg fill it in. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15If glamor is too old for depth 30, fall back to EXA or ShadowFBMichel Dänzer
Instead of not starting up at all. Corresponding to amdgpu commit 37c7260bdef3a53b0f0295a531f33938e9aad8cf. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15Call RADEONFreeRec from RADEONFreeScreen_KMS even if info == NULLMichel Dänzer
It's safe now. (Ported from amdgpu commit c9bd1399a13cea2e1331af2c826ca054b88db071) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15Don't call RADEONFreeRec from RADEONPreInit_KMSMichel Dänzer
If the latter fails, Xorg will call RADEONFreeScreen_KMS, which calls the former. (Ported from amdgpu commit 103b7285845b786929fb509083c57e074c48f9be) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15Don't use RADEONEntPriv in RADEONFreeRecMichel Dänzer
It crashes if info == NULL. (Ported from amdgpu commits fb8444e731765588c0ff1e9053c1c7b73f5f0907 & cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14glamor: Allow depth 30 with Xorg >= 1.19.99.1Michel Dänzer
Corresponding to amdgpu commit 6aee5770fb913713bb1b9a1af8f0d0892a66f21a. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-01-22Support exa screen color depth 30 on Linux 3.16 and later. (v2)Mario Kleiner
Linux 3.16's radeon-kms introduced 10 bpc fb support. Currently, as of X-Server 1.19, this works with exa accel, but not yet when using glamor acceleration. v2: Style fixes, check for glamor first, as suggested by Michel. Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-12-28Keep track of how many SW cursors are visible on each screenMichel Dänzer
And use this to determine when we cannot use page flipping for DRI clients. We previously did this based on whether the HW cursor cannot be used on at least one CRTC, which had at least two issues: * Even while the HW cursor cannot be used, no SW cursor may actually be visible (e.g. because all cursors are disabled), in which case we can use page flipping for DRI clients anyway * Even while the HW cursor can be used, there may be SW cursors visible from non-core pointer devices, in which case we cannot use page flipping for DRI clients anyway (Ported from amdgpu commit 69e20839bfeb3ee0b0a732d72de0a32d6c5435fc) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-27Move cursor related ScreenInit calls into RADEONCursorInit_KMSMichel Dänzer
And bail if xf86_cursors_init fails. (Ported from amdgpu commit dfccaa7043ccb157a1f8be7313123792bb7e7001) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-01Add radeon_dirty_src_drawable helperMichel Dänzer
Allows tidying up radeon_dirty_src_equals and redisplay_dirty slightly. (Cherry picked from amdgpu commit 1d65ac395971571094df21ca0408d5972c6b56ec) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-11-15Use correct ScrnInfoPtr in redisplay_dirtyMichel Dänzer
We used the destination pixmap's screen for flushing drawing commands. But when we are the master screen, the destination pixmap is from the slave screen. Fixes crash when the slave screen isn't using the same acceleration architecture as us. Bugzilla: https://bugs.freedesktop.org/103613 Fixes: 01b040b4a807 ("Adapt to PixmapDirtyUpdateRec::src being a DrawablePtr") (Ported from amdgpu commit 3a4f7422913093ed9e26b73ecd7f9e773478cb1e) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30Call TimerFree for timer created in LeaveVTMichel Dänzer
We were leaking the memory allocated by TimerSet. (Ported from amdgpu commit 84aad09f18fed6b52b0c073f0bbd675a6de07807) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30Free memory returned by xf86GetEntityInfoMichel Dänzer
We were leaking it. (Ported from amdgpu commit cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-20Free pRADEONEnt memory in RADEONFreeRecMichel Dänzer
We were leaking it. (Inspired by amdgpu commit 9d84934309e4ccd9a43c73d958b8ff10ef2fc990) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-04Bail if there's a problem with ShadowFBMichel Dänzer
If we hit a problem while setting up ShadowFB, just carrying on trying to set up HW acceleration instead is unlikely to work. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-03Fix VT switching with ShadowFBMichel Dänzer
We were trying to call acceleration specific functions from LeaveVT. Instead, memset the scanout buffer to all 0 in LeaveVT and allocate a new one in EnterVT. Bugzilla: https://bugs.freedesktop.org/102948 Fixes: 06a465484101 ("Make all active CRTCs scan out an all-black framebuffer in LeaveVT") Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-30Require xserver >= 1.13Michel Dänzer
xserver 1.13.0 was released on September 6th, 2012, almost 5 years ago. This allows cleaning up a bunch of backwards compatibility code. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-08-29Use a timer for unreferencing the all-black FBMichel Dänzer
The timer fires 1 second after LeaveVT. This gives the next DRM master enough time to set up scanout of its own buffers. Fixes prolonged intermittent black screen when switching from Xorg to e.g. the GDM Wayland mode login VT. Fixes: 06a465484101 ("Make all active CRTCs scan out an all-black framebuffer in LeaveVT") Reviewed-by: Alex Deucher <alexander.deucher@amd.com>