Commit 04c8c210 authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Ben Skeggs

drm/nouveau: unpin various bo's before destroying

These objects leak VRAM - but only on module unload.
Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 124ea297
...@@ -730,6 +730,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc) ...@@ -730,6 +730,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc); drm_crtc_cleanup(crtc);
nouveau_bo_unmap(nv_crtc->cursor.nvbo); nouveau_bo_unmap(nv_crtc->cursor.nvbo);
nouveau_bo_unpin(nv_crtc->cursor.nvbo);
nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
kfree(nv_crtc); kfree(nv_crtc);
} }
...@@ -1056,8 +1057,11 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num) ...@@ -1056,8 +1057,11 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
0, 0x0000, NULL, &nv_crtc->cursor.nvbo); 0, 0x0000, NULL, &nv_crtc->cursor.nvbo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(nv_crtc->cursor.nvbo); ret = nouveau_bo_map(nv_crtc->cursor.nvbo);
if (ret)
nouveau_bo_unpin(nv_crtc->cursor.nvbo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
} }
......
...@@ -155,6 +155,8 @@ nv10_fence_destroy(struct nouveau_drm *drm) ...@@ -155,6 +155,8 @@ nv10_fence_destroy(struct nouveau_drm *drm)
{ {
struct nv10_fence_priv *priv = drm->fence; struct nv10_fence_priv *priv = drm->fence;
nouveau_bo_unmap(priv->bo); nouveau_bo_unmap(priv->bo);
if (priv->bo)
nouveau_bo_unpin(priv->bo);
nouveau_bo_ref(NULL, &priv->bo); nouveau_bo_ref(NULL, &priv->bo);
drm->fence = NULL; drm->fence = NULL;
kfree(priv); kfree(priv);
...@@ -183,8 +185,11 @@ nv10_fence_create(struct nouveau_drm *drm) ...@@ -183,8 +185,11 @@ nv10_fence_create(struct nouveau_drm *drm)
0, 0x0000, NULL, &priv->bo); 0, 0x0000, NULL, &priv->bo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(priv->bo); ret = nouveau_bo_map(priv->bo);
if (ret)
nouveau_bo_unpin(priv->bo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &priv->bo); nouveau_bo_ref(NULL, &priv->bo);
} }
......
...@@ -1228,8 +1228,12 @@ nv50_crtc_destroy(struct drm_crtc *crtc) ...@@ -1228,8 +1228,12 @@ nv50_crtc_destroy(struct drm_crtc *crtc)
nv50_dmac_destroy(disp->core, &head->sync.base); nv50_dmac_destroy(disp->core, &head->sync.base);
nv50_pioc_destroy(disp->core, &head->curs.base); nv50_pioc_destroy(disp->core, &head->curs.base);
nouveau_bo_unmap(nv_crtc->cursor.nvbo); nouveau_bo_unmap(nv_crtc->cursor.nvbo);
if (nv_crtc->cursor.nvbo)
nouveau_bo_unpin(nv_crtc->cursor.nvbo);
nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
nouveau_bo_unmap(nv_crtc->lut.nvbo); nouveau_bo_unmap(nv_crtc->lut.nvbo);
if (nv_crtc->lut.nvbo)
nouveau_bo_unpin(nv_crtc->lut.nvbo);
nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
drm_crtc_cleanup(crtc); drm_crtc_cleanup(crtc);
kfree(crtc); kfree(crtc);
...@@ -1300,8 +1304,11 @@ nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index) ...@@ -1300,8 +1304,11 @@ nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index)
0, 0x0000, NULL, &head->base.lut.nvbo); 0, 0x0000, NULL, &head->base.lut.nvbo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(head->base.lut.nvbo); ret = nouveau_bo_map(head->base.lut.nvbo);
if (ret)
nouveau_bo_unpin(head->base.lut.nvbo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &head->base.lut.nvbo); nouveau_bo_ref(NULL, &head->base.lut.nvbo);
} }
...@@ -1324,8 +1331,11 @@ nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index) ...@@ -1324,8 +1331,11 @@ nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index)
0, 0x0000, NULL, &head->base.cursor.nvbo); 0, 0x0000, NULL, &head->base.cursor.nvbo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(head->base.cursor.nvbo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(head->base.cursor.nvbo, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(head->base.cursor.nvbo); ret = nouveau_bo_map(head->base.cursor.nvbo);
if (ret)
nouveau_bo_unpin(head->base.lut.nvbo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &head->base.cursor.nvbo); nouveau_bo_ref(NULL, &head->base.cursor.nvbo);
} }
...@@ -1917,6 +1927,8 @@ nv50_display_destroy(struct drm_device *dev) ...@@ -1917,6 +1927,8 @@ nv50_display_destroy(struct drm_device *dev)
nv50_dmac_destroy(disp->core, &disp->mast.base); nv50_dmac_destroy(disp->core, &disp->mast.base);
nouveau_bo_unmap(disp->sync); nouveau_bo_unmap(disp->sync);
if (disp->sync)
nouveau_bo_unpin(disp->sync);
nouveau_bo_ref(NULL, &disp->sync); nouveau_bo_ref(NULL, &disp->sync);
nouveau_display(dev)->priv = NULL; nouveau_display(dev)->priv = NULL;
...@@ -1957,8 +1969,11 @@ nv50_display_create(struct drm_device *dev) ...@@ -1957,8 +1969,11 @@ nv50_display_create(struct drm_device *dev)
0, 0x0000, NULL, &disp->sync); 0, 0x0000, NULL, &disp->sync);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(disp->sync); ret = nouveau_bo_map(disp->sync);
if (ret)
nouveau_bo_unpin(disp->sync);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &disp->sync); nouveau_bo_ref(NULL, &disp->sync);
} }
......
...@@ -110,8 +110,11 @@ nv50_fence_create(struct nouveau_drm *drm) ...@@ -110,8 +110,11 @@ nv50_fence_create(struct nouveau_drm *drm)
0, 0x0000, NULL, &priv->bo); 0, 0x0000, NULL, &priv->bo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM);
if (!ret) if (!ret) {
ret = nouveau_bo_map(priv->bo); ret = nouveau_bo_map(priv->bo);
if (ret)
nouveau_bo_unpin(priv->bo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &priv->bo); nouveau_bo_ref(NULL, &priv->bo);
} }
......
...@@ -190,6 +190,8 @@ nvc0_fence_destroy(struct nouveau_drm *drm) ...@@ -190,6 +190,8 @@ nvc0_fence_destroy(struct nouveau_drm *drm)
{ {
struct nvc0_fence_priv *priv = drm->fence; struct nvc0_fence_priv *priv = drm->fence;
nouveau_bo_unmap(priv->bo); nouveau_bo_unmap(priv->bo);
if (priv->bo)
nouveau_bo_unpin(priv->bo);
nouveau_bo_ref(NULL, &priv->bo); nouveau_bo_ref(NULL, &priv->bo);
drm->fence = NULL; drm->fence = NULL;
kfree(priv); kfree(priv);
...@@ -219,8 +221,11 @@ nvc0_fence_create(struct nouveau_drm *drm) ...@@ -219,8 +221,11 @@ nvc0_fence_create(struct nouveau_drm *drm)
TTM_PL_FLAG_VRAM, 0, 0, NULL, &priv->bo); TTM_PL_FLAG_VRAM, 0, 0, NULL, &priv->bo);
if (ret == 0) { if (ret == 0) {
ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM);
if (ret == 0) if (ret == 0) {
ret = nouveau_bo_map(priv->bo); ret = nouveau_bo_map(priv->bo);
if (ret)
nouveau_bo_unpin(priv->bo);
}
if (ret) if (ret)
nouveau_bo_ref(NULL, &priv->bo); nouveau_bo_ref(NULL, &priv->bo);
} }
......
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