From patchwork Wed Jul 25 20:29:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bas Nieuwenhuizen X-Patchwork-Id: 10544641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0457014E2 for ; Wed, 25 Jul 2018 20:30:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5CBD2AB46 for ; Wed, 25 Jul 2018 20:30:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7E6E2AB3D; Wed, 25 Jul 2018 20:30:20 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 891152AB3D for ; Wed, 25 Jul 2018 20:30:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A5576E408; Wed, 25 Jul 2018 20:30:19 +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 B1B136E3F4 for ; Wed, 25 Jul 2018 20:30:16 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id c14-v6so7288144wmb.4 for ; Wed, 25 Jul 2018 13:30:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kO1ZIiI1C5HGD45HhBds9T+Fk7IifgGVgq+gXS/1mUA=; b=SaVLgsLlgHpSEFppzlkAkOav5HnTNk2PjPWNR0PEU6s0v5ibx62xLUN4KqzDvY0XV6 taHYvroas3wNyPfTSJR6AOKME7S7+HOMEKaLAoJN2yWIgh2UIZe/4AdlZFCy7XhHgJ7S QFVZv1S1EmB8bgT5y0+ej/zU5tOloEz8Bcx2p8rfX403nFuEtP5lCkK73P1s3xYMdVS4 3nOeTMn7DnaNJ/r3N0lYTjB6RQNQu2REUTUPtG71/UCHOIYQurMeDbXN7Whi/vZpYI9b Y5nwsrPdqK4IrqMpBeLvJQ4gWbjE5yHScS3/HZtkcwMgRUJs9ntczCIycL7GOqfeXTrY Y0gg== X-Gm-Message-State: AOUpUlHIm6Sn2iEgiL/Sp0gnaAdBlZnO5Su7OdafCP6Br3fW7RCZ1qdn b5vnD/1aY2+PayzGa+5f5CIiOg== X-Google-Smtp-Source: AAOMgpdYmU9t7phWS0sJQkBuKg9oTc3pF9QFujbB6TYrDl6g6sSlCJo4csF7BiGNjIeLkAG7d/C4vA== X-Received: by 2002:a1c:87ca:: with SMTP id j193-v6mr5470830wmd.76.1532550615434; Wed, 25 Jul 2018 13:30:15 -0700 (PDT) Received: from bnieuwenhuizen.zrh.corp.google.com ([2a00:79e0:42:204:cdbd:aa9f:d9d4:2c4]) by smtp.gmail.com with ESMTPSA id s124-v6sm7746923wmf.47.2018.07.25.13.30.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 13:30:14 -0700 (PDT) From: Bas Nieuwenhuizen To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: Merge hugepage attr changes in ttm_dma_page_put. Date: Wed, 25 Jul 2018 22:29:50 +0200 Message-Id: <20180725202950.51216-1-basni@chromium.org> X-Mailer: git-send-email 2.18.0.233.g985f88cf7e-goog X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bas Nieuwenhuizen MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Every set_pages_array_wb call resulted in cross-core interrupts and TLB flushes. Merge more of them for less overhead. This reduces the time needed to free a 1.6 GiB GTT WC buffer as part of Vulkan CTS from ~2 sec to < 0.25 sec. (Allocation still takes more than 2 sec though) Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Huang Rui --- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index 4c659405a008a..9440ba0a55116 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -299,6 +299,25 @@ static int set_pages_array_uc(struct page **pages, int addrinarray) #endif return 0; } + +static int ttm_set_page_range_wb(struct page *p, unsigned long numpages) +{ +#if IS_ENABLED(CONFIG_AGP) + unsigned long i; + + for (i = 0; i < numpages; i++) + unmap_page_from_agp(p + i); +#endif + return 0; +} + +#else /* for !CONFIG_X86 */ + +static int ttm_set_page_range_wb(struct page *p, unsigned long numpages) +{ + return set_memory_wb((unsigned long)page_address(p), numpages); +} + #endif /* for !CONFIG_X86 */ static int ttm_set_pages_caching(struct dma_pool *pool, @@ -387,18 +406,16 @@ static void ttm_pool_update_free_locked(struct dma_pool *pool, static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page) { struct page *page = d_page->p; - unsigned i, num_pages; + unsigned num_pages; int ret; /* Don't set WB on WB page pool. */ if (!(pool->type & IS_CACHED)) { num_pages = pool->size / PAGE_SIZE; - for (i = 0; i < num_pages; ++i, ++page) { - ret = set_pages_array_wb(&page, 1); - if (ret) { - pr_err("%s: Failed to set %d pages to wb!\n", - pool->dev_name, 1); - } + ret = ttm_set_page_range_wb(page, num_pages); + if (ret) { + pr_err("%s: Failed to set %d pages to wb!\n", + pool->dev_name, num_pages); } }