Commit Graph

3238 Commits

Author SHA1 Message Date
Joakim Tjernlund
fccfd75ecf Fix non GLAMOR build
Non GLAMOR builds needs pRADEONEnt so move the USE_GLAMOR define
down to make pRADEONEnt defined in this case.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-11-27 11:13:10 +01:00
Michel Dänzer
15350bd553 Use correct ScrnInfoPtr in redisplay_dirty
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: 01b040b4a8 ("Adapt to PixmapDirtyUpdateRec::src being a
                     DrawablePtr")
(Ported from amdgpu commit 3a4f7422913093ed9e26b73ecd7f9e773478cb1e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-11-15 18:01:29 +01:00
Daniel Martin
6441210bc5 modesetting: Check crtc before searching link-status property
No need to lookup the link-status property if we don't have a crtc.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
(Ported from xserver commit 8d7f7e24261e68459e6f0a865e243473f65fe7ad)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-11-01 18:42:33 +01:00
Keith Packard
cafcb55768 modesetting: Skip no-longer-present connectors when resetting BAD links
Outputs may have NULL mode_output (connector) pointers if the
connector disappears while the server is running. Skip these when
resetting outputs with BAD link status.

(Ported from xserver commit 37f4e7651a2fd51efa613a08a1e705553be33e76)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30 18:41:31 +01:00
Michel Dänzer
0cd14777b7 Always call drmModeFreeProperty after drmModeGetProperty
We were not doing so in all cases, leaking memory allocated by the
latter.

(Cherry picked from amdgpu commit f6b39bcd45cb06976ba8a3600df77fc471c63995)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30 18:41:01 +01:00
Michel Dänzer
84c7d9c1c7 Call TimerFree for timer created in LeaveVT
We were leaking the memory allocated by TimerSet.

(Ported from amdgpu commit 84aad09f18fed6b52b0c073f0bbd675a6de07807)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30 18:40:46 +01:00
Michel Dänzer
d588015f4f Free memory returned by xf86GetEntityInfo
We were leaking it.

(Ported from amdgpu commit cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-30 18:40:27 +01:00
Michel Dänzer
ec90c94881 Free pRADEONEnt memory in RADEONFreeRec
We were leaking it.

(Inspired by amdgpu commit 9d84934309e4ccd9a43c73d958b8ff10ef2fc990)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-20 16:51:16 +02:00
Michel Dänzer
b93ae9b159 Unreference pixmap's FB with EXA as well in radeon_set_pixmap_bo
Not doing so resulted in DRI2 page flips not actually changing the FB
being scanned out, showing intermittent flicker of the "back" buffer
rendering.

Bugzilla: https://bugs.freedesktop.org/102643
Fixes: 55e513b978 "Use reference counting for tracking KMS framebuffer
                     lifetimes"
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-20 10:28:37 +02:00
Michel Dänzer
7d43535409 Bail if there's a problem with ShadowFB
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-04 11:11:33 +02:00
Michel Dänzer
34da04daec Fix VT switching with ShadowFB
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: 06a4654841 ("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-10-03 12:51:05 +02:00
Michel Dänzer
5cdd334b34 Require xserver >= 1.13
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-30 18:48:19 +09:00
Michel Dänzer
9d9c565c84 Use a timer for unreferencing the all-black FB
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: 06a4654841 ("Make all active CRTCs scan out an all-black
                      framebuffer in LeaveVT")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 18:07:51 +09:00
Michel Dänzer
e4a3df19d5 Remove drmmode_scanout_free
Not used anymore.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 16:36:01 +09:00
Michel Dänzer
06a4654841 Make all active CRTCs scan out an all-black framebuffer in LeaveVT
And destroy all other FBs. This is so that other DRM masters can only
get access to this all-black FB, not to any other FB we created, while
we're switched away and not DRM master.

Fixes: 55e513b978 ("Use reference counting for tracking KMS
                      framebuffer lifetimes")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 16:35:30 +09:00
Michel Dänzer
7f0cd68d1b Create radeon_master_screen helper
Preparatory, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 16:35:16 +09:00
Michel Dänzer
20f6b56fdb Create radeon_pixmap_get_fb_ptr helper
Preparatory, no functional change intended yet.

Also inline radeon_pixmap_create_fb into radeon_pixmap_get_fb, since
there's only one call-site anymore.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 16:34:54 +09:00
Michel Dänzer
4bc992c310 Create drmmode_set_mode helper
Preparatory, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29 16:34:30 +09:00
Michel Dänzer
3f6210ca2c Create radeon_pixmap_clear helper
Preparatory, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-23 16:27:25 +09:00
Martin Peres
0472a605e0 modesetting: re-set the crtc's mode when link-status goes BAD
Despite all the careful planning of the kernel, a link may become
insufficient to handle the currently-set mode. At this point, the
kernel should mark this particular configuration as being broken
and potentially prune the mode before setting the offending connector's
link-status to BAD and send the userspace a hotplug event. This may
happen right after a modeset or later on.

Upon receiving a hot-plug event, we iterate through the connectors to
re-apply the currently-set mode on all the connectors that have a
link-status property set to BAD. The kernel may be able to get the
link to work by dropping to using a lower link bpp (with the same
display bpp). However, the modeset may fail if the kernel has pruned
the mode, so to make users aware of this problem a warning is outputed
in the logs to warn about having a potentially-black display.

This patch does not modify the current behaviour of always propagating
the events to the randr clients. This allows desktop environments to
re-probe the connectors and select a new resolution based on the new
(currated) mode list if a mode disapeared. This behaviour is expected in
order to pass the Display Port compliance tests.

(Ported from xserver commit bcee1b76aa0db8525b491485e90b8740763d7de6)

[ Michel: Bump libdrm dependency to >= 2.4.78 for
  DRM_MODE_LINK_STATUS_BAD ]
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-18 14:40:19 +09:00
Michel Dänzer
d822a0f470 Make radeon_scanout_do_update take a PixmapPtr instead of a DrawablePtr
All callers were already passing in a pixmap.

This allows simplifying the rotated scanout case slightly.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 16:20:52 +09:00
Michel Dänzer
3e24770b1b Use xorg_list_append for the DRM event list
We were adding entries at the start of the list, i.e. the list was
ordered from most recently added to least recently added. However, the
corresponding DRM events are generally expected to arrive in the same
order as they are queued, which means that radeon_drm_queue_alloc would
generally have to traverse the whole list to find the entry
corresponding to an arrived event. Fix this by adding entries at the end
of the list.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 16:05:26 +09:00
Michel Dänzer
36ce792013 Consolidate radeon_scanout_flip_abort/handler helpers
While at it, make them use crtc->driver_private.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 16:04:21 +09:00
Michel Dänzer
d314cbfb22 Always allow DRI2 page flipping with TearFree
Even if TearFree is enabled for the CRTC we're synchronizing to.

v2:
* Move manpage hunk here from previous change.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-08-17 16:03:50 +09:00
Michel Dänzer
4445765af5 Always allow Present page flipping with TearFree
Even if TearFree is active for the the CRTC we're synchronizing to. In
that case, for Present flips synchronized to vertical blank, the other
scanout buffer is immediately synchronized and flipped to during the
target vertical blank period. For Present flips not synchronized to
vertical blank, we simply use the MSC and timestamp values of the last
vertical blank period for timing purposes, and let the normal TearFree
mechanism handle display updates.

v2:
* Move manpage hunk to next change, since TearFree can still prevent
  DRI2 page flipping with this change.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-08-17 15:52:24 +09:00
Michel Dänzer
65e0c5ea1b Pass extents to radeon_scanout_do_update
Preparation for following change, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:51:43 +09:00
Michel Dänzer
1443270e52 Add source drawable parameter to radeon_scanout_do_update
Preparation for following changes, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:49:01 +09:00
Michel Dänzer
7c10ee9c88 Handle multiple "pending" Present flips
The xserver Present code can submit a flip in response to notifying it
that a vblank event arrived. This can happen before the completion event
of the previous flip is processed. In that case, we were clearing the
drmmode_crtc->flip_pending field prematurely.

Prevent this by only clearing drmmode_crtc->flip_pending when it matches
the framebuffer being scanned out since the flip whose completion event
we're processing.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:45:37 +09:00
Michel Dänzer
e6d7dc2070 Wait for pending flips synchronously before turning off a CRTC
Allows removing drmmode_clear_pending_flip and the pending_dpms_mode
field and cleaning up the code considerably.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:42:45 +09:00
Michel Dänzer
f87acdbfb1 Create drmmode_crtc_wait_pending_event helper macro
Preparation for following change, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:38:21 +09:00
Michel Dänzer
99f1d7a474 Create drmmode_wait_vblank helper
Allows cleaning up the code considerably.

v2:
* Fix "drmWaiVBlank" typo, add blank line for readability (Slava Abramov)
* Rename in/out sequence parameters to "target_seq" and "result_seq",
  hopefully that will be clearer.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-08-17 15:24:22 +09:00
Michel Dänzer
49cc61ab97 Pass reference CRTC to radeon_do_pageflip directly
Simplifies the code slightly.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:23:34 +09:00
Michel Dänzer
3f120fa1d5 Remove drmmode_crtc->scanout_destroy[] array
No longer necessary since we're reference counting framebuffers.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com
2017-08-15 17:31:31 +09:00
Michel Dänzer
01b040b4a8 Adapt to PixmapDirtyUpdateRec::src being a DrawablePtr 2017-08-15 17:15:27 +09:00
Michel Dänzer
5309bde0c4 Allow DRI page flipping when some CRTCs use separate scanout buffers
As long as the CRTC we're synchronizing to doesn't.

v2:
* Remove redundant checks from can_exchange which still prevented DRI2
  page flipping

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-02 18:55:23 +09:00
Michel Dänzer
9bc3eef744 Add drmmode_crtc_can_flip helper
To reduce code duplication between DRI2 and Present. No functional
change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-02 18:54:54 +09:00
Michel Dänzer
c2d2689069 Use root window (pixmap) instead of screen pixmap for scanout updates
Preparation for following changes, no functional change intended yet.

v2:
* Add drmmode_screen_damage_destroy callback to prevent use-after-free
  on server shutdown

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-28 12:00:35 +09:00
Michel Dänzer
7d7abf99b5 Only handle reflection in the driver with Xorg < 1.16
Xorg doesn't handle the hardware cursor correctly in that case for
rotation and general transforms, and we can't force the SW cursor.

Fixes: f2bc882f1c ("Handle rotation in the driver also with Xorg
                      1.12-1.18")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-26 18:13:35 +09:00
Michel Dänzer
94dc2b80f3 If a TearFree flip fails, fall back to non-TearFree operation
In order to avoid possible freeze / log file spam in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99769
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-13 17:29:24 +09:00
Michel Dänzer
aff267ee36 Use drmmode_crtc->scanout_id instead of 0 to check for scanout buffer
Preparation for following change, no functional change intended.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-11 15:39:05 +09:00
Michel Dänzer
df88d51c50 Use pRADEONEnt->fd exclusively for the DRM file descriptor
This brings us closer to amdgpu.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-30 17:40:12 +09:00
Michel Dänzer
19626bce4e Improve drmmode_fb_reference debugging code
If a reference count is <= 0, call FatalError with the call location
(in case it doesn't get resolved in the backtrace printed by
FatalError).

(Ported from amdgpu commit 1b6ff5fd9933c00ec1ec90dfc62e0b531927749b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-30 17:39:53 +09:00
Michel Dänzer
bc46ffdf71 Increase reference count of FB assigned to drmmode_crtc->flip_pending
Otherwise, it could happen that we destroy the FB before the flip
completes, resulting in use-after-free and most likely a crash.

(Ported from amdgpu commit af7221e1c4d2dbdfd488eb0976a835584ea8441c)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 18:19:31 +09:00
Michel Dänzer
c9dd28cb0c Only call drmmode_scanout_free for non-GPU screens in LeaveVT
Destroying the scanout buffers of GPU screens resulted in a crash when
switching back to the Xorg VT.

Fixes: 4cfa4615f7 ("Use drmmode_crtc_scanout_* helpers for RandR 1.4
                      scanout pixmaps")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 11:59:08 +09:00
Michel Dänzer
78fad9ca16 Include xf86Pci.h for DRICreatePCIBusID with xserver Git master
The declaration has been moved there from dri.h.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-26 18:58:30 +09:00
Adam Jackson
ef95e3a3cc modesetting: Validate the atom for enum properties
The client could have said anything here, and if what they said doesn't
actually name an atom NameForAtom() will return NULL, and strcmp() will
be unhappy about that.

[copied from xserver d4995a3936ae283b9080fdaa0905daa669ebacfc]

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-06-15 12:22:30 +09:00
Eric Anholt
2b7d77b901 Use plain glamor_egl_create_textured_screen().
Since 5064ffab631 (2014), glamor's implementation of _ext just drops the
back_pixmap arg, which we were passing NULL (the default) to anyway.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-05-17 16:06:31 +09:00
Michel Dänzer
3a9f7e87c3 Remove unused struct members from drmmode_display.h
(Ported from amdgpu commit 462ac3341e5bfbded9086d3d9043821d19352b3e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:57:25 +09:00
Michel Dänzer
7dc68e2675 Simplify tracking of PRIME scanout pixmap
Remember the shared pixmap passed to drmmode_set_scanout_pixmap for each
CRTC, and just compare against that.

Fixes leaving stale entries in ScreenRec::pixmap_dirty_list under some
circumstances, which would usually result in use-after-free and a crash
down the line.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:52:43 +09:00
Michel Dänzer
55e513b978 Use reference counting for tracking KMS framebuffer lifetimes
References are held by the pixmaps corresponding to the FBs (so
the same KMS FB can be reused as long as the pixmap exists) and by the
CRTCs scanning out from them (so a KMS FB is only destroyed once it's
not being scanned out anymore, preventing intermittent black screens and
worse issues due to a CRTC turning off when it should be on).

v2:
* Only increase reference count in drmmode_fb_reference if it was sane
  before
* Make drmmode_fb_reference's indentation match the rest of
  drmmode_display.h

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:51:38 +09:00