From patchwork Thu Oct 5 13:07:49 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: 9987107 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 4D83F6029B for ; Thu, 5 Oct 2017 13:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E86628C66 for ; Thu, 5 Oct 2017 13:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334E228C90; Thu, 5 Oct 2017 13:08:08 +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 8A9C428C8E for ; Thu, 5 Oct 2017 13:08:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 952366E7D5; Thu, 5 Oct 2017 13:08:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 122B06E7D5; Thu, 5 Oct 2017 13:08:02 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id m72so2042358wmc.1; Thu, 05 Oct 2017 06:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=srKJ6UrbCjO0+X5x2RLaqh77HXvj73Xvzi1VbcgWw5w=; b=QS7J/0+KuBLDzhetu+hnWC984tBY02mfJKiWnFqKFImX1Vm6v3FoBlr/wLNUzg/aon hkxfVWUOpxhGwEKhbxLgErb23o4YkdbazrLLRZuvRmnUQSziTj+8rD0QJbJZgEdrBcAe 12DNQD59Cg4hOuUoNBrwGEWAlYHm9vCo4f+E04O6AiUOGeUpA0PcA4zRQi1OEK4ngaMO XWEWWeGiPNpis6AZZ3+QdM+pVuuajxoPyPyMSiHbTrsbbR7T/5+52b/NkCAbZENNCU8E YocUz3x1auTvGyOvl5q7Lxjy4gIne4G9SFe9kvOj2fAbtwQ39mxiRpFC2Con+Dd33Lxp afWw== 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:mime-version :content-transfer-encoding; bh=srKJ6UrbCjO0+X5x2RLaqh77HXvj73Xvzi1VbcgWw5w=; b=lCBFawrQ9PrXg5+x8NQ4Lst99gy42oeZPJ9aSrdh0eYUBEYkr98DRQfbUGCpHLi9MV Z4x7O7DtBk/uTmSnki4f8QxcJSWEUdPbJIeXS6iCOLh72EVa+i0FjksDhdLTe+u/MBW9 hQNQ5vzzswU3JvexPE4FdytNCTClEpOVZvNw89X0VsAU4Ko1QVuSk4GsABhIwLLopVmi WsK+c9VDLWKy44KN641Lvw7x4ub4bP5Ejd0Q3DUPSDvhW90m4TEtqmUZyTSQGgKx7bEm BckQ8+H3HeChlifw/XIv7e2n8Z+c+QbPpJGXZiuHWGOVQ0wr3uSTGb5BqmiCk1uqxyVr uoGA== X-Gm-Message-State: AMCzsaV6G8ovIwOPHoMvwOziW88XUtXtrHtwCC+JOzRHCmBoyZ/zcVuh XnGm5tLBKNevuJ92MYlQlc6Ua9be X-Google-Smtp-Source: AOwi7QDpz8HPIMxaVeOk7pV7Wvlk9kEzWfGZFMwSvuXGZbmvHdPFaOKCUeTO+Tj4y1aBwMGkFZ9raQ== X-Received: by 10.28.7.82 with SMTP id 79mr841560wmh.4.1507208881320; Thu, 05 Oct 2017 06:08:01 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:c12c:1293:87f3:cbfe]) by smtp.gmail.com with ESMTPSA id 133sm15002742wmu.4.2017.10.05.06.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 06:08:00 -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 1/6] drm/ttm: allocate/free multiple pages in a single call Date: Thu, 5 Oct 2017 15:07:49 +0200 Message-Id: <1507208874-3448-1-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.7.4 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 Acked-by: Felix Kuehling --- 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);