1. 04 Dec, 2012 6 commits
    • Inki Dae's avatar
      drm/exynos: add userptr feature for g2d module · 2a3098ff
      Inki Dae authored
      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: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      2a3098ff
    • Prathyush K's avatar
      drm/exynos: remove unnecessary sg_alloc_table call · 1119707e
      Prathyush K authored
      The function dma_get_sgtable will allocate a sg table internally so
      it is not necessary to allocate a sg table before it. The unnecessary
      'sg_alloc_table' call is removed.
      Signed-off-by: default avatarPrathyush K <prathyush.k@samsung.com>
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      1119707e
    • Rahul Sharma's avatar
      drm: exynos: fix for mapping of dma buffers · 4ddc404b
      Rahul Sharma authored
      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: default avatarRahul Sharma <rahul.sharma@samsung.com>
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      4ddc404b
    • Inki Dae's avatar
      drm/exynos: remove EXYNOS_BO_NONCONTIG type checking. · ea6d66c3
      Inki Dae authored
      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: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      ea6d66c3
    • Inki Dae's avatar
      drm/exynos: add iommu support for g2d · d87342c1
      Inki Dae authored
      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: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      d87342c1
    • Inki Dae's avatar
      drm/exynos: add iommu support for hdmi driver · 1055b39f
      Inki Dae authored
      Changelog v2:
      move iommu support feature to mixer side.
      And below is Prathyush's comment.
      
      According to the new IOMMU framework for exynos sysmmus,
      the owner of the sysmmu-tv is mixer (which is the actual
      device that does DMA) and not hdmi.
      The mmu-master in sysmmu-tv node is set as below in exynos5250.dtsi
      	sysmmu-tv {
      		-
      		mmu-master = <&mixer>;
      	};
      
      Changelog v1:
      The iommu will be enabled when hdmi sub driver is probed and
      will be disabled when removed.
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      1055b39f
  2. 29 Nov, 2012 17 commits
  3. 28 Nov, 2012 17 commits