Commit Graph

3554 Commits

Author SHA1 Message Date
Michel Dänzer
4b3e5f81c6 Call drmmode_crtc_gamma_do_set from drmmode_setup_colormap
Instead of from drmmode_set_mode_major. There's no need to re-set the
gamma LUT on every modeset, the kernel should preserve it.

(Ported from amdgpu commit baea4fa492f635cdfe746a84be2e337d9aeae8a9)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:09:53 +02:00
Michel Dänzer
16ddc10966 Remove #if 0'd code
This has always been disabled, no need to keep it.

(Ported from amdgpu commit 19a40758be04e1d451a030f452efb49e8aaad541)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:09:39 +02:00
Michel Dänzer
447ef0458f Check dimensions passed to drmmode_xf86crtc_resize
When enabling a secondary GPU output, Xorg can try resizing the screen
beyond the limit advertised by the driver, leading to drmModeAddFB
failing and primary GPU outputs turning off. Check for this and bail
instead.

(Ported from amdgpu commit 940c8b39f79789d4d5ddb8ab8d25a8ae05932756)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:09:24 +02:00
Michel Dänzer
6a0c01bbd4 Use drmmode_crtc_dpms in drmmode_set_desired_modes
Simplifies the latter slightly.

(Ported from amdgpu commit 74124f2c17dbb4b752707bb7eee398ae099e8a2c)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:09:08 +02:00
Michel Dänzer
59441ee3da Call drmmode_do_crtc_dpms from drmmode_crtc_dpms as well
Leo pointed out that drmmode_do_crtc_dpms wasn't getting called when
turning off an output with

 xrandr --output <output> --off

This meant that the vblank sequence number and timestamp wouldn't be
saved before turning off the CRTC in this case.

Reported-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
(Ported from amdgpu commit ceeacb455cd058492a493aac954deab8455804b5)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:08:55 +02:00
Michel Dänzer
4050b0ad51 Replace 'foo == NULL' with '!foo'
Shorter and sweeter. :)

(Ported from amdgpu commit e8e688f3852fb06b0c34ed5bce47c9493bcd1613)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:08:34 +02:00
Michel Dänzer
cf8bc72e34 Wait for pending flips in drmmode_output_set_tear_free
This prevents a nested call to drmHandleEvent, which would hang.

Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is
page flipping.

(Ported from amdgpu commit 04947b83cce3a7782e59dece2c7797cc396c1e05)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:08:19 +02:00
Michel Dänzer
f01d8cf2bd Refactor drmmode_output_set_tear_free helper
Preparation for the following fix, no functional change intended.

(Ported from amdgpu commit fa30f4601de7a44edfb4a95873bd648946fd4292)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:08:07 +02:00
Michel Dänzer
ee7e157461 Set drmmode_crtc->scanout_id = 0 when TearFree is disabled
When disabling TearFree, drmmode_crtc->scanout_id could remain as 1,
but drmmode_set_mode_major would destroy drmmode_crtc->scanout[1], so
scanout_do_update() would keep bailing, and the scanout buffer would
stop being updated.

Fixes freeze after disabling TearFree on a CRTC with active RandR
rotation or other transform.

(Ported from amdgpu commit 7db0c8e9d7586cff4312d4b93684d35de3e6376f)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:07:55 +02:00
Michel Dänzer
e9d2d14948 Simplify drmmode_handle_transform
Set crtc->driverIsPerformingTransform for any case we can handle before
calling xf86CrtcRotate. We already clear it afterwards when the latter
clears crtc->transform_in_use.

This should allow our separate scanout buffer mechanism to be used in
more cases.

(Cherry picked from amdgpu commit 8e544b4a0de6717feb4abf00052d57c5b726b5ce)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:07:35 +02:00
Michel Dänzer
89d38e976f Don't call scanout_flip/update with a legacy RandR scanout buffer
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-12 18:07:05 +02:00
Michel Dänzer
9f2409c4d3 Simplify drmmode_crtc_scanout_update
Use our own BoxRec for the extents, and RegionEmpty for clearing the
scanout damage region.

(Ported from amdgpu commit 72c3e9c7308fbcdf85708b72f9be14a5f2f8e7b5)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:06:53 +02:00
Michel Dänzer
e07c386492 Update RandR CRTC state if set_mode_major fails in set_desired_modes
Without this, RandR would report the CRTC and its outputs as enabled,
even though they were actually off due to the failure.

(Cherry picked from amdgpu commit 4dcda0b48d62944c841cd9540f4ad4c7ac8dee47)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:06:39 +02:00
Michel Dänzer
05390ae36a Abort scanout_update_pending event when possible
We don't need to wait for a non-TearFree scanout update before scanning
out from the screen pixmap or before flipping, as the scanout update
won't be visible anyway. Instead, just abort it.

(Ported from amdgpu commit 36d01989cd842588f12fdae5b2cba5fdcf9c91dd)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:06:17 +02:00
Michel Dänzer
290291a115 Track DRM event queue sequence number in scanout_update_pending
Preparation for next change, no behaviour change intended.
(Ported from amdgpu commit 04a5c5f7cfacad8d9ccffe81e388cc3da2036cb5)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:06:00 +02:00
Michel Dänzer
d14ff6b778 Ignore RADEON_DRM_QUEUE_ERROR (0) in radeon_drm_abort_entry
This allows a following change to be slightly simpler.
(Ported from amdgpu commit 8fcc3a9b43d3907052a83a96e5a2423afab5ad3f)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:02:07 +02:00
Emil Velikov
731d4b386a Do not export the DriverRec RADEON
Unused externally and should not be exported.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
(Ported from amdgpu commit 7fb8b49895e225b3908c8bd186539de23afe91d1)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12 18:01:53 +02:00
Jim Qu
cc1d0824a8 Wait for pending scanout update before calling drmmode_crtc_scanout_free
There is a case that when set screen from reverse to normal, the old
scanout damage is freed in modesetting before scanout update handler,
so it causes segment fault issue.

Signed-off-by: Jim Qu <Jim.Qu@amd.com>

[ Michel Dänzer: Only call drmmode_crtc_wait_pending_event before
  drmmode_crtc_scanout_free is actually called, slightly tweak commit
  message ]
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
(Ported from amdgpu commit 9f6a8905611b5b1d8fcd31bebbc9af7ca1355cc3)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-11 18:34:53 +02:00
Michel Dänzer
413622bccc Swap pixmap privates in radeon_dri2_exchange_buffers
Instead of only the BOs.

This matches what amdgpu does, and fixes issues with DRI2 page flipping.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-10 17:23:24 +02:00
Michel Dänzer
3c4c0213c1 glamor: Use GBM for BO allocation when possible
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-09 18:28:21 +02:00
Michel Dänzer
b85b7b11f5 Add struct radeon_buffer
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-09 18:28:05 +02:00
Michel Dänzer
37ba075b34 Refactor radeon_finish helper
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:27:45 +02:00
Jammy Zhou
6c986e9971 Remove throttling from radeon_dri2_copy_region2
Throttling should be handled by the client-side drivers.

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
(Ported from amdgpu commit 8a34a8149860ac15e83ccdbd8d9a527d8d3e5997)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:27:27 +02:00
Michel Dänzer
90b94d4044 Move flush from radeon_scanout_do_update to its callers
No functional change intended.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:27:13 +02:00
Michel Dänzer
5da2bf43e6 Factor out radeon_surface_initialize helper
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:26:57 +02:00
Michel Dänzer
ba5d5402b3 glamor: Don't store radeon_surfaces in pixmaps
Only EXA needs them.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:24:39 +02:00
Michel Dänzer
eec4a41925 Only initialize libdrm_radeon surface manager for >= R600
Not used with older GPUs.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:24:21 +02:00
Michel Dänzer
ac18a993a3 EXA: Remove old RADEONEXACreatePixmap hook
Not used by any supported version of xserver.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09 18:14:19 +02:00
Michel Dänzer
25836375e0 Drop unused drmmode_create_bo_pixmap surface parameter
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-23 12:07:44 +02:00
Michel Dänzer
65c9dfea4e glamor: Bail CreatePixmap on unsupported pixmap depth
Fixes crash in that case.

Bugzilla: https://bugs.freedesktop.org/106293
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-22 18:30:48 +02:00
Michel Dänzer
3dcfce8d0f Bail from dri2_create_buffer2 if we can't get a pixmap
We would store the NULL pointer and continue, which would lead to a
crash down the road.

Bugzilla: https://bugs.freedesktop.org/106293
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-17 09:50:50 +02:00
Michel Dänzer
fdba537352 Bump version for 18.0.1 release xf86-video-ati-18.0.1 2018-03-15 17:19:59 +01:00
Michel Dänzer
e0f5020117 Pass extents to radeon_scanout_do_update by value
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-14 16:54:52 +01:00
Michel Dänzer
b915e8e6fb Wrap the whole miPointerScreenFuncRec, instead of only Set/MoveCursor
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: 1fe8ca7597 ("Keep track of how many SW cursors are visible on
                      each screen")
Reported-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-03-07 17:28:55 +01:00
Michel Dänzer
7e18aea984 Bump version for 18.0.0 release xf86-video-ati-18.0.0 2018-03-06 18:15:45 +01:00
Michel Dänzer
504b8721b1 Only change Set/MoveCursor hooks from what we expect
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: 1fe8ca7597 ("Keep track of how many SW cursors are visible on
                      each screen")
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-05 18:41:44 +01:00
Keith Packard
e0d2309233 modesetting: Update property values at detect and uevent time
We were updating the link-status property when a uevent came in, but
we also want to update the non-desktop property, and potentially
others as well. We also want to check at detect time in case we don't
get a hotplug event.

This patch updates every property provided by the kernel, sending
changes to DIX so it can track things as well.

Signed-off-by: Keith Packard <keithp@keithp.com>

(Ported from amdgpu commit 374cb8fef4fdbb648af089ee80803ec78321f1b2)
2018-03-02 12:13:43 +01:00
Daniel Martin
aef8fe6e9e modesetting: Reset output_id if drmModeGetConnector failed
If drmModeGetConnector() fails in drmmode_output_detect(), we have to
reset the output_id to -1 too.

Yet another spot leading to a potential NULL dereference when handling
the mode_output member as output_id was != -1. Though, this case should
be very hard to hit.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>

(Ported from amdgpu commit 10054b6c3d9a755b30abb43020121b9631fa296d)
2018-03-02 12:12:09 +01:00
Daniel Martin
1ef12a92ca modesetting: Use helper to fetch drmModeProperty(Blob)s
Replace the various loops to lookup drmModeProperty(Blob)s by
introducing helper functions.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>

(Ported from amdgpu commit fb58e06acd6c6bd59de2dbdadbca27eb1dd0025b)
2018-03-02 12:08:09 +01:00
Michel Dänzer
ace1e3871c Disable all unused CRTCs before setting desired modes
This might avoid modeset failures in some cases where a CRTC which isn't
used by Xorg was enabled before.

(Ported from amdgpu commit e3aae7a24296f640c0153d1459f3e0820485468a)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-02 12:06:11 +01:00
Christoph Haag
f2915eb7a4 fix include order for present.h configure test
xorg-server.h defines _XSERVER64 which is used in X.h to choose the
correct definition of XID

this prevents a failure in the present.h configure test that disables
DRI3 on X.Org 1.20

Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2018-03-01 16:25:52 +01:00
Michel Dänzer
f777e909fd Don't bail from drmmode_set_desired_modes immediately
If we fail to find or set the mode for a CRTC, keep trying for the
remaining CRTCs, and only return FALSE if we failed for all CRTCs that
should be on.

(Ported from amdgpu commit f5ac5f385f41d1547cfd7ccc8bb35a537a8fffeb)
2018-02-16 16:55:03 +01:00
Michel Dänzer
2d63748667 Simplify depth 30 "kernel too old" error message
We know it's depth 30, no need to have xf86DrvMsg fill it in.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15 18:28:41 +01:00
Michel Dänzer
680b4ab43f If glamor is too old for depth 30, fall back to EXA or ShadowFB
Instead of not starting up at all.

Corresponding to amdgpu commit 37c7260bdef3a53b0f0295a531f33938e9aad8cf.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15 17:28:04 +01:00
Michel Dänzer
16954fab59 Call RADEONFreeRec from RADEONFreeScreen_KMS even if info == NULL
It's safe now.

(Ported from amdgpu commit c9bd1399a13cea2e1331af2c826ca054b88db071)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15 17:23:49 +01:00
Michel Dänzer
6b44b8c584 Don't call RADEONFreeRec from RADEONPreInit_KMS
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-15 17:23:30 +01:00
Michel Dänzer
8a55e66bfd Don't use RADEONEntPriv in RADEONFreeRec
It crashes if info == NULL.

(Ported from amdgpu commits fb8444e731765588c0ff1e9053c1c7b73f5f0907 &
 cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-15 17:23:02 +01:00
Michel Dänzer
703cbb7177 glamor: Allow depth 30 with Xorg >= 1.19.99.1
Corresponding to amdgpu commit 6aee5770fb913713bb1b9a1af8f0d0892a66f21a.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14 17:28:10 +01:00
Michel Dänzer
733f606dd6 Always use screen depth/bpp for KMS framebuffers
DRI clients can use depth 32 pixmaps while the screen is depth 24, in
which case page flipping would fail.

Reported-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-and-Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-01-25 16:59:30 +01:00
Mario Kleiner
8312442604 Make XvMC extension initialize at depth 30.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-01-25 16:47:59 +01:00