drm: Branch 'master' - 3 commits

[email protected] (Alex Deucher)
Newsgroups gmane.comp.video.dri.patches
Message-ID <[email protected]>
 amdgpu/amdgpu_device.c   |   24 +++++++-----------------
 amdgpu/amdgpu_internal.h |    4 ++--
 amdgpu/amdgpu_vamgr.c    |    6 +++---
 3 files changed, 12 insertions(+), 22 deletions(-)

New commits:
commit fe7cb34eda1855ac9770bc9f3e582897000e41b0
Author: Alex Xie <[email protected]>
Date:   Sat Jan 28 21:50:44 2017 +0200

    amdgpu: vamgr can be a struct instead of a pointer
    
    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.
    
    Reviewed-by: Edward O'Callaghan <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>
    Signed-off-by: Alex Xie <[email protected]>
    Reviewed-by: Christian König <[email protected]>
    [Grazvydas Ignotas: rebase, correct a typo in commit message]
    Signed-off-by: Alex Deucher <[email protected]>

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);
commit 067e9a1d47a8373b3145481a70fec84ce8e76441
Author: Alex Xie <[email protected]>
Date:   Sat Jan 28 21:50:36 2017 +0200

    amdgpu: vamgr_32 can be a struct instead of a pointer
    
    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.
    
    Reviewed-by: Edward O'Callaghan <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>
    Signed-off-by: Alex Xie <[email protected]>
    Reviewed-by: Christian König <[email protected]>
    [Grazvydas Ignotas: rebase, correct a typo in commit message]
    Signed-off-by: Alex Deucher <[email protected]>

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);
 	}
commit 7a03cdf6a703911d2a8e8ab0781f1e6b88412329
Author: Alex Xie <[email protected]>
Date:   Sat Jan 28 21:49:30 2017 +0200

    amdgpu: Free/uninit vamgr_32 in theoretically correct order
    
    vamgr_32 is a region inside general VAM range. It is better to free and
    deinitialize it before general VAM range.
    
    Reviewed-by: Edward O'Callaghan <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>
    Signed-off-by: Alex Xie <[email protected]>
    Reviewed-by: Christian König <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>

diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index f4ede03..cad7133 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -131,10 +131,10 @@ static int amdgpu_get_auth(int fd, int *auth)
 
 static void amdgpu_device_free_internal(amdgpu_device_handle dev)
 {
-	amdgpu_vamgr_deinit(dev->vamgr);
-	free(dev->vamgr);
 	amdgpu_vamgr_deinit(dev->vamgr_32);
 	free(dev->vamgr_32);
+	amdgpu_vamgr_deinit(dev->vamgr);
+	free(dev->vamgr);
 	util_hash_table_destroy(dev->bo_flink_names);
 	util_hash_table_destroy(dev->bo_handles);
 	pthread_mutex_destroy(&dev->bo_table_mutex);

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

--
_______________________________________________
Dri-patches mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.