From patchwork Thu Apr 2 15:29:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 6149431 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 07EF2C1F7E for ; Thu, 2 Apr 2015 15:31:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26084203AD for ; Thu, 2 Apr 2015 15:31:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 386B9203B1 for ; Thu, 2 Apr 2015 15:31:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7ABDC6EAB0; 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 476756EA4C 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-JA; Thu, 02 Apr 2015 17:30:57 +0200 From: Lucas Stach To: dri-devel@lists.freedesktop.org Subject: [PATCH RFC 041/111] staging: etnaviv: convert get_pages()/put_pages() to take etnaviv_obj Date: Thu, 2 Apr 2015 17:29:43 +0200 Message-Id: <1427988653-754-42-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 Convert the internal get_pages()/put_pages() functions to take an etnaviv_obj rather tha converting between drm_gem_object and our private one. Signed-off-by: Russell King --- drivers/staging/etnaviv/etnaviv_gem.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c index 1cd5c6bc2532..493ffc025569 100644 --- a/drivers/staging/etnaviv/etnaviv_gem.c +++ b/drivers/staging/etnaviv/etnaviv_gem.c @@ -24,16 +24,14 @@ #include "etnaviv_mmu.h" /* called with dev->struct_mutex held */ -static struct page **get_pages(struct drm_gem_object *obj) +static struct page **get_pages(struct etnaviv_gem_object *etnaviv_obj) { - struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); - if (!etnaviv_obj->pages) { - struct drm_device *dev = obj->dev; + struct drm_device *dev = etnaviv_obj->base.dev; struct page **p; - int npages = obj->size >> PAGE_SHIFT; + int npages = etnaviv_obj->base.size >> PAGE_SHIFT; - p = drm_gem_get_pages(obj); + p = drm_gem_get_pages(&etnaviv_obj->base); if (IS_ERR(p)) { dev_err(dev->dev, "could not get pages: %ld\n", @@ -44,7 +42,7 @@ static struct page **get_pages(struct drm_gem_object *obj) etnaviv_obj->sgt = drm_prime_pages_to_sg(p, npages); if (IS_ERR(etnaviv_obj->sgt)) { dev_err(dev->dev, "failed to allocate sgt\n"); - drm_gem_put_pages(obj, p, false, false); + drm_gem_put_pages(&etnaviv_obj->base, p, false, false); return ERR_CAST(etnaviv_obj->sgt); } @@ -61,22 +59,23 @@ static struct page **get_pages(struct drm_gem_object *obj) return etnaviv_obj->pages; } -static void put_pages(struct drm_gem_object *obj) +static void put_pages(struct etnaviv_gem_object *etnaviv_obj) { - struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); - if (etnaviv_obj->pages) { + struct drm_device *dev = etnaviv_obj->base.dev; + /* For non-cached buffers, ensure the new pages are clean * because display controller, GPU, etc. are not coherent: */ if (etnaviv_obj->flags & (ETNA_BO_WC|ETNA_BO_UNCACHED)) - dma_unmap_sg(obj->dev->dev, etnaviv_obj->sgt->sgl, + dma_unmap_sg(dev->dev, etnaviv_obj->sgt->sgl, etnaviv_obj->sgt->nents, DMA_BIDIRECTIONAL); sg_free_table(etnaviv_obj->sgt); kfree(etnaviv_obj->sgt); - drm_gem_put_pages(obj, etnaviv_obj->pages, true, false); + drm_gem_put_pages(&etnaviv_obj->base, etnaviv_obj->pages, + true, false); etnaviv_obj->pages = NULL; } @@ -88,7 +87,7 @@ struct page **etnaviv_gem_get_pages(struct drm_gem_object *obj) struct page **p; mutex_lock(&dev->struct_mutex); - p = get_pages(obj); + p = get_pages(to_etnaviv_bo(obj)); mutex_unlock(&dev->struct_mutex); return p; @@ -189,7 +188,7 @@ int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) goto out; /* make sure we have pages attached now */ - pages = get_pages(obj); + pages = get_pages(to_etnaviv_bo(obj)); if (IS_ERR(pages)) { ret = PTR_ERR(pages); goto out_unlock; @@ -273,7 +272,7 @@ int etnaviv_gem_get_iova_locked(struct etnaviv_gpu *gpu, if (!etnaviv_obj->iova && !(etnaviv_obj->flags & ETNA_BO_CMDSTREAM)) { struct etnaviv_drm_private *priv = obj->dev->dev_private; struct etnaviv_iommu *mmu = priv->mmu; - struct page **pages = get_pages(obj); + struct page **pages = get_pages(etnaviv_obj); uint32_t offset; struct drm_mm_node *node = NULL; @@ -375,7 +374,7 @@ void *etnaviv_gem_vaddr_locked(struct drm_gem_object *obj) WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex)); if (!etnaviv_obj->vaddr) { - struct page **pages = get_pages(obj); + struct page **pages = get_pages(etnaviv_obj); if (IS_ERR(pages)) return ERR_CAST(pages); @@ -536,7 +535,7 @@ static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj) { if (etnaviv_obj->vaddr) vunmap(etnaviv_obj->vaddr); - put_pages(&etnaviv_obj->base); + put_pages(etnaviv_obj); } static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = {