Improve logging of memory allocation passes, and clean the code up a bit.
This commit is contained in:
parent
54198b26e8
commit
7bb725dee9
|
|
@ -812,27 +812,6 @@ i830SetHotkeyControl(ScrnInfoPtr pScrn, int mode)
|
|||
pI830->writeControl(pI830, GRX, 0x18, gr18);
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
/**
|
||||
* This is called per zaphod head (so usually just once) to do initialization
|
||||
* before the Screen is created.
|
||||
|
|
@ -2158,7 +2137,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
|
|||
I830Ptr pI8301 = NULL;
|
||||
unsigned long sys_mem;
|
||||
int i;
|
||||
Bool allocation_done;
|
||||
Bool allocation_done = FALSE;
|
||||
MessageType from;
|
||||
#ifdef XF86DRI
|
||||
Bool driDisabled;
|
||||
|
|
@ -2268,7 +2247,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
|
|||
pI830->mmSize = 0;
|
||||
}
|
||||
|
||||
if (I830IsPrimary(pScrn) && !pI830->directRenderingDisabled) {
|
||||
if (!pI830->directRenderingDisabled) {
|
||||
int savedDisplayWidth = pScrn->displayWidth;
|
||||
Bool tiled = FALSE;
|
||||
|
||||
|
|
@ -2306,70 +2285,80 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
allocation_done = FALSE;
|
||||
/*
|
||||
* If the displayWidth is a tilable pitch, test if there's enough
|
||||
* memory available to enable tiling.
|
||||
/* Attempt several rounds of allocation to get 2d and 3d memory to fit:
|
||||
*
|
||||
* 0: tiled, large memory manager
|
||||
* 1: tiled, small memory manager
|
||||
* 2: untiled, large
|
||||
* 3: untiled, small
|
||||
*/
|
||||
|
||||
pI830->disableTiling = FALSE;
|
||||
savedMMSize = pI830->mmSize;
|
||||
if (tiled) {
|
||||
retry_dryrun:
|
||||
i830_reset_allocations(pScrn);
|
||||
if (!i830_allocate_2d_memory(pScrn) ||
|
||||
!i830_allocate_3d_memory(pScrn))
|
||||
{
|
||||
/* Failure to set up allocations, so try reducing the DRI memory
|
||||
* manager's size if we haven't yet.
|
||||
*/
|
||||
if (KB(pI830->mmSize) > I830_MM_MINPAGES * GTT_PAGE_SIZE) {
|
||||
I830ReduceMMSize(pScrn, I830_MM_MINPAGES * GTT_PAGE_SIZE,
|
||||
"to make room for tiling.");
|
||||
goto retry_dryrun;
|
||||
}
|
||||
/* Otherwise, disable tiling. */
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!tiled && i < 2)
|
||||
continue;
|
||||
|
||||
if (i >= 2) {
|
||||
/* For further allocations, disable tiling */
|
||||
pI830->disableTiling = TRUE;
|
||||
pScrn->displayWidth = savedDisplayWidth;
|
||||
pI830->allowPageFlip = FALSE;
|
||||
} else if (pScrn->displayWidth != savedDisplayWidth) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
|
||||
"Increasing the scanline pitch to allow tiling mode "
|
||||
"(%d -> %d).\n",
|
||||
savedDisplayWidth, pScrn->displayWidth);
|
||||
allocation_done = TRUE;
|
||||
}
|
||||
}
|
||||
if (!allocation_done) {
|
||||
/*
|
||||
* Tiling can't be enabled. Check if there's enough memory for DRI
|
||||
* without tiling.
|
||||
*/
|
||||
pI830->mmSize = savedMMSize;
|
||||
pI830->disableTiling = TRUE;
|
||||
retry_dryrun2:
|
||||
i830_reset_allocations(pScrn);
|
||||
if (!i830_allocate_2d_memory(pScrn) ||
|
||||
!i830_allocate_3d_memory(pScrn))
|
||||
{
|
||||
/* Failure to set up allocations, so try reducing the DRI memory
|
||||
* manager's size if we haven't yet.
|
||||
|
||||
if (i & 1) {
|
||||
/* For this allocation, switch to a smaller DRI memory manager
|
||||
* size.
|
||||
*/
|
||||
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,
|
||||
"Not enough video memory. Disabling DRI.");
|
||||
pI830->mmSize = 0;
|
||||
pI830->directRenderingDisabled = TRUE;
|
||||
pI830->mmSize = I830_MM_MINPAGES * GTT_PAGE_SIZE;
|
||||
} else {
|
||||
allocation_done = TRUE;
|
||||
pI830->mmSize = savedMMSize;
|
||||
}
|
||||
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
|
||||
"Attempting memory allocation with %s buffers and \n"
|
||||
"\t %s DRI memory manager reservation:\n",
|
||||
(i & 2) ? "untiled" : "tiled",
|
||||
(i & 1) ? "small" : "large");
|
||||
|
||||
if (i830_allocate_2d_memory(pScrn) &&
|
||||
i830_allocate_3d_memory(pScrn))
|
||||
{
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Success.\n");
|
||||
if (pScrn->displayWidth != savedDisplayWidth) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
|
||||
"Increasing the scanline pitch to allow tiling mode "
|
||||
"(%d -> %d).\n",
|
||||
savedDisplayWidth, pScrn->displayWidth);
|
||||
}
|
||||
allocation_done = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
i830_reset_allocations(pScrn);
|
||||
}
|
||||
|
||||
if (i == 4) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Not enough video memory. Disabling DRI.\n");
|
||||
pI830->mmSize = 0;
|
||||
pI830->directRenderingDisabled = TRUE;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
pI830->disableTiling = TRUE; /* no DRI - so disableTiling */
|
||||
|
||||
if (!allocation_done) {
|
||||
if (!i830_allocate_2d_memory(pScrn)) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
"Couldn't allocate video memory\n");
|
||||
return FALSE;
|
||||
}
|
||||
allocation_done = TRUE;
|
||||
}
|
||||
|
||||
i830_describe_allocations(pScrn, 1, "");
|
||||
|
||||
if (!IS_I965G(pI830) && pScrn->displayWidth > 2048) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
"Cannot support DRI with frame buffer width > 2048.\n");
|
||||
|
|
@ -2537,7 +2526,6 @@ retry_dryrun2:
|
|||
pI830->directRenderingEnabled = FALSE;
|
||||
#endif
|
||||
|
||||
i830_describe_allocations(pScrn, 1, "");
|
||||
#ifdef XF86DRI
|
||||
if (pI830->directRenderingEnabled)
|
||||
pI830->directRenderingEnabled = I830DRIDoMappings(pScreen);
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ i830_unbind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
|
|||
static void
|
||||
i830_free_memory(ScrnInfoPtr pScrn, i830_memory *mem)
|
||||
{
|
||||
if (mem == NULL)
|
||||
return;
|
||||
|
||||
i830_unbind_memory(pScrn, mem);
|
||||
|
||||
/* Disconnect from the list of allocations */
|
||||
|
|
@ -641,7 +644,7 @@ i830_allocate_overlay(ScrnInfoPtr pScrn)
|
|||
OVERLAY_SIZE, GTT_PAGE_SIZE,
|
||||
NEED_PHYSICAL_ADDR);
|
||||
if (pI830->overlay_regs == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate Overlay register space.\n");
|
||||
/* This failure isn't fatal. */
|
||||
}
|
||||
|
|
@ -652,7 +655,7 @@ i830_allocate_overlay(ScrnInfoPtr pScrn)
|
|||
KB(pI830->LinearAlloc),
|
||||
GTT_PAGE_SIZE, 0);
|
||||
if (pI830->xaa_linear == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate linear buffer space\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -937,8 +940,8 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
|
|||
pI830->exa_offscreen = i830_allocate_memory(pScrn, "exa offscreen",
|
||||
size, 1, 0);
|
||||
if (pI830->exa_offscreen == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to allocate "
|
||||
"offscreen memory. Not enough VRAM?\n");
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate EXA offscreen memory.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -948,9 +951,8 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
|
|||
i830_allocate_memory(pScrn, "exa G965 state buffer",
|
||||
EXA_LINEAR_EXTRA, GTT_PAGE_SIZE, 0);
|
||||
if (pI830->exa_965_state == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
"G965: Failed to allocate exa state buffer "
|
||||
"space.\n");
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate exa state buffer for 965.\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -982,9 +984,8 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
|
|||
MIN_SCRATCH_BUFFER_SIZE, GTT_PAGE_SIZE,
|
||||
0);
|
||||
if (pI830->xaa_scratch == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
"Failed to allocate scratch buffer "
|
||||
"space\n");
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate scratch buffer space\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1003,7 +1004,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
|
|||
MIN_SCRATCH_BUFFER_SIZE,
|
||||
GTT_PAGE_SIZE, 0);
|
||||
if (pI830->xaa_scratch_2 == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate secondary scratch "
|
||||
"buffer space\n");
|
||||
return FALSE;
|
||||
|
|
@ -1063,7 +1064,7 @@ i830_allocate_backbuffer(ScrnInfoPtr pScrn)
|
|||
}
|
||||
|
||||
if (pI830->back_buffer == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate back buffer space.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1107,7 +1108,7 @@ i830_allocate_depthbuffer(ScrnInfoPtr pScrn)
|
|||
}
|
||||
|
||||
if (pI830->depth_buffer == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate depth buffer space.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1152,7 +1153,7 @@ i830_allocate_texture_memory(ScrnInfoPtr pScrn)
|
|||
pI830->textures = i830_allocate_memory(pScrn, "textures", size,
|
||||
GTT_PAGE_SIZE, 0);
|
||||
if (pI830->textures == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate texture space.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1172,7 +1173,7 @@ i830_allocate_3d_memory(ScrnInfoPtr pScrn)
|
|||
pI830->logical_context = i830_allocate_memory(pScrn, "logical 3D context",
|
||||
KB(32), GTT_PAGE_SIZE, 0);
|
||||
if (pI830->logical_context == NULL) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
"Failed to allocate logical context space.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue