From patchwork Fri Sep 22 12:13:21 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: 9965917 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 A27EB600C5 for ; Fri, 22 Sep 2017 12:13:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 866722988D for ; Fri, 22 Sep 2017 12:13:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B45929892; Fri, 22 Sep 2017 12:13:40 +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 2EF1C2988D for ; Fri, 22 Sep 2017 12:13:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 770416E9BC; Fri, 22 Sep 2017 12:13:36 +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 1DCEF6E9AC; Fri, 22 Sep 2017 12:13:34 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id r136so1111657wmf.3; Fri, 22 Sep 2017 05:13:34 -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=0YAgN+Z9hPTR/xcJnY6XnrqTyqELmukKKb/vmhro93w=; b=SknImUh0HrDZzCJ9LIhO8EKtQcHWhkuPchVNZizQ1o0ufSrQLHDCdoqsDoqZ70RFWs ZuVbPlAifwzfdafEnyM7RLtPd5OrPR2hHnAjLhFR4Vf67/nQX+5vG9/sm26b2Dp56IIP 9exSM7bylYl8SkGIW/RuylY9ZLw96or7t3ZgNzK35cpYpNq/fXEZBdl4PXBWWFR3HOsx hLNltFLkkcLlRvwS3TI1wnQhbpLw+35jW5zRg9ZJIrBhx3MW2TqGSUl+5jYjGgl5d/xU ZCH+ekmCJhoIGQoc/2c3V/wwuws1xIhhxB+L9ytWL4Qob3U5s0Rs70mh7gYvPo++IN7B Qjfg== 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=0YAgN+Z9hPTR/xcJnY6XnrqTyqELmukKKb/vmhro93w=; b=mduncAOgX80JT8pEkhomjCOJfsipRATmB7nhXSHhO5yOy0zVi8chyR9PPHW7gFnfPx Ueo2xFXj/JEL/1dr4O89QM1wAZFLvwj2Dwn8A9dj9mgmE8pUr1zG+a7DuGPmxshThhKL O0+yo/b/w1eSt3XdpqXR86scdUt1wA/Oq6zW5sblig7XF4M4gj9Q4CprAG2Zybazhuel OwQJGfytcnlc9b0hg1T4D0XUYYYpVLSvnnBMDmqppUY83wSji8Zq2yHo5IYr24Q/KM41 +LmjHQFNyvWj4yuS0hcbFFdwQlEg+uZBlgAVuDO3uqTkGD2tz+gS4Y7TWSPuEJe+5JQd Aiig== X-Gm-Message-State: AHPjjUhfEBLZrxA+p1fmPDf+m2rdllIZXved2BJDxEo9b7N37cbhZPT1 2CjRqgGDYHP0k+Ql9FJFoBECc0a3 X-Google-Smtp-Source: AOwi7QB22V/GKeiokcwvyun1XVFh/L5F/wUobFQexkitMCLCMqcIGLNY2iIZ0y39Ok0CzerRsEkFng== X-Received: by 10.28.125.6 with SMTP id y6mr4026611wmc.85.1506082412673; Fri, 22 Sep 2017 05:13:32 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 05:13:31 -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 5/9] drm/ttm: DMA map/unmap compound pages as a whole Date: Fri, 22 Sep 2017 14:13:21 +0200 Message-Id: <1506082405-1556-5-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 Instead of mapping them bit by bit map/unmap the whole compound pages as in one call. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 482dd9a..3309926 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -922,16 +922,18 @@ EXPORT_SYMBOL(ttm_pool_unpopulate); #if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU) int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt) { - unsigned i; + unsigned i, j; int r; r = ttm_pool_populate(&tt->ttm); if (r) return r; - for (i = 0; i < tt->ttm.num_pages; i++) { + for (i = 0; i < tt->ttm.num_pages; ++i) { + size_t num_pages = 1 << compound_order(tt->ttm.pages[i]); + tt->dma_address[i] = dma_map_page(dev, tt->ttm.pages[i], - 0, PAGE_SIZE, + 0, num_pages * PAGE_SIZE, DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, tt->dma_address[i])) { while (i--) { @@ -942,6 +944,11 @@ int ttm_populate_and_map_pages(struct device *dev, struct ttm_dma_tt *tt) ttm_pool_unpopulate(&tt->ttm); return -EFAULT; } + + for (j = 1; j < num_pages; ++j) { + tt->dma_address[i + 1] = tt->dma_address[i] + PAGE_SIZE; + ++i; + } } return 0; } @@ -950,12 +957,20 @@ EXPORT_SYMBOL(ttm_populate_and_map_pages); void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt) { unsigned i; - - for (i = 0; i < tt->ttm.num_pages; i++) { - if (tt->dma_address[i]) { - dma_unmap_page(dev, tt->dma_address[i], - PAGE_SIZE, DMA_BIDIRECTIONAL); + + for (i = 0; i < tt->ttm.num_pages;) { + size_t num_pages; + + if (!tt->dma_address[i] || !tt->ttm.pages[i]) { + ++i; + continue; } + + num_pages = 1 << compound_order(tt->ttm.pages[i]); + dma_unmap_page(dev, tt->dma_address[i], num_pages * PAGE_SIZE, + DMA_BIDIRECTIONAL); + + i += num_pages; } ttm_pool_unpopulate(&tt->ttm); }