All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicolai Hähnle" <nhaehnle@gmail.com>
To: Emil Velikov <emil.l.velikov@gmail.com>, dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH libdrm 2/3] amdgpu: don't mess with shared_handle if amdgpu_bo_import() fails
Date: Mon, 23 Jan 2017 17:14:30 +0100	[thread overview]
Message-ID: <ce6bb726-b57a-a2a8-f63d-6ac9673a128b@gmail.com> (raw)
In-Reply-To: <20170122184813.12995-2-emil.l.velikov@gmail.com>

I don't think is correct. The incoming handle is in shared_handle, not 
in handle. Once the code block around line 310 has executed, 
shared_handle is the handle produced by drmPrimeFDToHandle, and closing 
it on error (as the code currently does) should be the correct thing to do.

The only possible issue is that I'm seeing is that perhaps the handle 
should be closed _before_ the unlock. Maybe someone else knows the details.

Cheers,
Nicolai

On 22.01.2017 19:48, Emil Velikov wrote:
> Do not close the handle if someone else has created it. Afaict there's
> no change of ownership implied if the function fails. Thus the caller is
> responsible to doing the right thing - trying again, closing the handle
> and/or other.
>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> ---
> Not 100% sure if it's the correct thing.
> ---
>  amdgpu/amdgpu_bo.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index c9f31587..24fa8880 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -310,7 +310,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>  		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;
>  		}
>  		lseek(shared_handle, 0, SEEK_SET);
> @@ -355,9 +354,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
>  	bo = calloc(1, sizeof(struct amdgpu_bo));
>  	if (!bo) {
>  		pthread_mutex_unlock(&dev->bo_table_mutex);
> -		if (type == amdgpu_bo_handle_type_dma_buf_fd) {
> -			amdgpu_close_kms_handle(dev, shared_handle);
> -		}
>  		return -ENOMEM;
>  	}
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-01-23 16:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 18:48 [PATCH libdrm 1/3] amdgpu: add missing unlock on drmPrimeFDToHandle() failure Emil Velikov
     [not found] ` <20170122184813.12995-1-emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-22 18:48   ` [PATCH libdrm 2/3] amdgpu: don't mess with shared_handle if amdgpu_bo_import() fails Emil Velikov
2017-01-23 16:14     ` Nicolai Hähnle [this message]
2017-01-24  3:53       ` Emil Velikov
2017-01-23 16:15   ` [PATCH libdrm 1/3] amdgpu: add missing unlock on drmPrimeFDToHandle() failure Nicolai Hähnle
2017-01-22 18:48 ` [PATCH libdrm 3/3] amdgpu: rework and remove amdgpu_get_auth() Emil Velikov
2017-03-07  0:45   ` Emil Velikov
     [not found]     ` <CACvgo50BMP2qZsFzJK7Jmc-sAJkz7NVGKz0XjxZP3dMGs7_wtg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-07  0:47       ` Emil Velikov
2017-08-21 12:31   ` Emil Velikov
2017-08-21 12:56     ` Christian König
2017-08-21 16:37     ` Daniel Vetter

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=ce6bb726-b57a-a2a8-f63d-6ac9673a128b@gmail.com \
    --to=nhaehnle@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    /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 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.