Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309702
b: refs/heads/master
c: 35916ac
h: refs/heads/master
v: v3
  • Loading branch information
Dave Airlie committed May 31, 2012
1 parent 50bb216 commit e589179
Show file tree
Hide file tree
Showing 3 changed files with 43 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: e8aa1d1ebcbcf98fbb20cad83098f25c7d52753f
refs/heads/master: 35916acedd8dadb361ef6439d05d60fbe8f53032
3 changes: 3 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ struct nouveau_bo {

struct drm_gem_object *gem;
int pin_refcnt;

struct ttm_bo_kmap_obj dma_buf_vmap;
int vmapping_count;
};

#define nouveau_bo_tile_layout(nvbo) \
Expand Down
39 changes: 39 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,43 @@ static int nouveau_gem_prime_mmap(struct dma_buf *dma_buf, struct vm_area_struct
return -EINVAL;
}

static void *nouveau_gem_prime_vmap(struct dma_buf *dma_buf)
{
struct nouveau_bo *nvbo = dma_buf->priv;
struct drm_device *dev = nvbo->gem->dev;
int ret;

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

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

static void nouveau_gem_prime_vunmap(struct dma_buf *dma_buf, void *vaddr)
{
struct nouveau_bo *nvbo = dma_buf->priv;
struct drm_device *dev = nvbo->gem->dev;

mutex_lock(&dev->struct_mutex);
nvbo->vmapping_count--;
if (nvbo->vmapping_count == 0) {
ttm_bo_kunmap(&nvbo->dma_buf_vmap);
}
mutex_unlock(&dev->struct_mutex);
}

static const struct dma_buf_ops nouveau_dmabuf_ops = {
.map_dma_buf = nouveau_gem_map_dma_buf,
.unmap_dma_buf = nouveau_gem_unmap_dma_buf,
Expand All @@ -75,6 +112,8 @@ static const struct dma_buf_ops nouveau_dmabuf_ops = {
.kunmap = nouveau_gem_kunmap,
.kunmap_atomic = nouveau_gem_kunmap_atomic,
.mmap = nouveau_gem_prime_mmap,
.vmap = nouveau_gem_prime_vmap,
.vunmap = nouveau_gem_prime_vunmap,
};

static int
Expand Down

0 comments on commit e589179

Please sign in to comment.