From: Grazvydas Ignotas <notasas@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org, Alex Xie <AlexBin.Xie@amd.com>
Subject: [PATCH libdrm 3/3] amdgpu: vamgr can be a struct instead of a pointer
Date: Sat, 28 Jan 2017 21:50:44 +0200 [thread overview]
Message-ID: <1485633044-4965-1-git-send-email-notasas@gmail.com> (raw)
From: Alex Xie <AlexBin.Xie@amd.com>
vamgr 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 <AlexBin.Xie@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
[Grazvydas Ignotas: rebase, correct a typo in commit message]
---
amdgpu/amdgpu_device.c | 16 +++++-----------
amdgpu/amdgpu_internal.h | 2 +-
amdgpu/amdgpu_vamgr.c | 2 +-
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index 11714e4..f473d2d 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -132,8 +132,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);
- amdgpu_vamgr_deinit(dev->vamgr);
- free(dev->vamgr);
+ amdgpu_vamgr_deinit(&dev->vamgr);
util_hash_table_destroy(dev->bo_flink_names);
util_hash_table_destroy(dev->bo_handles);
pthread_mutex_destroy(&dev->bo_table_mutex);
@@ -254,16 +253,12 @@ int amdgpu_device_initialize(int fd,
if (r)
goto cleanup;
- dev->vamgr = calloc(1, sizeof(struct amdgpu_bo_va_mgr));
- if (dev->vamgr == NULL)
- goto cleanup;
-
- amdgpu_vamgr_init(dev->vamgr, dev->dev_info.virtual_address_offset,
+ amdgpu_vamgr_init(&dev->vamgr, dev->dev_info.virtual_address_offset,
dev->dev_info.virtual_address_max,
dev->dev_info.virtual_address_alignment);
max = MIN2(dev->dev_info.virtual_address_max, 0xffffffff);
- start = amdgpu_vamgr_find_va(dev->vamgr,
+ start = amdgpu_vamgr_find_va(&dev->vamgr,
max - dev->dev_info.virtual_address_offset,
dev->dev_info.virtual_address_alignment, 0);
if (start > 0xffffffff)
@@ -282,10 +277,9 @@ int amdgpu_device_initialize(int fd,
free_va:
r = -ENOMEM;
- amdgpu_vamgr_free_va(dev->vamgr, start,
+ amdgpu_vamgr_free_va(&dev->vamgr, start,
max - dev->dev_info.virtual_address_offset);
- amdgpu_vamgr_deinit(dev->vamgr);
- free(dev->vamgr);
+ amdgpu_vamgr_deinit(&dev->vamgr);
cleanup:
if (dev->fd >= 0)
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 7e237ac..cf119a5 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -85,7 +85,7 @@ struct amdgpu_device {
struct drm_amdgpu_info_device dev_info;
struct amdgpu_gpu_info info;
/** The global VA manager for the whole virtual address space */
- struct amdgpu_bo_va_mgr *vamgr;
+ struct amdgpu_bo_va_mgr vamgr;
/** The VA manager for the 32bit address space */
struct amdgpu_bo_va_mgr vamgr_32;
};
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 4dc4253..2b1388e 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -238,7 +238,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
if (flags & AMDGPU_VA_RANGE_32_BIT)
vamgr = &dev->vamgr_32;
else
- vamgr = dev->vamgr;
+ vamgr = &dev->vamgr;
va_base_alignment = MAX2(va_base_alignment, vamgr->va_alignment);
size = ALIGN(size, vamgr->va_alignment);
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
reply other threads:[~2017-01-28 19:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485633044-4965-1-git-send-email-notasas@gmail.com \
--to=notasas@gmail.com \
--cc=AlexBin.Xie@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox