From patchwork Sun Jul 7 18:58:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 2824616 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 131F99F9DE for ; Sun, 7 Jul 2013 19:03:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1960620122 for ; Sun, 7 Jul 2013 19:03:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 337B320121 for ; Sun, 7 Jul 2013 19:03:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26770E5D76 for ; Sun, 7 Jul 2013 12:03:42 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 9BA90E5C1F for ; Sun, 7 Jul 2013 11:59:13 -0700 (PDT) Received: by mail-pd0-f172.google.com with SMTP id z10so3390848pdj.17 for ; Sun, 07 Jul 2013 11:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=jHitTSgNagIP6IixbgY8LzYmPOs/ZvLPEUq2/2R5hd0=; b=AkfLmbDsG9o62UOpk4K1LuwifLedVZwmyClrJ2AA3C3hnXTmfAw3Dqy4r8Z+Wjt8h+ nyDDMs9L7fyMxPRrq7t6yuCgOfvKv5BTbAOkvfaCifl+QjFP7g9aGKhXGSFoWy/1LdtT gsO6pB7zYXjQ2pc+PmmqG1MqP8t8hYBKU50ni8wxTbwR4LUa3Gt03UEgatQEKRhwcumr jTLflLX4CtaV4iOb5Y8cyKsSGCRGRXSmkpIVTZzWrO5uCpygSigkBBIWQL5x+cWJQfqh wjQhz8Otqq8jp6vk3QqLcvkxgA4wAsPBTzVjkNqowGKLLMdYORNlHFjCNJuulAlMj+vj PMUw== X-Received: by 10.68.171.99 with SMTP id at3mr18411784pbc.64.1373223553381; Sun, 07 Jul 2013 11:59:13 -0700 (PDT) Received: from localhost (netblock-66-245-248-130.dslextreme.com. [66.245.248.130]) by mx.google.com with ESMTPSA id sz6sm19753437pab.5.2013.07.07.11.59.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 07 Jul 2013 11:59:12 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm/udl: use gem get/put page helpers Date: Sun, 7 Jul 2013 14:58:50 -0400 Message-Id: <1373223531-19058-5-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1373223531-19058-1-git-send-email-robdclark@gmail.com> References: <1373223531-19058-1-git-send-email-robdclark@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Signed-off-by: Rob Clark --- drivers/gpu/drm/udl/udl_gem.c | 44 ++++++------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index ef034fa..e37e75a 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -123,55 +123,23 @@ int udl_gem_init_object(struct drm_gem_object *obj) static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask) { - int page_count, i; - struct page *page; - struct inode *inode; - struct address_space *mapping; + struct page **pages; if (obj->pages) return 0; - page_count = obj->base.size / PAGE_SIZE; - BUG_ON(obj->pages != NULL); - obj->pages = drm_malloc_ab(page_count, sizeof(struct page *)); - if (obj->pages == NULL) - return -ENOMEM; - - inode = file_inode(obj->base.filp); - mapping = inode->i_mapping; - gfpmask |= mapping_gfp_mask(mapping); + pages = drm_gem_get_pages(&obj->base, gfpmask); + if (IS_ERR(pages)) + return PTR_ERR(pages); - for (i = 0; i < page_count; i++) { - page = shmem_read_mapping_page_gfp(mapping, i, gfpmask); - if (IS_ERR(page)) - goto err_pages; - obj->pages[i] = page; - } + obj->pages = pages; return 0; -err_pages: - while (i--) - page_cache_release(obj->pages[i]); - drm_free_large(obj->pages); - obj->pages = NULL; - return PTR_ERR(page); } static void udl_gem_put_pages(struct udl_gem_object *obj) { - int page_count = obj->base.size / PAGE_SIZE; - int i; - - if (obj->base.import_attach) { - drm_free_large(obj->pages); - obj->pages = NULL; - return; - } - - for (i = 0; i < page_count; i++) - page_cache_release(obj->pages[i]); - - drm_free_large(obj->pages); + drm_gem_put_pages(&obj->base, obj->pages, false, false); obj->pages = NULL; }