1. 05 9月, 2013 2 次提交
  2. 21 8月, 2013 1 次提交
    • D
      drm/gem: fix up flink name create race · a8e11d1c
      Daniel Vetter 提交于
      This is the 2nd attempt, I've always been a bit dissatisified with the
      tricky nature of the first one:
      
      http://lists.freedesktop.org/archives/dri-devel/2012-July/025451.html
      
      The issue is that the flink ioctl can race with calling gem_close on
      the last gem handle. In that case we'll end up with a zero handle
      count, but an flink name (and it's corresponding reference). Which
      results in a neat space leak.
      
      In my first attempt I've solved this by rechecking the handle count.
      But fundamentally the issue is that ->handle_count isn't your usual
      refcount - it can be resurrected from 0 among other things.
      
      For those special beasts atomic_t often suggest way more ordering that
      it actually guarantees. To prevent being tricked by those hairy
      semantics take the easy way out and simply protect the handle with the
      existing dev->object_name_lock.
      
      With that change implemented it's dead easy to fix the flink vs. gem
      close reace: When we try to create the name we simply have to check
      whether there's still officially a gem handle around and if not refuse
      to create the flink name. Since the handle count decrement and flink
      name destruction is now also protected by that lock the reace is gone
      and we can't ever leak the flink reference again.
      
      Outside of the drm core only the exynos driver looks at the handle
      count, and tbh I have no idea why (it's just for debug dmesg output
      luckily).
      
      I've considered inlining the drm_gem_object_handle_free, but I plan to
      add more name-like things (like the exported dma_buf) to this scheme,
      so it's clearer to leave the handle freeing in its own function.
      
      This is exercised by the new gem_flink_race i-g-t testcase, which on
      my snb leaks gem objects at a rate of roughly 1k objects/s.
      
      v2: Fix up the error path handling in handle_create and make it more
      robust by simply calling object_handle_unreference.
      
      v3: Fix up the handle_unreference logic bug - atomic_dec_and_test
      retursn 1 for 0. Oops.
      
      v4: Squash in inlining of drm_gem_object_handle_reference as suggested
      by Dave Airlie and add a note that we now have a testcase.
      
      Cc: Dave Airlie <airlied@gmail.com>
      Cc: Inki Dae <inki.dae@samsung.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      a8e11d1c
  3. 07 8月, 2013 1 次提交
  4. 25 7月, 2013 1 次提交
    • D
      drm/gem: convert to new unified vma manager · 0de23977
      David Herrmann 提交于
      Use the new vma manager instead of the old hashtable. Also convert all
      drivers to use the new convenience helpers. This drops all the
      (map_list.hash.key << PAGE_SHIFT) non-sense.
      
      Locking and access-management is exactly the same as before with an
      additional lock inside of the vma-manager, which strictly wouldn't be
      needed for gem.
      
      v2:
       - rebase on drm-next
       - init nodes via drm_vma_node_reset() in drm_gem.c
      v3:
       - fix tegra
      v4:
       - remove duplicate if (drm_vma_node_has_offset()) checks
       - inline now trivial drm_vma_node_offset_addr() calls
      v5:
       - skip node-reset on gem-init due to kzalloc()
       - do not allow mapping gem-objects with offsets (backwards compat)
       - remove unneccessary casts
      
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Acked-by: NPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@gmail.com>
      0de23977
  5. 04 7月, 2013 1 次提交
  6. 28 6月, 2013 2 次提交
  7. 29 4月, 2013 1 次提交
  8. 20 3月, 2013 1 次提交
  9. 21 2月, 2013 1 次提交
  10. 04 1月, 2013 1 次提交
  11. 13 12月, 2012 1 次提交
  12. 05 12月, 2012 1 次提交
  13. 04 12月, 2012 5 次提交
    • I
      drm/exynos: add vm_ops to specific gem mmaper · 5b07c660
      Inki Dae 提交于
      Changelog v3:
      use drm_file's file object instead of gem object's
      - gem object's file represents the shmem storage so
        process-unique file object should be used instead.
      
      Changelog v2:
      call mutex_lock before drm_vm_open_locked is called.
      
      Changelog v1:
      This patch makes it takes a reference to gem object when
      specific gem mmap is requested. For this, it sets
      dev->driver->gem_vm_ops to vma->vm_ops.
      
      And this patch is based on exynos-drm-next-iommu branch of
      	git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynosSigned-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      5b07c660
    • I
      drm/exynos: add userptr feature for g2d module · 2a3098ff
      Inki Dae 提交于
      This patch adds userptr feautre for G2D module.
      
      The userptr means user space address allocated by malloc().
      And the purpose of this feature is to make G2D's dma able
      to access the user space region.
      
      To user this feature, user should flag G2D_BUF_USRPTR to
      offset variable of struct drm_exynos_g2d_cmd and fill
      struct drm_exynos_g2d_userptr with user space address
      and size for it and then should set a pointer to
      drm_exynos_g2d_userptr object to data variable of struct
      drm_exynos_g2d_cmd. The last bit of offset variable is used
      to check if the cmdlist's buffer type is userptr or not.
      If userptr, the g2d driver gets user space address and size
      and then gets pages through get_user_pages().
      (another case is counted as gem handle)
      
      Below is sample codes:
      
      static void set_cmd(struct drm_exynos_g2d_cmd *cmd,
      		unsigned long offset, unsigned long data)
      {
      	cmd->offset = offset;
      	cmd->data = data;
      }
      
      static int solid_fill_test(int x, int y, unsigned long userptr)
      {
      	struct drm_exynos_g2d_cmd cmd_gem[5];
      	struct drm_exynos_g2d_userptr g2d_userptr;
      	unsigned int gem_nr = 0;
      	...
      
      	g2d_userptr.userptr = userptr;
      	g2d_userptr.size = x * y * 4;
      
      	set_cmd(&cmd_gem[gem_nr++], DST_BASE_ADDR_REG |
      					G2D_BUF_USERPTR,
      			(unsigned long)&g2d_userptr);
      	...
      }
      
      int main(int argc, char **argv)
      {
      	unsigned long addr;
      	...
      
      	addr = malloc(x * y * 4);
      	...
      
      	solid_fill_test(x, y, addr);
      	...
      }
      
      And next, the pages are mapped with iommu table and the device
      address is set to cmdlist so that G2D's dma can access it.
      As you may know, the pages from get_user_pages() are pinned.
      In other words, they CAN NOT be migrated and also swapped out.
      So the dma access would be safe.
      
      But the use of userptr feature has performance overhead so
      this patch also has memory pool to the userptr feature.
      Please, assume that user sends cmdlist filled with userptr
      and size every time to g2d driver, and the get_user_pages
      funcion will be called every time.
      
      The memory pool has maximum 64MB size and the userptr that
      user had ever sent, is holded in the memory pool.
      This meaning is that if the userptr from user is same as one
      in the memory pool, device address to the userptr in the memory
      pool is set to cmdlist.
      
      And last, the pages from get_user_pages() will be freed once
      user calls free() and the dma access is completed. Actually,
      get_user_pages() takes 2 reference counts if the user process
      has never accessed user region allocated by malloc(). Then, if
      the user calls free(), the page reference count becomes 1 and
      becomes 0 with put_page() call. And the reverse holds as well.
      This means how the pages backed are used by dma and freed.
      
      This patch is based on "drm/exynos: add iommu support for g2d",
      	https://patchwork.kernel.org/patch/1629481/Signed-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      2a3098ff
    • R
      drm: exynos: fix for mapping of dma buffers · 4ddc404b
      Rahul Sharma 提交于
      This patch fixes the problem of mapping contigous and non contigous dma buffers.
      
      Currently page struct is calculated from the buf->dma_addr which is not the
      physical address. It is replaced by buf->pages which points to the page struct
      of the first page of contigous memory chunk. This gives the correct page frame
      number for mapping.
      
      Non-contigous dma buffers are described using SG table and SG lists. Each
      valid SG List is pointing to a single page or group of pages which are
      physically contigous. Current implementation just maps the first page of each
      SG List and leave the other pages unmapped, leading to a crash. Given solution
      finds the page struct for the faulting page through parsing SG table and map it.
      Signed-off-by: NRahul Sharma <rahul.sharma@samsung.com>
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      4ddc404b
    • I
      drm/exynos: remove EXYNOS_BO_NONCONTIG type checking. · ea6d66c3
      Inki Dae 提交于
      With iommu support, non-continuous buffer also is supported so
      this patch removes these checking from exynos_drm_gem_get/put_dma_addr
      funciton.
      
      This patch is based on the below patch set, "drm/exynos: add
      iommu support for -next".
      	http://www.spinics.net/lists/dri-devel/msg29041.htmlSigned-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      ea6d66c3
    • I
      drm/exynos: add iommu support for g2d · d87342c1
      Inki Dae 提交于
      Chagelog v2:
      removed unnecessary structure, struct g2d_gem_node.
      
      Chagelog v1:
      This patch adds iommu support for g2d driver. For this, it
      adds subdrv_probe/remove callback to enable or disable
      g2d iommu. And with this patch, in case of using g2d iommu,
      we can get or put device address to a gem handle from user
      through exynos_drm_gem_get/put_dma_addr(). Actually, these
      functions take a reference to a gem handle so that the gem
      object used by g2d dma is released properly.
      
      And runqueue_node has a pointer to drm_file object of current
      process to manage gem handles to owner.
      
      This patch is based on the below patch set, "drm/exynos: add
      iommu support for -next".
           http://www.spinics.net/lists/dri-devel/msg29041.htmlSigned-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      d87342c1
  14. 29 11月, 2012 1 次提交
    • I
      drm/exynos: add iommu support for exynos drm framework · 0519f9a1
      Inki Dae 提交于
      Changelog v4:
      - fix condition to drm_iommu_detach_device funtion.
      
      Changelog v3:
      - add dma_parms->max_segment_size setting of drm_device->dev.
      - use devm_kzalloc instead of kzalloc.
      
      Changelog v2:
      - fix iommu attach condition.
        . check archdata.dma_ops of drm device instead of
          subdrv device's one.
      - code clean to exynos_drm_iommu.c file.
        . remove '#ifdef CONFIG_ARM_DMA_USE_IOMMU' from exynos_drm_iommu.c
          and add it to driver/gpu/drm/exynos/Kconfig.
      
      Changelog v1:
      This patch adds iommu support for exynos drm framework with dma mapping
      api. In this patch, we used dma mapping api to allocate physical memory
      and maps it with iommu table and removed some existing codes and added
      new some codes for iommu support.
      
      GEM allocation requires one device object to use dma mapping api so
      this patch uses one iommu mapping for all sub drivers. In other words,
      all sub drivers have same iommu mapping.
      Signed-off-by: NInki Dae <inki.dae@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      0519f9a1
  15. 09 10月, 2012 1 次提交
    • K
      mm: kill vma flag VM_RESERVED and mm->reserved_vm counter · 314e51b9
      Konstantin Khlebnikov 提交于
      A long time ago, in v2.4, VM_RESERVED kept swapout process off VMA,
      currently it lost original meaning but still has some effects:
      
       | effect                 | alternative flags
      -+------------------------+---------------------------------------------
      1| account as reserved_vm | VM_IO
      2| skip in core dump      | VM_IO, VM_DONTDUMP
      3| do not merge or expand | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP
      4| do not mlock           | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP
      
      This patch removes reserved_vm counter from mm_struct.  Seems like nobody
      cares about it, it does not exported into userspace directly, it only
      reduces total_vm showed in proc.
      
      Thus VM_RESERVED can be replaced with VM_IO or pair VM_DONTEXPAND | VM_DONTDUMP.
      
      remap_pfn_range() and io_remap_pfn_range() set VM_IO|VM_DONTEXPAND|VM_DONTDUMP.
      remap_vmalloc_range() set VM_DONTEXPAND | VM_DONTDUMP.
      
      [akpm@linux-foundation.org: drivers/vfio/pci/vfio_pci.c fixup]
      Signed-off-by: NKonstantin Khlebnikov <khlebnikov@openvz.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Carsten Otte <cotte@de.ibm.com>
      Cc: Chris Metcalf <cmetcalf@tilera.com>
      Cc: Cyrill Gorcunov <gorcunov@openvz.org>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Morris <james.l.morris@oracle.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Kentaro Takeda <takedakn@nttdata.co.jp>
      Cc: Matt Helsley <matthltc@us.ibm.com>
      Cc: Nick Piggin <npiggin@kernel.dk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Robert Richter <robert.richter@amd.com>
      Cc: Suresh Siddha <suresh.b.siddha@intel.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Venkatesh Pallipadi <venki@google.com>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      314e51b9
  16. 03 10月, 2012 2 次提交
  17. 13 9月, 2012 2 次提交
  18. 27 7月, 2012 5 次提交
  19. 05 6月, 2012 1 次提交
  20. 08 5月, 2012 3 次提交
  21. 23 4月, 2012 3 次提交
  22. 21 4月, 2012 1 次提交
    • L
      VM: add "vm_mmap()" helper function · 6be5ceb0
      Linus Torvalds 提交于
      This continues the theme started with vm_brk() and vm_munmap():
      vm_mmap() does the same thing as do_mmap(), but additionally does the
      required VM locking.
      
      This uninlines (and rewrites it to be clearer) do_mmap(), which sadly
      duplicates it in mm/mmap.c and mm/nommu.c.  But that way we don't have
      to export our internal do_mmap_pgoff() function.
      
      Some day we hopefully don't have to export do_mmap() either, if all
      modular users can become the simpler vm_mmap() instead.  We're actually
      very close to that already, with the notable exception of the (broken)
      use in i810, and a couple of stragglers in binfmt_elf.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6be5ceb0
  23. 03 4月, 2012 1 次提交
  24. 20 3月, 2012 1 次提交