From patchwork Thu Apr 2 15:29:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 6149601 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41A94BF4A6 for ; Thu, 2 Apr 2015 15:31:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52FF8203B1 for ; Thu, 2 Apr 2015 15:31:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4FEB7203AB for ; Thu, 2 Apr 2015 15:31:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A29246EA43; Thu, 2 Apr 2015 08:31:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id 240996EA55 for ; Thu, 2 Apr 2015 08:30:58 -0700 (PDT) Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ydh57-0005OD-El; Thu, 02 Apr 2015 17:30:57 +0200 From: Lucas Stach To: dri-devel@lists.freedesktop.org Subject: [PATCH RFC 039/111] staging: etnaviv: move msm_gem_import() etc to etnaviv_gem_prime.c Date: Thu, 2 Apr 2015 17:29:41 +0200 Message-Id: <1427988653-754-40-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> References: <1427988653-754-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: Russell King , kernel@pengutronix.de X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russell King Move the prime import code out into etnaviv_gem_prime.c, which keeps all this functionality together. Signed-off-by: Russell King --- drivers/staging/etnaviv/etnaviv_gem.c | 55 ----------------------------- drivers/staging/etnaviv/etnaviv_gem_prime.c | 55 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c index 185cd1702b2e..1cd5c6bc2532 100644 --- a/drivers/staging/etnaviv/etnaviv_gem.c +++ b/drivers/staging/etnaviv/etnaviv_gem.c @@ -17,7 +17,6 @@ #include #include -#include #include "etnaviv_drv.h" #include "etnaviv_gem.h" @@ -702,57 +701,3 @@ int etnaviv_gem_new_private(struct drm_device *dev, size_t size, uint32_t flags, return 0; } - -static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj) -{ - if (etnaviv_obj->vaddr) - dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf, - etnaviv_obj->vaddr); - - /* Don't drop the pages for imported dmabuf, as they are not - * ours, just free the array we allocated: - */ - if (etnaviv_obj->pages) - drm_free_large(etnaviv_obj->pages); - - drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt); -} - -static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = { - .release = etnaviv_gem_prime_release, -}; - -struct drm_gem_object *msm_gem_import(struct drm_device *dev, - uint32_t size, struct sg_table *sgt) -{ - struct etnaviv_gem_object *etnaviv_obj; - int ret, npages; - - size = PAGE_ALIGN(size); - - ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, &etnaviv_obj); - if (ret < 0) - return ERR_PTR(ret); - - npages = size / PAGE_SIZE; - - etnaviv_obj->ops = &etnaviv_gem_prime_ops; - etnaviv_obj->sgt = sgt; - etnaviv_obj->pages = drm_malloc_ab(npages, sizeof(struct page *)); - if (!etnaviv_obj->pages) { - ret = -ENOMEM; - goto fail; - } - - ret = drm_prime_sg_to_page_addr_arrays(sgt, etnaviv_obj->pages, - NULL, npages); - if (ret) - goto fail; - - return &etnaviv_obj->base; - -fail: - drm_gem_object_unreference_unlocked(&etnaviv_obj->base); - - return ERR_PTR(ret); -} diff --git a/drivers/staging/etnaviv/etnaviv_gem_prime.c b/drivers/staging/etnaviv/etnaviv_gem_prime.c index 9c152b5640bc..4cf9e043c604 100644 --- a/drivers/staging/etnaviv/etnaviv_gem_prime.c +++ b/drivers/staging/etnaviv/etnaviv_gem_prime.c @@ -15,6 +15,7 @@ * this program. If not, see . */ +#include #include "etnaviv_drv.h" #include "etnaviv_gem.h" @@ -56,3 +57,57 @@ void msm_gem_prime_unpin(struct drm_gem_object *obj) if (!obj->import_attach) msm_gem_put_pages(obj); } + +static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj) +{ + if (etnaviv_obj->vaddr) + dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf, + etnaviv_obj->vaddr); + + /* Don't drop the pages for imported dmabuf, as they are not + * ours, just free the array we allocated: + */ + if (etnaviv_obj->pages) + drm_free_large(etnaviv_obj->pages); + + drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt); +} + +static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = { + .release = etnaviv_gem_prime_release, +}; + +struct drm_gem_object *msm_gem_import(struct drm_device *dev, + uint32_t size, struct sg_table *sgt) +{ + struct etnaviv_gem_object *etnaviv_obj; + int ret, npages; + + size = PAGE_ALIGN(size); + + ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, &etnaviv_obj); + if (ret < 0) + return ERR_PTR(ret); + + npages = size / PAGE_SIZE; + + etnaviv_obj->ops = &etnaviv_gem_prime_ops; + etnaviv_obj->sgt = sgt; + etnaviv_obj->pages = drm_malloc_ab(npages, sizeof(struct page *)); + if (!etnaviv_obj->pages) { + ret = -ENOMEM; + goto fail; + } + + ret = drm_prime_sg_to_page_addr_arrays(sgt, etnaviv_obj->pages, + NULL, npages); + if (ret) + goto fail; + + return &etnaviv_obj->base; + +fail: + drm_gem_object_unreference_unlocked(&etnaviv_obj->base); + + return ERR_PTR(ret); +}