From patchwork Sat Jan 28 19:49:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 9543445 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 CD4936046A for ; Sat, 28 Jan 2017 19:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDE2B28178 for ; Sat, 28 Jan 2017 19:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1C9D28338; Sat, 28 Jan 2017 19:49:42 +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 125E728178 for ; Sat, 28 Jan 2017 19:49:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89D956E0A1; Sat, 28 Jan 2017 19:49:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id E90936E09E; Sat, 28 Jan 2017 19:49:37 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id q89so28458868lfi.1; Sat, 28 Jan 2017 11:49:37 -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=CXlZnhuGaNK4OOqMK5uE8oZQ0oTw+1GX8dSr017p/Xs=; b=tGGAyV85yDkNiQues8WcXy08bBiPNfh4BdVqcw/UlZymLC3vdbt+FqARj6IYCQ2cqF ZhwnokzkZXBFu2EZepfDoVR/4qYT6KbQ6x2PU4QyVWNw3qkDc9oahwQYp6Ck2OmgQttA iJwplIpvXywbeGzmOpmUW64+bfniymUZAb0sgTYdNLY6hAtJK/pKLsaZz+UToPEJmn6A t1kNhA8d/df8E+N4ecqUSr8hkcSPIt1mnZiX0LVnLQt/TwSvKGb1GGwGkqQC3YPSKqGp mQ5MD7Y8q87sDZDVKUI27ZmZ5CQlNGHnb3GzyJKphGVI0wSutz2NJUUg7a6vFJOHFuHk 3qaw== 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=CXlZnhuGaNK4OOqMK5uE8oZQ0oTw+1GX8dSr017p/Xs=; b=tc3YuisSP9MlcHF1OCiveL0aY+2FYybbtZ3NKyHUL0JDfTUKkAlflk2rlt+jBQ1bhS MNKPwvNeKCsP2tFh1z4uDlWzqwGCuQFZchpwt6NTuHpeS6K8vr6QKfSSD2X0vvbofsOC Je+QpvXBQxJKVXCYixqTQUzMAnoJwe31rE6yrLJBuo8CKENfTDwADH9MWLJVqJTlmpMp gsHKeykLoX7UvqKk+zOT57+AuV6tW/5GXEp5hof0Rgwv9VtwyH/xO6yhnj+mRENxQiQl 2/hDy0uFnquMZoWgwk18kOziAYmFC+p0gi/Pt55KBp0a3/tcYnXRyF9kUKaYF1YsWkGO kuhQ== X-Gm-Message-State: AIkVDXJRkNQqzU/xKYvryg7aCxHwhXRqzr7kJ1BPOpy9NedamFb7txlh9Z+CLbzlk/yKqQ== X-Received: by 10.25.221.193 with SMTP id w62mr4535894lfi.169.1485632975984; Sat, 28 Jan 2017 11:49:35 -0800 (PST) Received: from localhost.localdomain ([5.20.238.37]) by smtp.gmail.com with ESMTPSA id e23sm2334912lji.29.2017.01.28.11.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Jan 2017 11:49:35 -0800 (PST) From: Grazvydas Ignotas To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/3] amdgpu: vamgr_32 can be a struct instead of a pointer Date: Sat, 28 Jan 2017 21:49:31 +0200 Message-Id: <1485632972-4790-3-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485632972-4790-1-git-send-email-notasas@gmail.com> References: <1485632972-4790-1-git-send-email-notasas@gmail.com> MIME-Version: 1.0 Cc: amd-gfx@lists.freedesktop.org, Alex Xie 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: Alex Xie vamgr_32 is an integral part of amdgpu_device. We don't need to calloc and free it. This can save CPU time, reduce heap fragmentation. Signed-off-by: Alex Xie Reviewed-by: Christian König [Grazvydas Ignotas: rebase, correct a typo in commit message] --- amdgpu/amdgpu_device.c | 8 ++------ amdgpu/amdgpu_internal.h | 2 +- amdgpu/amdgpu_vamgr.c | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index cad7133..11714e4 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -131,8 +131,7 @@ static int amdgpu_get_auth(int fd, int *auth) static void amdgpu_device_free_internal(amdgpu_device_handle dev) { - amdgpu_vamgr_deinit(dev->vamgr_32); - free(dev->vamgr_32); + amdgpu_vamgr_deinit(&dev->vamgr_32); amdgpu_vamgr_deinit(dev->vamgr); free(dev->vamgr); util_hash_table_destroy(dev->bo_flink_names); @@ -270,10 +269,7 @@ int amdgpu_device_initialize(int fd, if (start > 0xffffffff) goto free_va; /* shouldn't get here */ - dev->vamgr_32 = calloc(1, sizeof(struct amdgpu_bo_va_mgr)); - if (dev->vamgr_32 == NULL) - goto free_va; - amdgpu_vamgr_init(dev->vamgr_32, start, max, + amdgpu_vamgr_init(&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); *major_version = dev->major_version; diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 4f039b6..7e237ac 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -87,7 +87,7 @@ struct amdgpu_device { /** The global VA manager for the whole virtual address space */ struct amdgpu_bo_va_mgr *vamgr; /** The VA manager for the 32bit address space */ - struct amdgpu_bo_va_mgr *vamgr_32; + struct amdgpu_bo_va_mgr vamgr_32; }; struct amdgpu_bo { diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index 8a707cb..4dc4253 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -236,7 +236,7 @@ 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; + vamgr = &dev->vamgr_32; else vamgr = dev->vamgr; @@ -249,7 +249,7 @@ 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; + vamgr = &dev->vamgr_32; *va_base_allocated = amdgpu_vamgr_find_va(vamgr, size, va_base_alignment, va_base_required); }