From patchwork Wed Jul 22 07:33:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 36715 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6M7Zr7S002520 for ; Wed, 22 Jul 2009 07:35:54 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE3039E7B5; Wed, 22 Jul 2009 00:35:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 2373C9E799 for ; Wed, 22 Jul 2009 00:35:50 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 22 Jul 2009 00:35:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.43,245,1246863600"; d="scan'208";a="167624270" Received: from xhh-945g.sh.intel.com (HELO localhost.localdomain) ([10.239.36.95]) by azsmga001.ch.intel.com with ESMTP; 22 Jul 2009 00:35:49 -0700 From: "Xiang, Haihao" To: intel-gfx@lists.freedesktop.org Date: Wed, 22 Jul 2009 15:33:43 +0800 Message-Id: <1248248023-23325-1-git-send-email-haihao.xiang@intel.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <> References: <> Subject: [Intel-gfx] [PATCH] XvMC: pin XvMC buffers under KMS. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Under KMS, the buffer allocated by i830_allocate_memory isn't pinned any more. However currently 915 XvMC needs static offsets. Fixes bug #22872 --- src/i830.h | 1 + src/i830_hwmc.c | 2 +- src/i830_memory.c | 26 ++++++++++++++++++++++++-- src/i915_hwmc.c | 20 ++++++++++---------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/i830.h b/src/i830.h index 21c98f5..58afe76 100644 --- a/src/i830.h +++ b/src/i830.h @@ -726,6 +726,7 @@ void i830_init_bufmgr(ScrnInfoPtr pScrn); #ifdef INTEL_XVMC Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, i830_memory **buffer, unsigned long size, int flags); +void i830_free_xvmc_buffer(ScrnInfoPtr pScrn, i830_memory *buffer); #endif extern uint32_t i830_create_new_fb(ScrnInfoPtr pScrn, int width, int height, int *pitch); diff --git a/src/i830_hwmc.c b/src/i830_hwmc.c index dee17ca..72385de 100644 --- a/src/i830_hwmc.c +++ b/src/i830_hwmc.c @@ -171,7 +171,7 @@ void intel_xvmc_fini_batch(ScrnInfoPtr pScrn) xvmc_driver->batch_handle = 0; } if (xvmc_driver->batch) { - i830_free_memory(pScrn, xvmc_driver->batch); + i830_free_xvmc_buffer(pScrn, xvmc_driver->batch); xvmc_driver->batch = NULL; } } diff --git a/src/i830_memory.c b/src/i830_memory.c index cc9d376..d3c9299 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1652,6 +1652,8 @@ Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, i830_memory **buffer, unsigned long size, int flags) { + I830Ptr pI830 = I830PTR(pScrn); + *buffer = i830_allocate_memory(pScrn, name, size, PITCH_NONE, GTT_PAGE_SIZE, flags, TILE_NONE); @@ -1661,11 +1663,31 @@ Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, return FALSE; } - if (!i830_bind_memory(pScrn, *buffer)) - return FALSE; + if (pI830->use_drm_mode && (*buffer)->bo) { + if (drm_intel_bo_pin((*buffer)->bo, GTT_PAGE_SIZE)) { + i830_free_memory(pScrn, *buffer); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to bind XvMC buffer bo!\n"); + return FALSE; + } + + (*buffer)->offset = (*buffer)->bo->offset; + } return TRUE; } + +void +i830_free_xvmc_buffer(ScrnInfoPtr pScrn, i830_memory *buffer) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (pI830->use_drm_mode && buffer->bo) + drm_intel_bo_unpin(buffer->bo); + + i830_free_memory(pScrn, buffer); +} + #endif void diff --git a/src/i915_hwmc.c b/src/i915_hwmc.c index 0723c80..6712caa 100644 --- a/src/i915_hwmc.c +++ b/src/i915_hwmc.c @@ -368,32 +368,32 @@ static Bool i915_allocate_xvmc_buffers(ScrnInfoPtr pScrn, I915XvMCContextPriv *c static void i915_free_xvmc_buffers(ScrnInfoPtr pScrn, I915XvMCContextPriv *ctxpriv) { if (ctxpriv->mcStaticIndirectState) { - i830_free_memory(pScrn, ctxpriv->mcStaticIndirectState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcStaticIndirectState); ctxpriv->mcStaticIndirectState = NULL; } if (ctxpriv->mcSamplerState) { - i830_free_memory(pScrn, ctxpriv->mcSamplerState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcSamplerState); ctxpriv->mcSamplerState = NULL; } if (ctxpriv->mcMapState) { - i830_free_memory(pScrn, ctxpriv->mcMapState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcMapState); ctxpriv->mcMapState = NULL; } if (ctxpriv->mcPixelShaderProgram) { - i830_free_memory(pScrn, ctxpriv->mcPixelShaderProgram); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcPixelShaderProgram); ctxpriv->mcPixelShaderProgram = NULL; } if (ctxpriv->mcPixelShaderConstants) { - i830_free_memory(pScrn, ctxpriv->mcPixelShaderConstants); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcPixelShaderConstants); ctxpriv->mcPixelShaderConstants = NULL; } if (ctxpriv->mcCorrdata) { - i830_free_memory(pScrn, ctxpriv->mcCorrdata); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcCorrdata); ctxpriv->mcCorrdata = NULL; } @@ -606,7 +606,7 @@ static int i915_xvmc_create_surface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf, (drmAddress)&sfpriv->surface_handle) < 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] drmAddMap(surface_handle) failed!\n"); - i830_free_memory(pScrn, sfpriv->surface); + i830_free_xvmc_buffer(pScrn, sfpriv->surface); xfree(sfpriv); xfree(*priv); *priv = NULL; @@ -694,7 +694,7 @@ static int i915_xvmc_create_subpict(ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp, (drmAddress)&sfpriv->surface_handle) < 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] drmAddMap(surface_handle) failed!\n"); - i830_free_memory(pScrn, sfpriv->surface); + i830_free_xvmc_buffer(pScrn, sfpriv->surface); xfree(sfpriv); xfree(*priv); *priv = NULL; @@ -744,7 +744,7 @@ static void i915_xvmc_destroy_surface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf) for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) { if (pXvMC->surfaces[i] == pSurf->surface_id) { drmRmMap(pI830->drmSubFD, pXvMC->sfprivs[i]->surface_handle); - i830_free_memory(pScrn, pXvMC->sfprivs[i]->surface); + i830_free_xvmc_buffer(pScrn, pXvMC->sfprivs[i]->surface); xfree(pXvMC->sfprivs[i]); pXvMC->nsurfaces--; pXvMC->sfprivs[i] = 0; @@ -766,7 +766,7 @@ static void i915_xvmc_destroy_subpict (ScrnInfoPtr pScrn, for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) { if (pXvMC->surfaces[i] == pSubp->subpicture_id) { drmRmMap(pI830->drmSubFD, pXvMC->sfprivs[i]->surface_handle); - i830_free_memory(pScrn, pXvMC->sfprivs[i]->surface); + i830_free_xvmc_buffer(pScrn, pXvMC->sfprivs[i]->surface); xfree(pXvMC->sfprivs[i]); pXvMC->nsurfaces--; pXvMC->sfprivs[i] = 0;