From patchwork Mon Feb 26 13:16:35 2018 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: 10242263 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 693E5602DC for ; Mon, 26 Feb 2018 13:16:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58EEF29FFB for ; Mon, 26 Feb 2018 13:16:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DBDD2A000; Mon, 26 Feb 2018 13:16:45 +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 F1B0229FFB for ; Mon, 26 Feb 2018 13:16:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A281D6E485; Mon, 26 Feb 2018 13:16:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 497996E47B; Mon, 26 Feb 2018 13:16:39 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id z9so17086844wmb.3; Mon, 26 Feb 2018 05:16:39 -0800 (PST) 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=S3115YJT7iTjxwqoYPYJiwtaUsidKegj0dhRMFyysZo=; b=AeqY4ei2ATJZQVoMCP8c9WsGYJWUTj3x9Sb6H0+HvFvY3PSyEh4ZBRB6CSl7lX3Dqw KX+yoQg6rRwA+/A2A/UmGzU7Fy19QC8/y3+IK//lCLlC5pWuofyn24zYDaJTcEOvV2HE KH83KOtbdnU7Q1kOfVzl7fA9qG2e/CDpyr9jdtnkSRx2RzK19GbL3/M+pMhaId8hUvG/ N6mm2I1DNUWqEvgoreARSIOrIMYOq3YJEf2ESsHrn1090txlUM1TfqlGXq3mgatYm03V wBbmqacUi1gX6F+AZYsd3z+5YWJaxk6F+fk408vUh1pSKzL7J9y667eABrqCe+QJsG1h lxYQ== 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=S3115YJT7iTjxwqoYPYJiwtaUsidKegj0dhRMFyysZo=; b=lXw0lI1iFjEH/YBLZT/CDzPAnIfmYFrUza/7PxUWrKVlusDtD9VL9WbBWGl4JDAYhp EpFm5HrTdaqEcdv/NfbyY6g1L1eO6qxPlUILKxg1XxpwzX+uYoGIgdouAI9vDbB7e9mo FMP0pDz2dG5hOPH2ow1mkN6RCM26p06laO+gDTdeQzap+yfdwcuJsm/tLehsgB2S0i6p ILbwXE6jnoZ5nTyoJ0lMMAnMN0Sm51mov6S3Yy0bN+TwLOLX8w9T0LRAPI99bYB63nHk s6LxPYcIadOVMoyh5ecnZGN6efaHpcyEYh1y2YKQOTQHHyDAkuAk6dgzOhxbcm6jLeGy JVPA== X-Gm-Message-State: APf1xPDcYYPaZcOAoVdD6hxU2p0KnfH+03GahFzUGRHCfo/d9AdW+OKs hykzNvZPniT2rdhX1lbZdg0o3w== X-Google-Smtp-Source: AG47ELvL4oEYen7EPe1MDppUAdXzUM1SZYBmNxUBm5MWYgZe3UKjYFpLHR5JGO5pjVl9RldQHZ91/w== X-Received: by 10.28.16.138 with SMTP id 132mr5630144wmq.28.1519650997681; Mon, 26 Feb 2018 05:16:37 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:f91b:e92d:3b5f:700b]) by smtp.gmail.com with ESMTPSA id w15sm10275603wrb.33.2018.02.26.05.16.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 05:16:37 -0800 (PST) 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 libdrm 2/2] amdgpu: add AMDGPU_VA_RANGE_HIGH Date: Mon, 26 Feb 2018 14:16:35 +0100 Message-Id: <20180226131635.54635-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180226131635.54635-1-christian.koenig@amd.com> References: <20180226131635.54635-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 Return high addresses if requested and available. Signed-off-by: Christian König Reviewed-by: Marek Olšák --- amdgpu/amdgpu.h | 1 + amdgpu/amdgpu_device.c | 6 ++++-- amdgpu/amdgpu_internal.h | 1 - amdgpu/amdgpu_vamgr.c | 24 +++++++++++++++++++----- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 928b2a68..36f91058 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1162,6 +1162,7 @@ int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, * Flag to request VA address range in the 32bit address space */ #define AMDGPU_VA_RANGE_32_BIT 0x1 +#define AMDGPU_VA_RANGE_HIGH 0x2 /** * Allocate virtual address range diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index ca0c7987..9ff6ad16 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -268,7 +268,6 @@ int amdgpu_device_initialize(int fd, max = MIN2(dev->dev_info.virtual_address_max, 0x100000000ULL); amdgpu_vamgr_init(&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); - dev->address32_hi = start >> 32; start = max; max = MAX2(dev->dev_info.virtual_address_max, 0x100000000ULL); @@ -323,7 +322,10 @@ int amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info, switch (info) { case amdgpu_sw_info_address32_hi: - *val32 = dev->address32_hi; + if (dev->vamgr_high_32.va_max) + *val32 = dev->vamgr_high_32.va_max >> 32; + else + *val32 = dev->vamgr_32.va_max >> 32; return 0; } return -EINVAL; diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 423880ed..aeb5d651 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -73,7 +73,6 @@ struct amdgpu_device { int flink_fd; unsigned major_version; unsigned minor_version; - uint32_t address32_hi; char *marketing_name; /** List of buffer handles. Protected by bo_table_mutex. */ diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index 58400428..ac1202de 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -201,10 +201,21 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev, { struct amdgpu_bo_va_mgr *vamgr; - if (flags & AMDGPU_VA_RANGE_32_BIT) - vamgr = &dev->vamgr_32; - else - vamgr = &dev->vamgr; + /* Clear the flag when the high VA manager is not initialized */ + if (flags & AMDGPU_VA_RANGE_HIGH && !dev->vamgr_high_32.va_max) + flags &= ~AMDGPU_VA_RANGE_HIGH; + + if (flags & AMDGPU_VA_RANGE_HIGH) { + if (flags & AMDGPU_VA_RANGE_32_BIT) + vamgr = &dev->vamgr_high_32; + else + vamgr = &dev->vamgr_high; + } else { + if (flags & AMDGPU_VA_RANGE_32_BIT) + vamgr = &dev->vamgr_32; + else + vamgr = &dev->vamgr; + } va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment); size = ALIGN(size, vamgr->va_alignment); @@ -215,7 +226,10 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev, if (!(flags & AMDGPU_VA_RANGE_32_BIT) && (*va_base_allocated == AMDGPU_INVALID_VA_ADDRESS)) { /* fallback to 32bit address */ - vamgr = &dev->vamgr_32; + if (flags & AMDGPU_VA_RANGE_HIGH) + vamgr = &dev->vamgr_high_32; + else + vamgr = &dev->vamgr_32; *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size, va_base_alignment, va_base_required); }