From patchwork Thu Mar 21 00:41:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Vaswani X-Patchwork-Id: 2310761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id CE29A40213 for ; Thu, 21 Mar 2013 00:44:54 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UITZp-0002on-Ab; Thu, 21 Mar 2013 00:41:53 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UITZl-0002nu-Bb for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2013 00:41:50 +0000 X-IronPort-AV: E=Sophos;i="4.84,881,1355126400"; d="scan'208";a="31387714" Received: from pdmz-ns-snip_114_130.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.114.130]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Mar 2013 17:41:46 -0700 Received: from codeaurora.org (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 601FD10004B3; Wed, 20 Mar 2013 17:41:46 -0700 (PDT) From: Rohit Vaswani To: mstreet@quicinc.com, David Brown , Bryan Huntsman , Daniel Walker Subject: [PATCH] Changes to resolve the multiple client issue: by Michael Street Date: Wed, 20 Mar 2013 17:41:37 -0700 Message-Id: <1363826498-7254-1-git-send-email-rvaswani@codeaurora.org> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130320_204149_593455_27573E74 X-CRM114-Status: GOOD ( 18.13 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.251 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-msm@vger.kernel.org, Rohit Vaswani , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Signed-off-by: Rohit Vaswani --- src/msm-dri2.c | 21 +++++++++++++++++++-- src/msm-drm.c | 39 ++++++++++++++++++++++++++++++--------- src/msm-drm.h | 1 + 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/msm-dri2.c b/src/msm-dri2.c index e5bdf8a..7eadc48 100644 --- a/src/msm-dri2.c +++ b/src/msm-dri2.c @@ -131,9 +131,10 @@ DoFlipMDP4(ScreenPtr pScreen, PixmapPtr pPixmap, { struct mdp_overlay overlay; struct msmfb_overlay_data play; + struct drm_kgsl_gem_get_ion_fd ionfdioctl; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MSMPtr pMsm = MSMPTR(pScrn); - int ret; + int ret = 0; struct msm_pixmap_priv *pixpriv; @@ -190,9 +191,21 @@ DoFlipMDP4(ScreenPtr pScreen, PixmapPtr pPixmap, } pixpriv = exaGetPixmapDriverPrivate(pPixmap); + ionfdioctl.ion_fd = 0; + if(pixpriv->bo->ion_fd == 0) { + ionfdioctl.handle = pixpriv->bo->handle; + ret = ioctl(pixpriv->bo->fd, DRM_IOCTL_KGSL_GEM_GET_ION_FD, &ionfdioctl); + if (ret < 0) { + ErrorF("DRM: DRM_IOCTL_KGSL_GEM_GET_ION_FD failed: %m\n"); + return ret; + } + play.data.memory_id = ionfdioctl.ion_fd; + } + else { + play.data.memory_id = pixpriv->bo->ion_fd; + } play.id = fbOverlay; play.data.offset = pixpriv->bo->offsets[pixpriv->bo->active]; - play.data.memory_id = pixpriv->bo->ion_fd; play.data.priv = 0; play.data.flags = 0; @@ -206,6 +219,10 @@ DoFlipMDP4(ScreenPtr pScreen, PixmapPtr pPixmap, if (ret < 0) ErrorF("FBIOPAN_DISPLAY failed line %d error %d\n",__LINE__,errno); + if(ionfdioctl.ion_fd != 0) { + close(ionfdioctl.ion_fd); + } + return ret == 0 ? TRUE : FALSE; } #endif diff --git a/src/msm-drm.c b/src/msm-drm.c index 1e13d4a..3603cbd 100644 --- a/src/msm-drm.c +++ b/src/msm-drm.c @@ -218,6 +218,7 @@ msm_drm_bo_create(MSMPtr pMsm, int fd, int size, int type) bo->fd = fd; bo->active = 0; bo->count = 1; + bo->allocated = 0; /* All memory defaults to KMEM */ bo->memtype = DRM_KGSL_GEM_TYPE_KMEM; @@ -260,20 +261,21 @@ int msm_drm_bo_alloc(struct msm_drm_bo *bo) { struct drm_kgsl_gem_alloc alloc; - struct drm_kgsl_gem_get_ion_fd ionfdioctl; + //struct drm_kgsl_gem_get_ion_fd ionfdioctl; int ret; if (bo == NULL) return -1; /* If the offset is set, then assume it has been allocated */ - if (bo->ion_fd != 0) + if (bo->allocated != 0) return 0; memset(&alloc, 0, sizeof(alloc)); alloc.handle = bo->handle; ret = ioctl(bo->fd, DRM_IOCTL_KGSL_GEM_ALLOC, &alloc); + bo->allocated = 1; if (ret) { /* if the ioctl isn't supported, then use the legacy PREP ioctl */ @@ -299,13 +301,13 @@ msm_drm_bo_alloc(struct msm_drm_bo *bo) return ret; } - ionfdioctl.handle = bo->handle; - ret = ioctl(bo->fd, DRM_IOCTL_KGSL_GEM_GET_ION_FD, &ionfdioctl); - if (ret < 0) { - ErrorF("DRM: DRM_IOCTL_KGSL_GEM_GET_ION_FD failed: %m\n"); - return ret; - } - bo->ion_fd = ionfdioctl.ion_fd; +// ionfdioctl.handle = bo->handle; +// ret = ioctl(bo->fd, DRM_IOCTL_KGSL_GEM_GET_ION_FD, &ionfdioctl); +// if (ret < 0) { +// ErrorF("DRM: DRM_IOCTL_KGSL_GEM_GET_ION_FD failed: %m\n"); +// return ret; +// } +// bo->ion_fd = ionfdioctl.ion_fd; bo->offset = alloc.offset; return 0; @@ -356,6 +358,7 @@ msm_drm_bo_map(struct msm_drm_bo *bo) { int ret, i; unsigned int mapsize; + struct drm_kgsl_gem_get_ion_fd ionfdioctl; if (bo == NULL) return -1; @@ -401,8 +404,22 @@ msm_drm_bo_map(struct msm_drm_bo *bo) if (ret == 0) { + ionfdioctl.handle = bo->handle; + if(bo->ion_fd == 0) + { + ret = ioctl(bo->fd, DRM_IOCTL_KGSL_GEM_GET_ION_FD, &ionfdioctl); + if (ret < 0) { + ErrorF("DRM: DRM_IOCTL_KGSL_GEM_GET_ION_FD failed: %m\n"); + return ret; + } + bo->ion_fd = ionfdioctl.ion_fd; + } + else ErrorF("DRM: ion_fd %d already allocated\n", bo->ion_fd); + bo->hostptr = mmap(0, mapsize, PROT_READ | PROT_WRITE, MAP_SHARED, bo->ion_fd, 0); + close(bo->ion_fd); + bo->ion_fd = 0; } else { @@ -434,6 +451,8 @@ msm_drm_bo_unmap(struct msm_drm_bo *bo) munmap((void *) bo->hostptr, bo->size); bo->hostptr = 0; + close(bo->ion_fd); + bo->ion_fd = 0; #endif } @@ -452,6 +471,8 @@ msm_drm_bo_free(MSMPtr pMsm, struct msm_drm_bo *bo) } else _msm_drm_bo_free(bo); + + bo->allocated = 0; } /* Set the next buffer in the list as active */ diff --git a/src/msm-drm.h b/src/msm-drm.h index 55d071d..1eaf8e4 100644 --- a/src/msm-drm.h +++ b/src/msm-drm.h @@ -53,6 +53,7 @@ struct msm_drm_bo { int ref; int active; unsigned long long offset; + int allocated; }; int msm_drm_init(int fd);