[libdrm] amdgpu: don't call add_handle_to_table for KMS BO exports

Submitted by Marek Olšák on July 6, 2018, 8:16 p.m.

Details

Message ID 1530908218-10976-1-git-send-email-maraeo@gmail.com
State New
Headers show
Series "amdgpu: don't call add_handle_to_table for KMS BO exports" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Marek Olšák July 6, 2018, 8:16 p.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 amdgpu/amdgpu_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 9e37b14..9e7f958 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -233,21 +233,21 @@  int amdgpu_bo_export(amdgpu_bo_handle bo,
 	switch (type) {
 	case amdgpu_bo_handle_type_gem_flink_name:
 		r = amdgpu_bo_export_flink(bo);
 		if (r)
 			return r;
 
 		*shared_handle = bo->flink_name;
 		return 0;
 
 	case amdgpu_bo_handle_type_kms:
-		amdgpu_add_handle_to_table(bo);
+		/* Don't add the handle to the hash table. It can't be reimported. */
 		*shared_handle = bo->handle;
 		return 0;
 
 	case amdgpu_bo_handle_type_dma_buf_fd:
 		amdgpu_add_handle_to_table(bo);
 		return drmPrimeHandleToFD(bo->dev->fd, bo->handle,
 					  DRM_CLOEXEC | DRM_RDWR,
 					  (int*)shared_handle);
 	}
 	return -EINVAL;

Comments

On 07/07/2018 04:16 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> ---
>   amdgpu/amdgpu_bo.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
> index 9e37b14..9e7f958 100644
> --- a/amdgpu/amdgpu_bo.c
> +++ b/amdgpu/amdgpu_bo.c
> @@ -233,21 +233,21 @@ int amdgpu_bo_export(amdgpu_bo_handle bo,
>   	switch (type) {
>   	case amdgpu_bo_handle_type_gem_flink_name:
>   		r = amdgpu_bo_export_flink(bo);
>   		if (r)
>   			return r;
>
>   		*shared_handle = bo->flink_name;
>   		return 0;
>
>   	case amdgpu_bo_handle_type_kms:
> -		amdgpu_add_handle_to_table(bo);
> +		/* Don't add the handle to the hash table. It can't be reimported. */

Yeah, good catch.

Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>

That's really likely to confuse someone.
Maybe we need to consider to separate it into a new function.

Jerry

>   		*shared_handle = bo->handle;
>   		return 0;
>
>   	case amdgpu_bo_handle_type_dma_buf_fd:
>   		amdgpu_add_handle_to_table(bo);
>   		return drmPrimeHandleToFD(bo->dev->fd, bo->handle,
>   					  DRM_CLOEXEC | DRM_RDWR,
>   					  (int*)shared_handle);
>   	}
>   	return -EINVAL;
>