Re: [Mesa-dev] [PATCH 5/5] anv: Update the teardown in reverse order of the anv_CreateDevice

2016-11-25 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 

On Fri, Nov 25, 2016 at 6:34 AM, Mun Gwan-gyeong  wrote:

> This updates releasing of resource in reverse order of the anv_CreateDevice
> to anv_DestroyDevice.
> And it fixes resource leak in pthread_mutex, pthread_cond, anv_gem_context.
>
> Signed-off-by: Mun Gwan-gyeong 
> ---
>  src/intel/vulkan/anv_device.c | 23 ++-
>  1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 1964fb7..76ea4cf 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -1007,10 +1007,10 @@ void anv_DestroyDevice(
>  {
> ANV_FROM_HANDLE(anv_device, device, _device);
>
> -   anv_queue_finish(>queue);
> -
> anv_device_finish_blorp(device);
>
> +   anv_queue_finish(>queue);
> +
>  #ifdef HAVE_VALGRIND
> /* We only need to free these to prevent valgrind errors.  The backing
>  * BO will go away in a couple of lines so we don't actually leak.
> @@ -1018,22 +1018,27 @@ void anv_DestroyDevice(
> anv_state_pool_free(>dynamic_state_pool,
> device->border_colors);
>  #endif
>
> +   anv_scratch_pool_finish(device, >scratch_pool);
> +
> anv_gem_munmap(device->workaround_bo.map, device->workaround_bo.size);
> anv_gem_close(device, device->workaround_bo.gem_handle);
>
> -   anv_bo_pool_finish(>batch_bo_pool);
> -   anv_state_pool_finish(>dynamic_state_pool);
> -   anv_block_pool_finish(>dynamic_state_block_pool);
> -   anv_state_pool_finish(>instruction_state_pool);
> -   anv_block_pool_finish(>instruction_block_pool);
> anv_state_pool_finish(>surface_state_pool);
> anv_block_pool_finish(>surface_state_block_pool);
> -   anv_scratch_pool_finish(device, >scratch_pool);
> +   anv_state_pool_finish(>instruction_state_pool);
> +   anv_block_pool_finish(>instruction_block_pool);
> +   anv_state_pool_finish(>dynamic_state_pool);
> +   anv_block_pool_finish(>dynamic_state_block_pool);
>
> -   close(device->fd);
> +   anv_bo_pool_finish(>batch_bo_pool);
>
> +   pthread_cond_destroy(>queue_submit);
> pthread_mutex_destroy(>mutex);
>
> +   anv_gem_destroy_context(device, device->context_id);
> +
> +   close(device->fd);
> +
> vk_free(>alloc, device);
>  }
>
> --
> 2.10.2
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/5] anv: Update the teardown in reverse order of the anv_CreateDevice

2016-11-25 Thread Mun Gwan-gyeong
This updates releasing of resource in reverse order of the anv_CreateDevice
to anv_DestroyDevice.
And it fixes resource leak in pthread_mutex, pthread_cond, anv_gem_context.

Signed-off-by: Mun Gwan-gyeong 
---
 src/intel/vulkan/anv_device.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 1964fb7..76ea4cf 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1007,10 +1007,10 @@ void anv_DestroyDevice(
 {
ANV_FROM_HANDLE(anv_device, device, _device);
 
-   anv_queue_finish(>queue);
-
anv_device_finish_blorp(device);
 
+   anv_queue_finish(>queue);
+
 #ifdef HAVE_VALGRIND
/* We only need to free these to prevent valgrind errors.  The backing
 * BO will go away in a couple of lines so we don't actually leak.
@@ -1018,22 +1018,27 @@ void anv_DestroyDevice(
anv_state_pool_free(>dynamic_state_pool, device->border_colors);
 #endif
 
+   anv_scratch_pool_finish(device, >scratch_pool);
+
anv_gem_munmap(device->workaround_bo.map, device->workaround_bo.size);
anv_gem_close(device, device->workaround_bo.gem_handle);
 
-   anv_bo_pool_finish(>batch_bo_pool);
-   anv_state_pool_finish(>dynamic_state_pool);
-   anv_block_pool_finish(>dynamic_state_block_pool);
-   anv_state_pool_finish(>instruction_state_pool);
-   anv_block_pool_finish(>instruction_block_pool);
anv_state_pool_finish(>surface_state_pool);
anv_block_pool_finish(>surface_state_block_pool);
-   anv_scratch_pool_finish(device, >scratch_pool);
+   anv_state_pool_finish(>instruction_state_pool);
+   anv_block_pool_finish(>instruction_block_pool);
+   anv_state_pool_finish(>dynamic_state_pool);
+   anv_block_pool_finish(>dynamic_state_block_pool);
 
-   close(device->fd);
+   anv_bo_pool_finish(>batch_bo_pool);
 
+   pthread_cond_destroy(>queue_submit);
pthread_mutex_destroy(>mutex);
 
+   anv_gem_destroy_context(device, device->context_id);
+
+   close(device->fd);
+
vk_free(>alloc, device);
 }
 
-- 
2.10.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev