From patchwork Fri Dec 18 17:55:38 2020 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: 11982691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7733C2BBD5 for ; Fri, 18 Dec 2020 17:55:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C1AA23B51 for ; Fri, 18 Dec 2020 17:55:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C1AA23B51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A797D893B9; Fri, 18 Dec 2020 17:55:45 +0000 (UTC) Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 594FE893A4 for ; Fri, 18 Dec 2020 17:55:44 +0000 (UTC) Received: by mail-ed1-x52c.google.com with SMTP id h16so3228808edt.7 for ; Fri, 18 Dec 2020 09:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ewF5EIClYqqy4RXQ0HaSbN4c5NdKEVFW8AB8itR38dA=; b=jauBYRUNJuLZDse/TmUAPSsD+LJ/5+H48sxNJJ30Zl+Pu6N3Ch//pWHOVt1NqBAx9T KBLsx7OTGCjiF+AAjh4DIVu1Y2200GFaEeGMjgPOpyyURb6BeizPZm8+4R6Gg+/ilx/n kbdSTzgL8U1GIIKmo7tJoeCy/i9FhteN9VYOINhgzjKfp9uHNjVJU6GcLtrx2/TQw5HQ RWUQ6QLLm5nyU5mvFrkiZzcpyL2lMBjeY7pntECOnlvNHS3WyAub9Yn5Ym3xrX+VW+a9 REe6tAz2wcMM1S88MAQGwl8vNaDJFii8Ix2GnPlLhO/RCeaSQxAlnRYRrbLY4M5hIHGj hLpg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ewF5EIClYqqy4RXQ0HaSbN4c5NdKEVFW8AB8itR38dA=; b=MOOk39DKll0ULkW3qni48e84cGSTyKZ0BKs80uu17ukc5qRv2N6ABuzPPLE9LxMvle uYBRkdMkn7Kc3yiSV0iyfVYFGlRPgIShUDzI/7/U+GSh4IC+6aREBfZIY3w7b+VstGt7 G5inQWovwwJakEErbTAzvIXoP5QsJMfq9kmjBbTygKVSL1sXEPiIHUe23aJjQJTItjWU I9965KnOEu7c2FSXJauPQL2S0+kfYNW+Gqi4f/GvuX/KtLzyGB9gy3pNTE8CqCaczqud TaUJc2lDGb6SyRkruJn2K6mPx7DjALJgP8rIEMLY+XrsdF3cIgBNlNDyYvsbV/6nwSwG UFsw== X-Gm-Message-State: AOAM530PavpEgp/yvNCHn8XfIabP6eAs1267CAAlk87owis3lkDx7Cxk r5+3SY6mxOtFwdFgMNn63ZScApivM5k= X-Google-Smtp-Source: ABdhPJyglIhCALeVdX4tEKO+1uHx3GqN7STIXHydy7Oo/q16FczDWAp8FXgeZ88z9TmgYdNWP6pZeQ== X-Received: by 2002:aa7:d485:: with SMTP id b5mr5450106edr.214.1608314142761; Fri, 18 Dec 2020 09:55:42 -0800 (PST) Received: from abel.fritz.box ([2a02:908:1252:fb60:4769:42ab:9b50:97cf]) by smtp.gmail.com with ESMTPSA id x6sm26751795edl.67.2020.12.18.09.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:55:42 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/ttm: optimize ttm pool shrinker a bit Date: Fri, 18 Dec 2020 18:55:38 +0100 Message-Id: <20201218175538.1364-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218175538.1364-1-christian.koenig@amd.com> References: <20201218175538.1364-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ray.huang@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Only initialize the DMA coherent pools if they are used. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_pool.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index 1cdacd58753a..f09e34614226 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -504,10 +504,12 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev, pool->use_dma_alloc = use_dma_alloc; pool->use_dma32 = use_dma32; - for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) - for (j = 0; j < MAX_ORDER; ++j) - ttm_pool_type_init(&pool->caching[i].orders[j], - pool, i, j); + if (use_dma_alloc) { + for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) + for (j = 0; j < MAX_ORDER; ++j) + ttm_pool_type_init(&pool->caching[i].orders[j], + pool, i, j); + } } EXPORT_SYMBOL(ttm_pool_init); @@ -523,9 +525,11 @@ void ttm_pool_fini(struct ttm_pool *pool) { unsigned int i, j; - for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) - for (j = 0; j < MAX_ORDER; ++j) - ttm_pool_type_fini(&pool->caching[i].orders[j]); + if (pool->use_dma_alloc) { + for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) + for (j = 0; j < MAX_ORDER; ++j) + ttm_pool_type_fini(&pool->caching[i].orders[j]); + } } EXPORT_SYMBOL(ttm_pool_fini); @@ -630,6 +634,11 @@ int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m) { unsigned int i; + if (!pool->use_dma_alloc) { + seq_puts(m, "unused\n"); + return 0; + } + ttm_pool_debugfs_header(m); spin_lock(&shrinker_lock);