Commit Graph

316 Commits

Author SHA1 Message Date
Michel Dänzer
a47c009333 autogen.sh: Pass -f to autoreconf
To ensure that any existing copies of autotools files will be replaced
with the current versions.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-27 15:13:36 +09:00
Michel Dänzer
842bad4b95 Makefile.am: Set ACLOCAL_AMFLAGS = -I m4
Suggested by one of the tools called by autoreconf.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-27 15:13:36 +09:00
Michel Dänzer
227b399bad Add AC_CONFIG_MACRO_DIRS([m4]) to configure.ac
Suggested by one of the tools called by autoreconf.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-27 15:13:36 +09:00
Michel Dänzer
4d36306bce 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
(Ported from radeon commit 94dc2b80f3ef0b2c17c20501d824fb0447d52e7a)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-26 16:49:31 +09:00
Michel Dänzer
88147c1a53 Use drmmode_crtc->scanout_id instead of 0 to check for scanout buffer
Preparation for following change, no functional change intended.

(Ported from radeon commit aff267ee36cc6a703a532f91f82adc1ba1425ff3)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-13 17:35:55 +09:00
Michel Dänzer
e90721ba65 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: b10ecdbd89 ("Use drmmode_crtc_scanout_* helpers for RandR 1.4
                      scanout pixmaps")
(Ported from radeon commit c9dd28cb0c9c3de676eadac61e727732510f6b9b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 18:13:05 +09:00
Michel Dänzer
1b6ff5fd99 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).

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 15:33:00 +09:00
Michel Dänzer
af7221e1c4 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.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-21 19:01:54 +09:00
Adam Jackson
184d50e008 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:19:07 +09:00
Michel Dänzer
bbdac40e2a Improve AMDGPUPreInitAccel_KMS log messages
Now it should always be clear in the log file why acceleration isn't
enabled.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-08 10:46:26 +09:00
Michel Dänzer
b09fde0d81 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

(Ported from radeon commit 55e513b978b2afc52b7cafc5bfcb0d1dc78d75f6)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-26 18:24:27 +09:00
Michel Dänzer
000e5eaeb2 Update URLs
* Point to the amd-gfx mailing list
* Specify the component in all bugzilla URLs
* Use https:// for all HTML URLs

(Ported from radeon commit d80d01a73c2eaba2e3649b7bc0a3541b3ff782f6)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-24 10:12:55 +09:00
Michel Dänzer
2ea2d4d827 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.

(Ported from radeon commit 7dc68e26755466f9056f8c72195ab8690660693d)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-24 10:10:17 +09:00
Eric Anholt
8cb41b962e 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>
(Ported from radeon commit 2b7d77b90108911777a11ecaa63435552000c958)
2017-05-17 16:11:52 +09:00
Michel Dänzer
e900e48a11 Don't enable DRI3 without glamor
Can't work currently. Fixes crash when trying to run a DRI3 client when
glamor isn't enabled.

Bugzilla: https://bugs.freedesktop.org/100968

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:41:40 +09:00
Michel Dänzer
462ac3341e Remove unused struct members from drmmode_display.h
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-10 18:12:55 +09:00
Michel Dänzer
82fa615f38 Apply gamma correction to HW cursor
The display hardware CLUT we're currently using for gamma correction
doesn't affect the HW cursor, so we have to apply it manually when
uploading the HW cursor data.

This currently only works in depth 24/32.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-02 11:53:25 +09:00
Michel Dänzer
981bac185c Don't set modes before AMDGPUWindowExposures_oneshot is called
The root window contents may be undefined before that, so we don't want
to show anything yet.

Fixes a crash on startup with rotation and virtual resolution set in
xorg.conf.

Bugzilla: https://bugs.freedesktop.org/100276
Fixes: ad53635af1 ("Move DPMS check from amdgpu_scanout_do_update to
                      amdgpu_scanout_flip")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-17 18:27:13 +09:00
Daniel Stone
51e17041cb Set correct DRM event context version
DRM_EVENT_CONTEXT_VERSION is the latest context version supported by
whatever version of libdrm is present. We were blindly asserting we
supported whatever version that may be, even if we actually didn't.

Set the version as 2, which should be bumped only with the appropriate
version checks.

Signed-off-by: Daniel Stone <daniels@collabora.com>
(Ported from xserver commit 0c8e6ed85810e96d84173a52d628863802a78d82)
v2: Remove second paragraph of commit log, we always initialize
        page_flip_handler2 = NULL (Emil Velikov)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-04-10 17:36:01 +09:00
Nicholas Molloy
67d155e62f Fix a misspelling of 'acceleration' in amdgpu_kms.c
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-03-28 10:26:23 +09:00
Michel Dänzer
165b514476 manpage: Don't put "'" at the beginning of a line
It caused the whole line to be dropped.

Fixes: af0b24c1ac ("Allow toggling TearFree at runtime via output
                      property")
Reported-by: Andy Furniss <adf.lists@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-23 18:04:11 +09:00
Michel Dänzer
1b476d417f Post-release version bump 2017-03-23 18:03:56 +09:00
Michel Dänzer
804e30e14e Bump version for 1.3.0 release xf86-video-amdgpu-1.3.0 2017-03-16 17:28:11 +09:00
Michel Dänzer
3a8582944e Pass TRUE to drmmode_set_desired_modes the first time for GPU screens
This is the only place we call drmmode_set_desired_modes for GPU screens
during server startup. Without this change, the display outputs of
secondary GPUs may stay on even while Xorg isn't using them.

(Ported from radeon commit 9a71445094b728f3d78db8f6808b4782ee19a453)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-10 11:45:32 +09:00
Michel Dänzer
82b15a4da1 Skip some initialization steps for GPU screens
Xorg doesn't use the following functionality of GPU screens, so don't
bother initializing it:

* DRI page flipping
* DRI3 / Present / SYNC fences
* XVideo / XvMC
* Root window with background None

(Ported from radeon commit 67ae5e00a748ad52cf92738d401afff2947b1891)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-09 15:47:24 +09:00
Michel Dänzer
fa85331f0c glamor: Use glamor_finish when available
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 18:02:29 +09:00
Hans De Goede
7884e38e94 amdgpu_probe: Do not close server managed drm fds
This fixes the xserver only seeing AMD/ATI devices supported by the amdgpu
driver, as by the time xf86-video-ati gets a chance to probe them, the
fd has been closed.

This fixes e.g. Xorg not seeing the dGPU on a Lenovo Thinkpad E465 laptop
with a CARRIZO iGPU and a HAINAN dGPU.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

v2: Rebased on top of new patch 1.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:58:29 +09:00
Michel Dänzer
a2c360fa1d Refactor amdgpu_kernel_close_fd helper
Preparation for the following change.

Assign pAMDGPUEnt->fd = -1 instead of 0 when we're not using the file
descriptor anymore.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:57:51 +09:00
Michel Dänzer
947017194d glamor: Don't flush in BlockHandler with Xorg >= 1.19
This was only necessary with older versions for driving the FBO cache
expiry mechanism.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:57:25 +09:00
Michel Dänzer
86907a5e4c Only define transform_region for XF86_CRTC_VERSION >= 4
Not used with older versions of Xorg. Fixes warning in that case:

../../src/amdgpu_kms.c:328:1: warning: ‘transform_region’ defined but not used [-Wunused-function]
 transform_region(RegionPtr region, struct pict_f_transform *transform,
 ^~~~~~~~~~~~~~~~

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:56:51 +09:00
Michel Dänzer
8d2b7d1758 Use local implementation of RegionDuplicate for older xserver
It was only added in xserver 1.15. Fixes build against older xserver.

Reported-by: Pali Rohár <pali.rohar@gmail.com>
(Ported from radeon commit 80cc892ee1ce54fad3cb7dd11bd9df18c359136f)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:56:24 +09:00
Michel Dänzer
cd73100114 Don't use pScrn->is_gpu in AMDGPUCreateScreenResources_KMS
Looks like this snuck in accidentally.

Brings us back in line with the radeon driver, and fixes the build
against older versions of xserver which didn't have the is_gpu field
yet.

Fixes: 6bab8fabb3 ("Remove info->dri2.drm_fd and info->drmmode->fd")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:55:44 +09:00
Michel Dänzer
351baa89b9 Don't call amdgpu_glamor_flush in drmmode_copy_fb
AMDGPUWindowExposures_oneshot takes care of it.

(Ported from radeon commit d63881623f0686a66a2e3e3c1f84e496aa52ec6b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:55:23 +09:00
Michel Dänzer
ad53635af1 Move DPMS check from amdgpu_scanout_do_update to amdgpu_scanout_flip
When amdgpu_scanout_do_update is called from
drmmode_crtc_scanout_update, drmmode_crtc->pending_dpms_mode may still
be != DPMSModeOn, e.g. during server startup.

Fixes intermittently showing garbage with TearFree enabled.

(Ported from radeon commit cc9d6b7db9c2078be1e530a64af6d517c6a42024)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:55:00 +09:00
Michel Dänzer
378bd05c84 Call drmmode_set_desired_modes from a WindowExposures hook
This is the earliest opportunity where the root window contents are
guaranteed to be initialized, and prevents drmmode_set_mode_major from
getting called before drmmode_set_desired_modes via AMDGPUUnblank ->
drmmode_crtc_dpms. Also, in contrast to the BlockHandler hook, this is
called when running Xorg with -pogo.

Fixes intermittently showing garbage on server startup or after server
reset.

As a bonus, this avoids trouble due to higher layers (e.g. the tigervnc
Xorg module) calling AMDGPUBlockHandler_oneshot repeatedly even after
we set pScreen->BlockHandler = AMDGPUBlockHandler_KMS.

Bugzilla: https://bugs.freedesktop.org/99457
(Ported from radeon commits 0a12bf1085505017068dfdfd31d23133e51b45b9 and
f0e7948e1c0e984fc27f235f365639e9cf628291)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:54:27 +09:00
Michel Dänzer
8d4d73e05c present: Flush before flipping
This isn't necessary for DRI clients, but the Present extension can also
be used for presenting normal pixmaps rendered to via the X11 protocol.

(Ported from radeon commit 9035b6abea557828e672ee455f0c84e43da0906f)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:54:04 +09:00
Michel Dänzer
88725b68ca present: Use async flip for unflip if possible
In that case, unflip operations should finish faster in general.

(Ported from radeon commit 0a4eb0e12f0c9c653cf4cea6fd62e1a507eb261c)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:53:27 +09:00
Michel Dänzer
b31489c086 present: Also flush before using a flip to unflip
Not doing so might result in intermittently scanning out stale contents
of the screen pixmap.

(Ported from radeon commit 9a951a3e551db58ba50e7a594521ceac54d90615)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:53:02 +09:00
Michel Dänzer
f6a3c87c30 present: Wait for GPU idle before setting modes for unflip
To make sure the screen pixmap contents are up to date when it starts
being scanned out.

(Ported from radeon commit 244d4bc7f8c8f6bc90f49556c0b9344c8aa40295)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:52:34 +09:00
Michel Dänzer
012ffffb45 present: Only call drmModeRmFB after setting modes for unflip
Fixes display intermittently blanking when a modeset is used for unflip.

(Ported from radeon commit 3ff29e5a14451916bc66b4e0028e9a317f0723f8)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-07 16:52:14 +09:00
Michel Dänzer
f4719bb473 Use drmmode_crtc_scanout_free in drmmode_fini
We were leaking drmmode_crtc->scanout_damage, which caused trouble on
server reset. Fixes server reset with active separate scanout pixmaps.

(Cherry picked from radeon commit 0c29deb5a97d9a57e994cc0053c49ddf7aca6ecb)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:19:11 +09:00
Michel Dänzer
af0b24c1ac Allow toggling TearFree at runtime via output property
Option "TearFree" now sets the default value of the output property.
See the manpage update for details.

TearFree is now enabled by default for outputs using rotation or other
RandR transforms, and for RandR 1.4 slave outputs.

(Ported from radeon commit 58cd1600057e41aade0106d4acf78e23eac6e44f)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:12:26 +09:00
Michel Dänzer
77853f02e5 Factor out drmmode_crtc_scanout_update helper
Cleanup in preparation for following change, no functional change
intended.

(Ported from radeon commit 305e2cbf335837a2ab6a24e9ff65815afe038296)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:11:54 +09:00
Michel Dänzer
d25cc3b2b3 Factor out amdgpu_prime_dirty_to_crtc helper
Cleanup in preparation for the following change, no functional change
intended.

(Ported from radeon commit 649644a88347a6d03de68f8c41db03a82deeb23b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:11:32 +09:00
Michel Dänzer
a6d363008e Don't destroy current FB if drmModeAddFB fails
It would probably result in a black screen.

(Ported from radeon commit 1351e48efe7a2c28eab447e16f36a00fbd02ae48)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:11:12 +09:00
Michel Dänzer
53926db235 Fix flip event data leak if calloc or drmModeAddFB fails
(Ported from radeon commit 481394e3c9f9f7d88bb66fe9ae8834c87952a8ab)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:10:07 +09:00
Mihail Konev
45a8ec6257 autogen: add default patch prefix
(Ported from radeon commit 8e6a4e96b7b27559e186f71b5547abb0a80b96dd)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:09:26 +09:00
Michel Dänzer
ba2aa0a8c1 Handle rotation in the driver also with Xorg 1.12-1.18
We cannot use the HW cursor in that case, but in turn we get more
efficient and less teary updates of rotated outputs.

(Ported from radeon commit f2bc882f1c1082bed9f496cfab6c8f07a76bc122)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:08:21 +09:00
Michel Dänzer
7f3abf35a2 Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create
Not used anywhere else anymore.

(Ported from radeon commit ae921a3150f69c38b5b3c88a9e37d54fdf0d5093)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03 16:07:49 +09:00
Michel Dänzer
03c2db3c67 Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well
Calling drmmode_crtc_scanout_allocate in drmmode_crtc_shadow_allocate
resulted in drmmode_crtc_scanout_create called from
drmmode_crtc_shadow_create passing an uninitialized pitch value to
drmmode_create_bo_pixmap.

Fixes issues such as failure to allocate the scanout pixmap or visual
corruption and GPUVM faults when attempting to use rotation with Xorg
<1.19.

Bugzilla: https://bugs.freedesktop.org/99916
Fixes: 5f71238088 ("Pass pitch from drmmode_crtc_scanout_allocate to
                      drmmode_create_bo_pixmap")
(Ported from radeon commit 987a34adb319923ad36e2b47a26837248f187c3e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-02 16:42:04 +09:00