From patchwork Fri Sep 22 12:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 9965925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE95A600C5 for ; Fri, 22 Sep 2017 12:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B315D2988E for ; Fri, 22 Sep 2017 12:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A82ED29893; Fri, 22 Sep 2017 12:14:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 707F22988E for ; Fri, 22 Sep 2017 12:14:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67DC86E9CB; Fri, 22 Sep 2017 12:13:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id E234C6E9B2; Fri, 22 Sep 2017 12:13:32 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id n64so558454wrb.2; Fri, 22 Sep 2017 05:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LWyuS9cfKgpDM5/fm7aO3qSPpG3v7K1Wrw7Ofox9ADg=; b=um7mUN/v6BMTCYhnwj6BWxUoTcFBBQagwRnuIt9Zwg9ZDHvnmRKlOLrgAOUKwOwD07 lWl/LW5jnbvH4XksXQ4+Pt0m+tE0Sn61Cy1x8epZ4qHB9uOW5ZCY8Oo8ZkpG+6Z5i/7M xhrCaBOk5y77yq0hdP9hFzqQK7oBYyH/EJpTDmjHf+xsXEvqdEalm5X5agwUXmAcY9hA 9l/AMtj+5L9jSmL9XQWTWxA2/qwIdU0P4AXbRXhAExYJQ7rjg8p8lbGHJJeZcMWbjEVU QhpVPvHWaDkt4keiOj4YCjptAPybiQ7Ar6ZD9CDIs+L9PHMrC0y6MEXDJNrhG/vnankK 6AQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LWyuS9cfKgpDM5/fm7aO3qSPpG3v7K1Wrw7Ofox9ADg=; b=AEyQJ9Dbv76lcOu6rTXaognpOLLGAayMOL3+hnW66hvvPrY5S7nyGA4m5/SCsQPWNj 1aTP3quvlkPxI+ZxPBgpuBVOU/QRPwReSe6Pmxjrnhyi1+WP+hC8+SDeetMZPupNGBni m2ELmiAv1qvPRdjyGX+6tsoZJ2APvPohu7avSC54iAl29BONkfahxb+W7Oegv/VTb8Uu n96TIv9+ZVpP07RzpdPPfBaq8aGW63cQzqvF6NEfRVJTuGWQX7efk+pUJHIRX3CO43Vk GrjXMv3krDR5b89GQLvjOKiyYlqhbXO+msTUrIG8KdyHGoisq9S87m2xwpMY1j8mhLem o9/Q== X-Gm-Message-State: AHPjjUitD2bMRnaurMnlsCuHCXMLI6j0LkFrjDVbVNCOM32ykZO7bmQd Bm/JaiqKmSivSTWXkBU4dRtfoQnz X-Google-Smtp-Source: AOwi7QBRULO3hMXzKNlKLQu2JbVy+w1yIFWOT9Day3umbem7g5Okmj+Xn3JErgLqsK6uyPj/YJ27Tw== X-Received: by 10.223.154.81 with SMTP id z75mr5116517wrb.124.1506082411410; Fri, 22 Sep 2017 05:13:31 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:98cd:d000:f7ff:c900]) by smtp.gmail.com with ESMTPSA id i50sm4044739wrf.84.2017.09.22.05.13.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 05:13:30 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/9] drm/ttm: allocate/free multiple pages in a single call Date: Fri, 22 Sep 2017 14:13:20 +0200 Message-Id: <1506082405-1556-4-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506082405-1556-1-git-send-email-deathsimple@vodafone.de> References: <1506082405-1556-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Totally surprisingly this is more efficient than doing it page by page. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index e11fd76..482dd9a 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -873,15 +873,14 @@ int ttm_pool_populate(struct ttm_tt *ttm) if (ttm->state != tt_unpopulated) return 0; - for (i = 0; i < ttm->num_pages; ++i) { - ret = ttm_get_pages(&ttm->pages[i], 1, - ttm->page_flags, - ttm->caching_state); - if (ret != 0) { - ttm_pool_unpopulate(ttm); - return -ENOMEM; - } + ret = ttm_get_pages(ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state); + if (unlikely(ret != 0)) { + ttm_pool_unpopulate(ttm); + return ret; + } + for (i = 0; i < ttm->num_pages; ++i) { ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], PAGE_SIZE); if (unlikely(ret != 0)) { @@ -908,14 +907,14 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm) unsigned i; for (i = 0; i < ttm->num_pages; ++i) { - if (ttm->pages[i]) { - ttm_mem_global_free_page(ttm->glob->mem_glob, - ttm->pages[i], PAGE_SIZE); - ttm_put_pages(&ttm->pages[i], 1, - ttm->page_flags, - ttm->caching_state); - } + if (!ttm->pages[i]) + continue; + + ttm_mem_global_free_page(ttm->glob->mem_glob, ttm->pages[i], + PAGE_SIZE); } + ttm_put_pages(ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state); ttm->state = tt_unpopulated; } EXPORT_SYMBOL(ttm_pool_unpopulate);