From c1687f9ca9ce7b52043272e877e070c810e6599f Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 14 Aug 2008 15:48:02 -0700 Subject: Map/unmap render state only when bo is available Otherwise just use the GTT address. --- src/i965_render.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/i965_render.c') diff --git a/src/i965_render.c b/src/i965_render.c index bd693cab..a4334c65 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -1441,6 +1441,7 @@ gen4_render_state_init(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); struct gen4_render_state *render_state; + int ret; if (pI830->gen4_render_state == NULL) pI830->gen4_render_state = calloc(sizeof(*render_state), 1); @@ -1449,12 +1450,19 @@ gen4_render_state_init(ScrnInfoPtr pScrn) render_state->card_state_offset = pI830->gen4_render_state_mem->offset; - if (dri_bo_map(pI830->gen4_render_state_mem->bo, 1)) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to map gen4 state\n"); - return; + if (pI830->gen4_render_state_mem->bo) { + ret = dri_bo_map(pI830->gen4_render_state_mem->bo, 1); + if (ret) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Failed to map gen4 state\n"); + return; + } + render_state->card_state = pI830->gen4_render_state_mem->bo->virtual; + } else { + render_state->card_state = (gen4_state_t *) + (pI830->FbBase + render_state->card_state_offset); } - render_state->card_state = pI830->gen4_render_state_mem->bo->virtual; gen4_state_init(render_state); } @@ -1466,8 +1474,10 @@ gen4_render_state_cleanup(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); - dri_bo_unmap(pI830->gen4_render_state_mem->bo); - dri_bo_unreference(pI830->gen4_render_state_mem->bo); + if (pI830->gen4_render_state_mem->bo) { + dri_bo_unmap(pI830->gen4_render_state_mem->bo); + dri_bo_unreference(pI830->gen4_render_state_mem->bo); + } pI830->gen4_render_state->card_state = NULL; } -- cgit v1.2.3