All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] amdgpu: remove sequence mutex
@ 2015-08-24  9:43 Christian König
  2015-08-24  9:43 ` [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle Christian König
  0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2015-08-24  9:43 UTC (permalink / raw)
  To: dri-devel

From: Christian König <christian.koenig@amd.com>

It's not used any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 amdgpu/amdgpu_cs.c       | 10 ----------
 amdgpu/amdgpu_internal.h |  3 ---
 2 files changed, 13 deletions(-)

diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 41071fd..ae78a4c 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -58,10 +58,6 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
 
 	gpu_context->dev = dev;
 
-	r = pthread_mutex_init(&gpu_context->sequence_mutex, NULL);
-	if (r)
-		goto error;
-
 	/* Create the context */
 	memset(&args, 0, sizeof(args));
 	args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
@@ -75,7 +71,6 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
 	return 0;
 
 error:
-	pthread_mutex_destroy(&gpu_context->sequence_mutex);
 	free(gpu_context);
 	return r;
 }
@@ -96,8 +91,6 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context)
 	if (NULL == context)
 		return -EINVAL;
 
-	pthread_mutex_destroy(&context->sequence_mutex);
-
 	/* now deal with kernel side */
 	memset(&args, 0, sizeof(args));
 	args.in.op = AMDGPU_CTX_OP_FREE_CTX;
@@ -195,8 +188,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
 		chunk_data[i].ib_data.flags = ib->flags;
 	}
 
-	pthread_mutex_lock(&context->sequence_mutex);
-
 	if (user_fence) {
 		i = cs.in.num_chunks++;
 
@@ -249,7 +240,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
 	ibs_request->seq_no = cs.out.handle;
 
 error_unlock:
-	pthread_mutex_unlock(&context->sequence_mutex);
 	free(dependencies);
 	return r;
 }
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index 7161db0..a6051ef 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -108,9 +108,6 @@ struct amdgpu_bo_list {
 
 struct amdgpu_context {
 	struct amdgpu_device *dev;
-	/** Mutex for accessing fences and to maintain command submissions
-	    in good sequence. */
-	pthread_mutex_t sequence_mutex;
 	/* context id*/
 	uint32_t id;
 };
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
  2015-08-24  9:43 [PATCH 1/2] amdgpu: remove sequence mutex Christian König
@ 2015-08-24  9:43 ` Christian König
  2015-08-24 13:55   ` Zhou, Jammy
  2015-08-24 15:10   ` Emil Velikov
  0 siblings, 2 replies; 5+ messages in thread
From: Christian König @ 2015-08-24  9:43 UTC (permalink / raw)
  To: dri-devel

From: Christian König <christian.koenig@amd.com>

Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 amdgpu/amdgpu_bo.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index dab3804..adf4253 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -289,6 +289,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 	int dma_fd;
 	uint64_t dma_buf_size = 0;
 
+	/* We must maintain a list of pairs <handle, bo>, so that we always
+	 * return the same amdgpu_bo instance for the same handle. */
+	pthread_mutex_lock(&dev->bo_table_mutex);
+
 	/* Convert a DMA buf handle to a KMS handle now. */
 	if (type == amdgpu_bo_handle_type_dma_buf_fd) {
 		uint32_t handle;
@@ -303,6 +307,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 		/* Query the buffer size. */
 		size = lseek(shared_handle, 0, SEEK_END);
 		if (size == (off_t)-1) {
+			pthread_mutex_unlock(&dev->bo_table_mutex);
 			amdgpu_close_kms_handle(dev, handle);
 			return -errno;
 		}
@@ -312,10 +317,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 		shared_handle = handle;
 	}
 
-	/* We must maintain a list of pairs <handle, bo>, so that we always
-	 * return the same amdgpu_bo instance for the same handle. */
-	pthread_mutex_lock(&dev->bo_table_mutex);
-
 	/* If we have already created a buffer with this handle, find it. */
 	switch (type) {
 	case amdgpu_bo_handle_type_gem_flink_name:
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
  2015-08-24  9:43 ` [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle Christian König
@ 2015-08-24 13:55   ` Zhou, Jammy
  2015-08-25 14:31     ` Alex Deucher
  2015-08-24 15:10   ` Emil Velikov
  1 sibling, 1 reply; 5+ messages in thread
From: Zhou, Jammy @ 2015-08-24 13:55 UTC (permalink / raw)
  To: Christian König, dri-devel@lists.freedesktop.org

Both patches are Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>

Regards,
Jammy

-----Original Message-----
From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of Christian K?nig
Sent: Monday, August 24, 2015 5:44 PM
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle

From: Christian König <christian.koenig@amd.com>

Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 amdgpu/amdgpu_bo.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index dab3804..adf4253 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -289,6 +289,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 	int dma_fd;
 	uint64_t dma_buf_size = 0;
 
+	/* We must maintain a list of pairs <handle, bo>, so that we always
+	 * return the same amdgpu_bo instance for the same handle. */
+	pthread_mutex_lock(&dev->bo_table_mutex);
+
 	/* Convert a DMA buf handle to a KMS handle now. */
 	if (type == amdgpu_bo_handle_type_dma_buf_fd) {
 		uint32_t handle;
@@ -303,6 +307,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 		/* Query the buffer size. */
 		size = lseek(shared_handle, 0, SEEK_END);
 		if (size == (off_t)-1) {
+			pthread_mutex_unlock(&dev->bo_table_mutex);
 			amdgpu_close_kms_handle(dev, handle);
 			return -errno;
 		}
@@ -312,10 +317,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 		shared_handle = handle;
 	}
 
-	/* We must maintain a list of pairs <handle, bo>, so that we always
-	 * return the same amdgpu_bo instance for the same handle. */
-	pthread_mutex_lock(&dev->bo_table_mutex);
-
 	/* If we have already created a buffer with this handle, find it. */
 	switch (type) {
 	case amdgpu_bo_handle_type_gem_flink_name:
--
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
  2015-08-24  9:43 ` [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle Christian König
  2015-08-24 13:55   ` Zhou, Jammy
@ 2015-08-24 15:10   ` Emil Velikov
  1 sibling, 0 replies; 5+ messages in thread
From: Emil Velikov @ 2015-08-24 15:10 UTC (permalink / raw)
  To: Christian König, dri-devel; +Cc: mesa-dev@lists.freedesktop.org

[CCing mesa-dev as mesa will need similar fixes]

Hi Christian,

On 24/08/15 10:43, Christian König wrote:
> From: Christian König <christian.koenig@amd.com>
> 
> Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  amdgpu/amdgpu_bo.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index dab3804..adf4253 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -289,6 +289,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>  	int dma_fd;
>  	uint64_t dma_buf_size = 0;
>  
> +	/* We must maintain a list of pairs <handle, bo>, so that we always
> +	 * return the same amdgpu_bo instance for the same handle. */
> +	pthread_mutex_lock(&dev->bo_table_mutex);
> +
>  	/* Convert a DMA buf handle to a KMS handle now. */
>  	if (type == amdgpu_bo_handle_type_dma_buf_fd) {
>  		uint32_t handle;
> @@ -303,6 +307,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>  		/* Query the buffer size. */
>  		size = lseek(shared_handle, 0, SEEK_END);
>  		if (size == (off_t)-1) {
> +			pthread_mutex_unlock(&dev->bo_table_mutex);
>  			amdgpu_close_kms_handle(dev, handle);
>  			return -errno;
>  		}
> @@ -312,10 +317,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>  		shared_handle = handle;
>  	}
>  
> -	/* We must maintain a list of pairs <handle, bo>, so that we always
> -	 * return the same amdgpu_bo instance for the same handle. */
> -	pthread_mutex_lock(&dev->bo_table_mutex);
> -
>  	/* If we have already created a buffer with this handle, find it. */
>  	switch (type) {
>  	case amdgpu_bo_handle_type_gem_flink_name:
> 
From a quick look radeon (radeon/radeon_bo_gem.c) will also need a
similar patch.


For consistency sake there are a few mesa users (I'm not suggesting that
you should fix them).

src/gallium/drivers/vc4/vc4_bufmgr.c
src/gallium/winsys/svga/drm/vmw_screen_dri.c
src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c


Cheers,
Emil

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
  2015-08-24 13:55   ` Zhou, Jammy
@ 2015-08-25 14:31     ` Alex Deucher
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2015-08-25 14:31 UTC (permalink / raw)
  To: Zhou, Jammy; +Cc: dri-devel@lists.freedesktop.org

On Mon, Aug 24, 2015 at 9:55 AM, Zhou, Jammy <Jammy.Zhou@amd.com> wrote:
> Both patches are Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>

I pushed the series.  thanks!

Alex

>
> Regards,
> Jammy
>
> -----Original Message-----
> From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of Christian K?nig
> Sent: Monday, August 24, 2015 5:44 PM
> To: dri-devel@lists.freedesktop.org
> Subject: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
>
> From: Christian König <christian.koenig@amd.com>
>
> Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  amdgpu/amdgpu_bo.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index dab3804..adf4253 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -289,6 +289,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>         int dma_fd;
>         uint64_t dma_buf_size = 0;
>
> +       /* We must maintain a list of pairs <handle, bo>, so that we always
> +        * return the same amdgpu_bo instance for the same handle. */
> +       pthread_mutex_lock(&dev->bo_table_mutex);
> +
>         /* Convert a DMA buf handle to a KMS handle now. */
>         if (type == amdgpu_bo_handle_type_dma_buf_fd) {
>                 uint32_t handle;
> @@ -303,6 +307,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>                 /* Query the buffer size. */
>                 size = lseek(shared_handle, 0, SEEK_END);
>                 if (size == (off_t)-1) {
> +                       pthread_mutex_unlock(&dev->bo_table_mutex);
>                         amdgpu_close_kms_handle(dev, handle);
>                         return -errno;
>                 }
> @@ -312,10 +317,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>                 shared_handle = handle;
>         }
>
> -       /* We must maintain a list of pairs <handle, bo>, so that we always
> -        * return the same amdgpu_bo instance for the same handle. */
> -       pthread_mutex_lock(&dev->bo_table_mutex);
> -
>         /* If we have already created a buffer with this handle, find it. */
>         switch (type) {
>         case amdgpu_bo_handle_type_gem_flink_name:
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-25 14:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  9:43 [PATCH 1/2] amdgpu: remove sequence mutex Christian König
2015-08-24  9:43 ` [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle Christian König
2015-08-24 13:55   ` Zhou, Jammy
2015-08-25 14:31     ` Alex Deucher
2015-08-24 15:10   ` Emil Velikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.