Skip to contentSkip to conversation

drm/amdgpu/sdma4: set wptr shadow atomically (v2)

PATCH In review Alex Deucher 2 participants 5 messages Jul 28, 2017 – Jul 29, 2017 1 message not in the archive

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

PATCH 1/4 drm/amdgpu/sdma4: set wptr shadow atomically (v2)

No functional change until wptr polling uses this
location (future patch).

v2: use WRITE_ONCE

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3 -2
index bca5d8e..660704d 100644
@@ -293,6 +293,8 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
 
 	DRM_DEBUG("Setting write pointer\n");
 	if (ring->use_doorbell) {
+		u64 *wb = (u64 *)&adev->wb.wb[ring->wptr_offs];
+
 		DRM_DEBUG("Using doorbell -- "
 				"wptr_offs == 0x%08x "
 				"lower_32_bits(ring->wptr) << 2 == 0x%08x "
@@ -301,8 +303,7 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
 				lower_32_bits(ring->wptr << 2),
 				upper_32_bits(ring->wptr << 2));
 		/* XXX check if swapping is necessary on BE */
-		adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr << 2);
-		adev->wb.wb[ring->wptr_offs + 1] = upper_32_bits(ring->wptr << 2);
+		WRITE_ONCE(*wb, (ring->wptr << 2));
 		DRM_DEBUG("calling WDOORBELL64(0x%08x, 0x%016llx)\n",
 				ring->doorbell_index, ring->wptr << 2);
 
Signature · 6 lines
2.5.5

_______________________________________________
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): 1501274048-4375-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/4 drm/amdgpu/sdma4: drop hdp flush from wptr shadow update

The wb buffer is in system memory, not vram so the flush is useless.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -1
index 660704d..c76727b 100644
@@ -313,7 +313,6 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
 					offset = adev->sdma.instance[i].poll_mem_offs;
 					atomic64_set((atomic64_t *)&adev->wb.wb[offset],
 						     (ring->wptr << 2));
-					nbio_v6_1_hdp_flush(adev);
 				}
 			}
 		}
Signature · 6 lines
2.5.5

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

PATCH 3/4 drm/amdgpu/sdma4: drop allocation of poll_mem_offs

In reply to a message not in the archive

We already allocate this as part of the ring structure, use that instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  1 -
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 45 +++++++---------------------------
 2 files changed, 9 insertions(+), 37 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index 9533aed..27ccdde 100644
@@ -1205,7 +1205,6 @@ struct amdgpu_sdma_instance {
 
 	struct amdgpu_ring	ring;
 	bool			burst_nop;
-	uint32_t		poll_mem_offs;
 };
 
 struct amdgpu_sdma {
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +9 -36

90 lines not on this page · raw message

Signature · 6 lines
2.5.5

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

PATCH 4/4 drm/amdgpu/sdma4: move wptr polling setup

In reply to a message not in the archive

Move it up before ring enablement with all of the other engine setup and explicitly disable it for bare metal.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -11
index 85b8561..79a9e44 100644
@@ -662,6 +662,19 @@ static int sdma_v4_0_gfx_resume(struct amdgpu_device *adev)
 			WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_F32_CNTL), temp);
 		}
 
+		/* setup the wptr shadow polling */
+		wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
+		WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_LO),
+		       lower_32_bits(wptr_gpu_addr));
+		WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI),
+		       upper_32_bits(wptr_gpu_addr));
+		wptr_poll_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL));
+		if (amdgpu_sriov_vf(adev))
+			wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 1);
+		else
+			wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 0);
+		WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), wptr_poll_cntl);
+
 		/* enable DMA RB */
 		rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 1);
 		WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
@@ -690,17 +703,6 @@ static int sdma_v4_0_gfx_resume(struct amdgpu_device *adev)
 		if (adev->mman.buffer_funcs_ring == ring)
 			amdgpu_ttm_set_active_vram_size(adev, adev->mc.real_vram_size);
 
-		if (amdgpu_sriov_vf(adev)) {
-			wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
-			wptr_poll_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL));
-			wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 1);
-
-			WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_LO),
-			       lower_32_bits(wptr_gpu_addr));
-			WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI),
-			       upper_32_bits(wptr_gpu_addr));
-			WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), wptr_poll_cntl);
-		}
 	}
 
 	return 0;
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#5 lore raw
In reply to a message not in the archive

Am 28.07.2017 um 22:34 schrieb Alex Deucher:

Quoted 7 lines

No functional change until wptr polling uses this
location (future patch).

v2: use WRITE_ONCE

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -0
index bca5d8e..660704d 100644
@@ -293,6 +293,8 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
 
  	DRM_DEBUG("Setting write pointer\n");
  	if (ring->use_doorbell) {
+		u64 *wb = (u64 *)&adev->wb.wb[ring->wptr_offs];
+
  		DRM_DEBUG("Using doorbell -- "
  				"wptr_offs == 0x%08x "
  				"lower_32_bits(ring->wptr) << 2 == 0x%08x "

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring) · line 309

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -2
@@ -301,8 +303,7 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring)
  				lower_32_bits(ring->wptr << 2),
  				upper_32_bits(ring->wptr << 2));
  		/* XXX check if swapping is necessary on BE */
-		adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr << 2);
-		adev->wb.wb[ring->wptr_offs + 1] = upper_32_bits(ring->wptr << 2);
+		WRITE_ONCE(*wb, (ring->wptr << 2));
  		DRM_DEBUG("calling WDOORBELL64(0x%08x, 0x%016llx)\n",
  				ring->doorbell_index, ring->wptr << 2);
 

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