dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Emil Velikov <emil.l.velikov@gmail.com>
To: "Christian König" <deathsimple@vodafone.de>,
	dri-devel@lists.freedesktop.org
Cc: "mesa-dev@lists.freedesktop.org" <mesa-dev@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle
Date: Mon, 24 Aug 2015 16:10:02 +0100	[thread overview]
Message-ID: <55DB33CA.4000609@gmail.com> (raw)
In-Reply-To: <1440409410-7907-2-git-send-email-deathsimple@vodafone.de>

[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

      parent reply	other threads:[~2015-08-24 15:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=55DB33CA.4000609@gmail.com \
    --to=emil.l.velikov@gmail.com \
    --cc=deathsimple@vodafone.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mesa-dev@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