Commit Graph

9591 Commits

Author SHA1 Message Date
Chris Wilson 8f2d08016a sna: Force posting of shadow updates for NotifyFd
The update for ABI 22 and NotifyFd left behind an important flush for
shadow rendering.

Fixes: 4ab9145c7748 ("Update to ABI 22 and NotifyFd")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-04-01 13:27:49 +01:00
Chris Wilson 7418d53c58 sna/dri2: Clip application of damage to windowed swapbuffers
Since forever we have been passing region=NULL when doing a windowed
swapbuffer on vblank, and using that to mark the entire pixmap as being
damaged. For an uncomposited window, this is incorrect as it points to a
clipped region of the ScreenPixmap and so we were marking the entire
ScreenPixmap as being flushed, but only having operated on the windowed
region. Instead pass along the clip extents if region is unset.

References: https://bugs.freedesktop.org/show_bug.cgi?id=105720
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-03-28 19:42:06 +01:00
Chris Wilson 6c1e70ca42 sna: Fixup early assert of xf86ScrnToScreen
During early init, xf86ScrnToScreen() may return NULL, so handle that
possibility inside the assert.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-03-26 22:41:30 +01:00
dom.constant@free.fr aa36399cca sna: CustomEDID fix
For my HTPC setup, I'm using the option "CustomEDID".
With this option, output attaching and destroying events leads to
crashes.

The following sequence leads to a crash:
- In xorg.conf: Option "CustomEDID" "HDMI2:/etc/my_edid.bin"
- Starting Xorg
- Connect HDMI2
- Disconnect HDMI2
- Reconnect HDMI2
  -> Crash

The crash happens in xf86OutputSetEDID
(xorg/xserver/hw/xfree86/modes/xf86Crtc.c)
at "free(output->MonInfo)". MonInfo is assigned with
sna_output->fake_edid_mon
which is allocated by intel driver in sna_output_load_fake_edid
(src/sna/sna_display.c).

Sequence details:
- Starting Xorg
   -> fake_edid_mon is initialized

- Connect HDMI2
   -> xf86OutputSetEDID is called:
       - MonInfo is NULL
       - MonInfo is assigned with fake_edid_mon pointer
       - MonInfo is read by Xorg

- Disconnect HDMI2

- Reconnect HDMI2
   -> xf86OutputSetEDID is called:
       - MonInfo is freed thus also fake_edid_mon
       - MonInfo is assigned with fake_edid_mon
       - MonInfo is read but it was freed -> CRASH

The fix consists of a new instance of xf86MonPtr for each calls of
xf86OutputSetEDID.
is initialized with fake_edid_raw which render
fake_edid_mon useless.
With this proposal, the behaviour of an EDID override is similar to
a "real" EDID.

Signed-off-by: Dominique Constant <dom.constant@free.fr>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-03-02 15:17:35 +00:00
Ville Syrjälä 9b4f400190 sna: Add XV_COLORSPACE attribute support for sprite Xv adaptors
Use the new "COLOR_ENCODING" plane property to implement the
XV_COLORSPACE port attribute for sprite Xv adaptors.

v2: assert(colorspace < ARRAY_SIZE) (Chris)

Cc: Jyri Sarha <jsarha@ti.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-03-02 15:17:21 +00:00
Ville Syrjälä 7579552300 sna/video: Actually use the NV12 shader on gen8
Oops. We never actually select the NV12 shader on gen8, causing
us to render garbage. Looks like this is the only one I somehow
missed.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-02-14 20:49:26 +00:00
Chris Wilson 5c7e4e0e05 intel: Only check file type bits not mode when searching for rendernodes
Before checking st_rdev, we first need to validate that the file is a
device node, but we only want to check the file type bits and not
compare the permissions.

Reported-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-02-08 17:20:55 +00:00
Chris Wilson 2d6af9e736 sna: Switch from ifdef PICT_ to if XORG_VERSION_CURRENT
The PICT_ are enums and so never report true to ifdef PICT_a2r10g10b10
and instead we need to check the xserver version they were introduced.

Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-02-07 19:04:54 +00:00
Ville Syrjälä 781fd07e55 meson: Add meson build system
Allow building the driver with meson. Could probably use
plenty of cleanups, but at least it gives me a working driver.
And I think I managed to make it build everything that
autotools builds.

Quite a few compiler warnings were suppressed as well. Might
want to look at those at some point.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-02-06 13:12:33 +00:00
Ville Syrjälä a3a9e99b52 autotools: Nuke IPC_RMID_DEFERRED_RELEASE
IPC_RMID_DEFERRED_RELEASE is unused so nuke it.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-02-06 13:12:33 +00:00
Ville Syrjälä 896122c9f6 sna: Make DBG() and ERR() non-empty
Use do{}while(0) for DBG() and ERR() to avoid isses with if/else/etc.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-02-06 13:12:33 +00:00
Ville Syrjälä c8c6ec0df0 sna/video: Try to use hw scaling with SKL+ sprites
SKL reintroduced plane scaling once more. Let's try to make use of it.

The one annoying caveat is that you can't do colorkeying and scaling at
the same time :(  For now we'll leave the choice of colorkey vs.
scaling to the user via that XV_ALWAYS_ON_TOP attribute.

One possible idea for improving the situation would be to add support
for autopaint colorkey, and automatically disable the colorkey whenever
the window is not obscured by anything and autopaint colorkey is enabled.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-02-06 13:11:32 +00:00
Liwei Song 26f5406841 Add Coffeelake PCI IDs for S Skus
Add the Coffeelake PCI IDs based on the following kernel patches:

commit b056f8f3d6b900e8afd19f312719160346d263b4
Author: Anusha Srivatsa <anusha.srivatsa@intel.com>
Date:   Thu Jun 8 16:41:05 2017 -0700

    drm/i915/cfl: Add Coffee Lake PCI IDs for S Skus.

Signed-off-by: Liwei Song <liwei.song@windriver.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-01-11 07:52:21 +00:00
Chris Wilson 708255cbca sna: Drop redundant sync of an inactive snoop cache
Having requested an inactive snooped buffer, we know that it is
already flushed and do not need to flush it again. With debugging
enabled, we hit an assert while flushing that the buffer has a refcout,
which at this present time of being plucked from the snoop cache it does
not.

Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=104341#c2
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-20 08:49:11 +00:00
Chris Wilson 032a581fd7 sna: Fixup sna->scrn == scrn assert for early initialisation
Very early on when creating the sna privates, we call to_sna(scrn) before
we have even set the sna->scrn backpointer. Reorder the code such that
we always set sna->scrn before the first to_sna() so that the
assert(to_sna(scrn)->scrn == scrn) can always hold.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-20 08:28:15 +00:00
Chris Wilson af6d8e9e8f sna: Avoid calling kgem_bo_free() on a still active bo
If we fail to manipulate a bo from the active cache for reuse, then we
have to be careful not to immediately close it as it is still referenced
from the current batch.

Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c44
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-12-16 10:59:09 +00:00
Chris Wilson 21008aaa1f sna: Assert idempotent conversions between sna <-> ScreenPtr
Check that the struct sna we retrieve from the ScreenPtr points back to
the screen, and vice versa.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-11-09 00:36:49 +00:00
Chris Wilson 37a682aa8a sna: Update vtSema for Leave/EnterVT
Xorg changed behaviour in 78f0667d6df9 (xf86Events: split xf86VTSwitch
into xf86VTLeave and xf86VTEnter functions) and stopped altering the
state of scrn->vtSema around calls to Leave/EnterVT. So we must do so
ourselves (albeit a bit belated in noticing the change!)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-11-09 00:24:01 +00:00
Chris Wilson 8dfb6477be sna: Disable DPMS-deferred modesetting when run as a secondary screen
When being run as a secondary screen, we do not receive DPMS events
(xf86DPMS() only operates on the primary screen, I guess one day we will
have to fix that and undo this hack). As such we cannot defer the
modesets until the final DPMS as it will never be sent.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103618
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-11-09 00:23:33 +00:00
Chris Wilson 91822571ba sna: Allow a PRIME pixmap to be reused
The code expected that a fresh pixmap header to be created for each
PRIME pixmap, but it appears that set_shared_pixmap is being called on
the same pixmap with fd=-1.

References: https://bugs.freedesktop.org/show_bug.cgi?id=103618
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-11-08 23:20:18 +00:00
Ville Syrjälä 4798e18b2b sna: Implement i830 3DSTATE_BUFFER_INFO w/a
i830 can hang if 3DSTATE_BUFFER_INFO straddles two cachelines.
To prevent that emit MI_NOOPs to align 3DSTATE_BUFFER_INFO to
a cacheline boundary.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-10-18 16:07:47 +01:00
Chris Wilson 04b4f3b7f7 sna: Fix up assert()s
Two pushes later and the discovery that the build scripts no longer do a
debug build leads to some embarrassment.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-12 20:05:15 +01:00
Chris Wilson d287d46d5c sna: Validate rrPrimaryOutput belongs to our Screen
If the randr->rrPrimaryOutput is set to an output on a slave, we have to
reject it in favour of one of our own.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-12 17:58:46 +01:00
Chris Wilson a384b462a3 sna: Move the public sna_crtc fields into a named struct
Avoid compiler trickery by making the layout of the sna_crtc_public
pointed to by xf86CrtcPtr->devPrivate known.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-12 14:37:25 +01:00
Chris Wilson efb9c92184 sna: Avoid fopen inside signalsafe debug paths
We need the debug code to be signalsafe as it may be run when updating
the cursor from a signal. This excludes the use of fopen() as it may
malloc (causing a potential recursion upon the malloc locks).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-08 12:27:11 +01:00
Chris Wilson f50b9d5405 sna/present: Queue the keepalive vblank
Insert the keepalive vblank into the sorted list of msc carefully. This
way we can discard redundant keepalives - as we don't want to queue a
second event for the same vblank needlessly.

Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c13
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-08 12:27:11 +01:00
Chris Wilson cebb756f3d sna: Check if the kernel reports a tiling-stride less than our request
Looks like a bug has snuck in somewhere in our set-tiling path. Since it
exists, try to workaround it whilst it is root caused.

Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c9
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-07 11:37:25 +01:00
Chris Wilson a33a96a353 sna: Skip the exact match if we can't change tiling
If we can't change tiling on the cached bo and we expect an exact match
(for e.g. scanout) then skip over the unwanted bo.

Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c5
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-10-06 15:10:25 +01:00
Ville Syrjälä 291fdcdc09 sna/video: Expose NV12 support for the textured Xv adaptor on gen4+
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:01:05 +01:00
Ville Syrjälä 8906d8b0e2 sna/video: Add NV12 video copy funcs
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:00:55 +01:00
Ville Syrjälä 27d58e4b37 sna/video: Add support for NV12 video in all gen4+ render paths
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:00:55 +01:00
Ville Syrjälä 0fee13926a sna/video: Add NV12 shader binaries
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:00:55 +01:00
Ville Syrjälä 4322c978f8 sna/video: Add NV12 shaders
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:00:55 +01:00
Ville Syrjälä 0a3d4a1a20 sna/video: Add FOURCC_NV12
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-09-27 19:00:55 +01:00
Chris Wilson 54a1f6337e sna: Allow reallocation of larger framebuffers
Since we can assign larger framebuffer to a smaller CRTC, we can reuse
a bo even if it was last used for a bigger framebuffer (without
discarding that framebuffer or bo).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-08-31 14:01:10 +01:00
Chris Wilson 88db4f1dc1 sna: Tweak fb size assertion
When pageflipping, we should be able to flip to an fb that is larger
than the CRTC, so we can relax the assertion that checking for the exact
size.

References: https://bugs.freedesktop.org/show_bug.cgi?id=102442#c12
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-08-30 13:10:43 +01:00
Chris Wilson c89905754b sna/gen8+: Discard any blt using a LINEAR buffer that is not 64byte aligned
The bug we discovered back in

commit 3a22b6f6d5
Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Date:   Wed Nov 19 15:10:05 2014 +0200

    sna: gen8 BLT broken when address has bit 4 set

turns out to be even wider than our initial finding. It is now
recommended that you avoid using the BLT on LINEAR addresses that are not
cache-line aligned (64 bytes). You can convert the offset into a
coordinate offset (provided the address is at least pixel aligned), but
that remains quite hairy to fit into the current code base. So keep
saying no to misaligned blits (we either use the 3D engine instead,
which may end up thrashing the TLBs given the LINEAR layout, or we just
use the CPU).

The impact of issuing misaligned blits is that the blitter ends up
performing the blit presuming the aligned address, causing it to end up
offset (and vary per line).

Reported-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-08-22 20:29:20 +01:00
Chris Wilson 7534e96ffb sna/dri2: Defer the drawable flush
Just flag the DRI2 flush to occur on the next callback flush, as per
normal, instead of manually emitting the batch.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-08-22 20:27:35 +01:00
Chris Wilson 2100efa105 sna/dri2: Don't cache allocate-as-scanout flag
commit 74c1e45ed5 ("sna/dri2: Look for potential flip targets when
recreating backbuffers") cached the decision on whether to create the
new back buffer as a scanout target believing that we would always get
notified when the DRI2 drawable size changed. However, this is only true
inside a composited environment where we see a change in the Window's
pixmap. In a bare environment, we either need to chain into the
screen->ResizeWindow or check every time whether we think a new
backbuffer should be pre-allocated for use on the scanout.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-07-28 18:47:48 +01:00
Emil Velikov e436cf597d legacy/i810: remove unused numVisualConfigs
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-07-18 12:29:44 +01:00
Chris Wilson 6babcf15dd sna/present: Drop TearFree assert at the end of unflip
There are more reasons than just TearFree as to why the shadow may be
disabled (such as no outputs), so without taking those into account the
assert is bogus.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-06-07 11:05:25 +01:00
Chris Wilson 405ca1e74c sna/present: Move too-late unflip check earlier
Present only unflips after a resize, after it has lost control of the
Screen. It's unflip request is stale and triggers an assert about the
graphical glitch - just reorder the assert to ignore the snafu.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-06-07 09:43:01 +01:00
Chris Wilson 1fc7841c79 sna: Check active_scanout flag across TearFree exchange
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-06-07 09:43:01 +01:00
Chris Wilson 8eed38e03a sna/dri2: Check active state on front/back before swap
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-06-07 09:43:01 +01:00
Chris Wilson abbc590879 sna: Squash compiler warning for mismatched pointers
No harm, just noise about a missing cast.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-06-07 09:43:01 +01:00
Chris Wilson c72bb27a3a sna: Fix fallback clearing of the shadow
The size we need to clear is pitch * height, not pitch * width.

Reported-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-04-18 20:40:47 +01:00
Chris Wilson b57abe20e8 sna: Use a slightly larger preallocated array for properties
We use an on-stack array to GETPROPERTY value to try and do a single
ioctl/copy avoiding a short-lived malloc.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-04-10 12:41:05 +01:00
Chris Wilson cb6ba2da05 sna: Use the first active crtc as the primary output fallback
When desperate for any crtc, check all available crtc for an active one
first.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-25 01:21:46 +00:00
Chris Wilson c0d41c371f sna: Protect against RROutputPrimary being on a slave
RandR allows the Primary output to belong to a slave GPU, i.e. with the
condition that screen->primaryOutput->screen != screen. When we fallback
to using the PrimaryOutput, we therefore have to check that the output
belong to us before treating it as a sna_output.

Reported-by: Peter Wu <peter@lekensteyn.nl>
Buzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100382
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-25 01:09:20 +00:00
Chris Wilson 2452066b77 sna: Fixup for fb24 xorg ABI change
commit 0803918e64262482035f042e5e1f2a571d3dea1b
Author: Adam Jackson <ajax@redhat.com>
Date:   Sat Sep 24 19:40:52 2016 -0400

    fb: Remove 24bpp support (v3)

removes the gc.pRotatedPixmap member without a guide to the ABI bump.
Don't initialize pRotatedPixmap out from the start of the unstable tag .

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-20 09:46:18 +00:00