All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs
@ 2020-05-06  0:59 Felix Kuehling
  2020-05-06  8:11 ` Christian König
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Kuehling @ 2020-05-06  0:59 UTC (permalink / raw)
  To: amd-gfx

Releasing the AMDGPU BO ref directly leads to problems when BOs were
exported as DMA bufs. Releasing the GEM reference makes sure that the
AMDGPU/TTM BO is not freed too early.

Also take a GEM reference when importing BOs from DMABufs to keep
references to imported BOs balances properly.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Tested-by: Alex Sierra <alex.sierra@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 1247938b1ec1..da8b31a53291 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1354,7 +1354,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
 	}
 
 	/* Free the BO*/
-	amdgpu_bo_unref(&mem->bo);
+	drm_gem_object_put_unlocked(&mem->bo->tbo.base);
 	mutex_destroy(&mem->lock);
 	kfree(mem);
 
@@ -1699,7 +1699,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
 		| KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
 		| KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;
 
-	(*mem)->bo = amdgpu_bo_ref(bo);
+	drm_gem_object_get(&bo->tbo.base);
+	(*mem)->bo = bo;
 	(*mem)->va = va;
 	(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
 		AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs
  2020-05-06  0:59 [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs Felix Kuehling
@ 2020-05-06  8:11 ` Christian König
  2020-05-06 18:25   ` Sierra Guiza, Alejandro (Alex)
  0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2020-05-06  8:11 UTC (permalink / raw)
  To: Felix Kuehling, amd-gfx

Am 06.05.20 um 02:59 schrieb Felix Kuehling:
> Releasing the AMDGPU BO ref directly leads to problems when BOs were
> exported as DMA bufs. Releasing the GEM reference makes sure that the
> AMDGPU/TTM BO is not freed too early.
>
> Also take a GEM reference when importing BOs from DMABufs to keep
> references to imported BOs balances properly.
>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
> Tested-by: Alex Sierra <alex.sierra@amd.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 1247938b1ec1..da8b31a53291 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -1354,7 +1354,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
>   	}
>   
>   	/* Free the BO*/
> -	amdgpu_bo_unref(&mem->bo);
> +	drm_gem_object_put_unlocked(&mem->bo->tbo.base);
>   	mutex_destroy(&mem->lock);
>   	kfree(mem);
>   
> @@ -1699,7 +1699,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
>   		| KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
>   		| KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;
>   
> -	(*mem)->bo = amdgpu_bo_ref(bo);
> +	drm_gem_object_get(&bo->tbo.base);
> +	(*mem)->bo = bo;
>   	(*mem)->va = va;
>   	(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
>   		AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* RE: [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs
  2020-05-06  8:11 ` Christian König
@ 2020-05-06 18:25   ` Sierra Guiza, Alejandro (Alex)
  0 siblings, 0 replies; 3+ messages in thread
From: Sierra Guiza, Alejandro (Alex) @ 2020-05-06 18:25 UTC (permalink / raw)
  To: Koenig, Christian, Kuehling, Felix, amd-gfx

[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Alex Sierra <alex.sierra@amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Christian König
Sent: Wednesday, May 6, 2020 3:12 AM
To: Kuehling, Felix <Felix.Kuehling@amd.com>; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs

Am 06.05.20 um 02:59 schrieb Felix Kuehling:
> Releasing the AMDGPU BO ref directly leads to problems when BOs were 
> exported as DMA bufs. Releasing the GEM reference makes sure that the 
> AMDGPU/TTM BO is not freed too early.
>
> Also take a GEM reference when importing BOs from DMABufs to keep 
> references to imported BOs balances properly.
>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
> Tested-by: Alex Sierra <alex.sierra@amd.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 1247938b1ec1..da8b31a53291 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -1354,7 +1354,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
>   	}
>   
>   	/* Free the BO*/
> -	amdgpu_bo_unref(&mem->bo);
> +	drm_gem_object_put_unlocked(&mem->bo->tbo.base);
>   	mutex_destroy(&mem->lock);
>   	kfree(mem);
>   
> @@ -1699,7 +1699,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
>   		| KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
>   		| KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;
>   
> -	(*mem)->bo = amdgpu_bo_ref(bo);
> +	drm_gem_object_get(&bo->tbo.base);
> +	(*mem)->bo = bo;
>   	(*mem)->va = va;
>   	(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
>   		AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calex.sierra%40amd.com%7C14fc955a4c63411b3fe808d7f1952092%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243495134045678&amp;sdata=3QrUtuE4LU8V1xGRPjaQJ9QeAv9hKhFTZ7GLCuskVeM%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-05-06 18:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06  0:59 [PATCH 1/1] drm/amdgpu: Use GEM obj reference for KFD BOs Felix Kuehling
2020-05-06  8:11 ` Christian König
2020-05-06 18:25   ` Sierra Guiza, Alejandro (Alex)

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.