Skip to contentSkip to conversation

drm/amdgpu: Use the ALIGN() macro

PATCH In review Tuikov, Luben 3 participants 4 messages Oct 3, 2019 – Oct 5, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Use the ALIGN() macro

Use the ALIGN() macro to set "num_dw" to a
multiple of 8, i.e. lower 3 bits cleared.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -9
index 68c541e11189..73c628bc6a5b 100644
@@ -1923,10 +1923,7 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
 	*addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE *
 		AMDGPU_GPU_PAGE_SIZE;
 
-	num_dw = adev->mman.buffer_funcs->copy_num_dw;
-	while (num_dw & 0x7)
-		num_dw++;
-
+	num_dw = ALIGN(adev->mman.buffer_funcs->copy_num_dw, 8);
 	num_bytes = num_pages * 8;
 
 	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job);
@@ -1986,11 +1983,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
 
 	max_bytes = adev->mman.buffer_funcs->copy_max_bytes;
 	num_loops = DIV_ROUND_UP(byte_count, max_bytes);
-	num_dw = num_loops * adev->mman.buffer_funcs->copy_num_dw;
-
-	/* for IB padding */
-	while (num_dw & 0x7)
-		num_dw++;
+	num_dw = ALIGN(num_loops * adev->mman.buffer_funcs->copy_num_dw, 8);
 
 	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
 	if (r)
Signature · 6 lines
2.23.0.169.g8a3a6817e2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw

Am 04.10.19 um 01:39 schrieb Tuikov, Luben:

Quoted 4 lines

Use the ALIGN() macro to set "num_dw" to a
multiple of 8, i.e. lower 3 bits cleared.

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -4
index 68c541e11189..73c628bc6a5b 100644
@@ -1923,10 +1923,7 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
  	*addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE *
  		AMDGPU_GPU_PAGE_SIZE;
 
-	num_dw = adev->mman.buffer_funcs->copy_num_dw;
-	while (num_dw & 0x7)
-		num_dw++;
-
+	num_dw = ALIGN(adev->mman.buffer_funcs->copy_num_dw, 8);
  	num_bytes = num_pages * 8;
 
  	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job);
@@ -1986,11 +1983,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
 
  	max_bytes = adev->mman.buffer_funcs->copy_max_bytes;

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, · line 1989

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -5
  	num_loops = DIV_ROUND_UP(byte_count, max_bytes);
-	num_dw = num_loops * adev->mman.buffer_funcs->copy_num_dw;
-
-	/* for IB padding */
-	while (num_dw & 0x7)
-		num_dw++;
+	num_dw = ALIGN(num_loops * adev->mman.buffer_funcs->copy_num_dw, 8);
 
  	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
  	if (r)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): f4f4bdef-577a-7402-e467-7003be73687a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 7 lines · Christian König

Am 04.10.19 um 01:39 schrieb Tuikov, Luben:

Quoted 4 lines

Use the ALIGN() macro to set "num_dw" to a
multiple of 8, i.e. lower 3 bits cleared.

Hi Christian,

No ACK?

I've been running this version of the driver and no problems.

Regards,
Luben

Quoted 32 lines
Quoted 32 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -9
index 68c541e11189..73c628bc6a5b 100644
@@ -1923,10 +1923,7 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
  	*addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE *
  		AMDGPU_GPU_PAGE_SIZE;
 
-	num_dw = adev->mman.buffer_funcs->copy_num_dw;
-	while (num_dw & 0x7)
-		num_dw++;
-
+	num_dw = ALIGN(adev->mman.buffer_funcs->copy_num_dw, 8);
  	num_bytes = num_pages * 8;
 
  	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job);
@@ -1986,11 +1983,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
 
  	max_bytes = adev->mman.buffer_funcs->copy_max_bytes;
  	num_loops = DIV_ROUND_UP(byte_count, max_bytes);
-	num_dw = num_loops * adev->mman.buffer_funcs->copy_num_dw;
-
-	/* for IB padding */
-	while (num_dw & 0x7)
-		num_dw++;
+	num_dw = ALIGN(num_loops * adev->mman.buffer_funcs->copy_num_dw, 8);
 
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, · line 1989

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
  	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
  	if (r)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 911f3f03-3484-f03f-ee89-c6ad6e9ff68f-5C7GfCeVMHo@public.gmane.org

#6 lore raw
Quoted 8 lines · Luben
Quoted 6 lines · Christian König

Am 04.10.19 um 01:39 schrieb Tuikov, Luben:

Quoted 4 lines

Use the ALIGN() macro to set "num_dw" to a
multiple of 8, i.e. lower 3 bits cleared.

Quoted 8 lines
Quoted 1 line

Hi Christian,

No ACK?

I've been running this version of the driver and no problems.

You can go ahead and commit. You have a reviewed-by.

Alex

Quoted 35 lines

Regards,
Luben

Quoted 32 lines
Quoted 32 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -9
index 68c541e11189..73c628bc6a5b 100644
@@ -1923,10 +1923,7 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
     *addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE *
             AMDGPU_GPU_PAGE_SIZE;
 
-    num_dw = adev->mman.buffer_funcs->copy_num_dw;
-    while (num_dw & 0x7)
-            num_dw++;
-
+    num_dw = ALIGN(adev->mman.buffer_funcs->copy_num_dw, 8);
     num_bytes = num_pages * 8;
 
     r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job);
@@ -1986,11 +1983,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
 
     max_bytes = adev->mman.buffer_funcs->copy_max_bytes;
     num_loops = DIV_ROUND_UP(byte_count, max_bytes);
-    num_dw = num_loops * adev->mman.buffer_funcs->copy_num_dw;
-
-    /* for IB padding */
-    while (num_dw & 0x7)
-            num_dw++;
+    num_dw = ALIGN(num_loops * adev->mman.buffer_funcs->copy_num_dw, 8);
 
Quoted 8 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, · line 1989

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
     r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
     if (r)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx