<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Thu, Jul 12, 2018, 3:31 AM Michel Dänzer <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2018-07-12 02:47 AM, Marek Olšák wrote:<br>
> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank" rel="noreferrer">marek.olsak@amd.com</a>><br>
> <br>
> ---<br>
>  amdgpu/amdgpu.h    | 7 ++++++-<br>
>  amdgpu/amdgpu_bo.c | 4 ++++<br>
>  2 files changed, 10 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h<br>
> index 36f91058..be83b457 100644<br>
> --- a/amdgpu/amdgpu.h<br>
> +++ b/amdgpu/amdgpu.h<br>
> @@ -77,21 +77,26 @@ struct drm_amdgpu_info_hw_ip;<br>
>   *<br>
>  */<br>
>  enum amdgpu_bo_handle_type {<br>
>       /** GEM flink name (needs DRM authentication, used by DRI2) */<br>
>       amdgpu_bo_handle_type_gem_flink_name = 0,<br>
>  <br>
>       /** KMS handle which is used by all driver ioctls */<br>
>       amdgpu_bo_handle_type_kms = 1,<br>
>  <br>
>       /** DMA-buf fd handle */<br>
> -     amdgpu_bo_handle_type_dma_buf_fd = 2<br>
> +     amdgpu_bo_handle_type_dma_buf_fd = 2,<br>
> +<br>
> +     /** KMS handle, but re-importing as a DMABUF handle through<br>
> +      *  drmPrimeHandleToFD is forbidden. (Glamor does that)<br>
> +      */<br>
> +     amdgpu_bo_handle_type_kms_noimport = 3,<br>
>  };<br>
>  <br>
>  /** Define known types of GPU VM VA ranges */<br>
>  enum amdgpu_gpu_va_range<br>
>  {<br>
>       /** Allocate from "normal"/general range */<br>
>       amdgpu_gpu_va_range_general = 0<br>
>  };<br>
>  <br>
>  enum amdgpu_sw_info {<br>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c<br>
> index 9e37b149..d29be244 100644<br>
> --- a/amdgpu/amdgpu_bo.c<br>
> +++ b/amdgpu/amdgpu_bo.c<br>
> @@ -234,20 +234,22 @@ int amdgpu_bo_export(amdgpu_bo_handle bo,<br>
>       case amdgpu_bo_handle_type_gem_flink_name:<br>
>               r = amdgpu_bo_export_flink(bo);<br>
>               if (r)<br>
>                       return r;<br>
>  <br>
>               *shared_handle = bo->flink_name;<br>
>               return 0;<br>
>  <br>
>       case amdgpu_bo_handle_type_kms:<br>
>               amdgpu_add_handle_to_table(bo);<br>
> +             /* fall through */<br>
> +     case amdgpu_bo_handle_type_kms_noimport:<br>
>               *shared_handle = bo->handle;<br>
>               return 0;<br>
<br>
What is the rationale for this? I.e. why do you want to not store some<br>
handles in the hash table?</blockquote></div></div><div dir="auto"><br></div><div dir="auto">Because I have the option.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> And how can code using<br>
amdgpu_bo_handle_type_kms_noimport be sure that the BO will never be<br>
re-imported via dma-buf?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That's for the user to decide and prove when it's safe.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The experience with the previous patch has shown that it's hard to keep<br>
track of all possible ways in which BOs are imported, and that if we<br>
miss one, this breaks pretty spectacularly.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">You are assuming that it will be used incorrectly based on your previous bad experience. All I need to do is not to hand the handle to components that would misuse it.</div><div dir="auto"><br></div><div dir="auto">Marek</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
-- <br>
Earthling Michel Dänzer               |               <a href="http://www.amd.com" rel="noreferrer noreferrer" target="_blank">http://www.amd.com</a><br>
Libre software enthusiast             |             Mesa and X developer<br>
</blockquote></div></div></div>