From 12fce00b2ecf4c6be6cc86c8a7374878bb7dfc20 Mon Sep 17 00:00:00 2001 From: Stuart Bennett Date: Wed, 22 Oct 2008 02:47:45 +0100 Subject: [PATCH] Remove all object with mmaps in CloseScreen, so that drmClose actually calls the drm release method (and so subsequently, we can be DRM master on the next drmOpen) --- src/nouveau_xv.c | 2 +- src/nv30_xv_tex.c | 11 +++++------ src/nv40_xv_tex.c | 11 +++++------ src/nv_accel_common.c | 7 +++++++ src/nv_driver.c | 11 +++++++++++ src/nv_proto.h | 4 +++- src/nv_type.h | 1 + 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/nouveau_xv.c b/src/nouveau_xv.c index 506c3f4..96a7f8e 100644 --- a/src/nouveau_xv.c +++ b/src/nouveau_xv.c @@ -359,7 +359,7 @@ nouveau_xv_bo_realloc(ScrnInfoPtr pScrn, unsigned flags, unsigned size, * @param pScrn screen whose port wants to free memory * @param pPriv port to free memory of */ -static void +void NVFreePortMemory(ScrnInfoPtr pScrn, NVPortPrivPtr pPriv) { if(pPriv->video_mem) { diff --git a/src/nv30_xv_tex.c b/src/nv30_xv_tex.c index 4af12f6..501cad0 100644 --- a/src/nv30_xv_tex.c +++ b/src/nv30_xv_tex.c @@ -86,27 +86,26 @@ static void compute_filter_table(int8_t *t) { } } -static struct nouveau_bo *table_mem = NULL; static void NV30_LoadFilterTable(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - if (!table_mem) { + if (!pNv->xv_filtertable_mem) { if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART, - 0, TABLE_SIZE*sizeof(float)*4, &table_mem)) { + 0, TABLE_SIZE*sizeof(float)*4, &pNv->xv_filtertable_mem)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't alloc filter table!\n"); return; } - if (nouveau_bo_map(table_mem, NOUVEAU_BO_RDWR)) { + if (nouveau_bo_map(pNv->xv_filtertable_mem, NOUVEAU_BO_RDWR)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't map filter table!\n"); return; } - int8_t *t=table_mem->map; + int8_t *t=pNv->xv_filtertable_mem->map; compute_filter_table(t); } } @@ -312,7 +311,7 @@ NV30PutTextureImage(ScrnInfoPtr pScrn, struct nouveau_bo *src, int src_offset, OUT_RING (chan, NV34TCL_TX_UNITS_ENABLE_TX0 | NV34TCL_TX_UNITS_ENABLE_TX1); - NV30VideoTexture(pScrn, table_mem, 0, TABLE_SIZE, 1, 0 , 0); + NV30VideoTexture(pScrn, pNv->xv_filtertable_mem, 0, TABLE_SIZE, 1, 0 , 0); NV30VideoTexture(pScrn, src, src_offset, src_w, src_h, src_pitch, 1); /* We've got NV12 format, which means half width and half height texture of chroma channels. */ NV30VideoTexture(pScrn, src, src_offset2, src_w/2, src_h/2, src_pitch, 2); diff --git a/src/nv40_xv_tex.c b/src/nv40_xv_tex.c index c78e614..6c6250f 100644 --- a/src/nv40_xv_tex.c +++ b/src/nv40_xv_tex.c @@ -88,27 +88,26 @@ static void compute_filter_table(int8_t *t) { } } -static struct nouveau_bo *table_mem = NULL; static void NV40_LoadFilterTable(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - if (!table_mem) { + if (!pNv->xv_filtertable_mem) { if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART, - 0, TABLE_SIZE*sizeof(float)*4, &table_mem)) { + 0, TABLE_SIZE*sizeof(float)*4, &pNv->xv_filtertable_mem)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't alloc filter table!\n"); return; } - if (nouveau_bo_map(table_mem, NOUVEAU_BO_RDWR)) { + if (nouveau_bo_map(pNv->xv_filtertable_mem, NOUVEAU_BO_RDWR)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't map filter table!\n"); return; } - int8_t *t=table_mem->map; + int8_t *t=pNv->xv_filtertable_mem->map; compute_filter_table(t); } } @@ -290,7 +289,7 @@ NV40PutTextureImage(ScrnInfoPtr pScrn, NV40_LoadFilterTable(pScrn); - NV40VideoTexture(pScrn, table_mem, 0, TABLE_SIZE, 1, 0 , 0); + NV40VideoTexture(pScrn, pNv->xv_filtertable_mem, 0, TABLE_SIZE, 1, 0 , 0); NV40VideoTexture(pScrn, src, src_offset, src_w, src_h, src_pitch, 1); /* We've got NV12 format, which means half width and half height texture of chroma channels. */ NV40VideoTexture(pScrn, src, src_offset2, src_w/2, src_h/2, src_pitch, 2); diff --git a/src/nv_accel_common.c b/src/nv_accel_common.c index 4e82c4e..95c91e9 100644 --- a/src/nv_accel_common.c +++ b/src/nv_accel_common.c @@ -549,3 +549,10 @@ NVAccelCommonInit(ScrnInfoPtr pScrn) return TRUE; } +void NVAccelFree(NVPtr pNv) +{ + if (pNv->tesla_scratch) + nouveau_bo_del(&pNv->tesla_scratch); + if (pNv->shader_mem) + nouveau_bo_del(&pNv->shader_mem); +} diff --git a/src/nv_driver.c b/src/nv_driver.c index c4230ed..0831f2f 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -796,7 +796,10 @@ NVCloseScreen(int scrnIndex, ScreenPtr pScreen) } } + NVAccelFree(pNv); NVUnmapMem(pScrn); + nouveau_channel_free(&pNv->chan); + vgaHWUnmapMem(pScrn); NVDRICloseScreen(pScrn); xf86_cursors_fini(pScreen); @@ -1661,6 +1664,14 @@ NVUnmapMem(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); + nouveau_bo_del(&pNv->xv_filtertable_mem); + if (pNv->blitAdaptor) + NVFreePortMemory(pScrn, GET_BLIT_PRIVATE(pNv)); + if (pNv->textureAdaptor[0]) + NVFreePortMemory(pScrn, pNv->textureAdaptor[0]->pPortPrivates[0].ptr); + if (pNv->textureAdaptor[1]) + NVFreePortMemory(pScrn, pNv->textureAdaptor[1]->pPortPrivates[0].ptr); + nouveau_bo_del(&pNv->FB); nouveau_bo_del(&pNv->GART); nouveau_bo_del(&pNv->Cursor); diff --git a/src/nv_proto.h b/src/nv_proto.h index 34adb17..a03fd05 100644 --- a/src/nv_proto.h +++ b/src/nv_proto.h @@ -8,6 +8,7 @@ Bool NVAccelCommonInit(ScrnInfoPtr pScrn); Bool NVAccelGetCtxSurf2DFormatFromPixmap(PixmapPtr pPix, int *fmt_ret); Bool NVAccelGetCtxSurf2DFormatFromPicture(PicturePtr pPix, int *fmt_ret); PixmapPtr NVGetDrawablePixmap(DrawablePtr pDraw); +void NVAccelFree(NVPtr pNv); /* in nv_driver.c */ Bool NVI2CInit(ScrnInfoPtr pScrn); @@ -29,11 +30,12 @@ void NVDACLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual ); Bool NVDACi2cInit(ScrnInfoPtr pScrn); -/* in nv_video.c */ +/* in nouveau_xv.c */ void NVInitVideo(ScreenPtr); void NVWaitVSync(ScrnInfoPtr pScrn, int crtc); void NVSetPortDefaults (ScrnInfoPtr pScrn, NVPortPrivPtr pPriv); unsigned int nv_window_belongs_to_crtc(ScrnInfoPtr, int, int, int, int); +void NVFreePortMemory(ScrnInfoPtr pScrn, NVPortPrivPtr pPriv); /* in nv_setup.c */ void RivaEnterLeave(ScrnInfoPtr pScrn, Bool enter); diff --git a/src/nv_type.h b/src/nv_type.h index b3e6e41..88377b1 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -518,6 +518,7 @@ typedef struct _NVRec { struct nouveau_grobj *Nv3D; struct nouveau_bo *tesla_scratch; struct nouveau_bo *shader_mem; + struct nouveau_bo *xv_filtertable_mem; } NVRec; #define NVPTR(p) ((NVPtr)((p)->driverPrivate)) -- 2.32.0.93.g670b81a890