1. 21 8月, 2013 4 次提交
  2. 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
  3. 05 7月, 2013 2 次提交
  4. 04 7月, 2013 1 次提交
  5. 28 6月, 2013 6 次提交
  6. 19 6月, 2013 1 次提交
  7. 11 6月, 2013 3 次提交
  8. 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
  9. 23 3月, 2013 1 次提交
  10. 08 2月, 2013 1 次提交
    • A
      drm: add prime helpers · 89177644
      Aaron Plattner 提交于
      Instead of reimplementing all of the dma_buf functionality in every driver,
      create helpers drm_prime_import and drm_prime_export that implement them in
      terms of new, lower-level hook functions:
      
        gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT
        gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export
        gem_prime_import_sg_table: convert an sg_table into a drm_gem_object
        gem_prime_vmap, gem_prime_vunmap: map and unmap an object
      
      These hooks are optional; drivers can opt in by using drm_gem_prime_import and
      drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of
      struct drm_driver.
      
      v2:
      - Drop .begin_cpu_access.  None of the drivers this code replaces implemented
        it.  Having it here was a leftover from when I was trying to include i915 in
        this rework.
      - Use mutex_lock instead of mutex_lock_interruptible, as these three drivers
        did.  This patch series shouldn't change that behavior.
      - Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table.
        Rename struct sg_table* variables to 'sgt' for clarity.
      - Update drm.tmpl for these new hooks.
      
      v3:
      - Pass the vaddr down to the driver.  This lets drivers that just call vunmap on
        the pointer avoid having to store the pointer in their GEM private structures.
      - Move documentation into a /** DOC */ comment in drm_prime.c and include it in
        drm.tmpl with a !P line.  I tried to use !F lines to include documentation of
        the individual functions from drmP.h, but the docproc / kernel-doc scripts
        barf on that file, so hopefully this is good enough for now.
      - apply refcount fix from commit be8a42ae
        ("drm/prime: drop reference on imported dma-buf come from gem")
      Signed-off-by: NAaron Plattner <aplattner@nvidia.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@linux.ie>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      89177644
  11. 03 10月, 2012 1 次提交
  12. 23 5月, 2012 2 次提交
  13. 30 3月, 2012 1 次提交