Skip to content
  1. Oct 02, 2021
  2. Oct 01, 2021
    • Simon Ser's avatar
      drm/lease: allow empty leases · 4bb2d367
      Simon Ser authored
      This can be used to create a separate DRM file description, thus
      creating a new GEM handle namespace.
      
      My use-case is wlroots. The library splits responsibilities between
      separate components: the GBM allocator creates buffers, the GLES2
      renderer uses EGL to import them and render to them, the DRM
      backend imports the buffers and displays them. wlroots has a
      modular architecture, and any of these components can be swapped
      and replaced with something else. For instance, the pipeline can
      be set up so that the DRM dumb buffer allocator is used instead of
      GBM and the Pixman renderer is used instead of GLES2. Library users
      can also replace any of these components with their own custom one.
      
      DMA-BUFs are used to pass buffer references across components. We
      could use GEM handles instead, but this would result in pain if
      multiple GPUs are in use: wlroots copies buffers across GPUs as
      needed. Importing a GEM handle created on one GPU into a completely
      different GPU will blow up (fail at best, mix unrelated buffers
      otherwise).
      
      Everything is fine if all components use Mesa. However, this isn't
      always desirable. For instance when running with DRM dumb buffers
      and the Pixman software renderer it's unfortunate to depend on GBM
      in the DRM backend just to turn DMA-BUFs into FB IDs. GBM loads
      Mesa drivers to perform an action which has nothing driver-specific.
      Additionally, drivers will fail the import if the 3D engine can't
      use the imported buffer, for instance amdgpu will refuse to import
      DRM dumb buffers [1]. We might also want to be running with a Vulkan
      renderer and a Vulkan allocator in the future, and GBM wouldn't be
      welcome in this setup.
      
      To address this, GBM can be side-stepped in the DRM backend, and
      can be replaced with drmPrimeFDToHandle calls. However because of
      GEM handle reference counting issues, care must be taken to avoid
      double-closing the same GEM handle. In particular, it's not
      possible to share a DRM FD with GBM or EGL and perform some
      drmPrimeFDToHandle calls manually.
      
      So wlroots needs to re-open the DRM FD to create a new GEM handle
      namespace. However there's no guarantee that the file-system
      permissions will be set up so that the primary FD can be opened
      by the compsoitor. On modern systems seatd or logind is a privileged
      process responsible for doing this, and other processes aren't
      expected to do it. For historical reasons systemd still allows
      physically logged in users to open primary DRM nodes, but this
      doesn't work on non-systemd setups and it's desirable to lock
      them down at some point.
      
      Some might suggest to open the render node instead of re-opening
      the primary node. However some systems don't have a render node
      at all (e.g. no GPU, or a split render/display SoC).
      
      Solutions to this issue have been discussed in [2]. One solution
      would be to open the magic /proc/self/fd/<fd> file, but it's a
      Linux-specific hack (wlroots supports BSDs too). Another solution
      is to add support for re-opening a DRM primary node to seatd/logind,
      but they don't support it now and really haven't been designed for
      this (logind would need to grow a completely new API, because it
      assumes unique dev_t IDs). Also this seems like pushing down a
      kernel limitation to user-space a bit too hard.
      
      Another solution is to allow creating empty DRM leases. The lessee
      FD would have its own GEM handle namespace, so wouldn't conflict
      wth GBM/EGL. It would have the master bit set, but would be able
      to manage zero resources. wlroots doesn't intend to share this FD
      with any other process.
      
      All in all IMHO that seems like a pretty reasonable solution to the
      issue at hand.
      
      Note, I've discussed with Jonas Ådahl and Mutter plans to adopt a
      similar design in the future.
      
      Example usage in wlroots is available at [3]. IGT test available
      at [4].
      
      [1]: https://github.com/swaywm/wlroots/issues/2916
      [2]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110
      [3]: https://github.com/swaywm/wlroots/pull/3158
      [4]: https://patchwork.freedesktop.org/series/94323/
      
      
      
      Signed-off-by: default avatarSimon Ser <contact@emersion.fr>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Daniel Stone <daniels@collabora.com>
      Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
      Cc: Michel Dänzer <michel@daenzer.net>
      Cc: Emil Velikov <emil.l.velikov@gmail.com>
      Cc: Keith Packard <keithp@keithp.com>
      Cc: Boris Brezillon <boris.brezillon@collabora.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Acked-by: default avatarPekka Paalanen <pekka.paalanen@collabora.com>
      Reviewed-by: default avatarDaniel Stone <daniels@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210903130000.1590-2-contact@emersion.fr
      4bb2d367
    • Arnd Bergmann's avatar
      drm: fb_helper: fix CONFIG_FB dependency · 606b1028
      Arnd Bergmann authored
      With CONFIG_FB=m and CONFIG_DRM=y, we get a link error in the fb helper:
      
      aarch64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_alloc_fbi':
      (.text+0x10cc): undefined reference to `framebuffer_alloc'
      
      Tighten the dependency so it is only allowed in the case that DRM can
      link against FB.
      
      Fixes: f611b1e7 ("drm: Avoid circular dependencies for CONFIG_FB")
      Link: https://lore.kernel.org/all/20210721152211.2706171-1-arnd@kernel.org/
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210927142816.2069269-1-arnd@kernel.org
      606b1028
    • Christian König's avatar
      dma-buf: fix and rework dma_buf_poll v7 · 6b51b02a
      Christian König authored
      
      
      Daniel pointed me towards this function and there are multiple obvious problems
      in the implementation.
      
      First of all the retry loop is not working as intended. In general the retry
      makes only sense if you grab the reference first and then check the sequence
      values.
      
      Then we should always also wait for the exclusive fence.
      
      It's also good practice to keep the reference around when installing callbacks
      to fences you don't own.
      
      And last the whole implementation was unnecessary complex and rather hard to
      understand which could lead to probably unexpected behavior of the IOCTL.
      
      Fix all this by reworking the implementation from scratch. Dropping the
      whole RCU approach and taking the lock instead.
      
      Only mildly tested and needs a thoughtful review of the code.
      
      Pushing through drm-misc-next to avoid merge conflicts and give the code
      another round of testing.
      
      v2: fix the reference counting as well
      v3: keep the excl fence handling as is for stable
      v4: back to testing all fences, drop RCU
      v5: handle in and out separately
      v6: add missing clear of events
      v7: change coding style as suggested by Michel, drop unused variables
      
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Tested-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
      CC: stable@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20210720131110.88512-1-christian.koenig@amd.com
      6b51b02a
    • Fangzhi Zuo's avatar
      drm/dp: Add Additional DP2 Headers · 241ffeb0
      Fangzhi Zuo authored
      
      
      Include FEC, DSC, Link Training related headers.
      
      Change since v2
      - Align with the spec for DP_DSC_SUPPORT_AND_DSC_DECODER_COUNT
      
      Signed-off-by: default avatarFangzhi Zuo <Jerry.Zuo@amd.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Signed-off-by: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210927192324.5428-1-Jerry.Zuo@amd.com
      241ffeb0
  3. Sep 30, 2021
  4. Sep 29, 2021
  5. Sep 28, 2021