From patchwork Fri Jan 12 06:14:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10159633 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 A25A6602A7 for ; Fri, 12 Jan 2018 06:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F96428906 for ; Fri, 12 Jan 2018 06:14:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8416528912; Fri, 12 Jan 2018 06:14:30 +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=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 85A0028906 for ; Fri, 12 Jan 2018 06:14:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C3496E6EB; Fri, 12 Jan 2018 06:14:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0077.outbound.protection.outlook.com [104.47.37.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id EED0C6E6E3 for ; Fri, 12 Jan 2018 06:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nsxNM+69gcTUav5YqK2e+3fSz1JmCaTVCVRllqszo8g=; b=fB0LXYVwSaCxELSFSzp+ETEY5Lo5jNG1gYl8vcpCRl4rYEZ1CcXs6ShTo+UvWwje34YJreH5PM35u/Tsn0DPARlGQQoA6LAKcVFZHeQ0pou6kzMJ7cdI+HAQtGRGq5wqNBbJojvvWVx2ch3hma/gvNpV/QmT1EEpxhVH87Wmk4U= Received: from DM3PR12CA0049.namprd12.prod.outlook.com (10.161.151.17) by CY4PR12MB1446.namprd12.prod.outlook.com (10.172.71.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Fri, 12 Jan 2018 06:14:23 +0000 Received: from BY2NAM03FT024.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::205) by DM3PR12CA0049.outlook.office365.com (2603:10b6:0:56::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Fri, 12 Jan 2018 06:14:23 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by BY2NAM03FT024.mail.protection.outlook.com (10.152.84.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.19 via Frontend Transport; Fri, 12 Jan 2018 06:14:23 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Fri, 12 Jan 2018 00:14:21 -0600 From: Roger He To: Subject: [PATCH 1/2] drm/ttm: don't update global memory count for some special cases Date: Fri, 12 Jan 2018 14:14:16 +0800 Message-ID: <1515737657-2983-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(39380400002)(39860400002)(2980300002)(428003)(199004)(189003)(5660300001)(6916009)(50226002)(47776003)(68736007)(305945005)(81166006)(105586002)(356003)(6666003)(81156014)(8676002)(2906002)(478600001)(2351001)(59450400001)(4326008)(106466001)(8936002)(97736004)(316002)(54906003)(16586007)(104016004)(50466002)(53416004)(86362001)(51416003)(53936002)(72206003)(48376002)(15650500001)(77096006)(7696005)(575784001)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1446; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT024; 1:aO6n+xu9hLQLRNZIJu7bgtCa9QBOr31UvtMk0naveeBX4V86gPc4E3VsIRHD30WZrMlyhRa0IuHgzNAaAapmwDQzsHApEABDctZzQ7gSEgm3lHDNmj9IYYkxBiF42yid X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01c9be44-49a5-4971-54c5-08d55983b99e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020077)(4652020)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY4PR12MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 3:HzC+i4JL3kEGuZ5l+QVnh6OJdKjIraIq6F/yXI4NhazPf8hOKwCwHQyudFDc2aAnu9x4+dSxbwhiDHqHZPHI9hIkQHs5ko2vjS2R0RuSEUUoh69h2fykK380M+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gtw6C6SJTPROPsmIYZ60YAkGgt+Qf1z/oDUWHx4JjuPVVa2KUfa+3GmrK4JNol0MmHR+CHlcIeJjBkpxrv0CaR48BgtPKtEPku725T3FG8kD5vRYfnk/rcRw8sZ8auLymmwlk/DBl+7B5W4B5QIyhWr1/+p5OTadoIHwO7z7ZI62EDSilu056Uvc3Ok+DjTWseCnVsCKfW7ozAf+UKfNVRSU5YOK3pcYRUsmtMRqpUOi/ftZWnUbL3sPx6I9kVZghjOUJTk4BCNvXjtA2XvYJzF/bkoI/qLUDQ+lnygQO5HkgC9G3TJDQea8ndLwIqwuAuRSbQJa1Ii+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501140)(3002001)(10201501046)(93006095)(93003095)(6055026)(6041268)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(6072148)(201708071742011); SRVR:CY4PR12MB1446; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR12MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 4:32KUhz8Z94McgepHDi5wlWjCnZIovwtBgPRxqUxIh4ohHYMc04t69yS6RESwYI+SSg3Jdj2Y07ja8JRE1Tcw+By4Zui3IwfrMhk1XfvY4gSPPRRMOJ7QpmM9K/sPUBTgCrCUO9S4+yY+zurNa+2qzYO6/mLYz1V3jZA9NrX9UGimLyQYs4/3Q3EBNo3qIVBzOknVLjQlmntzciBU45tWI21JeKKGDug9wORpG/BpncCDR71GtPCbFDmZdc1EzcQARmJA9kb8bWBkh+S82wUqmQx1ApnoJx8LUPHrpHnmp2dT+6u1ndOCcbxKF//i/qRc X-Forefront-PRVS: 0550778858 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1446; 23:78CY1Hn0lEmLD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QT/DEmVGkH/bKaoboOV6naL7u+ygcXbmv8cqivD0+2HpD+vsIP8c45PnvILWAGMwYSWXYdlA23v0CkdPtXFX6kbRtHH4CYhapKiH8/T5Bm6CZ9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 20:ny0ZEsCiA9mJR4mRWLQRHrwci0FAcQXxuK8LgUVhGkPqkTk9VURXv5yjQBu87xjrKdiek/QNK4ZVVzw3a7cqGBv5ZX9239AXIIBfWfeY23rekjxIlIJsYbiXuwUjdnKcq1qV9h7OVyEQDPD4LOmLUOl33X+KHt7ogWwga2qknDK/CWZzC3b2yFqFxktsdM+Qfo5bvS3YBi3YqfAdzdN6Lhg6wrctzhC8RLe9MgkEVgiOdx+Gk8n8kfr8bzf5tgZh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2018 06:14:23.0979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01c9be44-49a5-4971-54c5-08d55983b99e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1446 Cc: Roger He , Christian.Koenig@amd.com 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 add input parameter for ttm_dma_unpopulate. when ttm_dma_pool_get_pages or ttm_mem_global_alloc_page fail, don't call ttm_mem_global_free_page to update global memory count. Signed-off-by: Roger He --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 19 +++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +- include/drm/ttm/ttm_page_alloc.h | 5 +++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index e4bb435..723ccf1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1046,7 +1046,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) #ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl()) { - ttm_dma_unpopulate(>t->ttm, adev->dev); + ttm_dma_unpopulate(>t->ttm, adev->dev, true); return; } #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index ce328ed..3f7c30f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1632,7 +1632,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) if (swiotlb_nr_tbl()) { - ttm_dma_unpopulate((void *)ttm, dev); + ttm_dma_unpopulate((void *)ttm, dev, true); return; } #endif diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index a0a839b..449cc65 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -789,7 +789,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) #ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl()) { - ttm_dma_unpopulate(>t->ttm, rdev->dev); + ttm_dma_unpopulate(>t->ttm, rdev->dev, true); return; } #endif diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index c7f01a4..4cda764 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -969,7 +969,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], pool->size, ctx); if (unlikely(ret != 0)) { - ttm_dma_unpopulate(ttm_dma, dev); + ttm_dma_unpopulate(ttm_dma, dev, false); return -ENOMEM; } @@ -998,14 +998,14 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, while (num_pages) { ret = ttm_dma_pool_get_pages(pool, ttm_dma, i); if (ret != 0) { - ttm_dma_unpopulate(ttm_dma, dev); + ttm_dma_unpopulate(ttm_dma, dev, false); return -ENOMEM; } ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], pool->size, ctx); if (unlikely(ret != 0)) { - ttm_dma_unpopulate(ttm_dma, dev); + ttm_dma_unpopulate(ttm_dma, dev, false); return -ENOMEM; } @@ -1016,7 +1016,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, if (unlikely(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)) { ret = ttm_tt_swapin(ttm); if (unlikely(ret != 0)) { - ttm_dma_unpopulate(ttm_dma, dev); + ttm_dma_unpopulate(ttm_dma, dev, true); return ret; } } @@ -1027,7 +1027,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, EXPORT_SYMBOL_GPL(ttm_dma_populate); /* Put all pages in pages list to correct pool to wait for reuse */ -void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) +void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev, + bool update_glob_count) { struct ttm_tt *ttm = &ttm_dma->ttm; struct dma_pool *pool; @@ -1049,7 +1050,8 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) continue; count++; - ttm_mem_global_free_page(ttm->glob->mem_glob, + if (update_glob_count) + ttm_mem_global_free_page(ttm->glob->mem_glob, d_page->p, pool->size); ttm_dma_page_put(pool, d_page); } @@ -1094,11 +1096,12 @@ 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, + if (update_glob_count) + ttm_mem_global_free_page(ttm->glob->mem_glob, d_page->p, pool->size); ttm_dma_page_put(pool, d_page); } - } else { + } else if (update_glob_count) { for (i = 0; i < count; i++) { ttm_mem_global_free_page(ttm->glob->mem_glob, ttm->pages[i], pool->size); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index 22231bc..38df05d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c @@ -681,7 +681,7 @@ static void vmw_ttm_unpopulate(struct ttm_tt *ttm) size_t size = ttm_round_pot(ttm->num_pages * sizeof(dma_addr_t)); - ttm_dma_unpopulate(&vmw_tt->dma_ttm, dev_priv->dev->dev); + ttm_dma_unpopulate(&vmw_tt->dma_ttm, dev_priv->dev->dev, true); ttm_mem_global_free(glob, size); } else ttm_pool_unpopulate(ttm); diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h index 4d9b019..8518cd5 100644 --- a/include/drm/ttm/ttm_page_alloc.h +++ b/include/drm/ttm/ttm_page_alloc.h @@ -92,7 +92,8 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data); int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, struct ttm_operation_ctx *ctx); -void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev); +void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev, + bool update_glob_count); #else static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, @@ -114,7 +115,7 @@ static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, return -ENOMEM; } static inline void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, - struct device *dev) + struct device *dev, bool update_glob_count); { } #endif