1. 06 6月, 2021 2 次提交
  2. 05 6月, 2021 1 次提交
  3. 04 6月, 2021 3 次提交
  4. 20 5月, 2021 1 次提交
  5. 08 4月, 2021 1 次提交
  6. 25 2月, 2021 2 次提交
  7. 24 2月, 2021 3 次提交
  8. 10 2月, 2021 1 次提交
  9. 03 2月, 2021 1 次提交
  10. 22 1月, 2021 3 次提交
  11. 18 1月, 2021 1 次提交
    • D
      dma-buf: Add debug option · 84335675
      Daniel Vetter 提交于
      We have too many people abusing the struct page they can get at but
      really shouldn't in importers. Aside from that the backing page might
      simply not exist (for dynamic p2p mappings) looking at it and using it
      e.g. for mmap can also wreak the page handling of the exporter
      completely. Importers really must go through the proper interface like
      dma_buf_mmap for everything.
      
      I'm semi-tempted to enforce this for dynamic importers since those
      really have no excuse at all to break the rules.
      
      Unfortuantely we can't store the right pointers somewhere safe to make
      sure we oops on something recognizable, so best is to just wrangle
      them a bit by flipping all the bits. At least on x86 kernel addresses
      have all their high bits sets and the struct page array is fairly low
      in the kernel mapping, so flipping all the bits gives us a very high
      pointer in userspace and hence excellent chances for an invalid
      dereference.
      
      v2: Add a note to the @map_dma_buf hook that exporters shouldn't do
      fancy caching tricks, which would blow up with this address scrambling
      trick here (Chris)
      
      Enable by default when CONFIG_DMA_API_DEBUG is enabled.
      
      v3: Only one copy of the mangle/unmangle code (Christian)
      
      v4: #ifdef, not #if (0day)
      
      v5: sg_table can also be an ERR_PTR (Chris, Christian)
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: NChristian König <christian.koenig@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: David Stevens <stevensd@chromium.org>
      Cc: linux-media@vger.kernel.org
      Cc: linaro-mm-sig@lists.linaro.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20210115164739.3958206-1-daniel.vetter@ffwll.ch
      84335675
  12. 11 1月, 2021 1 次提交
    • J
      dma-buf: cma_heap: Fix memory leak in CMA heap · a0adc8ea
      John Stultz 提交于
      Bing Song noticed the CMA heap was leaking memory due to a flub
      I made in commit a5d2d29e ("dma-buf: heaps: Move heap-helper
      logic into the cma_heap implementation"), and provided this fix
      which ensures the pagelist is also freed on release.
      
      Cc: Bing Song <bing.song@nxp.com>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reported-by: NBing Song <bing.song@nxp.com>
      Fixes: a5d2d29e ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210107202616.75170-1-john.stultz@linaro.org
      a0adc8ea
  13. 07 1月, 2021 1 次提交
    • C
      dmabuf: fix use-after-free of dmabuf's file->f_inode · 05cd8469
      Charan Teja Reddy 提交于
      It is observed 'use-after-free' on the dmabuf's file->f_inode with the
      race between closing the dmabuf file and reading the dmabuf's debug
      info.
      
      Consider the below scenario where P1 is closing the dma_buf file
      and P2 is reading the dma_buf's debug info in the system:
      
      P1						P2
      					dma_buf_debug_show()
      dma_buf_put()
        __fput()
          file->f_op->release()
          dput()
          ....
            dentry_unlink_inode()
              iput(dentry->d_inode)
              (where the inode is freed)
      					mutex_lock(&db_list.lock)
      					read 'dma_buf->file->f_inode'
      					(the same inode is freed by P1)
      					mutex_unlock(&db_list.lock)
            dentry->d_op->d_release()-->
              dma_buf_release()
                .....
                mutex_lock(&db_list.lock)
                removes the dmabuf from the list
                mutex_unlock(&db_list.lock)
      
      In the above scenario, when dma_buf_put() is called on a dma_buf, it
      first frees the dma_buf's file->f_inode(=dentry->d_inode) and then
      removes this dma_buf from the system db_list. In between P2 traversing
      the db_list tries to access this dma_buf's file->f_inode that was freed
      by P1 which is a use-after-free case.
      
      Since, __fput() calls f_op->release first and then later calls the
      d_op->d_release, move the dma_buf's db_list removal from d_release() to
      f_op->release(). This ensures that dma_buf's file->f_inode is not
      accessed after it is released.
      
      Cc: <stable@vger.kernel.org> # 5.4.x-
      Fixes: 4ab59c3c ("dma-buf: Move dma_buf_release() from fops to dentry_ops")
      Acked-by: NChristian König <christian.koenig@amd.com>
      Signed-off-by: NCharan Teja Reddy <charante@codeaurora.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Signed-off-by: NThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/1609857399-31549-1-git-send-email-charante@codeaurora.org
      05cd8469
  14. 17 12月, 2020 1 次提交
    • J
      dma-buf: cma_heap: Include linux/vmalloc.h to fix build failures on MIPS · 8075c300
      John Stultz 提交于
      We need to include <linux/vmalloc.h> in order for MIPS to find
      vmap(), as it doesn't otherwise get included there.
      
      Without this patch, one can hit the following build error:
        drivers/dma-buf/heaps/cma_heap.c: In function 'cma_heap_do_vmap':
        drivers/dma-buf/heaps/cma_heap.c:195:10: error: implicit declaration of function 'vmap'
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Fixes: a5d2d29e ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201216004931.113505-1-john.stultz@linaro.org
      8075c300
  15. 16 12月, 2020 5 次提交
  16. 25 11月, 2020 1 次提交
  17. 23 11月, 2020 5 次提交
    • J
      dma-buf: system_heap: Allocate higher order pages if available · d963ab0f
      John Stultz 提交于
      While the system heap can return non-contiguous pages,
      try to allocate larger order pages if possible.
      
      This will allow slight performance gains and make implementing
      page pooling easier.
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-6-john.stultz@linaro.org
      d963ab0f
    • J
      dma-buf: heaps: Skip sync if not mapped · 4c68e499
      John Stultz 提交于
      This patch is basically a port of Ørjan Eide's similar patch for ION
       https://lore.kernel.org/lkml/20200414134629.54567-1-orjan.eide@arm.com/
      
      Only sync the sg-list of dma-buf heap attachment when the attachment
      is actually mapped on the device.
      
      dma-bufs may be synced at any time. It can be reached from user space
      via DMA_BUF_IOCTL_SYNC, so there are no guarantees from callers on when
      syncs may be attempted, and dma_buf_end_cpu_access() and
      dma_buf_begin_cpu_access() may not be paired.
      
      Since the sg_list's dma_address isn't set up until the buffer is used
      on the device, and dma_map_sg() is called on it, the dma_address will be
      NULL if sync is attempted on the dma-buf before it's mapped on a device.
      
      Before v5.0 (commit 55897af6 ("dma-direct: merge swiotlb_dma_ops
      into the dma_direct code")) this was a problem as the dma-api (at least
      the swiotlb_dma_ops on arm64) would use the potentially invalid
      dma_address. How that failed depended on how the device handled physical
      address 0. If 0 was a valid address to physical ram, that page would get
      flushed a lot, while the actual pages in the buffer would not get synced
      correctly. While if 0 is an invalid physical address it may cause a
      fault and trigger a crash.
      
      In v5.0 this was incidentally fixed by commit 55897af6 ("dma-direct:
      merge swiotlb_dma_ops into the dma_direct code"), as this moved the
      dma-api to use the page pointer in the sg_list, and (for Ion buffers at
      least) this will always be valid if the sg_list exists at all.
      
      But, this issue is re-introduced in v5.3 with
      commit 449fa54d ("dma-direct: correct the physical addr in
      dma_direct_sync_sg_for_cpu/device") moves the dma-api back to the old
      behaviour and picks the dma_address that may be invalid.
      
      dma-buf core doesn't ensure that the buffer is mapped on the device, and
      thus have a valid sg_list, before calling the exporter's
      begin_cpu_access.
      
      Logic and commit message originally by: Ørjan Eide <orjan.eide@arm.com>
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-5-john.stultz@linaro.org
      4c68e499
    • J
      dma-buf: heaps: Remove heap-helpers code · 064fae53
      John Stultz 提交于
      The heap-helpers code was not as generic as initially hoped
      and it is now not being used, so remove it from the tree.
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-4-john.stultz@linaro.org
      064fae53
    • J
      dma-buf: heaps: Move heap-helper logic into the cma_heap implementation · a5d2d29e
      John Stultz 提交于
      Since the heap-helpers logic ended up not being as generic as
      hoped, move the heap-helpers dma_buf_ops implementations into
      the cma_heap directly.
      
      This will allow us to remove the heap_helpers code in a following
      patch.
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-3-john.stultz@linaro.org
      a5d2d29e
    • J
      dma-buf: system_heap: Rework system heap to use sgtables instead of pagelists · 38129575
      John Stultz 提交于
      In preparation for some patches to optmize the system
      heap code, rework the dmabuf exporter to utilize sgtables rather
      then pageslists for tracking the associated pages.
      
      This will allow for large order page allocations, as well as
      more efficient page pooling.
      
      In doing so, the system heap stops using the heap-helpers logic
      which sadly is not quite as generic as I was hoping it to be, so
      this patch adds heap specific implementations of the dma_buf_ops
      function handlers.
      
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Liam Mark <lmark@codeaurora.org>
      Cc: Laura Abbott <labbott@kernel.org>
      Cc: Brian Starkey <Brian.Starkey@arm.com>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Sandeep Patil <sspatil@google.com>
      Cc: Daniel Mentz <danielmentz@google.com>
      Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
      Cc: Ørjan Eide <orjan.eide@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Ezequiel Garcia <ezequiel@collabora.com>
      Cc: Simon Ser <contact@emersion.fr>
      Cc: James Jones <jajones@nvidia.com>
      Cc: linux-media@vger.kernel.org
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NSumit Semwal <sumit.semwal@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-2-john.stultz@linaro.org
      38129575
  18. 19 11月, 2020 2 次提交
  19. 06 11月, 2020 2 次提交
  20. 05 11月, 2020 3 次提交