All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
@ 2020-01-25 11:46 ` Stephen Kitt
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:46 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: amd-gfx, dri-devel, linux-kernel, linux-media, Stephen Kitt

Instead of hand-coding the dma_resv_list allocation, use
dma_resv_list_alloc, which masks the shared_max handling. While we're
at it, since we only need shared_count fences, allocate shared_count
fences rather than shared_max.

(This is the only place in the kernel, outside of dma-resv.c, which
touches shared_max. This suggests we'd probably be better off without
it!)

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 888209eb8cec..aec595752200 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -234,12 +234,11 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 	if (!old)
 		return 0;
 
-	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
-		      GFP_KERNEL);
+	new = dma_resv_list_alloc(old->shared_count);
 	if (!new)
 		return -ENOMEM;
 
-	/* Go through all the shared fences in the resevation object and sort
+	/* Go through all the shared fences in the reservation object and sort
 	 * the interesting ones to the end of the list.
 	 */
 	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) {
@@ -253,7 +252,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 		else
 			RCU_INIT_POINTER(new->shared[k++], f);
 	}
-	new->shared_max = old->shared_max;
 	new->shared_count = k;
 
 	/* Install the new fence list, seqcount provides the barriers */
-- 
2.24.1


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

* [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
@ 2020-01-25 11:46 ` Stephen Kitt
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:46 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: linux-media, Stephen Kitt, dri-devel, amd-gfx, linux-kernel

Instead of hand-coding the dma_resv_list allocation, use
dma_resv_list_alloc, which masks the shared_max handling. While we're
at it, since we only need shared_count fences, allocate shared_count
fences rather than shared_max.

(This is the only place in the kernel, outside of dma-resv.c, which
touches shared_max. This suggests we'd probably be better off without
it!)

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 888209eb8cec..aec595752200 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -234,12 +234,11 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 	if (!old)
 		return 0;
 
-	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
-		      GFP_KERNEL);
+	new = dma_resv_list_alloc(old->shared_count);
 	if (!new)
 		return -ENOMEM;
 
-	/* Go through all the shared fences in the resevation object and sort
+	/* Go through all the shared fences in the reservation object and sort
 	 * the interesting ones to the end of the list.
 	 */
 	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) {
@@ -253,7 +252,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 		else
 			RCU_INIT_POINTER(new->shared[k++], f);
 	}
-	new->shared_max = old->shared_max;
 	new->shared_count = k;
 
 	/* Install the new fence list, seqcount provides the barriers */
-- 
2.24.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
@ 2020-01-25 11:46 ` Stephen Kitt
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:46 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: linux-media, Stephen Kitt, dri-devel, amd-gfx, linux-kernel

Instead of hand-coding the dma_resv_list allocation, use
dma_resv_list_alloc, which masks the shared_max handling. While we're
at it, since we only need shared_count fences, allocate shared_count
fences rather than shared_max.

(This is the only place in the kernel, outside of dma-resv.c, which
touches shared_max. This suggests we'd probably be better off without
it!)

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 888209eb8cec..aec595752200 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -234,12 +234,11 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 	if (!old)
 		return 0;
 
-	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
-		      GFP_KERNEL);
+	new = dma_resv_list_alloc(old->shared_count);
 	if (!new)
 		return -ENOMEM;
 
-	/* Go through all the shared fences in the resevation object and sort
+	/* Go through all the shared fences in the reservation object and sort
 	 * the interesting ones to the end of the list.
 	 */
 	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) {
@@ -253,7 +252,6 @@ static int amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
 		else
 			RCU_INIT_POINTER(new->shared[k++], f);
 	}
-	new->shared_max = old->shared_max;
 	new->shared_count = k;
 
 	/* Install the new fence list, seqcount provides the barriers */
-- 
2.24.1

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

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

* Re: [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
  2020-01-25 11:46 ` Stephen Kitt
  (?)
@ 2020-01-25 11:52   ` Stephen Kitt
  -1 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:52 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: amd-gfx, dri-devel, linux-kernel, linux-media, steve

And of course I forgot this is an internal API, so this doesn't work 
without some of other stuff which isn't ready.

Please ignore...

Regards,

Stephen


Le 25/01/2020 12:46, Stephen Kitt a écrit :
> Instead of hand-coding the dma_resv_list allocation, use
> dma_resv_list_alloc, which masks the shared_max handling. While we're
> at it, since we only need shared_count fences, allocate shared_count
> fences rather than shared_max.
> 
> (This is the only place in the kernel, outside of dma-resv.c, which
> touches shared_max. This suggests we'd probably be better off without
> it!)
> 
> Signed-off-by: Stephen Kitt <steve@sk2.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 888209eb8cec..aec595752200 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -234,12 +234,11 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  	if (!old)
>  		return 0;
> 
> -	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
> -		      GFP_KERNEL);
> +	new = dma_resv_list_alloc(old->shared_count);
>  	if (!new)
>  		return -ENOMEM;
> 
> -	/* Go through all the shared fences in the resevation object and sort
> +	/* Go through all the shared fences in the reservation object and 
> sort
>  	 * the interesting ones to the end of the list.
>  	 */
>  	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) 
> {
> @@ -253,7 +252,6 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  		else
>  			RCU_INIT_POINTER(new->shared[k++], f);
>  	}
> -	new->shared_max = old->shared_max;
>  	new->shared_count = k;
> 
>  	/* Install the new fence list, seqcount provides the barriers */

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

* Re: [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
@ 2020-01-25 11:52   ` Stephen Kitt
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:52 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: linux-media, steve, dri-devel, amd-gfx, linux-kernel

And of course I forgot this is an internal API, so this doesn't work 
without some of other stuff which isn't ready.

Please ignore...

Regards,

Stephen


Le 25/01/2020 12:46, Stephen Kitt a écrit :
> Instead of hand-coding the dma_resv_list allocation, use
> dma_resv_list_alloc, which masks the shared_max handling. While we're
> at it, since we only need shared_count fences, allocate shared_count
> fences rather than shared_max.
> 
> (This is the only place in the kernel, outside of dma-resv.c, which
> touches shared_max. This suggests we'd probably be better off without
> it!)
> 
> Signed-off-by: Stephen Kitt <steve@sk2.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 888209eb8cec..aec595752200 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -234,12 +234,11 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  	if (!old)
>  		return 0;
> 
> -	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
> -		      GFP_KERNEL);
> +	new = dma_resv_list_alloc(old->shared_count);
>  	if (!new)
>  		return -ENOMEM;
> 
> -	/* Go through all the shared fences in the resevation object and sort
> +	/* Go through all the shared fences in the reservation object and 
> sort
>  	 * the interesting ones to the end of the list.
>  	 */
>  	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) 
> {
> @@ -253,7 +252,6 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  		else
>  			RCU_INIT_POINTER(new->shared[k++], f);
>  	}
> -	new->shared_max = old->shared_max;
>  	new->shared_count = k;
> 
>  	/* Install the new fence list, seqcount provides the barriers */
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] amdgpu: use dma-resv API instead of manual kmalloc
@ 2020-01-25 11:52   ` Stephen Kitt
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Kitt @ 2020-01-25 11:52 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, Sumit Semwal
  Cc: linux-media, steve, dri-devel, amd-gfx, linux-kernel

And of course I forgot this is an internal API, so this doesn't work 
without some of other stuff which isn't ready.

Please ignore...

Regards,

Stephen


Le 25/01/2020 12:46, Stephen Kitt a écrit :
> Instead of hand-coding the dma_resv_list allocation, use
> dma_resv_list_alloc, which masks the shared_max handling. While we're
> at it, since we only need shared_count fences, allocate shared_count
> fences rather than shared_max.
> 
> (This is the only place in the kernel, outside of dma-resv.c, which
> touches shared_max. This suggests we'd probably be better off without
> it!)
> 
> Signed-off-by: Stephen Kitt <steve@sk2.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 888209eb8cec..aec595752200 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -234,12 +234,11 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  	if (!old)
>  		return 0;
> 
> -	new = kmalloc(offsetof(typeof(*new), shared[old->shared_max]),
> -		      GFP_KERNEL);
> +	new = dma_resv_list_alloc(old->shared_count);
>  	if (!new)
>  		return -ENOMEM;
> 
> -	/* Go through all the shared fences in the resevation object and sort
> +	/* Go through all the shared fences in the reservation object and 
> sort
>  	 * the interesting ones to the end of the list.
>  	 */
>  	for (i = 0, j = old->shared_count, k = 0; i < old->shared_count; ++i) 
> {
> @@ -253,7 +252,6 @@ static int
> amdgpu_amdkfd_remove_eviction_fence(struct amdgpu_bo *bo,
>  		else
>  			RCU_INIT_POINTER(new->shared[k++], f);
>  	}
> -	new->shared_max = old->shared_max;
>  	new->shared_count = k;
> 
>  	/* Install the new fence list, seqcount provides the barriers */
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-01-25 15:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-25 11:46 [PATCH] amdgpu: use dma-resv API instead of manual kmalloc Stephen Kitt
2020-01-25 11:46 ` Stephen Kitt
2020-01-25 11:46 ` Stephen Kitt
2020-01-25 11:52 ` Stephen Kitt
2020-01-25 11:52   ` Stephen Kitt
2020-01-25 11:52   ` Stephen Kitt

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.