From patchwork Sun Jul 7 18:58:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 2824615 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 973EFC0AB2 for ; Sun, 7 Jul 2013 19:03:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1AEE20122 for ; Sun, 7 Jul 2013 19:02:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CC34520121 for ; Sun, 7 Jul 2013 19:02:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB954E60D4 for ; Sun, 7 Jul 2013 12:02:58 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by gabe.freedesktop.org (Postfix) with ESMTP id D593BE5DD0 for ; Sun, 7 Jul 2013 11:59:10 -0700 (PDT) Received: by mail-pb0-f54.google.com with SMTP id ro2so3570791pbb.13 for ; Sun, 07 Jul 2013 11:59:10 -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=x8CW2R/MTxaTE4oDmOdhljHI2DV+qCtiocUH5iN1QWA=; b=wdLap4weqgS1qq4PM6i0HI6DXhF7VqRly/cdz8FdAP1MpCktDikPlKP54aj3pqk7zn OJLn2KBjrZwB6ohTtIbgNl0BRG54C+y+eLNXmyp6oLXVWtXdZHX4epEcgA472/jyP/Ep ubeAV0Ey40m+YFSUrywlDIdm7HtuHQiDRbWy4VJsn94kRUJT2RnaBH5wYonYkMqSorAX Xyj3fX/iwmSz0DjQLJidFn+9zHknC0P1T5RE3lyZ5b84DeIbMl3DrUv8JbD4Oz9Cg3QX vMDaG8u8W4BkxWM8qZo8gaGjbUH2n3yiij/2yYcltqPeFOS2XPhfX93hYpDPSghjBLfk OfLA== X-Received: by 10.69.8.65 with SMTP id di1mr9829059pbd.32.1373223550716; Sun, 07 Jul 2013 11:59:10 -0700 (PDT) Received: from localhost (netblock-66-245-248-130.dslextreme.com. [66.245.248.130]) by mx.google.com with ESMTPSA id s5sm18250611pbo.38.2013.07.07.11.59.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 07 Jul 2013 11:59:10 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/gma500: use gem get/put page helpers Date: Sun, 7 Jul 2013 14:58:49 -0400 Message-Id: <1373223531-19058-4-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=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 Signed-off-by: Rob Clark --- drivers/gpu/drm/gma500/gtt.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c index 1f82183..92babac 100644 --- a/drivers/gpu/drm/gma500/gtt.c +++ b/drivers/gpu/drm/gma500/gtt.c @@ -196,37 +196,17 @@ void psb_gtt_roll(struct drm_device *dev, struct gtt_range *r, int roll) */ static int psb_gtt_attach_pages(struct gtt_range *gt) { - struct inode *inode; - struct address_space *mapping; - int i; - struct page *p; - int pages = gt->gem.size / PAGE_SIZE; + struct page **pages; WARN_ON(gt->pages); - /* This is the shared memory object that backs the GEM resource */ - inode = file_inode(gt->gem.filp); - mapping = inode->i_mapping; + pages = drm_gem_get_pages(>->gem, 0); + if (IS_ERR(pages)) + return PTR_ERR(pages); - gt->pages = kmalloc(pages * sizeof(struct page *), GFP_KERNEL); - if (gt->pages == NULL) - return -ENOMEM; - gt->npage = pages; + gt->pages = pages; - for (i = 0; i < pages; i++) { - p = shmem_read_mapping_page(mapping, i); - if (IS_ERR(p)) - goto err; - gt->pages[i] = p; - } return 0; - -err: - while (i--) - page_cache_release(gt->pages[i]); - kfree(gt->pages); - gt->pages = NULL; - return PTR_ERR(p); } /** @@ -240,13 +220,7 @@ err: */ static void psb_gtt_detach_pages(struct gtt_range *gt) { - int i; - for (i = 0; i < gt->npage; i++) { - /* FIXME: do we need to force dirty */ - set_page_dirty(gt->pages[i]); - page_cache_release(gt->pages[i]); - } - kfree(gt->pages); + drm_gem_put_pages(>->gem, gt->pages, true, false); gt->pages = NULL; }