From patchwork Fri Sep 22 12:13:18 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: 9965915 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 36B7B600C5 for ; Fri, 22 Sep 2017 12:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A3412988D for ; Fri, 22 Sep 2017 12:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F58D29891; Fri, 22 Sep 2017 12:13:38 +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 AD0AC2988D for ; Fri, 22 Sep 2017 12:13:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54D7A6E9B2; Fri, 22 Sep 2017 12:13:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42AE66E02A; Fri, 22 Sep 2017 12:13:31 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m127so1122442wmm.0; Fri, 22 Sep 2017 05:13:30 -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=ruiXTLKj4gRMtupqx4lRg4lM/ujFUsBQMuyFJAhWTus=; b=F+kbpfw5mCIE+S8NfL/0vNJdeRgiAc38o5mD//UrQ1LjBgKS+KcBMYGQ0TpnDRqMXE 7LJcvFf54XVFi1r+K7FgSIohQ8ATGI7SfwbF53IoXvbhOsDNjXvO71yHAUHXKrphigJX O6fbTdaUNZXjBtiRWNuT6RcMw5N7yTSc8NJpPtjRRFLb/G2eAqbIjp0dD0vYRVtZmvBl gWGrsYh24VkCQedmNdkYG/OlWwwR2bDIVBJivQtAc6t494NSRq4lEImH5cctRRhtDqxu G0xFyDGRkc4FSkPHRgODPkDbPMdKwrWORPXXpmhJSH5WVsO/8CxebhvevbfQbZgn+Q8y HPOw== 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=ruiXTLKj4gRMtupqx4lRg4lM/ujFUsBQMuyFJAhWTus=; b=jY4tQELfX6kCiqjdeKpv/YgRrpscUeI20LwYWv20ksajqqR3hKgSq+rF1HxEeIuwY/ AgMv9IFo/JLkUVwk7oFFz1hNt3RTvw4BZ1F/Sxl0T6Q5gYW6JqGRg4S/q7sXLLlla8Ff h8n8zEQXygG6WK5Szr0f0SjIK1sdmZgv/6evRtPNu4OPNtvA3uNBIUATZnc81UG0C5ie lTfg1s5OFHF58aIT9MfnY+RWfPw6hDo5Q8en32bcKJAKXi44e4oFjtyAGzqbDQETqj2i qCF4kDkHmZYOOHE7KGGUeJkrvuU2n3SlWKzq2nZSHLTAYfieXXwm/WlUn3hWw1Oy7bzH qQDg== X-Gm-Message-State: AHPjjUjxn4wr7RN5//iwJWHsSFsQbM4kLNPZp66R3sUivuoreSNsRSRv zLAnhQk8l6s/oK+G23Qm5NFxT47Z X-Google-Smtp-Source: AOwi7QAsTe9qoBtnJajKuoLPOH7lSme6xlJuGRtrSyaQyK7wMJ51UjjWvmghWxtlYjXp6EjD60dAHg== X-Received: by 10.28.213.79 with SMTP id m76mr3710800wmg.44.1506082409459; Fri, 22 Sep 2017 05:13:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 05:13:28 -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 2/9] drm/ttm: add support for different pool sizes Date: Fri, 22 Sep 2017 14:13:18 +0200 Message-Id: <1506082405-1556-2-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 Correctly handle different page sizes in the memory accounting. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_memory.c | 10 +++++----- drivers/gpu/drm/ttm/ttm_page_alloc.c | 5 +++-- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 7 ++++--- include/drm/ttm/ttm_memory.h | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 4f9978c..e963749 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -546,7 +546,7 @@ int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, EXPORT_SYMBOL(ttm_mem_global_alloc); int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, - struct page *page) + struct page *page, uint64_t size) { struct ttm_mem_zone *zone = NULL; @@ -563,10 +563,11 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) zone = glob->zone_kernel; #endif - return ttm_mem_global_alloc_zone(glob, zone, PAGE_SIZE, false, false); + return ttm_mem_global_alloc_zone(glob, zone, size, false, false); } -void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page) +void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, + uint64_t size) { struct ttm_mem_zone *zone = NULL; @@ -577,10 +578,9 @@ void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page) if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) zone = glob->zone_kernel; #endif - ttm_mem_global_free_zone(glob, zone, PAGE_SIZE); + ttm_mem_global_free_zone(glob, zone, size); } - size_t ttm_round_pot(size_t size) { if ((size & (size - 1)) == 0) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 74f465e..e11fd76 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -882,7 +882,8 @@ int ttm_pool_populate(struct ttm_tt *ttm) return -ENOMEM; } - ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i]); + ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], + PAGE_SIZE); if (unlikely(ret != 0)) { ttm_pool_unpopulate(ttm); return -ENOMEM; @@ -909,7 +910,7 @@ void ttm_pool_unpopulate(struct ttm_tt *ttm) for (i = 0; i < ttm->num_pages; ++i) { if (ttm->pages[i]) { ttm_mem_global_free_page(ttm->glob->mem_glob, - ttm->pages[i]); + ttm->pages[i], PAGE_SIZE); ttm_put_pages(&ttm->pages[i], 1, ttm->page_flags, ttm->caching_state); diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index b8905bd..5362657 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -902,7 +902,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev) return -ENOMEM; } - ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i]); + ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], + pool->size); if (unlikely(ret != 0)) { ttm_dma_unpopulate(ttm_dma, dev); return -ENOMEM; @@ -967,13 +968,13 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) if (is_cached) { list_for_each_entry_safe(d_page, next, &ttm_dma->pages_list, page_list) { ttm_mem_global_free_page(ttm->glob->mem_glob, - d_page->p); + d_page->p, pool->size); ttm_dma_page_put(pool, d_page); } } else { for (i = 0; i < count; i++) { ttm_mem_global_free_page(ttm->glob->mem_glob, - ttm->pages[i]); + ttm->pages[i], pool->size); } } diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 8184ff1..2c1e359 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h @@ -150,9 +150,9 @@ extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, extern void ttm_mem_global_free(struct ttm_mem_global *glob, uint64_t amount); extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, - struct page *page); + struct page *page, uint64_t size); extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, - struct page *page); + struct page *page, uint64_t size); extern size_t ttm_round_pot(size_t size); extern uint64_t ttm_get_kernel_zone_memory_size(struct ttm_mem_global *glob); #endif