From 933fd803f0aadc934f448937dbeb305256fe8893 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Fri, 10 Oct 2008 23:14:57 +0200 Subject: [PATCH] Some fixes that bring me closer to surviving to the 2nd X server generation. - Not quite done, i get a fifo dump when something tries to render. - Something is keeping an fd, which is preventing a full takedown, but this is not a valid reason for failing (kernel modesetting for example will never have full takedown). --- src/nouveau_channel.c | 2 +- src/nouveau_device.c | 2 +- src/nv_dri.c | 24 ++++++++++++++++++++---- src/nv_driver.c | 10 +++++++--- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/nouveau_channel.c b/src/nouveau_channel.c index 741e9ae..4ccb80d 100644 --- a/src/nouveau_channel.c +++ b/src/nouveau_channel.c @@ -109,7 +109,6 @@ nouveau_channel_free(struct nouveau_channel **userchan) struct drm_nouveau_channel_free cf; nv = nouveau_device((*userchan)->device); - *userchan = NULL; FIRE_RING_CH(*userchan); @@ -123,6 +122,7 @@ nouveau_channel_free(struct nouveau_channel **userchan) drmCommandWrite(nv->fd, DRM_NOUVEAU_CHANNEL_FREE, &cf, sizeof(cf)); free(chan); + *userchan = NULL; } } diff --git a/src/nouveau_device.c b/src/nouveau_device.c index 159fd72..f6a1779 100644 --- a/src/nouveau_device.c +++ b/src/nouveau_device.c @@ -82,7 +82,7 @@ nouveau_device_close(struct nouveau_device **userdev) { struct nouveau_device_priv *nv; - if (userdev || !*userdev) + if (!userdev || !*userdev) return; nv = (struct nouveau_device_priv *)*userdev; *userdev = NULL; diff --git a/src/nv_dri.c b/src/nv_dri.c index 6418557..a65a6b7 100644 --- a/src/nv_dri.c +++ b/src/nv_dri.c @@ -248,7 +248,9 @@ Bool NVDRIGetVersion(ScrnInfoPtr pScrn) #ifdef XF86DRM_MODE if (!pNv->drmmode) /* drmmode still needs the file descriptor */ #endif + { drmClose(fd); + } if (pNv->pKernelDRMVersion == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -306,7 +308,7 @@ Bool NVDRIScreenInit(ScrnInfoPtr pScrn) drm_page_size = getpagesize(); if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; - + pNv->pDRIInfo = pDRIInfo; pDRIInfo->drmDriverName = "nouveau"; pDRIInfo->clientDriverName = "nouveau"; @@ -374,8 +376,8 @@ Bool NVDRIScreenInit(ScrnInfoPtr pScrn) return FALSE; } - /* turn on need_close, so we explictly drmClose() on exit */ - if (nouveau_device_open_existing(&pNv->dev, 1, drm_fd, 0)) { + /* need_close = 0, because DRICloseScreen() will handle the closing. */ + if (nouveau_device_open_existing(&pNv->dev, 0, drm_fd, 0)) { xf86DrvMsg(pScreen->myNum, X_ERROR, "Error creating device\n"); xfree(pDRIInfo->devPrivate); pDRIInfo->devPrivate = NULL; @@ -425,7 +427,21 @@ void NVDRICloseScreen(ScrnInfoPtr pScrn) ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; NVPtr pNv = NVPTR(pScrn); - DRICloseScreen(pScreen); + /* close fifo channel so it won't fail on open for next server generation. */ + nouveau_channel_free(&pNv->chan); + + /* this may not work for kernel modesetting, so i'm leaving a note. */ nouveau_device_close(&pNv->dev); + + DRICloseScreen(pScreen); + + if (pNv->pDRIInfo) { + if (pNv->pDRIInfo->devPrivate) { + xfree(pNv->pDRIInfo->devPrivate); + pNv->pDRIInfo->devPrivate = NULL; + } + DRIDestroyInfoRec(pNv->pDRIInfo); + pNv->pDRIInfo = NULL; + } } diff --git a/src/nv_driver.c b/src/nv_driver.c index c8f7052..4defe47 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -830,9 +830,6 @@ NVCloseScreen(int scrnIndex, ScreenPtr pScreen) } } - if (pNv->pInt10) - xf86FreeInt10(pNv->pInt10); - NVUnmapMem(pScrn); vgaHWUnmapMem(pScrn); NVDRICloseScreen(pScrn); @@ -880,6 +877,13 @@ NVFreeScreen(int scrnIndex, int flags) * This only gets called when a screen is being deleted. It does not * get called routinely at the end of a server generation. */ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NVPtr pNv = NVPTR(pScrn); + + /* Free this here and not in CloseScreen, as it's needed after the first server generation. */ + if (pNv->pInt10) + xf86FreeInt10(pNv->pInt10); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) vgaHWFreeHWRec(xf86Screens[scrnIndex]); NVFreeRec(xf86Screens[scrnIndex]); -- 2.32.0.93.g670b81a890