1. 15 12月, 2015 1 次提交
    • D
      drm/doc: Convert to markdown · f03d8ede
      Danilo Cesar Lemes de Paula 提交于
      DRM Docbook is now Markdown ready. This means its doc is able to
      use markdown text on it.
      
      * Documentation/DocBook/drm.tmpl: Contains a table duplicated from
        drivers/gpu/drm/i915/i915_reg.h. This is not needed anymore
      
      * drivers/gpu/drm/drm_modeset_lock.c: had a code example that used
        to look pretty bad on html. Fixed by using proper code markup.
      
      * drivers/gpu/drm/drm_prime.c: Remove spaces between lines to make
        a proper markup list.
      
      * drivers/gpu/drm/i915/i915_reg.h: Altought pandoc supports tables,
        it doesn't support table cell spanning. But we can use fixed-width
        for those special cases.
      
      * include/drm/drm_vma_manager.h: Another code example that should be
        proper indented with four spaces.
      
      v2 (Daniel): Adjust name to gpu.xml due to rename.
      
      v3 (Daniel):
      Split out the actual enabling in the Makefile - this way we can merge
      the conversion, while just keeping the enabling in a drm-private tree.
      
      Signed-off-by: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> (v1)
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Stephan Mueller <smueller@chronox.de>
      Cc: Michal Marek <mmarek@suse.cz>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-doc@vger.kernel.org
      Cc: intel-gfx <intel-gfx@lists.freedesktop.org>
      Cc: dri-devel <dri-devel@lists.freedesktop.org>
      Acked-by: NDave Airlie <airlied@redhat.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/1448471279-19748-2-git-send-email-daniel.vetter@ffwll.ch
      f03d8ede
  2. 19 6月, 2015 1 次提交
  3. 12 5月, 2015 1 次提交
  4. 21 4月, 2015 1 次提交
  5. 13 11月, 2014 1 次提交
  6. 21 10月, 2014 1 次提交
  7. 30 9月, 2014 1 次提交
  8. 24 9月, 2014 1 次提交
  9. 12 9月, 2014 1 次提交
  10. 09 7月, 2014 1 次提交
  11. 13 3月, 2014 1 次提交
    • D
      drm/doc: Add PRIME function references · 39cc344a
      Daniel Vetter 提交于
      For giant hilarity the DocBook reference overview is only generated
      when in a level 2 section, not in a level 3 section. So we need to
      move this up a bit as a side-by-side section to the main PRIME
      documentation.
      
      Whatever.
      
      To have a complete set of references add the missing kerneldoc for all
      functions exported to modules with the exception of the file private
      init/destroy functions - drivers have no business calling those, so
      let's just drop the EXPORT_SYMBOL instead.
      
      Also reflow the function parameters to align correctly and break at 80
      chars - my OCD couldn't stand them while writing the kerneldoc ;-)
      Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      39cc344a
  12. 08 2月, 2014 1 次提交
    • C
      dma-buf: avoid using IS_ERR_OR_NULL · fee0c54e
      Colin Cross 提交于
      dma_buf_map_attachment and dma_buf_vmap can return NULL or
      ERR_PTR on a error.  This encourages a common buggy pattern in
      callers:
      	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
      	if (IS_ERR_OR_NULL(sgt))
                      return PTR_ERR(sgt);
      
      This causes the caller to return 0 on an error.  IS_ERR_OR_NULL
      is almost always a sign of poorly-defined error handling.
      
      This patch converts dma_buf_map_attachment to always return
      ERR_PTR, and fixes the callers that incorrectly handled NULL.
      There are a few more callers that were not checking for NULL
      at all, which would have dereferenced a NULL pointer later.
      There are also a few more callers that correctly handled NULL
      and ERR_PTR differently, I left those alone but they could also
      be modified to delete the NULL check.
      
      This patch also converts dma_buf_vmap to always return NULL.
      All the callers to dma_buf_vmap only check for NULL, and would
      have dereferenced an ERR_PTR and panic'd if one was ever
      returned. This is not consistent with the rest of the dma buf
      APIs, but matches the expectations of all of the callers.
      Signed-off-by: NColin Cross <ccross@android.com>
      Reviewed-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fee0c54e
  13. 01 10月, 2013 1 次提交
  14. 30 8月, 2013 1 次提交
  15. 21 8月, 2013 7 次提交
    • D
      drm/prime: Always add exported buffers to the handle cache · d0b2c533
      Daniel Vetter 提交于
      ... not only when the dma-buf is freshly created. In contrived
      examples someone else could have exported/imported the dma-buf already
      and handed us the gem object with a flink name. If such on object gets
      reexported as a dma_buf we won't have it in the handle cache already,
      which breaks the guarantee that for dma-buf imports we always hand
      back an existing handle if there is one.
      
      This is exercised by igt/prime_self_import/with_one_bo_two_files
      
      Now if we extend the locked sections just a notch more we can also
      plug th racy buf/handle cache setup in handle_to_fd:
      
      If evil userspace races a concurrent gem close against a prime export
      operation we can end up tearing down the gem handle before the dma buf
      handle cache is set up. When handle_to_fd gets around to adding the
      handle to the cache there will be no one left to clean it up,
      effectily leaking the bo (and the dma-buf, since the handle cache
      holds a ref on the dma-buf):
      
      Thread A			Thread B
      
      handle_to_fd:
      
      lookup gem object from handle
      creates new dma_buf
      
      				gem_close on the same handle
      				obj->dma_buf is set, but file priv buf
      				handle cache has no entry
      
      				obj->handle_count drops to 0
      
      drm_prime_add_buf_handle sets up the handle cache
      
      -> We have a dma-buf reference in the handle cache, but since the
      handle_count of the gem object already dropped to 0 no on will clean
      it up. When closing the drm device fd we'll hit the WARN_ON in
      drm_prime_destroy_file_private.
      
      The important change is to extend the critical section of the
      filp->prime.lock to cover the gem handle lookup. This serializes with
      a concurrent gem handle close.
      
      This leak is exercised by igt/prime_self_import/export-vs-gem_close-race
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      d0b2c533
    • D
      drm/prime: make drm_prime_lookup_buf_handle static · de9564d8
      Daniel Vetter 提交于
      ... and move it to the top of the function to avoid a forward
      declaration.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      de9564d8
    • D
      drm/prime: proper locking+refcounting for obj->dma_buf link · 319c933c
      Daniel Vetter 提交于
      The export dma-buf cache is semantically similar to an flink name. So
      semantically it makes sense to treat it the same and remove the name
      (i.e. the dma_buf pointer) and its references when the last gem handle
      disappears.
      
      Again we need to be careful, but double so: Not just could someone
      race and export with a gem close ioctl (so we need to recheck
      obj->handle_count again when assigning the new name), but multiple
      exports can also race against each another. This is prevented by
      holding the dev->object_name_lock across the entire section which
      touches obj->dma_buf.
      
      With the new scheme we also need to reinstate the obj->dma_buf link at
      import time (in case the only reference userspace has held in-between
      was through the dma-buf fd and not through any native gem handle). For
      simplicity we don't check whether it's a native object but
      unconditionally set up that link - with the new scheme of removing the
      obj->dma_buf reference when the last handle disappears we can do that.
      
      To make it clear that this is not just for exported buffers anymore
      als rename it from export_dma_buf to dma_buf.
      
      To make sure that now one can race a fd_to_handle or handle_to_fd with
      gem_close we use the same tricks as in flink of extending the
      dev->object_name_locking critical section. With this change we finally
      have a guaranteed 1:1 relationship (at least for native objects)
      between gem objects and dma-bufs, even accounting for races (which can
      happen since the dma-buf itself holds a reference while in-flight).
      
      This prevent igt/prime_self_import/export-vs-gem_close-race from
      Oopsing the kernel. There is still a leak though since the per-file
      priv dma-buf/handle cache handling is racy. That will be fixed in a
      later patch.
      
      v2: Remove the bogus dma_buf_put from the export_and_register_object
      failure path if we've raced with the handle count dropping to 0.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      319c933c
    • D
      drm/prime: clarify logic a bit in drm_gem_prime_fd_to_handle · 84341c28
      Daniel Vetter 提交于
      if (!ret) implies that ret == 0, so no need to clear it again. And
      explicitly check for ret == 0 to indicate that we're checking an errno
      integer.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      84341c28
    • D
      drm/prime: shrink critical section protected by prime lock · bdf655de
      Daniel Vetter 提交于
      When exporting a gem object as a dma-buf the critical section for the
      per-fd prime lock is just the adding (and in case of errors, removing)
      of the handle to the per-fd lookup cache.
      
      So restrict the critical section to just that part of the function.
      
      This simplifies later reordering.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      bdf655de
    • D
      drm/prime: use proper pointer in drm_gem_prime_handle_to_fd · 4332bf43
      Daniel Vetter 提交于
      Part of the function uses the properly-typed dmabuf variable, the
      other an untyped void *buf. Kill the later.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      4332bf43
    • D
      drm/prime: fix error path in drm_gem_prime_fd_to_handle · 730c4ff9
      Daniel Vetter 提交于
      handle_unreference only clears up the obj->name and the reference,
      but would leave a dangling handle in the idr. The right thing
      to do is to call handle_delete.
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      730c4ff9
  16. 19 8月, 2013 2 次提交
    • D
      drm/prime: remove cargo-cult locking from map_sg helper · 01ce605a
      Daniel Vetter 提交于
      I've checked both implementations (radeon/nouveau) and they both grab
      the page array from ttm simply by dereferencing it and then wrapping
      it up with drm_prime_pages_to_sg in the callback and map it with
      dma_map_sg (in the helper).
      
      Only the grabbing of the underlying page array is anything we need to
      be concerned about, and either those pages are pinned independently,
      or we're screwed no matter what.
      
      And indeed, nouveau/radeon pin the backing storage in their
      attach/detach functions.
      
      Since I've created this patch cma prime support for dma_buf was added.
      drm_gem_cma_prime_get_sg_table only calls kzalloc and the creates&maps
      the sg table with dma_get_sgtable. It doesn't touch any gem object
      state otherwise. So the cma helpers also look safe.
      
      The only thing we might claim it does is prevent concurrent mapping of
      dma_buf attachments. But a) that's not allowed and b) the current code
      is racy already since it checks whether the sg mapping exists _before_
      grabbing the lock.
      
      So the dev->struct_mutex locking here does absolutely nothing useful,
      but only distracts. Remove it.
      
      This should also help Maarten's work to eventually pin the backing
      storage more dynamically by preventing locking inversions around
      dev->struct_mutex.
      
      v2: Add analysis for recently added cma helper prime code.
      
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
      Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Acked-by: NMaarten Lankhorst <maarten.lankhorst@canonical.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      01ce605a
    • D
      drm: use common drm_gem_dmabuf_release in i915/exynos drivers · c1d6798d
      Daniel Vetter 提交于
      Note that this is slightly tricky since both drivers store their
      native objects in dma_buf->priv. But both also embed the base
      drm_gem_object at the first position, so the implicit cast is ok.
      
      To use the release helper we need to export it, too.
      
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      c1d6798d
  17. 05 7月, 2013 2 次提交
  18. 04 7月, 2013 1 次提交
  19. 28 6月, 2013 6 次提交
  20. 19 6月, 2013 1 次提交
  21. 11 6月, 2013 3 次提交
  22. 01 5月, 2013 3 次提交
    • I
      drm/prime: warn for non-empty handle lookup list during drm file release · 98b76231
      Imre Deak 提交于
      drm_gem_release should release all handles connected to the drm file and
      so should also release the prime lookup entries of these handles. So
      just WARN if this isn't the case.
      Signed-off-by: NImre Deak <imre.deak@intel.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      98b76231
    • I
      drm: prime: fix refcounting on the dmabuf import error path · 011c2282
      Imre Deak 提交于
      In commit be8a42ae we inroduced a refcount problem, where on the
      drm_gem_prime_fd_to_handle() error path we'll call dma_buf_put() for
      self imported dma buffers.
      
      Fix this by taking a reference on the dma buffer in the .gem_import
      hook instead of assuming the caller had taken one. Besides fixing the
      bug this is also more logical.
      Signed-off-by: NImre Deak <imre.deak@intel.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      011c2282
    • D
      drm/prime: keep a reference from the handle to exported dma-buf (v6) · 219b4733
      Dave Airlie 提交于
      Currently we have a problem with this:
      1. i915: create gem object
      2. i915: export gem object to prime
      3. radeon: import gem object
      4. close prime fd
      5. radeon: unref object
      6. i915: unref object
      
      i915 has an imported object reference in its file priv, that isn't
      cleaned up properly until fd close. The reference gets added at step 2,
      but at step 6 we don't have enough info to clean it up.
      
      The solution is to take a reference on the dma-buf when we export it,
      and drop the reference when the gem handle goes away.
      
      So when we export a dma_buf from a gem object, we keep track of it
      with the handle, we take a reference to the dma_buf. When we close
      the handle (i.e. userspace is finished with the buffer), we drop
      the reference to the dma_buf, and it gets collected.
      
      This patch isn't meant to fix any other problem or bikesheds, and it doesn't
      fix any races with other scenarios.
      
      v1.1: move export symbol line back up.
      
      v2: okay I had to do a bit more, as the first patch showed a leak
      on one of my tests, that I found using the dma-buf debugfs support,
      the problem case is exporting a buffer twice with the same handle,
      we'd add another export handle for it unnecessarily, however
      we now fail if we try to export the same object with a different gem handle,
      however I'm not sure if that is a case I want to support, and I've
      gotten the code to WARN_ON if we hit something like that.
      
      v2.1: rebase this patch, write better commit msg.
      v3: cleanup error handling, track import vs export in linked list,
      these two patches were separate previously, but seem to work better
      like this.
      v4: danvet is correct, this code is no longer useful, since the buffer
      better exist, so remove it.
      v5: always take a reference to the dma buf object, import or export.
      (Imre Deak contributed this originally)
      v6: square the circle, remove import vs export tracking now
      that there is no difference
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      219b4733
  23. 23 3月, 2013 1 次提交