Commit Graph

9591 Commits

Author SHA1 Message Date
Aurelien Rebourg 2bfd75084f
add alder lake graphics 2022-11-04 10:08:28 +01:00
Chris Wilson 31486f40f8 sna: Always validate userptr upon creation
Since not all memory ranges can be mapped by userptr, in particular those
passed by XShmAttachFD, we need to validate the userptr before use. We
would ideally want to continue to lazily populate the pages as often the
userptr is created but never used, but preventing an EFAULT later is
more important.

In https://patchwork.freedesktop.org/series/33449/ we provided a more
efficient method for probing the userptr on construction while
preserving the lazy population of gup-pages. For now, always follow
userptr with set-domain.

Reported-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2021-01-15 20:59:05 +00:00
Chris Wilson ab906aa045 sna/gen7: Avoid clear-residuals overhead on all gen7
Since not just Haswell will enjoy clear-residuals, be very careful
before using a potential context switch from DRI clients.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2021-01-10 00:23:28 +00:00
Chris Wilson a511f22cde sna: Enable TearFree by default on recent HW
When there is ample memory bandwidth and we are not fighting for global
resources, enable TearFree by default. Avoiding tearing is much more
pleasant (for direct rendering where the source itself is not being
synchronized to vblank) at negligible power cost; just doubles the
memory footprint of scanout.

References: https://gitlab.freedesktop.org/drm/intel/-/issues/2799
References: https://gitlab.freedesktop.org/drm/intel/-/issues/2763
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-12-15 17:00:20 +00:00
Chris Wilson 9236c58252 sna: Defer fbGetWindowPixmap() for sna_composite
Mike Lothian ran into a surprising situation where compScreenUpdate was
calling CompositePicture without a pixmap attached to the destination
Window, and so we found ourselves chasing a NULL PixmapPtr.

  #1  to_sna_from_pixmap (pixmap=0x0) at sna.h:521
  #2  sna_composite (op=<optimized out>, src=0x55b3346c1420, mask=0x0,
      dst=0x55b3346c1d50, src_x=<optimized out>, src_y=<optimized out>, mask_x=0,
      mask_y=0, dst_x=0, dst_y=0, width=3840, height=2160) at sna_composite.c:652
  #3  0x000055b33202c208 in damageComposite (op=<optimized out>,
      pSrc=0x55b3346c1420, pMask=0x0, pDst=0x55b3346c1d50, xSrc=<optimized out>,
      ySrc=<optimized out>, xMask=0, yMask=0, xDst=0, yDst=0, width=3840,
      height=2160) at damage.c:513
  #4  0x000055b33201820c in CompositePicture (op=<optimized out>,
      op@entry=1 '\001', pSrc=pSrc@entry=0x55b3346c1420, pMask=pMask@entry=0x0,
      pDst=pDst@entry=0x55b3346c1d50, xSrc=xSrc@entry=0, ySrc=ySrc@entry=0,
      xMask=0, yMask=0, xDst=0, yDst=0, width=3840, height=2160) at picture.c:1547
  #5  0x000055b331fc85d3 in compWindowUpdateAutomatic (
      pWin=pWin@entry=0x55b3343a6bc0) at compwindow.c:705
  #6  0x000055b331fca029 in compPaintWindowToParent (pWin=pWin@entry=0x55b3343a6bc0)
      at compwindow.c:729
  #7  0x000055b331fc9fbb in compPaintChildrenToWindow (pWin=0x55b333e77b50)
      at compwindow.c:744
  #8  0x000055b331fca59f in compScreenUpdate (pClient=<optimized out>,
      closure=<optimized out>) at compalloc.c:57
  #9  0x000055b331f3abf4 in ProcessWorkQueue () at dixutils.c:536
  #10 0x000055b3320aaa51 in WaitForSomething (are_ready=<optimized out>)
      at WaitFor.c:192
  #11 0x000055b331f361a9 in Dispatch () at dispatch.c:421
  #12 0x000055b331f39cec in dix_main (argc=13, argv=0x7ffcf273f538,
      envp=<optimized out>) at main.c:276
  #13 0x000055b331f247de in main (argc=<optimized out>, argv=<optimized out>,
      envp=<optimized out>) at stubmain.c:34

Fortuitously, that drawable was also fully clipped so that it took an
early exit and so we can hide the segfault by delaying querying the
pixmap until after the clip check.

The ongoing mystery is how we ended up in that state in the first place.

Closes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/-/issues/204
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-11-26 20:19:48 +00:00
Chris Wilson ad5540f6ec More ABI changes for ABI_VIDEODRV_VERSION 25.2
Descending down into the naming changes, onto the next struct in the
chain.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-11-16 15:23:28 +00:00
Chris Wilson 4e8ae05f20 Track ABI changes for ABI_VIDEODRV_VERSION 25.2
Several structs had fields renamed, and so we must update our usage.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-11-16 15:11:19 +00:00
Chris Wilson 67f15b36fa sna/gen7: Prefer blitter for plain copies on Haswell
Since the clear-residuals security fix on gen7, context switches are
very slow. If X is being used with DRI clients, those clients will
typically be using the 3D engine for themselves and every frame
presented will then be copied by X, causing at least a couple of context
switches per frame. That greatly diminishes throughput, but if we prefer
to use the blitter engine for X, we can mostly keep off the render engine
avoiding the context thrash.

Reported-by: Rafael Ristovski <rafael.ristovski@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-08-20 09:30:19 +01:00
Ville Syrjälä 5ca3ac1a90 sna/video/overlay: Declare support for depth 8 and 30
Add 8 and 30 to the list of supported screen depths. The colorkey
massaging will be handled by the kernel so we don't have to worry
about it unlike with the sprite colorkey uapi.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-05-15 17:56:58 +01:00
Chris Wilson 7181c5a41c sna: Avoid selecting gen9 backend for future gen
Cannonlake, then Icelake introduce new instruction formats and state
command, and require a new render backend to be written. Avoid selecting
the gen9 backend as this will hang!

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1864
Fixes: 3d5a1238af ("sna: Restore blt fallback backend")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-05-11 10:49:36 +01:00
Chris Wilson e781d43dad sna/dri2: Prevent copying stale buffers
The back buffer of window/pixmap is invalidated by DRI2ScheduleSwap, and
is not available until the client calls DRI2GetBuffers. If they try to
use their old handles, they will only get stale data. Similarly if they
ask us to DRI2CopyRegion before the GetBuffers has reallocated a new
back buffer, that back buffer is stale. Since the back buffer is
out-of-date [likely containing data from a couple of swaps ago], we
should ignore the copy to avoid glitching [by hopefully having a less
noticeable glitch!] It's not entirely clear what the client intended at
this point...

Closes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/-/issues/195
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-05-06 19:03:18 +01:00
Chris Wilson 846b53dacd Add description for PCI-ID 0x3E98
Closes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/-/issues/162
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-04-21 14:57:15 +01:00
Liwei Song 8c2c0a080f Sync i915_pciids upto 8717c6b7414f
Import the kernel's i915_pciids.h, up to:

commit 8717c6b7414ffb890672276dccc284c23078ac0e
Author: Lee Shawn C <shawn.c.lee@intel.com>
Date:   Tue Dec 10 23:04:15 2019 +0800

    drm/i915/cml: Separate U series pci id from origianl list.

Signed-off-by: Liwei Song <liwei.song@windriver.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-04-21 12:28:48 +01:00
Chris Wilson f285365886 sna: Forcibly relinquish the GPU bo cache of a SHM pixmap on flushing
Before we indicate return control of the SHM Pixmap to the client (that
is prior to the next XReply), we ensure that the original SHM buffer is
uptodate with any changes made on the GPU. We must flush the GPU writes
back to the CPU and so not allow ourselves to keep the dirty cache of
the GPU bo.

Closes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/-/issues/189
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Alexei Podtelezhnikov <apodtele@gmail.com>
Tested-by: Alexei Podtelezhnikov <apodtele@gmail.com>
2020-04-17 21:49:50 +01:00
Alexei Podtelezhnikov db2356f586 sna: fix typo for --enable-debug=full
A typo in tightly_packed define for builds with optimisation disabled
left us creating many packed objects. When compiled with -fno-common the
compiler rightfully complains about the duplication.

Signed-off-by: Alexei Podtelezhnikov <apotele@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-04-17 14:12:24 +01:00
Chris Wilson 3d5a1238af sna: Restore blt fallback backend
Despite suggestions to the contrary, the BLT survived for another year.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-04-17 14:05:13 +01:00
Chris Wilson f2a54e256d sna/dri2: Interpret DRI2ATTACH_FORMAT as depth not bpp
In mesa i915/i965 pass the bpp to use when creating the surface, but the
gallium state tracker passed the depth. As it happens that
BitsPerPixel(format) will do the right thing for both, use that.

| DRI2ATTACH_FORMAT { attachment: CARD32
|		      format:     CARD32 }
|
|  The DRI2ATTACH_FORMAT describes an attachment and the associated
|  format.  'attachment' describes the attachment point for the buffer,
|  'format' describes an opaque, device-dependent format for the buffer.

Should we need to use an explicit format (heavens forbid as nobody likes
DRI2) then that will have to start in the range above 256 (or higher).

For now the convention is defined by the mixture of i965/iris, and that
is to assume it is essentially a depth.

Reported-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4569
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-04-15 17:25:40 +01:00
Hanno Böck 652d93cbbd i810: Avoid duplicate definition of I810PatternROP
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2020-03-10 14:46:18 +00:00
Ville Syrjälä f66d39544b sna: Fix dirtyfb detection
Fix the accidentally swapped bpp and depth values passed to
the addfb ioctl when we're testing for dirtyfb presence.
Currently the addfb fails every time so we don't even test
the actual dirtyfb ioctl.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-12-09 22:26:46 +00:00
Chris Wilson d90a2ff1a6 Revert "sna: Close each client op with an arbitrartion check"
This reverts commit b5ac286c9b as it escaped before being completed.
It proved it's worth in preventing sna from hogging the GPU for too long
under x11perf stress, but it didn't check to see if there was enough
space left in the batch before emitting the dword. Simply revert the
patch for now.

Reported-by: Matti Hämäläinen <ccr@tnsp.org>
Closes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/issues/174
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-12-09 14:41:14 +00:00
Chris Wilson 0867eea666 Update buglink for gitlan issues
Issue tracking has been moved from a bugzilla instance to a gitlab
instance to go alongside and integrated with the gitlab repo, still all on
freedesktop.org.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-11-27 12:09:28 +00:00
Chris Wilson e628d22673 sna: Fix overflow calculation for number of boxes that fit
We detect when the number of boxes we wished to emit into the batch
would overflow, but then miscalculated the number that would actually fit.

References: https://bugs.freedesktop.org/show_bug.cgi?id=112296
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-11-17 15:12:15 +00:00
Peter Wu cb6bff95ed sn: fix PRIME output support since xserver 1.20
Since "Make PixmapDirtyUpdateRec::src a DrawablePtr" in xserver, the
"src" pointer might point to the root window (created by the server)
instead of a pixmap (as created by xf86-video-intel). Use
get_drawable_pixmap to handle both cases.

When built with -fsanitize=address, the following test on a hybrid
graphics laptop will trigger a heap-buffer-overflow error due to
to_sna_from_pixmap receiving a window instead of a pixmap:

    xrandr --setprovideroutputsource modesetting Intel
    xrandr --output DP-1-1 --mode 2560x1440  # should not crash
    glxgears  # should display gears on both screens

With nouveau instead of modesetting, it does not crash but the external
monitor remains blank aside from a mouse cursor. This patch fixes both.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100086
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111976
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-11-15 19:20:30 +00:00
Chris Wilson b5ac286c9b sna: Close each client op with an arbitrartion check
Minimise preemption latency by frequently checking for pending preemption
events in between X11 client requests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-11-02 21:10:39 +00:00
Chris Wilson bff5eca49b sna: Scale cpp by 8 for bit depth
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111916
Fixes: 1804eacc85 ("sna: Add sna_br13_color_depth()")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-10-07 14:16:28 +01:00
Chris Wilson c6cb1b1995 sna: Squelch compiler warning for unused var
sna_display.c: In function ‘crtc_init_gamma’:
sna_display.c:7462:28: warning: unused variable ‘lut’ [-Wunused-variable]
sna_display.c:7444:14: warning: unused variable ‘sna’ [-Wunused-variable]

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-09-27 20:37:33 +01:00
Ville Syrjälä 581ddc5d2f sna: Fix compiler warnings due to DrawablePtr vs. PixmapPtr
Deal with xserver commit 8e3b26ceaa86 ("Make PixmapDirtyUpdateRec::src
a DrawablePtr")

Not sure this is still correct though. Is this stuff limited to
pixmaps anymore?

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:24:42 +03:00
Ville Syrjälä bfeeae4de9 tools: Get rid of -Wno-sign-compare
Fix the sign comparison warnings by changing some types, and
using a few casts.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:24:38 +03:00
Ville Syrjälä 97058e38d8 uxa: Get rid of -Wno-shift-negative-value
The minimum CS URB entry size is 1. Let's use that
instead of 0 so that we don't end up left shifting
a -1.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:22:18 +03:00
Ville Syrjälä e95e9d41ca sna: Get rid of -Wno-shift-negative-value
Use a cast to avoid the "left shift of negative value
[-Wshift-negative-value]" warning, and get rid of the
suppression.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:22:18 +03:00
Ville Syrjälä fbe15cf431 sna: Use -Wno-maybe-uninitialized
The compiler seems incapable of deducing whether something
is used uninitialized or not.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:22:18 +03:00
Ville Syrjälä 070fb84ecf sna/fb: Initialize xoff/yoff
The compiler seems to think src/mask xoff/yoff can be used
uninitialized. Zero them to make sure.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:22:18 +03:00
Ville Syrjälä be30b162e4 xvmc: Eliminate strict aliasing violations
Just access both halves of the motion vector thing
directly instead of doung the cast to uint and deref.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:20:20 +03:00
Ville Syrjälä e4a8d533da sna/fb: Use memcpy() to avoid strict aliasing violations
Replace the cast+deref with memcpy() so that we don't upset
the compiler's strict aliasing rules.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:18:40 +03:00
Ville Syrjälä d8a3db2574 sna: Avoid strict aliasing violations with glyphinfo
Just access the xGlyphInfo members directly to avoid the
compiler getting upset about strict aliasing violations.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:17:24 +03:00
Ville Syrjälä 97ce021570 sna: Use memcmp() to avoid strict aliasing warns
../src/sna/sna_display.c: In function ‘sna_covering_crtc’:
../src/sna/sna_display.c:8235:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   if (*(const uint64_t *)box == *(uint64_t *)&crtc->bounds) {

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:17:03 +03:00
Ville Syrjälä 17ecd906f3 sna: Increase the size of the path name buffer a bit
../src/intel_device.c: In function ‘__intel_open_device__pci.isra.6’:
../src/intel_device.c:321:25: warning: ‘%s’ directive writing up to 255 bytes into a region of size 247 [-Wformat-overflow=]
   sprintf(path + base, "%s", de->d_name);

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:01:19 +03:00
Ville Syrjälä 24a06fef71 sna: Use named initializers
Avoid -Wno-missing-field-initializers by using named
initializers.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:01:16 +03:00
Ville Syrjälä 696f7eda80 Avoid missing initializer warning
Use an empty {} as the terminator in intel_device_match[] to avoid
the warning about missing initlizers.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:01:16 +03:00
Ville Syrjälä 4b26ec2ef6 uxa: Use named initializers
Silence the compiler warning about missing initializers
by using named initializers.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:01:16 +03:00
Ville Syrjälä b88d9287df sna/fb: Eliminate implicit fallthrough
Duplicate a bit of code in FbDoLeftMaskByteRRop() switch statement
to avoid the fall through.

And while at it sort the cases based on the left byte and length.
Makes the pattern matcher in my brain much happier.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 19:01:16 +03:00
Ville Syrjälä 1804eacc85 sna: Add sna_br13_color_depth()
Refactor the BR13 color depth setup to common helper. This
eliminates a bunch of implicit fall through warns.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:41:21 +03:00
Ville Syrjälä 8cad99802b sna: Annotate more fall throughs
Sprinkle fall through comments where needed.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:41:21 +03:00
Ville Syrjälä f9f318e455 sna: Replace fall through comments with standard form
gcc doesn't like extra stuff in the fall through comments.
Replace them with the standard form.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:41:21 +03:00
Ville Syrjälä 04d8411d6c sna: undef FontSetPrivate() before redefining it
Avoid the compiler gettings upset about us redefining
FontSetPrivate().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:41:21 +03:00
Ville Syrjälä 2fae3b89f2 sna: Shut up more compiler warns
Suppress more compiler warnings.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:41:21 +03:00
Ville Syrjälä e95490a788 sna: Use -Wno-clobbered
../src/sna/sna_composite.c:567:11: warning: variable ‘sx’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
   int16_t sx = src_x + tx - (dst->pDrawable->x + dst_x);
           ^~
etc.

I had a quick look at a few of the cases and they seemed fine to me,
so feels like gcc just being dense.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-09-19 18:40:07 +03:00
Chris Wilson 6f4972d5c3 sna/dri2: Relinquish back-buffer cache on change of scanout status
If we change scanout status (i.e. whether or not this flip chain may be
presented directly on the CRTC), throwaway the previous back buffer
cache as those buffers may not be suitable for presentation.

Reported-by: Jiri Slaby <jirislaby@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=111197
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-07-24 14:12:50 +01:00
Chris Wilson fffb1f52b6 sna/dri2: Skip asserting distinct front/back for stale swaps
If the backbuffer is stale (i.e. the client didn't call DRI2GetBuffers
before swapping) the front/back bo may not be distinct. Move the
assertion for a valid swap after the handling of a stale swap so that
the assertions are more robust for a client error.

References: https://bugs.freedesktop.org/show_bug.cgi?id=111197
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-07-24 12:01:17 +01:00
Chris Wilson 364c916978 sna/dri2: Skip stale client swap before asserting
Check for a stale backbuffer (the client didn't call DRI2GetBuffers
between DRI2SwapBuffers) before asserting so that we should be
more resilient with asserts enabled for client errors.

References: https://bugs.freedesktop.org/show_bug.cgi?id=111197
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-07-24 11:22:17 +01:00