From patchwork Thu Oct 5 13:07:54 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: 9987117 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 BF4576029B for ; Thu, 5 Oct 2017 13:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B043C28C66 for ; Thu, 5 Oct 2017 13:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A514D28C8E; Thu, 5 Oct 2017 13:08:25 +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 6A76428C66 for ; Thu, 5 Oct 2017 13:08:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 917E56E7F6; Thu, 5 Oct 2017 13:08:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2787B6E7F1; Thu, 5 Oct 2017 13:08:17 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id z1so9599423wre.1; Thu, 05 Oct 2017 06:08:17 -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=hwWY7yudVPNZpK6yO3l++AUSbjj3qgsc9MWJAPtZhKg=; b=TRJrGoxhe+bVVoskTzc5Cn0q+WACKxGmBAALOD3EeWfe5UMwo6hHpn6bSDlXrisKhw d/pAQLC1QFW3WfcVYno61Ih5BzjxInXhaEmVH42Y9YM2NEZYmGKoKqfbxRoRt4rVPutX j9Qqmk9x93/QjqE+cHNl7XvMiWvSahozbw3vz7mR6YRD/iDKMAUUbQfgnD+wHck329Mq U9LNq+5Ji/E3AzaIkx28ls4VQRgd3TbbPM0MNKx+BFHrvqkMqP2z7Vk74zq1SJ+7QD2T 4x0cEamoWN7a3X9JIlRXch9tElw1YsNM/kFcycc/wjSm55R1u8jfmxSYoqzDzBoxF0ew OnWQ== 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=hwWY7yudVPNZpK6yO3l++AUSbjj3qgsc9MWJAPtZhKg=; b=VjqODnvS4Sk+SUg5INFNtXu2tlf5ZaMXbIC38adffzWSpjSmBvB+YgK4TFdJ/Ce0sL 3m86jgMRhAXS793SwgZDb1UXrDoGaHtL+cgjITu6pRC8WGtxWTjdEinbgbstgQCpHR0q N0y4oj80LHnDJRvgzJXBu0leDZNuuntPOyTIFefSWG8OORpZsLnI7ogZwaL3Yboruese 5d6UBKHUll3zogpHIWVzRTTSf7KpzPnQlrUZgXFPIvw+K3oYa/pSFiSF0/mtpWMbr38k ap2TQqxeG9jpZBGfiB/uPcVgs775aZtBsSByGWVan7GIsL5lNzRpWhEqUYujzD3d3hvW Urxw== X-Gm-Message-State: AMCzsaVdZKCdYrJZki8tuOLkrKF274C0wfSKRdlXHTv4KbfqFx9ew/55 ga/mWnKPYzGzB27DdA12j3jk53FU X-Google-Smtp-Source: AOwi7QCEzbFNLjiWJhdDuVyZjMXD3f/MmYJTMc+ExXcVu6oucd4wp70reHZOhNjw5fBs1naicU8B2w== X-Received: by 10.223.135.3 with SMTP id a3mr2979865wra.109.1507208895627; Thu, 05 Oct 2017 06:08:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:c12c:1293:87f3:cbfe]) by smtp.gmail.com with ESMTPSA id 133sm15002742wmu.4.2017.10.05.06.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 06:08:15 -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 6/6] drm/amdgpu: add VM support for huge pages v2 Date: Thu, 5 Oct 2017 15:07:54 +0200 Message-Id: <1507208874-3448-6-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507208874-3448-1-git-send-email-deathsimple@vodafone.de> References: <1507208874-3448-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 Convert GTT mappings into linear ones for huge page handling. v2: use fragment size as minimum for linear conversion Signed-off-by: Christian König Reviewed-by: Felix Kuehling Acked-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index bca9eeb..faedecc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1698,6 +1698,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, struct drm_mm_node *nodes, struct dma_fence **fence) { + unsigned min_linear_pages = 1 << adev->vm_manager.fragment_size; uint64_t pfn, start = mapping->start; int r; @@ -1732,6 +1733,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, } do { + dma_addr_t *dma_addr = NULL; uint64_t max_entries; uint64_t addr, last; @@ -1745,15 +1747,32 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, } if (pages_addr) { + uint64_t count; + max_entries = min(max_entries, 16ull * 1024ull); - addr = 0; + for (count = 1; count < max_entries; ++count) { + uint64_t idx = pfn + count; + + if (pages_addr[idx] != + (pages_addr[idx - 1] + PAGE_SIZE)) + break; + } + + if (count < min_linear_pages) { + addr = pfn << PAGE_SHIFT; + dma_addr = pages_addr; + } else { + addr = pages_addr[pfn]; + max_entries = count; + } + } else if (flags & AMDGPU_PTE_VALID) { addr += adev->vm_manager.vram_base_offset; + addr += pfn << PAGE_SHIFT; } - addr += pfn << PAGE_SHIFT; last = min((uint64_t)mapping->last, start + max_entries - 1); - r = amdgpu_vm_bo_update_mapping(adev, exclusive, pages_addr, vm, + r = amdgpu_vm_bo_update_mapping(adev, exclusive, dma_addr, vm, start, last, flags, addr, fence); if (r)