Bug 236003

Summary: x11-drivers/xf86-video-intel: update to 2019-11-17 snapshot and refactor
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: freebsd-x11 mailing list <x11>
Status: New ---    
Severity: Affects Only Me CC: javashin1986, o.hushchenkov, rkoberman, shuriku, swills, taku, theron, x11
Priority: --- Keywords: patch, patch-ready
Version: LatestFlags: bugzilla: maintainer-feedback? (x11)
jbeich: merge-quarterly?
Hardware: Any   
OS: Any   
URL: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/compare/e5ff8e1828f9...e628d22673df
Bug Depends on: 233902    
Bug Blocks:    
Description Flags
v1 (has commit message)
v2 (has commit message)
v3 (has commit message)
v3 (has commit message)
v4 (has commit message)
v4 (has commit message)
v5 (has commit message)
with localbase option
without localbase option
v7.1 none

Description Jan Beich freebsd_committer 2019-02-24 17:40:18 UTC
Created attachment 202331 [details]
v1 (has commit message)

Tested on Intel HD530 (aka Skylake GT2) + drm-current-kmod (Linux 4.20) + i965/anv (DRI3) + intel (SNA, DRI3) via mpv (EGL + VAAPI, Vulkan), ppsspp (Vulkan), rpcs3 (Vulkan, OpenGL 4.3+), firefox (WebRender).

No UXA changes since previous update, so testing on old iGPUs isn't necessary.

Build logs:
- 11.2 amd64: https://ptpb.pw/jGsv
- 11.2 i386:  https://ptpb.pw/RT-l
- 12.0 amd64: https://ptpb.pw/f3zv
- 12.0 i386:  https://ptpb.pw/0gRC
- 13.0 amd64: https://ptpb.pw/BhBf)
- 13.0 i386:  https://ptpb.pw/7E3a
- UDEV=on:    https://ptpb.pw/FQq0
Comment 1 Jan Beich freebsd_committer 2019-03-04 03:35:53 UTC
Created attachment 202533 [details]
v2 (has commit message)
Comment 2 Jan Beich freebsd_committer 2019-03-08 01:56:41 UTC
Am I the only user left?
Comment 3 rkoberman 2019-03-08 20:52:59 UTC
(In reply to Jan Beich from comment #2)
Almost certainly not, but you said that testing in old iGPUs is not needed and, since I have switched to the modesetting driver, I did not try out the code.
Comment 4 Steve Wills freebsd_committer 2019-04-01 16:23:01 UTC
I tested this and it seems to work fine.
Comment 5 Taku YAMAMOTO 2019-05-12 06:49:49 UTC
It works fine here on Kabylake (gen9) / Thinkpad X1 Carbon 6th, too!
SNA render acceleration (xfwm w/ compositing), Xv (mplayer), VAAPI, DRI (Firefox),  all performant and tear-free.

Even though suspend still doesn't work yet, I believe this definitely is an improvement.

And, modesetting is not an option for me because I can't afford so-called "tearing" effect, albeit suspend works.
Comment 6 Jan Beich freebsd_committer 2019-07-04 01:17:57 UTC
What's holding this? It was tested by real users (excluding me). Long delays every time are very discouraging.

Proposing for 2019Q3 as SNA fix (included) for drm-kmod >= 4.11 is too important.
Comment 7 Jan Beich freebsd_committer 2019-07-04 01:50:16 UTC
Created attachment 205509 [details]
v3 (has commit message)

Oops, I had an update but forgot to upload: 2 more upstream SNA fixes.
Comment 8 Jan Beich freebsd_committer 2019-07-04 01:54:12 UTC
Comment on attachment 205509 [details]
v3 (has commit message)

Nevermind. There's no difference between v2 and v3.
Comment 9 Alexandr Krivulya 2019-07-04 07:28:18 UTC
Works well on my Thinkpad T470p with Kaby Lake. Not tested yet with external display attached.
Comment 10 Jan Beich freebsd_committer 2019-07-23 10:07:44 UTC
Created attachment 206005 [details]
v3 (has commit message)

More upstream SNA fixes.
Comment 11 JavaShin 2019-07-25 09:48:41 UTC
Working Fine Here Thanks
Comment 12 Jan Beich freebsd_committer 2019-07-30 15:51:16 UTC
Created attachment 206160 [details]
v4 (has commit message)

More upstream SNA fixes.
Comment 13 Jan Beich freebsd_committer 2019-09-22 21:15:09 UTC
Created attachment 207727 [details]
v4 (has commit message)

Rebase after ports r509895
Comment 14 Jan Beich freebsd_committer 2019-09-30 11:46:49 UTC
Created attachment 207959 [details]
v5 (has commit message)

Upstream warning fixes.
Comment 15 Jan Beich freebsd_committer 2019-10-30 18:50:31 UTC
Created attachment 208705 [details]

Upstream SNA bugfix
Comment 16 Jan Beich freebsd_committer 2019-10-30 19:19:01 UTC
Neglect here suggests "playing solo" from bug 235050 comment 1 was really about self-reflection by the team. Sadly, applying "3 months or 3 timeouts" rule would cause more drama. And creating a new port has poor justification: no breaking changes, downstream-only improvements, cleanup. I really need a new GPU to forget about this port. ;\
Comment 17 Taku YAMAMOTO 2019-11-03 17:55:55 UTC
v6 works perfectly here, including suspend/resume!
I'm looking forward to your work being merged into the stock ports, really!

* ThinkPad X1 Carbon gen. 6 (UHD Graphics 620, aka Kabylake gen9)
* FreeBSD current r354159 (custom kernel based on MINIMAL + GENERIC-NODEBUG)
* drm-current-kmod-4.16.g20191023
* gpu-firmware-kmod-g20191015
* xorg.conf:
  - AccelMethod sna
  - TearFree true
  - TripleBuffer false (I haven't utilize TripleBuffer because TearFree alone is sufficient for my eyes to eliminate noticeable tearing completely)
* loader.conf:
  - compat.linuxkpi.enable_fbc="-1"
  - compat.linuxkpi.enable_psr="1"
  - compat.linuxkpi.enable_dc="2"

Sorry for being quiet, but I had been busy until recently.
Comment 18 Theron Tarigo freebsd_committer 2019-11-03 22:30:09 UTC
(In reply to Jan Beich from comment #0)
Hi, I should have been paying attention to this bug by now, since I have Intel(R) HD Graphics 530 (Skylake GT2).  With what has been available in ports, everything since DRM 4.9 kmod (drm-fbsd11.2-kmod-4.9g20181023) has been unusable: With "intel" driver and SNA+TearFree, after a few minutes of Xorg running, or even after launching Firefox, performance becomes terrible, where it feels as though in each 1/60th of a second, there is only a one in three chance of a frame getting pushed to the display).  "modesetting" has never worked for me with any drm-kmod without tearing, so I do not use it.  Here I thought I was the only user of Intel HD530 and the only one stuck on DRM 4.9.  Jan, has this been your experience with "intel" driver?  Is this one thing that the update fixes?

As long as DRM 4.9 continues to build and run on FreeBSD 12.x I haven't been able to justify putting enormous time into debugging the newer graphics stack, but it sounds like this update may be the fix; I can't tell.  (If you'd rather I just try it than ask questions then that is an option for me but it may delay my willingness to test it indefinitely).
Comment 19 Jan Beich freebsd_committer 2019-11-03 23:18:16 UTC
(In reply to Theron Tarigo from comment #18)
> Hi, I should have been paying attention to this bug by now, since I have
> Intel(R) HD Graphics 530 (Skylake GT2).  With what has been available in ports,
> everything since DRM 4.9 kmod (drm-fbsd11.2-kmod-4.9g20181023) has been
> unusable: With "intel" driver and SNA+TearFree, after a few minutes of Xorg
> running, or even after launching Firefox, performance becomes terrible, where
> it feels as though in each 1/60th of a second, there is only a one in three
> chance of a frame getting pushed to the display).

I'm on -CURRENT and don't use TearFree due to poor/jerky performance. A few month ago I've seen severe redraw skips on TearFree but don't remember what have fixed those: either upgrading drm-current-kmod to drm-devel-kmod or disabling framebuffer compression.

If you see "(EE) intel(0): Failed to submit rendering commands (Bad address), disabling acceleration." in Xorg.log on DRM > 4.9 then this update should help. The full list of changes is documented in the commit message (read the diff).
Comment 20 Jan Beich freebsd_committer 2019-11-03 23:38:23 UTC
Created attachment 208834 [details]

- Fix missing git hash in buildstring (used in Xorg.log) after ports r509895
- Rebase after ports rr516607
Comment 21 Oleh Hushchenkov 2019-11-04 09:35:44 UTC
Tested on Haswell IGPU. Fixes bug #241685. It have to be committed ASAP.

Thanks Jan!
Comment 22 JavaShin 2019-11-11 16:09:37 UTC
fetch -qo /tmp/intel-ddx-SNA-Fix.diff 'https://bugs.freebsd.org/bugzilla/attachment.cgi?id=208834'
patch -Efsp1 -i /tmp/intel-ddx-SNA-Fix.diff -d /usr/ports
cd /usr/ports/x11-drivers/xf86-video-intel ; make deinstall reinstall clean
Comment 23 Alexandr Krivulya 2019-11-11 19:23:40 UTC
There is a black screen with mouse cursor at center on my Thinkpad T470p with SNA enabled. With UXA all works fine, but sddm is starting about one minute.
Comment 24 Jan Beich freebsd_committer 2019-11-23 16:42:26 UTC
Created attachment 209362 [details]

Upstream SNA bugfixes.
Comment 25 Jan Beich freebsd_committer 2019-11-23 17:02:20 UTC
(In reply to Alexandr Krivulya from comment #23)
Can you try v7? If it doesn't help track down which version introduced the regression (may require downgrading the entire ports tree to avoid patch conflicts). After that it should be easy to bisect e.g.,
1. Run "git clone https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/"
2. Run "git bisect" using upstream commits from DISTVERSIONSUFFIX (strip "-g") or GL_COMMIT for the first bad and the last good version of the patch
4. Run "make makesum" to regen distinfo
5. Run "make clean all deinstall install" to start runtime testing
6. Run "git bisect bad" if still you can reproduce or "git bisect good" if you cannot
7. Repeat 3-6 steps until "git bisect" points to a single commit
8. Append the hash of the first bad to https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/commit/ to get an URL of the commit

Once you find what caused upstream regression it should be easier to understand why (unless kernel- or chip-specific), hack to make it work again or simply revert the change.
Comment 26 Jan Beich freebsd_committer 2019-11-23 17:09:20 UTC
Whether comment 23 tells about regression since comment 9 is still unclear as comment 9 didn't specify which AccelMethod was tested.
Comment 27 Alexandr Krivulya 2019-11-24 20:46:03 UTC
With v7 and UXA all works fine. With SNA enabled I have the same situation - black screen with mouse cursor. I'm not sure, but it seems I used UXA in comment #9. So, I'll try to fulfill your recommendations. Thanks!
Comment 28 Alexandr Krivulya 2019-11-25 17:05:19 UTC
I found interesting thing. This problem appears only when I apply a patch. If I on stock ports tree remove files/patch-src_sna_sna__video.c (for build purpose) and simply adjust port's Makefile all works fine with SNA.

-GL_COMMIT=     e5ff8e1828f97891c819c919d7115c6e18b2eb1f
+GL_COMMIT=     e628d22673dfa494230e6f79ceff7d178137c71a
Comment 29 Alexandr Krivulya 2019-11-25 20:58:50 UTC
I started to apply this patch line by line and found strings in Makefile that cause a problem:

-USES=		cpe gl xorg xorg-cat:driver
+USES=		cpe gl localbase xorg xorg-cat:driver
Comment 30 Jan Beich freebsd_committer 2019-11-25 21:59:10 UTC
(In reply to Alexandr Krivulya from comment #29)
USES=localbase is used to fix auto-detection of MIT SHM and Xinerama. Can you compare config.log before and after? I suspect bug 242236.
Comment 31 Alexandr Krivulya 2019-11-26 05:34:36 UTC
Created attachment 209443 [details]
with localbase option
Comment 32 Alexandr Krivulya 2019-11-26 05:35:09 UTC
Created attachment 209444 [details]
without localbase option
Comment 33 Jan Beich freebsd_committer 2019-11-26 20:37:32 UTC
Created attachment 209459 [details]

(In reply to Alexandr Krivulya from comment #31)
> +#define HAVE_SYS_SYSINFO_H 1

Does this version make SNA work again for you?
Comment 34 Alexandr Krivulya 2019-11-27 08:59:56 UTC
Yes, it works. Thank you!