From patchwork Fri Sep 22 12:13:25 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: 9965927 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 56C03600C5 for ; Fri, 22 Sep 2017 12:14:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AF3F2988E for ; Fri, 22 Sep 2017 12:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FD5F29893; Fri, 22 Sep 2017 12:14:11 +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 C41B92988E for ; Fri, 22 Sep 2017 12:14:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B5656E9D1; Fri, 22 Sep 2017 12:13:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CE346E9C4; Fri, 22 Sep 2017 12:13:39 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id f4so1108541wmh.4; Fri, 22 Sep 2017 05:13:39 -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=cKdQ9GQxNrHn6PwDhlITotWuvwxk6Aad+sG7mmX9sMo=; b=E28HDvRR9jRcVB/ZtCAtVFC9wNNOBgY/O/88Ajc7WT9ZMmAwWiHdHmRUs5PhZzELJ+ 2zCC5qyemjMSvKGXa2VOW8W9wCEBi7aNkZHdP8f6cMRLtaiP9B0qyiuJJvDXp7yfN87H Lik9nlGZE6tEuuEA+26cY492Q2YKICV8sskmdEwZMts7iHImc+2WPGIsNIWUSi2R0QIW y3UcJzAnfnHieyiT7sPz3qZ170MQdSrtddkGflUi/HrmkdvsMipwYqQMwS7H6FWwnsha dcCMQNQWbVDWhg/fpUARSZCNV/6uOIr9OfSpkzjczHDco/HWIovTllFldzrs10uVWH/A 8ntA== 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=cKdQ9GQxNrHn6PwDhlITotWuvwxk6Aad+sG7mmX9sMo=; b=j0axaJTiN+hzP+MQNBdjVaH3MEngjGb/3llLB+n0whk7uN9QlOrOh4cHQXDTnzcP1+ vm9QT/cAEzq912GpL9RLw/NgXJIyIpfv1M7VHpTeTDj0ImAbUOSBhG+4pBHT1/JYJ5+T WAuZ9ksoNiFzw2SltjqOnnPHPAEPNh0o5Zzo45fOVRBAoGFPQOfPS7u5bcN0D17/HR0T EvquIj6o0ye0ZnuT2Gk+mPnLSwzbEOzJAvOUxJ4QeANAxeIpSTNLp9kIBf7eKTLeCFTq TlI1uguZXYNfx9JaKEuVDTN9aEUea7xVWfyZiuPTuamlh4R8SqTI32HjPpgmmGCI/hlT +v0w== X-Gm-Message-State: AHPjjUhW5q8yDzAHGvWNg2scQOuxyBowrUH5nSjGUmg0ROpCgaT0eDCT IkVdryj4xSUjs7ywyfx22WmeRzkb X-Google-Smtp-Source: AOwi7QAZM3hICv/B7ewuCkQXSoNtxa7qInDxDXCXp9jtH9q9aLUNXQe/adz+eZB6V+uB6m8gNc6WIg== X-Received: by 10.28.4.135 with SMTP id 129mr3815399wme.34.1506082417746; Fri, 22 Sep 2017 05:13:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 05:13:36 -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 9/9] drm/amdgpu: add VM support for huge pages Date: Fri, 22 Sep 2017 14:13:25 +0200 Message-Id: <1506082405-1556-9-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 Convert GTT mappings into linear ones for huge page handling. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 3c86381..16454bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1732,6 +1732,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 +1746,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 < 64) { + 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)