diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-10-27 19:13:33 +0200 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-10-27 19:13:33 +0200 |
commit | c0ee50c4ee5ff2c594fdf60c9cb8b952e25644de (patch) | |
tree | b3945862c5fb5cd4a6968fad5767aef9cd46f4c5 | |
parent | 7d67324fa3a5b5cf0227550316c366752fe4abfb (diff) |
Add support for the new DRM memory manager.
Some code are duplicated with the new libdrm.
Once this code has been released with xserver,
it can be removed.
See the man page for new options and backwards
3D driver compatibility.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | man/i810.man | 24 | ||||
-rw-r--r-- | src/i810_driver.c | 6 | ||||
-rw-r--r-- | src/i830.h | 15 | ||||
-rw-r--r-- | src/i830_dri.c | 52 | ||||
-rw-r--r-- | src/i830_driver.c | 247 | ||||
-rw-r--r-- | src/i830_memory.c | 76 | ||||
-rw-r--r-- | src/i830_rotate.c | 43 |
8 files changed, 396 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac index c91b1df7..fc0f9cd8 100644 --- a/configure.ac +++ b/configure.ac @@ -122,7 +122,7 @@ CFLAGS="$CFLAGS $WARN_CFLAGS" AM_CONDITIONAL(DRI, test x$DRI = xyes) if test "$DRI" = yes; then - PKG_CHECK_MODULES(DRI, [libdrm >= 2.0 xf86driproto]) + PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto]) AC_DEFINE(XF86DRI,1,[Enable DRI driver support]) AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support]) fi diff --git a/man/i810.man b/man/i810.man index 50c2668b..a3f25ec6 100644 --- a/man/i810.man +++ b/man/i810.man @@ -203,6 +203,30 @@ Allows more memory for the offscreen allocator. This usually helps in situations where HDTV movies are required to play but not enough offscreen memory is usually available. Set this to 8160 for upto 1920x1080 HDTV support. Default 0KB (off). +.TP +.BI "Option \*qLegacy3D\*q \*q" boolean \*q +Enable support for the legacy i915_dri.so 3D driver. +This will, among other things, make the 2D driver tell libGL to +load the 3D driver i915_dri.so instead of the newer i915tex_dri.so. +This option is only used for chipsets in the range i830-i945. +Default for i830-i945 series: Enabled for i915 drm versions < 1.7.0. Otherwise +disabled. +Default for i810: The option is not used. +Default for i965: The option is always true. +.TP +.BI "Option \*qAperTexSize\*q \*q" integer \*q +Give the size in kiB of the AGP aperture area that is reserved for the +DRM memory manager present in i915 drm from version 1.7.0 and upwards, +and that is used with the 3D driver in Mesa from version 6.5.2 and +upwards. If the size is set too high to make room for pre-allocated +VideoRam, the driver will try to reduce it automatically. If you use only +older Mesa or DRM versions, you may set this value to zero, and +atctivate the legacy texture pool (see +.B "Option \*qLegacy3D\*q" +). If you run 3D programs with large texture memory requirements, you might +gain some performance by increasing this value. +Default: 32768. + .SH "SEE ALSO" __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) diff --git a/src/i810_driver.c b/src/i810_driver.c index cd6d9d7d..5143fd40 100644 --- a/src/i810_driver.c +++ b/src/i810_driver.c @@ -313,6 +313,12 @@ const char *I810drmSymbols[] = { "drmGetLibVersion", "drmGetVersion", "drmRmMap", +#ifdef XSERVER_LIBDRM_MM + "drmMMInit", + "drmMMTakedown", + "drmMMLock", + "drmMMUnlock", +#endif NULL }; @@ -107,6 +107,13 @@ typedef struct _VESARec { } VESARec, *VESAPtr; +#ifdef XF86DRI +#define I830_MM_MINPAGES 512 +#define I830_MM_MAXSIZE (32*1024) +#define I830_KERNEL_MM (1 << 0) /* Initialize the kernel memory manager*/ +#define I830_KERNEL_TEX (1 << 1) /* Allocate texture memory pool */ +#endif + typedef struct _I830Rec *I830Ptr; typedef void (*I830WriteIndexedByteFunc)(I830Ptr pI830, IOADDRESS addr, @@ -285,6 +292,8 @@ typedef struct _I830Rec { int TexGranularity; int drmMinor; Bool have3DWindows; + int mmModeFlags; + int mmSize; unsigned int front_tiled; unsigned int back_tiled; @@ -573,4 +582,10 @@ Rotation I830GetRotation(ScreenPtr pScreen); #define _845_DRAM_RW_CONTROL 0x90 #define DRAM_WRITE 0x33330000 +/* + * Xserver MM compatibility. Remove code guarded by this when the + * XServer contains the libdrm mm code + */ +#undef XSERVER_LIBDRM_MM + #endif /* _I830_H_ */ diff --git a/src/i830_dri.c b/src/i830_dri.c index 21af6518..524c4de7 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.15 2003/06/18 13:14:17 dawes Exp $ */ +/* $xfree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.15 2003/06/18 13:14:17 dawes Exp $ */ /************************************************************************** Copyright 2001 VA Linux Systems Inc., Fremont, California. @@ -84,8 +84,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dristruct.h" static char I830KernelDriverName[] = "i915"; -static char I830ClientDriverName[] = "i915"; +static char I830ClientDriverName[] = "i915tex"; static char I965ClientDriverName[] = "i965"; +static char I830LegacyClientDriverName[] = "i915"; static Bool I830InitVisualConfigs(ScreenPtr pScreen); static Bool I830CreateContext(ScreenPtr pScreen, VisualPtr visual, @@ -644,10 +645,31 @@ I830DRIScreenInit(ScreenPtr pScreen) return FALSE; } pI830->drmMinor = version->version_minor; + if (!(pI830->mmModeFlags & I830_KERNEL_TEX)) { + if ((version->version_major > 1) || + ((version->version_minor >= 7) && + (version->version_major == 1))) { + pI830->mmModeFlags |= I830_KERNEL_MM; + } else { + pI830->mmModeFlags |= I830_KERNEL_TEX; + } + } else { + xf86DrvMsg(pScreen->myNum, X_INFO, + "Not enabling the DRM memory manager.\n"); + } drmFreeVersion(version); } } + /* + * Backwards compatibility + */ + + if ((pDRIInfo->clientDriverName == I830ClientDriverName) && + (pI830->mmModeFlags & I830_KERNEL_TEX)) { + pDRIInfo->clientDriverName = I830LegacyClientDriverName; + } + return TRUE; } @@ -707,18 +729,20 @@ I830DRIMapScreenRegions(ScrnInfoPtr pScrn, drmI830Sarea *sarea) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Depth Buffer = 0x%08x\n", (int)sarea->depth_handle); - if (drmAddMap(pI830->drmSubFD, - (drm_handle_t)sarea->tex_offset + pI830->LinearAddr, - sarea->tex_size, DRM_AGP, 0, - (drmAddress) &sarea->tex_handle) < 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n"); - DRICloseScreen(pScreen); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] textures = 0x%08x\n", - (int)sarea->tex_handle); + if (pI830->mmModeFlags & I830_KERNEL_TEX) { + if (drmAddMap(pI830->drmSubFD, + (drm_handle_t)sarea->tex_offset + pI830->LinearAddr, + sarea->tex_size, DRM_AGP, 0, + (drmAddress) &sarea->tex_handle) < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n"); + DRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] textures = 0x%08x\n", + (int)sarea->tex_handle); + } return TRUE; } @@ -1475,7 +1499,7 @@ I830UpdateDRIBuffers(ScrnInfoPtr pScrn, drmI830Sarea *sarea) success = I830DRIMapScreenRegions(pScrn, sarea); - if (success) + if (success && (pI830->mmModeFlags & I830_KERNEL_TEX)) I830InitTextureHeap(pScrn, sarea); return success; diff --git a/src/i830_driver.c b/src/i830_driver.c index 432f0cb2..e950d7c3 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -197,6 +197,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef XF86DRI #include "dri.h" +#include <sys/ioctl.h> +#include <errno.h> #endif #define BIT(x) (1 << (x)) @@ -268,7 +270,9 @@ typedef enum { OPTION_SECONDHSYNC, OPTION_SECONDVREFRESH, OPTION_SECONDPOSITION, - OPTION_INTELXINERAMA + OPTION_INTELXINERAMA, + OPTION_INTELTEXPOOL, + OPTION_INTELMMSIZE } I830Opts; static OptionInfoRec I830BIOSOptions[] = { @@ -296,6 +300,8 @@ static OptionInfoRec I830BIOSOptions[] = { {OPTION_SECONDVREFRESH,"SecondMonitorVertRefresh",OPTV_STRING,{0}, FALSE }, {OPTION_SECONDPOSITION,"SecondPosition",OPTV_STRING, {0}, FALSE }, {OPTION_INTELXINERAMA,"MergedXinerama",OPTV_BOOLEAN, {0}, TRUE}, + {OPTION_INTELTEXPOOL,"Legacy3D", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_INTELMMSIZE, "AperTexSize", OPTV_INTEGER, {0}, FALSE}, {-1, NULL, OPTV_NONE, {0}, FALSE} }; /* *INDENT-ON* */ @@ -3825,6 +3831,28 @@ I830IsPrimary(ScrnInfoPtr pScrn) return TRUE; } +#ifdef XF86DRI +static void +I830ReduceMMSize(ScrnInfoPtr pScrn, unsigned long newSize, + const char *reason) +{ + I830Ptr pI830 = I830PTR(pScrn); + + newSize = ROUND_DOWN_TO(newSize, GTT_PAGE_SIZE); + if (newSize / GTT_PAGE_SIZE > I830_MM_MINPAGES) { + pI830->mmSize = newSize / 1024; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "DRM memory manager aperture size is reduced to %d kiB\n" + "\t%s\n", pI830->mmSize, reason); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "DRM memory manager will be disabled\n\t%s\n", reason); + pI830->mmSize = 0; + } +} +#endif + + static Bool I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) { @@ -3847,6 +3875,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) const char *chipname; unsigned int ver; char v[5]; +#ifdef XF86DRI + unsigned long savedMMSize; +#endif if (pScrn->numEntities != 1) return FALSE; @@ -4243,7 +4274,46 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) "runs only at depths 16 and 24.\n"); pI830->directRenderingDisabled = TRUE; } - } + + pI830->mmModeFlags = 0; + + if (!pI830->directRenderingDisabled) { + Bool tmp = FALSE; + + if (IS_I965G(pI830)) + pI830->mmModeFlags |= I830_KERNEL_TEX; + + from = X_PROBED; + if (xf86GetOptValBool(pI830->Options, + OPTION_INTELTEXPOOL, &tmp)) { + from = X_CONFIG; + if (tmp) { + pI830->mmModeFlags |= I830_KERNEL_TEX; + } else { + pI830->mmModeFlags &= ~I830_KERNEL_TEX; + } + } + if (from == X_CONFIG || + (pI830->mmModeFlags & I830_KERNEL_TEX)) { + xf86DrvMsg(pScrn->scrnIndex, from, + "Will %stry to allocate texture pool " + "for old Mesa 3D driver.\n", + (pI830->mmModeFlags & I830_KERNEL_TEX) ? + "" : "not "); + } + pI830->mmSize = I830_MM_MAXSIZE; + from = X_INFO; + if (xf86GetOptValInteger(pI830->Options, OPTION_INTELMMSIZE, + &(pI830->mmSize))) { + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "Will try to reserve %d kiB of AGP aperture space\n" + "\tfor the DRM memory manager.\n", + pI830->mmSize); + } + } + #endif pI830->LinearAlloc = 0; @@ -5351,9 +5421,15 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) * If DRI is potentially usable, check if there is enough memory available * for it, and if there's also enough to allow tiling to be enabled. */ + #if defined(XF86DRI) - if (!I830CheckDRIAvailable(pScrn)) + if (!I830CheckDRIAvailable(pScrn)) { pI830->directRenderingDisabled = TRUE; + pI830->mmSize = 0; + } else if (pScrn->videoRam > pI830->FbMapSize / 1024 - pI830->mmSize) { + I830ReduceMMSize(pScrn, pI830->FbMapSize - KB(pScrn->videoRam), + "to make room for video memory"); + } if (I830IsPrimary(pScrn) && !pI830->directRenderingDisabled) { int savedDisplayWidth = pScrn->displayWidth; @@ -5395,7 +5471,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) * If the displayWidth is a tilable pitch, test if there's enough * memory available to enable tiling. */ + savedMMSize = pI830->mmSize; if (pScrn->displayWidth == pitches[i]) { + retry_dryrun: I830ResetAllocations(pScrn, 0); if (I830Allocate2DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_INITIAL) && I830Allocate3DMemory(pScrn, ALLOCATE_DRY_RUN)) { @@ -5407,7 +5485,13 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) "required to\n\tenable tiling mode for DRI.\n", (memNeeded + 1023) / 1024); } - if (pI830->MemoryAperture.Size < 0) { + if (pI830->MemoryAperture.Size < 0) { + if (KB(pI830->mmSize) > I830_MM_MINPAGES * GTT_PAGE_SIZE) { + I830ReduceMMSize(pScrn, I830_MM_MINPAGES * GTT_PAGE_SIZE, + "to make room in AGP aperture for tiling."); + goto retry_dryrun; + } + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Allocation with DRI tiling enabled would " "exceed the\n" @@ -5435,7 +5519,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) * Tiling can't be enabled. Check if there's enough memory for DRI * without tiling. */ + pI830->mmSize = savedMMSize; pI830->disableTiling = TRUE; + retry_dryrun2: I830ResetAllocations(pScrn, 0); if (I830Allocate2DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_INITIAL) && I830Allocate3DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_NO_TILING)) { @@ -5448,6 +5534,11 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) (memNeeded + 1023) / 1024); } if (pI830->MemoryAperture.Size < 0) { + if (KB(pI830->mmSize) > I830_MM_MINPAGES * GTT_PAGE_SIZE) { + I830ReduceMMSize(pScrn, I830_MM_MINPAGES * GTT_PAGE_SIZE, + "to save AGP aperture space for video memory."); + goto retry_dryrun2; + } xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Allocation with DRI enabled would " "exceed the\n" @@ -5456,6 +5547,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) pI830->FbMapSize / 1024, -pI830->MemoryAperture.Size / 1024); } + pI830->mmSize = 0; pI830->directRenderingDisabled = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n"); } @@ -7020,6 +7112,87 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) } } +#ifdef XF86DRI +#ifndef DRM_BO_MEM_TT +#error "Wrong drm.h file included. You need to compile and install a recent libdrm." +#endif + +#ifndef XSERVER_LIBDRM_MM + +static int +I830DrmMMInit(int drmFD, unsigned long pageOffs, unsigned long pageSize, + unsigned memType) +{ + + drm_mm_init_arg_t arg; + int ret; + + memset(&arg, 0, sizeof(arg)); + arg.req.op = mm_init; + arg.req.p_offset = pageOffs; + arg.req.p_size = pageSize; + arg.req.mem_type = memType; + + ret = ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg); + + if (ret) + return -errno; + + return 0; + +} + +static int +I830DrmMMTakedown(int drmFD, unsigned memType) +{ + drm_mm_init_arg_t arg; + int ret = 0; + + memset(&arg, 0, sizeof(arg)); + arg.req.op = mm_takedown; + arg.req.mem_type = memType; + if (ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg)) { + ret = -errno; + } + + return ret; +} + +static int I830DrmMMLock(int fd, unsigned memType) +{ + drm_mm_init_arg_t arg; + int ret; + + memset(&arg, 0, sizeof(arg)); + arg.req.op = mm_lock; + arg.req.mem_type = memType; + + do{ + ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg); + } while (ret && errno == EAGAIN); + + return ret; +} + +static int I830DrmMMUnlock(int fd, unsigned memType) +{ + drm_mm_init_arg_t arg; + int ret; + + memset(&arg, 0, sizeof(arg)); + arg.req.op = mm_unlock; + arg.req.mem_type = memType; + + do{ + ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg); + } while (ret && errno == EAGAIN); + + return ret; +} + +#endif +#endif + static Bool I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { @@ -7527,9 +7700,52 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) break; } + +#ifdef XF86DRI + if (pI830->directRenderingEnabled && (pI830->mmModeFlags & I830_KERNEL_MM)) { + unsigned long aperEnd = ROUND_DOWN_TO(pI830->FbMapSize, GTT_PAGE_SIZE) + / GTT_PAGE_SIZE; + unsigned long aperStart = ROUND_TO(pI830->FbMapSize - KB(pI830->mmSize), GTT_PAGE_SIZE) + / GTT_PAGE_SIZE; + + if (aperEnd < aperStart || aperEnd - aperStart < I830_MM_MINPAGES) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Too little AGP aperture space for DRM memory manager.\n" + "\tPlease increase AGP aperture size from BIOS configuration screen\n" + "\tor decrease the amount of video RAM using option \"VideoRam\".\n" + "\tDisabling DRI.\n"); + pI830->directRenderingOpen = FALSE; + I830DRICloseScreen(pScreen); + pI830->directRenderingEnabled = FALSE; + } else { +#ifndef XSERVER_LIBDRM_MM + if (I830DrmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart, + DRM_BO_MEM_TT)) { +#else + if (drmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart, + DRM_BO_MEM_TT)) { +#endif + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Could not initialize the DRM memory manager.\n"); + + pI830->directRenderingOpen = FALSE; + I830DRICloseScreen(pScreen); + pI830->directRenderingEnabled = FALSE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Initialized DRM memory manager, %ld AGP pages\n" + "\tat AGP offset 0x%lx\n", + aperEnd - aperStart, + aperStart); + } + } + } +#endif + return TRUE; } + static void I830AdjustFrame(int scrnIndex, int x, int y, int flags) { @@ -7683,7 +7899,13 @@ I830BIOSLeaveVT(int scrnIndex, int flags) #ifdef XF86DRI if (pI830->directRenderingOpen) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); - + if (pI830->mmModeFlags & I830_KERNEL_MM) { +#ifndef XSERVER_LIBDRM_MM + I830DrmMMLock(pI830->drmSubFD, DRM_BO_MEM_TT); +#else + drmMMLock(pI830->drmSubFD, DRM_BO_MEM_TT); +#endif + } I830DRISetVBlankInterrupt (pScrn, FALSE); drmCtlUninstHandler(pI830->drmSubFD); @@ -8138,6 +8360,14 @@ I830BIOSEnterVT(int scrnIndex, int flags) for(i = 0; i < I830_NR_TEX_REGIONS+1 ; i++) sarea->texList[i].age = sarea->texAge; + if (pI830->mmModeFlags & I830_KERNEL_MM) { +#ifndef XSERVER_LIBDRM_MM + I830DrmMMUnlock(pI830->drmSubFD, DRM_BO_MEM_TT); +#else + drmMMUnlock(pI830->drmSubFD, DRM_BO_MEM_TT); +#endif + } + DPRINTF(PFX, "calling dri unlock\n"); DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); } @@ -8351,6 +8581,13 @@ I830BIOSCloseScreen(int scrnIndex, ScreenPtr pScreen) pI830->closing = TRUE; #ifdef XF86DRI if (pI830->directRenderingOpen) { + if (pI830->mmModeFlags & I830_KERNEL_MM) { +#ifndef XSERVER_LIBDRM_MM + I830DrmMMTakedown(pI830->drmSubFD, DRM_BO_MEM_TT); +#else + drmMMTakedown(pI830->drmSubFD, DRM_BO_MEM_TT); +#endif + } pI830->directRenderingOpen = FALSE; I830DRICloseScreen(pScreen); } diff --git a/src/i830_memory.c b/src/i830_memory.c index 2d09b2d4..09ef5be8 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1107,6 +1107,12 @@ I830ResetAllocations(ScrnInfoPtr pScrn, const int flags) pI830->MemoryAperture.Start = pI830->StolenMemory.End; pI830->MemoryAperture.End = pI830->FbMapSize; pI830->MemoryAperture.Size = pI830->FbMapSize - pI830->StolenMemory.Size; +#ifdef XF86DRI + if (!pI830->directRenderingDisabled) { + pI830->MemoryAperture.End -= KB(pI830->mmSize); + pI830->MemoryAperture.Size -= KB(pI830->mmSize); + } +#endif pI830->StolenPool.Fixed = pI830->StolenMemory; pI830->StolenPool.Total = pI830->StolenMemory; #if ALLOCATE_ALL_BIOSMEM @@ -1286,37 +1292,41 @@ I830AllocateTextureMemory(ScrnInfoPtr pScrn, const int flags) /* Allocate the remaining space for textures. */ memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem)); pI830->TexMem.Key = -1; - size = GetFreeSpace(pScrn); - if (dryrun && (size < MB(1))) - size = MB(1); - i = myLog2(size / I830_NR_TEX_REGIONS); - if (i < I830_LOG_MIN_TEX_REGION_SIZE) - i = I830_LOG_MIN_TEX_REGION_SIZE; - pI830->TexGranularity = i; - /* Truncate size */ - size >>= i; - size <<= i; - if (size < KB(512)) { - if (!dryrun) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Less than 512 kBytes for texture space (real %ld kBytes).\n", - size / 1024); + + if (pI830->mmModeFlags & I830_KERNEL_TEX) { + + size = GetFreeSpace(pScrn); + if (dryrun && (size < MB(1))) + size = MB(1); + i = myLog2(size / I830_NR_TEX_REGIONS); + if (i < I830_LOG_MIN_TEX_REGION_SIZE) + i = I830_LOG_MIN_TEX_REGION_SIZE; + pI830->TexGranularity = i; + /* Truncate size */ + size >>= i; + size <<= i; + if (size < KB(512)) { + if (!dryrun) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Less than 512 kBytes for texture space (real %ld kBytes).\n", + size / 1024); + } + return FALSE; } - return FALSE; - } - alloced = I830AllocVidMem(pScrn, &(pI830->TexMem), - &(pI830->StolenPool), size, GTT_PAGE_SIZE, - flags | FROM_ANYWHERE | ALLOCATE_AT_TOP); - if (alloced < size) { - if (!dryrun) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Failed to allocate texture space.\n"); + alloced = I830AllocVidMem(pScrn, &(pI830->TexMem), + &(pI830->StolenPool), size, GTT_PAGE_SIZE, + flags | FROM_ANYWHERE | ALLOCATE_AT_TOP); + if (alloced < size) { + if (!dryrun) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to allocate texture space.\n"); + } + return FALSE; } - return FALSE; + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, + "%sAllocated %ld kB for textures at 0x%lx\n", s, + alloced / 1024, pI830->TexMem.Start); } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, - "%sAllocated %ld kB for textures at 0x%lx\n", s, - alloced / 1024, pI830->TexMem.Start); return TRUE; } @@ -1514,7 +1524,9 @@ I830FixupOffsets(ScrnInfoPtr pScrn) I830FixOffset(pScrn, &(pI830->ContextMem)); I830FixOffset(pScrn, &(pI830->BackBuffer)); I830FixOffset(pScrn, &(pI830->DepthBuffer)); - I830FixOffset(pScrn, &(pI830->TexMem)); + if (pI830->mmModeFlags & I830_KERNEL_TEX) { + I830FixOffset(pScrn, &(pI830->TexMem)); + } } #endif return TRUE; @@ -1913,7 +1925,8 @@ I830BindAGPMemory(ScrnInfoPtr pScrn) return FALSE; if (!BindMemRange(pScrn, &(pI830->DepthBuffer))) return FALSE; - if (!BindMemRange(pScrn, &(pI830->TexMem))) + if ((pI830->mmModeFlags & I830_KERNEL_TEX) && + !BindMemRange(pScrn, &(pI830->TexMem))) return FALSE; } #endif @@ -1997,7 +2010,8 @@ I830UnbindAGPMemory(ScrnInfoPtr pScrn) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->DepthBuffer))) return FALSE; - if (!UnbindMemRange(pScrn, &(pI830->TexMem))) + if ((pI830->mmModeFlags & I830_KERNEL_TEX) && + !UnbindMemRange(pScrn, &(pI830->TexMem))) return FALSE; } #endif diff --git a/src/i830_rotate.c b/src/i830_rotate.c index 020d7e61..0471b55a 100644 --- a/src/i830_rotate.c +++ b/src/i830_rotate.c @@ -778,7 +778,7 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Do heap teardown here */ - { + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { drmI830MemDestroyHeap destroy; destroy.region = I830_MEM_REGION_AGP; @@ -790,10 +790,11 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) } } - - if (pI8301->TexMem.Key != -1) - xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key); - I830FreeVidMem(pScrn1, &(pI8301->TexMem)); + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { + if (pI8301->TexMem.Key != -1) + xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key); + I830FreeVidMem(pScrn1, &(pI8301->TexMem)); + } if (pI8301->StolenPool.Allocated.Key != -1) { xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key); xf86DeallocateGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key); @@ -943,9 +944,11 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) pI8301->disableTiling ? ALLOC_NO_TILING : 0)) goto BAIL3; - if (!I830AllocateTextureMemory(pScrn1, - pI8301->disableTiling ? ALLOC_NO_TILING : 0)) - goto BAIL4; + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { + if (!I830AllocateTextureMemory(pScrn1, + pI8301->disableTiling ? ALLOC_NO_TILING : 0)) + goto BAIL4; + } I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool)); @@ -958,8 +961,10 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset); if (pI8301->StolenPool.Allocated.Key != -1) xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset); - if (pI8301->TexMem.Key != -1) - xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { + if (pI8301->TexMem.Key != -1) + xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); + } I830SetupMemoryTiling(pScrn1); /* update fence registers */ for (i = 0; i < 8; i++) @@ -1031,7 +1036,6 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayModePtr mode) pI830->AccelInfoRec->maxOffPixWidth = 1; pI830->AccelInfoRec->maxOffPixHeight = 1; } - return TRUE; BAIL4: @@ -1175,11 +1179,12 @@ BAIL0: pI8301->disableTiling ? ALLOC_NO_TILING : 0)) xf86DrvMsg(pScrn1->scrnIndex, X_INFO, "Oh dear, the depth buffer failed - badness\n"); - - if (!I830AllocateTextureMemory(pScrn1, - pI8301->disableTiling ? ALLOC_NO_TILING : 0)) - xf86DrvMsg(pScrn1->scrnIndex, X_INFO, - "Oh dear, the texture cache failed - badness\n"); + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { + if (!I830AllocateTextureMemory(pScrn1, + pI8301->disableTiling ? ALLOC_NO_TILING : 0)) + xf86DrvMsg(pScrn1->scrnIndex, X_INFO, + "Oh dear, the texture cache failed - badness\n"); + } I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool)); @@ -1192,8 +1197,10 @@ BAIL0: xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset); if (pI8301->StolenPool.Allocated.Key != -1) xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset); - if (pI8301->TexMem.Key != -1) - xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); + if (pI8301->mmModeFlags & I830_KERNEL_TEX) { + if (pI8301->TexMem.Key != -1) + xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset); + } I830SetupMemoryTiling(pScrn1); /* update fence registers */ for (i = 0; i < 8; i++) |