Skip to content
Snippets Groups Projects
  1. Dec 20, 2022
    • Sultan Alsawaf's avatar
      modesetting: add support for TearFree page flips · a94dd953
      Sultan Alsawaf authored
      
      This adds support for TearFree page flips to eliminate tearing without the
      use of a compositor. It allocates two shadow buffers for each CRTC, a back
      buffer and a front buffer, and uses damage tracking to minimize excessive
      copying between buffers and skip unnecessary flips when the screen's
      contents remain unchanged. It works on transformed screens too, such as
      rotated and scaled CRTCs.
      
      When PageFlip is enabled, TearFree won't force fullscreen DRI clients to
      synchronize their page flips to the vblank interval.
      
      TearFree is disabled by default.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      a94dd953
    • Sultan Alsawaf's avatar
      modesetting: coalesce vblank events to avoid DRM event queue exhaustion · 2d272b70
      Sultan Alsawaf authored
      
      The DRM event queue in the kernel is quite small and can be easily
      exhausted by DRI clients. When the event queue is full, that means nothing
      can be queued onto it anymore, which can lead to incorrect presentation
      times for DRI clients and failure when attempting to queue a page flip.
      
      To make matters worse, once an event is placed onto the kernel's event
      queue, there's no straightforward way to prematurely remove it from the
      kernel's event queue in userspace, which means that aborting a sequence
      number doesn't free up space in the event queue.
      
      Since vblank events from DRI clients are the largest consumers of the
      event queue, and since it's often easy to know the desired target MSC of
      their vblank events without querying the kernel for a CRTC's current MSC,
      we can coalesce vblank events occurring at the same MSC such that only one
      of them is placed onto the kernel's event queue, instead of allowing
      duplicate vblank events to pollute the event queue.
      
      This is achieved by tracking the next kernel-queued event's MSC on a
      per-CRTC basis and then running all of that CRTC's vblank event handlers
      which have reached their target MSC when the queued MSC is signaled.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      2d272b70
    • Sultan Alsawaf's avatar
      modesetting: make do_queue_flip_on_crtc generic · 5f5690b8
      Sultan Alsawaf authored
      
      do_queue_flip_on_crtc() is about to be used to flip buffers other than the
      primary scanout (`ms->drmmode.fb_id`), so make it generic to accept any
      frame buffer ID, as well as x and y coordinates in the frame buffer, to
      flip on a given CRTC. Move the retry logic from queue_flip_on_crtc() into
      it as well, so that it's robust for all callers.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      5f5690b8
    • Sultan Alsawaf's avatar
      modesetting: make the shadow buffer helpers generic · 80d0035e
      Sultan Alsawaf authored
      
      Shadow buffers are about to be used for TearFree, so make the shadow buffer
      helpers generic such that they can be used to create arbitrary per-CRTC
      shadows aside from just the per-CRTC rotated buffer.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      80d0035e
  2. Apr 02, 2022
  3. Oct 08, 2021
    • Mario Kleiner's avatar
      modesetting: Handle mixed VRR and non-VRR display setups better. · 017ce263
      Mario Kleiner authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
      
      In a setup with both VRR capable and non-VRR capable displays,
      it was so far inconsistent if the driver would allow use of
      VRR support or not, as "is_connector_vrr_capable" was set to
      whatever the capabilities of the last added drm output were.
      Iow. the plugging order of monitors determined the outcome.
      
      Fix this: Now if at least one display is VRR capable, the driver
      will treat an X-Screen as capable for VRR, plugging order no
      longer matters.
      
      Tested with a dual-display setup with one VRR monitor and one
      non-VRR monitor. This is also beneficial with the new Option
      "AsyncFlipSecondaries".
      
      When we are at it, also add some so far missing description of
      the "VariableRefresh" driver option, copied from amdgpu-ddx.
      
      Signed-off-by: default avatarMario Kleiner <mario.kleiner.de@gmail.com>
      017ce263
  4. Oct 07, 2021
  5. Sep 27, 2021
    • Mario Kleiner's avatar
      Revert "modesetting: Only use GAMMA_LUT if its size is 1024" · 545fa90c
      Mario Kleiner authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
      
      This reverts commit 617f591f.
      
      The problem described in that commit exists, but the two
      preceeding commits with improvements to the servers RandR
      code should avoid the mentioned problems while allowing the
      use of GAMMA_LUT's instead of legacy gamma lut.
      
      Use of legacy gamma lut's is not a good fix, because it will reduce
      color output precision of gpu's with more than 1024 GAMMA_LUT
      slots, e.g., AMD, ARM MALI and KOMEDA with 4096 slot luts,
      and some Mediathek parts with 512 slot luts. On KOMEDA, legacy
      lut's are completely unsupported by the kms driver, so gamma
      correction gets disabled.
      
      The situation is especially bad on Intel Icelake and later:
      Use of legacy gamma tables will cause the kms driver to switch
      to hardware legacy lut's with 256 slots, 8 bit wide, without
      interpolation. This way color output precision is restricted to
      8 bpc and any deep color / HDR output (10 bpc, fp16, fixed point 16)
      becomes impossible. The latest Intel gen gpu's would have worse
      color precision than parts which are more than 10 years old.
      
      Signed-off-by: default avatarMario Kleiner <mario.kleiner.de@gmail.com>
      545fa90c
  6. Sep 15, 2021
    • Patrik Jakobsson's avatar
      modesetting: Fix dirty updates for sw rotation · db9e9d45
      Patrik Jakobsson authored and Povilas Kanapickas's avatar Povilas Kanapickas committed
      
      Rotation is broken for all drm drivers not providing hardware rotation
      support. Drivers that give direct access to vram and not needing dirty
      updates still work but only by accident. The problem is caused by
      modesetting not sending the correct fb_id to drmModeDirtyFB() and
      passing the damage rects in the rotated state and not as the crtc
      expects them. This patch takes care of both problems.
      
      Signed-off-by: default avatarPatrik Jakobsson <pjakobsson@suse.de>
      db9e9d45
  7. Sep 10, 2021
    • Aaron Plattner's avatar
      modesetting: Only use GAMMA_LUT if its size is 1024 · 617f591f
      Aaron Plattner authored
      
      GAMMA_LUT sizes other than 1024 cause a crash during startup if the memcpy()
      calls in xf86RandR12CrtcSetGamma() read past the end of the legacy X11 /
      XVidMode gamma ramp.
      
      This is a problem on Intel ICL / GEN11 platforms because they report a GAMMA_LUT
      size of 262145. Since it's not clear that the modesetting driver will generate a
      proper gamma ramp at that size even if xf86RandR12CrtcSetGamma() is fixed, just
      disable use of GAMMA_LUT for sizes other than 1024 for now. This will cause the
      modesetting driver to disable the CTM property and fall back to the legacy gamma
      LUT.
      
      Signed-off-by: Aaron Plattner's avatarAaron Plattner <aplattner@nvidia.com>
      Fixes: xorg/xserver#1193
      Tested-by: Mark Herbert
      617f591f
  8. Apr 05, 2021
    • Aaron Plattner's avatar
      modesetting: Defer crtc gamma size upgrade to drmmode_setup_colormap · b75d0cca
      Aaron Plattner authored
      Rather than trying to create a gamma ramp array of the appropriate size in
      drmmode_crtc_init when the GAMMA_LUT property should be used, just flag the crtc
      as wanting to use the GAMMA_LUT property and then replace the gamma ramp later,
      right before calling xf86HandleColormaps. This avoids a problem during initial
      startup where xf86RandR12CreateObjects12 hard-codes a gamma ramp size of 256,
      causing xf86RandR12CrtcSetGamma to read past the end of the DIX layer's RandR
      gamma ramp array:
      
        PreInit
          drmmode_pre_init
            drmmode_crtc_init
              crtc->gamma_size = 1024
      
        ScreenInit
          xf86CrtcScreenInit
            xf86RandR12Init
              xf86RandR12Init12
                xf86RandR12CreateObjects12
                  RRCrtcCreate
                    randr_crtc->gammaSize = 0
                xf86RandR12InitGamma(pScrn, 256)
                  RRCrtcGammaSetSize
                    randr_crtc->gammaSize = 256
                xf86RandR12InitGamma
                  xf86RandR12CrtcInitGamma
                    RRCrtcGammaSet
                      xf86RandR12CrtcSetGamma
                        // crtc->gamma_size is 1024 here, while randr_crtc->gammaRed
                        // is a 256-element array.
                        memcpy(crtc->gamma_red, randr_crtc->gammaRed, crtc->gamma_size * sizeof(crtc->gamma_red[0]));
          drmmode_setup_colormap
            xf86HandleColormaps
              xf86RandR12InitGamma
                RRCrtcGammaSetSize
                  randr_crtc->gammaSize = 1024
      
      Fixes: 245b9db0 - modesetting: Use GAMMA_LUT when available
      Closes: #1126
      
      
      Signed-off-by: Aaron Plattner's avatarAaron Plattner <aplattner@nvidia.com>
      Reviewed-by: default avatarRobert Morell <rmorell@nvidia.com>
      b75d0cca
  9. Nov 25, 2020
  10. Oct 29, 2020
  11. Sep 25, 2020
    • Kishore409's avatar
      modesetting: keep going if a modeset fails on EnterVT · efb3abdd
      Kishore409 authored and Martin Roukala's avatar Martin Roukala committed
      
      There was a time when setting a mode on a CRTC would not depend on the
      associated connector's state. If a mode had been set successfully once,
      it would mean it would work later on.
      
      This changed with the introduction of new connectors type that now
      require a link training sequence (DP, HDMI 2.0), and that means that
      some events may have happened while the X server was not master that
      would then prevent the mode from successfully be restored to its
      previous state.
      
      This patch relaxes the requirement that all modes should be restored on
      EnterVT, or the entire X-Server would go down by allowing modesets to
      fail (with some warnings). If a modeset fails, the CRTC will be
      disabled, and a RandR event will be sent for the desktop environment to
      fix the situation as well as possible.
      
      Additional patches might be needed to make sure that the user would
      never be left with all screens black in some scenarios.
      
      v2 (Martin Peres):
       - whitespace fixes
       - remove the uevent handling (it is done in a previous patch)
       - improve the commit message
       - reduce the size of the patch by not changing lines needlessly
       - return FALSE if one modeset fails in ignore mode
       - add comments/todos to explain why we do things
       - disable the CRTCs that failed the modeset
      
      Signed-off-by: default avatarKishore Kadiyala <kishore.kadiyala@intel.com>
      Signed-off-by: default avatarMartin Peres <martin.peres@linux.intel.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Tested-by: default avatarKishore Kadiyala <kishore.kadiyala@intel.com>
      Closes: #1010
      efb3abdd
    • Martin Roukala's avatar
      modesetting: check the kms state on EnterVT · 293cf660
      Martin Roukala authored
      
      Normally, we would receive a uevent coming from Linux's DRM subsystem,
      which would trigger the check for disappearing/appearing resources.
      However, this event is not received when X is not master (another VT
      is selected), and so the userspace / desktop environment would not be
      notified about the changes that happened while X wasn't master.
      
      To fix the issue, this patch forces a refresh on EnterVT by splitting
      the kms-checking code from the uevent handling into its own (exported)
      function called drmmode_update_kms_state. This function is then called
      from both the uevent-handling function, and on EnterVT right before
      restoring the modes.
      
      Signed-off-by: default avatarMartin Peres <martin.peres@linux.intel.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Acked-by: default avatarKishore Kadiyala <kishore.kadiyala@intel.com>
      Tested-by: default avatarKishore Kadiyala <kishore.kadiyala@intel.com>
      293cf660
  12. Sep 08, 2020
    • Uday Kiran Pichika's avatar
      modesetting: Lay the foundation for enabling VRR · 9823ea4e
      Uday Kiran Pichika authored and Martin Roukala's avatar Martin Roukala committed
      
      These changes have been ported from AMD GPU DDX driver.
      
      This patch adds support for setting the CRTC variable refresh property
      for suitable windows flipping via the Present extension.
      
      In order for a window to be suitable for variable refresh it must have
      the _VARIABLE_REFRESH property set by the MESA and inform Modesetting
      DDX driver with window property updates.
      
      Then the window must pass the checks required to be suitable for
      Present extension flips - it must cover the entire X screen and no
      other window may already be flipping. And also DRM connector should
      be VRR capable.
      
      With these conditions met every CRTC for the X screen will have their
      variable refresh property set to true.
      
      Kernel Changes to support this feature in I915 driver is under development.
      
      Tested with DOTA2, Xonotic and custom GLX apps.
      
      Signed-off-by: default avatarUday Kiran Pichika <pichika.uday.kiran@intel.com>
      9823ea4e
  13. Jul 09, 2020
  14. Jul 05, 2020
  15. Jun 27, 2020
  16. Jun 23, 2020
  17. Mar 13, 2020
  18. Feb 11, 2020
  19. Feb 05, 2020
  20. Jan 14, 2020
  21. Jan 03, 2020
    • Aaron Plattner's avatar
      modesetting: Check whether RandR was initialized before calling rrGetScrPriv · 4226c6d0
      Aaron Plattner authored
      Calling rrGetScrPriv when RandR isn't initialized causes an assertion
      failure that aborts the server:
      
       Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion `key->initialized' failed.
      
       Thread 1 "Xorg" received signal SIGABRT, Aborted.
       0x00007ffff78a8f25 in raise () from /usr/lib/libc.so.6
       (gdb) bt
       #0  0x00007ffff78a8f25 in raise () from /usr/lib/libc.so.6
       #1  0x00007ffff7892897 in abort () from /usr/lib/libc.so.6
       #2  0x00007ffff7892767 in __assert_fail_base.cold () from /usr/lib/libc.so.6
       #3  0x00007ffff78a1526 in __assert_fail () from /usr/lib/libc.so.6
       #4  0x00007ffff7fb57c1 in dixGetPrivateAddr (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:121
       #5  0x00007ffff7fb5822 in dixGetPrivate (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:136
       #6  0x00007ffff7fb586a in dixLookupPrivate (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:166
       #7  0x00007ffff7fb8445 in CreateScreenResources (pScreen=0x555555ab1790) at ../hw/xfree86/drivers/modesetting/driver.c:1335
       #8  0x000055555576c5e4 in xf86CrtcCreateScreenResources (screen=0x555555ab1790) at ../hw/xfree86/modes/xf86Crtc.c:744
       #9  0x00005555555d8bb6 in dix_main (argc=4, argv=0x7fffffffead8, envp=0x7fffffffeb00) at ../dix/main.c:214
       #10 0x00005555557a4f0b in main (argc=4, argv=0x7fffffffead8, envp=0x7fffffffeb00) at ../dix/stubmain.c:34
      
      This can happen, for example, if the server is configured with Xinerama
      and there is more than one X screen:
      
       Section "ServerLayout"
         Identifier "crash"
         Screen 0 "modesetting"
         Screen 1 "dummy" RightOf "modesetting"
         Option "Xinerama"
       EndSection
      
       Section "Device"
         Identifier "modesetting"
         Driver "modesetting"
       EndSection
      
       Section "Screen"
         Identifier "modesetting"
         Device "modesetting"
       EndSection
      
       Section "Device"
         Identifier "dummy"
         Driver "dummy"
       EndSection
      
       Section "Screen"
         Identifier "dummy"
         Device "dummy"
       EndSection
      
      The problem does not reproduce if there is only one X screen because of
      this code in xf86RandR12Init:
      
       #ifdef PANORAMIX
           /* XXX disable RandR when using Xinerama */
           if (!noPanoramiXExtension) {
               if (xf86NumScreens == 1)
                   noPanoramiXExtension = TRUE;
               else
                   return TRUE;
           }
       #endif
      
      Fix the problem by checking dixPrivateKeyRegistered(rrPrivKey) before
      calling rrGetScrPriv. This is similar to what the xf86-video-amdgpu
      driver does:
      https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/blob/fd66f5c0bea2b7c22a47bfd5eb1f22d32d166d9c/src/amdgpu_kms.c#L388
      
      
      
      Signed-off-by: Aaron Plattner's avatarAaron Plattner <aplattner@nvidia.com>
      Reviewed-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
      4226c6d0
  22. Nov 25, 2019
  23. Nov 21, 2019
  24. Nov 15, 2019
  25. Nov 13, 2019
  26. Oct 29, 2019
  27. Oct 23, 2019
  28. Oct 14, 2019
  29. Oct 11, 2019
    • Emil Velikov's avatar
      glamor_egl: disable modifiers via glamor_init() · f3ab3d0c
      Emil Velikov authored
      
      Currently we parse through xf86Info.debug to check if we the modifiers
      should be disabled. Handle that within DDX and pass GLAMOR_NO_MODIFIERS
      into the glamor_init() flags.
      
      This allows individual DDX control over the setting - say when modifiers
      are woking OK with one implementation and not the other.
      
      Most importantly, this removes the final xf86 piece from the codebase.
      
      Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
      f3ab3d0c
Loading