Skip to contentSkip to conversation

drm/amdgpu/sdma4: drop unused register header

PATCH In review Alex Deucher 3 participants 9 messages Jul 27, 2017 – Jul 28, 2017 4 messages not in the archive

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

PATCH 1/5 drm/amdgpu/sdma4: drop unused register header

nbio registers are not used in this file.

---
 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 5c24708..7cb5320 100644
@@ -35,7 +35,6 @@
 #include "vega10/MMHUB/mmhub_1_0_offset.h"
 #include "vega10/MMHUB/mmhub_1_0_sh_mask.h"
 #include "vega10/HDP/hdp_4_0_offset.h"
-#include "vega10/NBIO/nbio_6_1_offset.h"
 #include "raven1/SDMA0/sdma0_4_1_default.h"
 
 #include "soc15_common.h"
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): 1501184765-26699-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/5 drm/amdgpu/sdma4: set wptr shadow atomically

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

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
index 7cb5320..9392799 100644
@@ -301,8 +301,8 @@ 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);
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs],
+			     (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): 1501184765-26699-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/5] drm/amdgpu/sdma4: set wptr shadow atomically

Quoted 14 lines · Alex Deucher

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

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
index 7cb5320..9392799 100644

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

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
@@ -301,8 +301,8 @@ 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);
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs],
+			     (ring->wptr << 2));

This looks a bit awkward. Would "writeq" do the job? That's what we use for updating kernel queue doorbells in KFD.

The generic implementation of atomic64_set uses a spinlock. But that doesn't do anything for protecting against concurrent access by the GPU hardware.

Regards,
Felix

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
 		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

A message that is not in the archive (sent off-list or not yet received): ae92b966-bff6-b727-6c57-f4dbaa388b46-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Re: [PATCH 2/5] drm/amdgpu/sdma4: set wptr shadow atomically

Quoted 11 lines · Felix Kuehling
Quoted 9 lines · Alex Deucher

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

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

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

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
index 7cb5320..9392799 100644
@@ -301,8 +301,8 @@ 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);
+             atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs],
+                          (ring->wptr << 2));

This looks a bit awkward. Would "writeq" do the job? That's what we use for updating kernel queue doorbells in KFD.

Probably. We just want to make sure the whole 64 bit value is updated before the GPU polls the value.

Alex

Quoted 8 lines

The generic implementation of atomic64_set uses a spinlock. But that doesn't do anything for protecting against concurrent access by the GPU hardware.

Regards,
Felix

Quoted 8 lines

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
              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

_______________________________________________
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): CADnq5_OE3zAfpir1x-m-b7Oy53D=ZaN7TjB5XmUoQT0Ln=DC_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

Re: [PATCH 2/5] drm/amdgpu/sdma4: set wptr shadow atomically

Am 27.07.2017 um 22:50 schrieb Alex Deucher:

Quoted 25 lines · Felix Kuehling
Quoted 10 lines · Alex Deucher
Quoted 9 lines

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

---
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 14 lines

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

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +2 -2
index 7cb5320..9392799 100644
@@ -301,8 +301,8 @@ 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);
+             atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs],
+                          (ring->wptr << 2));

This looks a bit awkward. Would "writeq" do the job? That's what we use for updating kernel queue doorbells in KFD.

Quoted 2 lines

Probably. We just want to make sure the whole 64 bit value is updated before the GPU polls the value.

writeq is for iomem and does endian conversion IIRC.

How about WRITE_ONCE()?

Christian.

Quoted 13 lines

Alex

Quoted 10 lines

The generic implementation of atomic64_set uses a spinlock. But that doesn't do anything for protecting against concurrent access by the GPU hardware.

Regards,
Felix

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -0
               DRM_DEBUG("calling WDOORBELL64(0x%08x, 0x%016llx)\n",
                               ring->doorbell_index, ring->wptr << 2);
 
Quoted 8 lines
Quoted 4 lines

_______________________________________________
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

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

#9 lore raw

PATCH 3/5 drm/amdgpu/sdma4: drop hdp flush from wptr shadow update

In reply to a message not in the archive

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 9392799..3ffdf88 100644
@@ -312,7 +312,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
#10 lore raw

PATCH 4/5 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 89f7b4f..5f8d2e8 100644
@@ -1209,7 +1209,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
#11 lore raw

PATCH 5/5 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 7a88264..87a3ca1 100644
@@ -661,6 +661,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);
@@ -689,17 +702,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
#12 lore raw
In reply to a message not in the archive

Am 27.07.2017 um 21:46 schrieb Alex Deucher:

Quoted 4 lines

nbio registers are not used in this file.

Patches #1 and #3-#5 are Reviewed-by: Christian König <[email protected]>.

I agree with Felix that #2 looks a bit ugly, but using writeq doesn't sounds like the correct answer either.

If WRITE_ONCE() does the job then I would use that one.

Christian.

Quoted 9 lines
---
  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 -0
index 5c24708..7cb5320 100644

drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c line 40

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +0 -1
@@ -35,7 +35,6 @@
  #include "vega10/MMHUB/mmhub_1_0_offset.h"
  #include "vega10/MMHUB/mmhub_1_0_sh_mask.h"
  #include "vega10/HDP/hdp_4_0_offset.h"
-#include "vega10/NBIO/nbio_6_1_offset.h"
  #include "raven1/SDMA0/sdma0_4_1_default.h"
 
  #include "soc15_common.h"

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