Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309703
b: refs/heads/master
c: 63bc620
h: refs/heads/master
i:
  309701: 50bb216
  309699: bb91dff
  309695: 9291771
v: v3
  • Loading branch information
Dave Airlie committed May 31, 2012
1 parent e589179 commit c2a8177
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35916acedd8dadb361ef6439d05d60fbe8f53032
refs/heads/master: 63bc620b45af8c743ac291c8725933278c712692
3 changes: 3 additions & 0 deletions trunk/drivers/gpu/drm/radeon/radeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ struct radeon_bo {
/* Constant after initialization */
struct radeon_device *rdev;
struct drm_gem_object gem_base;

struct ttm_bo_kmap_obj dma_buf_vmap;
int vmapping_count;
};
#define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)

Expand Down
38 changes: 38 additions & 0 deletions trunk/drivers/gpu/drm/radeon/radeon_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ static int radeon_gem_prime_mmap(struct dma_buf *dma_buf, struct vm_area_struct
return -EINVAL;
}

static void *radeon_gem_prime_vmap(struct dma_buf *dma_buf)
{
struct radeon_bo *bo = dma_buf->priv;
struct drm_device *dev = bo->rdev->ddev;
int ret;

mutex_lock(&dev->struct_mutex);
if (bo->vmapping_count) {
bo->vmapping_count++;
goto out_unlock;
}

ret = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages,
&bo->dma_buf_vmap);
if (ret) {
mutex_unlock(&dev->struct_mutex);
return ERR_PTR(ret);
}
bo->vmapping_count = 1;
out_unlock:
mutex_unlock(&dev->struct_mutex);
return bo->dma_buf_vmap.virtual;
}

static void radeon_gem_prime_vunmap(struct dma_buf *dma_buf, void *vaddr)
{
struct radeon_bo *bo = dma_buf->priv;
struct drm_device *dev = bo->rdev->ddev;

mutex_lock(&dev->struct_mutex);
bo->vmapping_count--;
if (bo->vmapping_count == 0) {
ttm_bo_kunmap(&bo->dma_buf_vmap);
}
mutex_unlock(&dev->struct_mutex);
}
const static struct dma_buf_ops radeon_dmabuf_ops = {
.map_dma_buf = radeon_gem_map_dma_buf,
.unmap_dma_buf = radeon_gem_unmap_dma_buf,
Expand All @@ -99,6 +135,8 @@ const static struct dma_buf_ops radeon_dmabuf_ops = {
.kunmap = radeon_gem_kunmap,
.kunmap_atomic = radeon_gem_kunmap_atomic,
.mmap = radeon_gem_prime_mmap,
.vmap = radeon_gem_prime_vmap,
.vunmap = radeon_gem_prime_vunmap,
};

static int radeon_prime_create(struct drm_device *dev,
Expand Down

0 comments on commit c2a8177

Please sign in to comment.