Skip to content
  1. Nov 08, 2019
  2. Nov 07, 2019
  3. Nov 06, 2019
    • Daniel Vetter's avatar
      drm/ttm: remove ttm_bo_wait_unreserved · 6b1ce0a2
      Daniel Vetter authored
      
      
      With nouveau fixed all ttm-using drives have the correct nesting of
      mmap_sem vs dma_resv, and we can just lock the buffer.
      
      Assuming I didn't screw up anything with my audit of course.
      
      v2:
      - Dont forget wu_mutex (Christian König)
      - Keep the mmap_sem-less wait optimization (Thomas)
      - Use _lock_interruptible to be good citizens (Thomas)
      
      v3: Rebase over fault handler helperification.
      
      Reviewed-by: Christian König <christian.koenig@amd.com> (v2)
      Reviewed-by: Thomas Hellström <thellstrom@vmware.com> (v2)
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Christian Koenig <christian.koenig@amd.com>
      Cc: Huang Rui <ray.huang@amd.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: "VMware Graphics" <linux-graphics-maintainer@vmware.com>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191104173801.2972-3-daniel.vetter@ffwll.ch
      6b1ce0a2
    • Daniel Vetter's avatar
      drm/nouveau: slowpath for pushbuf ioctl · 03e0d26f
      Daniel Vetter authored
      
      
      We can't copy_*_user while holding reservations, that will (soon even
      for nouveau) lead to deadlocks. And it breaks the cross-driver
      contract around dma_resv.
      
      Fix this by adding a slowpath for when we need relocations, and by
      pushing the writeback of the new presumed offsets to the very end.
      
      Aside from "it compiles" entirely untested unfortunately.
      
      Cc: Ilia Mirkin <imirkin@alum.mit.edu>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: nouveau@lists.freedesktop.org
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Acked-by: default avatarDave Airlie <airlied@gmail.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191104173801.2972-2-daniel.vetter@ffwll.ch
      03e0d26f
    • Daniel Vetter's avatar
      dma_resv: prime lockdep annotations · b2a8116e
      Daniel Vetter authored
      
      
      Full audit of everyone:
      
      - i915, radeon, amdgpu should be clean per their maintainers.
      
      - vram helpers should be fine, they don't do command submission, so
        really no business holding struct_mutex while doing copy_*_user. But
        I haven't checked them all.
      
      - panfrost seems to dma_resv_lock only in panfrost_job_push, which
        looks clean.
      
      - v3d holds dma_resv locks in the tail of its v3d_submit_cl_ioctl(),
        copying from/to userspace happens all in v3d_lookup_bos which is
        outside of the critical section.
      
      - vmwgfx has a bunch of ioctls that do their own copy_*_user:
        - vmw_execbuf_process: First this does some copies in
          vmw_execbuf_cmdbuf() and also in the vmw_execbuf_process() itself.
          Then comes the usual ttm reserve/validate sequence, then actual
          submission/fencing, then unreserving, and finally some more
          copy_to_user in vmw_execbuf_copy_fence_user. Glossing over tons of
          details, but looks all safe.
        - vmw_fence_event_ioctl: No ttm_reserve/dma_resv_lock anywhere to be
          seen, seems to only create a fence and copy it out.
        - a pile of smaller ioctl in vmwgfx_ioctl.c, no reservations to be
          found there.
        Summary: vmwgfx seems to be fine too.
      
      - virtio: There's virtio_gpu_execbuffer_ioctl, which does all the
        copying from userspace before even looking up objects through their
        handles, so safe. Plus the getparam/getcaps ioctl, also both safe.
      
      - qxl only has qxl_execbuffer_ioctl, which calls into
        qxl_process_single_command. There's a lovely comment before the
        __copy_from_user_inatomic that the slowpath should be copied from
        i915, but I guess that never happened. Try not to be unlucky and get
        your CS data evicted between when it's written and the kernel tries
        to read it. The only other copy_from_user is for relocs, but those
        are done before qxl_release_reserve_list(), which seems to be the
        only thing reserving buffers (in the ttm/dma_resv sense) in that
        code. So looks safe.
      
      - A debugfs file in nouveau_debugfs_pstate_set() and the usif ioctl in
        usif_ioctl() look safe. nouveau_gem_ioctl_pushbuf() otoh breaks this
        everywhere and needs to be fixed up.
      
      v2: Thomas pointed at that vmwgfx calls dma_resv_init while it holds a
      dma_resv lock of a different object already. Christian mentioned that
      ttm core does this too for ghost objects. intel-gfx-ci highlighted
      that i915 has similar issues.
      
      Unfortunately we can't do this in the usual module init functions,
      because kernel threads don't have an ->mm - we have to wait around for
      some user thread to do this.
      
      Solution is to spawn a worker (but only once). It's horrible, but it
      works.
      
      v3: We can allocate mm! (Chris). Horrible worker hack out, clean
      initcall solution in.
      
      v4: Annotate with __init (Rob Herring)
      
      Cc: Rob Herring <robh@kernel.org>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: "VMware Graphics" <linux-graphics-maintainer@vmware.com>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Tested-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191104173801.2972-1-daniel.vetter@ffwll.ch
      b2a8116e
  4. Nov 05, 2019
  5. Nov 04, 2019
  6. Oct 31, 2019
    • Sean Paul's avatar
      Revert "dma-buf: Add dma-buf heaps framework" · fae7d7d5
      Sean Paul authored
      This reverts commit a69b0e85.
      
      This patchset doesn't meet the UAPI requirements set out in [1] for the DRM
      subsystem. Once the userspace component is reviewed and ready for merge
      we can try again.
      
      [1]- https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
      
      
      
      Fixes: a69b0e85 ("dma-buf: Add dma-buf heaps framework")
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Pratik Patel <pratikp@codeaurora.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
      Cc: Sudipto Paul <Sudipto.Paul@arm.com>
      Cc: Andrew F. Davis <afd@ti.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Chenbo Feng <fengc@google.com>
      Cc: Alistair Strachan <astrachan@google.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: Brian Starkey <brian.starkey@arm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: "Andrew F. Davis" <afd@ti.com>
      Cc: linux-media@vger.kernel.org
      Cc: linaro-mm-sig@lists.linaro.org
      Acked-by: default avatarDavid Airlie <airlied@linux.ie>
      Signed-off-by: default avatarSean Paul <sean@poorly.run>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191030203003.101156-6-sean@poorly.run
      fae7d7d5
    • Sean Paul's avatar
      Revert "dma-buf: heaps: Add heap helpers" · 837324d4
      Sean Paul authored
      This reverts commit 7b87ea70.
      
      This patchset doesn't meet the UAPI requirements set out in [1] for the DRM
      subsystem. Once the userspace component is reviewed and ready for merge
      we can try again.
      
      [1]- https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
      
      
      
      Fixes: 7b87ea70 ("dma-buf: heaps: Add heap helpers")
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Pratik Patel <pratikp@codeaurora.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
      Cc: Sudipto Paul <Sudipto.Paul@arm.com>
      Cc: Andrew F. Davis <afd@ti.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Chenbo Feng <fengc@google.com>
      Cc: Alistair Strachan <astrachan@google.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: Brian Starkey <brian.starkey@arm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: "Andrew F. Davis" <afd@ti.com>
      Cc: linux-media@vger.kernel.org
      Cc: linaro-mm-sig@lists.linaro.org
      Acked-by: default avatarDavid Airlie <airlied@linux.ie>
      Signed-off-by: default avatarSean Paul <sean@poorly.run>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191030203003.101156-5-sean@poorly.run
      837324d4