Commit 6797cea1 authored by Christian König's avatar Christian König

drm/nouveau: switch over to the new pin interface

Stop using TTM_PL_FLAG_NO_EVICT.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Link: https://patchwork.freedesktop.org/patch/391606/?series=81973&rev=1
parent fbe86ca5
...@@ -139,7 +139,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo) ...@@ -139,7 +139,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
struct drm_device *dev = drm->dev; struct drm_device *dev = drm->dev;
struct nouveau_bo *nvbo = nouveau_bo(bo); struct nouveau_bo *nvbo = nouveau_bo(bo);
WARN_ON(nvbo->pin_refcnt > 0); WARN_ON(nvbo->bo.pin_count > 0);
nouveau_bo_del_io_reserve_lru(bo); nouveau_bo_del_io_reserve_lru(bo);
nv10_bo_put_tile_region(dev, nvbo->tile, NULL); nv10_bo_put_tile_region(dev, nvbo->tile, NULL);
...@@ -417,9 +417,8 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain, ...@@ -417,9 +417,8 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain,
{ {
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
struct ttm_placement *pl = &nvbo->placement; struct ttm_placement *pl = &nvbo->placement;
uint32_t flags = (nvbo->force_coherent ? TTM_PL_FLAG_UNCACHED : uint32_t flags = nvbo->force_coherent ? TTM_PL_FLAG_UNCACHED :
TTM_PL_MASK_CACHING) | TTM_PL_MASK_CACHING;
(nvbo->pin_refcnt ? TTM_PL_FLAG_NO_EVICT : 0);
pl->placement = nvbo->placements; pl->placement = nvbo->placements;
set_placement_list(drm, nvbo->placements, &pl->num_placement, set_placement_list(drm, nvbo->placements, &pl->num_placement,
...@@ -453,7 +452,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig) ...@@ -453,7 +452,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig)
} }
} }
if (nvbo->pin_refcnt) { if (nvbo->bo.pin_count) {
bool error = evict; bool error = evict;
switch (bo->mem.mem_type) { switch (bo->mem.mem_type) {
...@@ -472,7 +471,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig) ...@@ -472,7 +471,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig)
bo->mem.mem_type, domain); bo->mem.mem_type, domain);
ret = -EBUSY; ret = -EBUSY;
} }
nvbo->pin_refcnt++; ttm_bo_pin(&nvbo->bo);
goto out; goto out;
} }
...@@ -483,18 +482,12 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig) ...@@ -483,18 +482,12 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t domain, bool contig)
goto out; goto out;
} }
nvbo->pin_refcnt++;
nouveau_bo_placement_set(nvbo, domain, 0); nouveau_bo_placement_set(nvbo, domain, 0);
/* drop pin_refcnt temporarily, so we don't trip the assertion
* in nouveau_bo_move() that makes sure we're not trying to
* move a pinned buffer
*/
nvbo->pin_refcnt--;
ret = nouveau_bo_validate(nvbo, false, false); ret = nouveau_bo_validate(nvbo, false, false);
if (ret) if (ret)
goto out; goto out;
nvbo->pin_refcnt++;
ttm_bo_pin(&nvbo->bo);
switch (bo->mem.mem_type) { switch (bo->mem.mem_type) {
case TTM_PL_VRAM: case TTM_PL_VRAM:
...@@ -519,30 +512,14 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo) ...@@ -519,30 +512,14 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
{ {
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
struct ttm_buffer_object *bo = &nvbo->bo; struct ttm_buffer_object *bo = &nvbo->bo;
int ret, ref; int ret;
ret = ttm_bo_reserve(bo, false, false, NULL); ret = ttm_bo_reserve(bo, false, false, NULL);
if (ret) if (ret)
return ret; return ret;
ref = --nvbo->pin_refcnt; ttm_bo_unpin(&nvbo->bo);
WARN_ON_ONCE(ref < 0); if (!nvbo->bo.pin_count) {
if (ref)
goto out;
switch (bo->mem.mem_type) {
case TTM_PL_VRAM:
nouveau_bo_placement_set(nvbo, NOUVEAU_GEM_DOMAIN_VRAM, 0);
break;
case TTM_PL_TT:
nouveau_bo_placement_set(nvbo, NOUVEAU_GEM_DOMAIN_GART, 0);
break;
default:
break;
}
ret = nouveau_bo_validate(nvbo, false, false);
if (ret == 0) {
switch (bo->mem.mem_type) { switch (bo->mem.mem_type) {
case TTM_PL_VRAM: case TTM_PL_VRAM:
drm->gem.vram_available += bo->mem.size; drm->gem.vram_available += bo->mem.size;
...@@ -555,9 +532,8 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo) ...@@ -555,9 +532,8 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
} }
} }
out:
ttm_bo_unreserve(bo); ttm_bo_unreserve(bo);
return ret; return 0;
} }
int int
...@@ -1066,7 +1042,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, ...@@ -1066,7 +1042,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
if (ret) if (ret)
return ret; return ret;
if (nvbo->pin_refcnt) if (nvbo->bo.pin_count)
NV_WARN(drm, "Moving pinned object %p!\n", nvbo); NV_WARN(drm, "Moving pinned object %p!\n", nvbo);
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
......
...@@ -40,9 +40,6 @@ struct nouveau_bo { ...@@ -40,9 +40,6 @@ struct nouveau_bo {
struct nouveau_drm_tile *tile; struct nouveau_drm_tile *tile;
/* protect by the ttm reservation lock */
int pin_refcnt;
struct ttm_bo_kmap_obj dma_buf_vmap; struct ttm_bo_kmap_obj dma_buf_vmap;
}; };
......
...@@ -107,7 +107,7 @@ nouveau_channel_del(struct nouveau_channel **pchan) ...@@ -107,7 +107,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
nvif_object_dtor(&chan->push.ctxdma); nvif_object_dtor(&chan->push.ctxdma);
nouveau_vma_del(&chan->push.vma); nouveau_vma_del(&chan->push.vma);
nouveau_bo_unmap(chan->push.buffer); nouveau_bo_unmap(chan->push.buffer);
if (chan->push.buffer && chan->push.buffer->pin_refcnt) if (chan->push.buffer && chan->push.buffer->bo.pin_count)
nouveau_bo_unpin(chan->push.buffer); nouveau_bo_unpin(chan->push.buffer);
nouveau_bo_ref(NULL, &chan->push.buffer); nouveau_bo_ref(NULL, &chan->push.buffer);
kfree(chan); kfree(chan);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment