Skip to contentSkip to conversation

drm/amdgpu/gfx9: fix ngg enablement to clear gds reserved memory

PATCH Superseded Junwei Zhang 3 participants 4 messages Jan 10, 2018 2 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/gfx9: fix ngg enablement to clear gds reserved memory

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5 -3
index ae976e3..5f2ae77 100644
@@ -1069,7 +1069,7 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
 	adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size;
 	adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size;
 	adev->gfx.ngg.gds_reserve_addr = SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE);
-	adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size;
+	adev->gfx.ngg.gds_reserve_addr += SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE);
 
 	/* Primitive Buffer */
 	r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,15 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
 
 	amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
 	amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
+				PACKET3_DMA_DATA_DST_SEL(0) |
 				PACKET3_DMA_DATA_SRC_SEL(2)));
 	amdgpu_ring_write(ring, 0);
 	amdgpu_ring_write(ring, 0);
 	amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_addr);
 	amdgpu_ring_write(ring, 0);
-	amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_size);
-
+	amdgpu_ring_write(ring, PACKET3_DMA_DATA_CMD_DAS |
+				PACKET3_DMA_DATA_CMD_RAW_WAIT |
+				adev->gfx.ngg.gds_reserve_size);
 
 	gfx_v9_0_write_data_to_reg(ring, 0, false,
 				   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0);
Signature · 6 lines
1.9.1

_______________________________________________
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): 1515572310-31508-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

________________________________
From: Junwei Zhang <[email protected]>
Sent: Wednesday, January 10, 2018 4:18:30 PM
To: [email protected]
Cc: Wang, Ken; Zhang, Jerry
Subject: [PATCH] drm/amdgpu/gfx9: fix ngg enablement to clear gds reserved memory

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5 -3
index ae976e3..5f2ae77 100644
@@ -1069,7 +1069,7 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
         adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size;
         adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size;
         adev->gfx.ngg.gds_reserve_addr = SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE);
-       adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size;
+       adev->gfx.ngg.gds_reserve_addr += SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE);
 
         /* Primitive Buffer */
         r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,15 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
 
         amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
         amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
+                               PACKET3_DMA_DATA_DST_SEL(0) |
                                 PACKET3_DMA_DATA_SRC_SEL(2)));
         amdgpu_ring_write(ring, 0);
         amdgpu_ring_write(ring, 0);
         amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_addr);
         amdgpu_ring_write(ring, 0);
-       amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_size);
-
+       amdgpu_ring_write(ring, PACKET3_DMA_DATA_CMD_DAS |
+                               PACKET3_DMA_DATA_CMD_RAW_WAIT |
+                               adev->gfx.ngg.gds_reserve_size);
 
         gfx_v9_0_write_data_to_reg(ring, 0, false,
                                    SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0);

--
1.9.1

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

#3 lore raw
In reply to a message not in the archive

Am 10.01.2018 um 09:18 schrieb Junwei Zhang:

Quoted 10 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index ae976e3..5f2ae77 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_init(struct amdgpu_device *adev) · line 1072

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -1069,7 +1069,7 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
  	adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size;
  	adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size;
  	adev->gfx.ngg.gds_reserve_addr = SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE);
-	adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size;
+	adev->gfx.ngg.gds_reserve_addr += SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE);

Both the old and the new code looks strongly incorrect to me.

SOC15_REG_OFFSET gives you the register offset, not the content of the register.

So adding two register offsets or doesn't seem to make any sense at all.

Regards,
Christian.

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
  	/* Primitive Buffer */
  	r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,15 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
 
  	amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
  	amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
+				PACKET3_DMA_DATA_DST_SEL(0) |
  				PACKET3_DMA_DATA_SRC_SEL(2)));
  	amdgpu_ring_write(ring, 0);
  	amdgpu_ring_write(ring, 0);

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_en(struct amdgpu_device *adev) · line 1195

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -2
  	amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_addr);
  	amdgpu_ring_write(ring, 0);
-	amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_size);
-
+	amdgpu_ring_write(ring, PACKET3_DMA_DATA_CMD_DAS |
+				PACKET3_DMA_DATA_CMD_RAW_WAIT |
+				adev->gfx.ngg.gds_reserve_size);
 
  	gfx_v9_0_write_data_to_reg(ring, 0, false,
  				   SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0);

_______________________________________________
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): 16496903-a459-48f5-b534-fca0e6e0a5fe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw
Quoted 20 lines · Christian König

Am 10.01.2018 um 09:18 schrieb Junwei Zhang:

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index ae976e3..5f2ae77 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_init(struct amdgpu_device *adev) · line 1072

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -1069,7 +1069,7 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
      adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size;
      adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size;
      adev->gfx.ngg.gds_reserve_addr = SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE);
-    adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size;
+    adev->gfx.ngg.gds_reserve_addr += SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE);

Both the old and the new code looks strongly incorrect to me.

Quoted 3 lines

SOC15_REG_OFFSET gives you the register offset, not the content of the register.

So adding two register offsets or doesn't seem to make any sense at all.

Thanks to point it out.
It's typo from the very beginning.
Going to correct it with RREG32_SOC15().

Jerry

Quoted 14 lines

Regards,
Christian.

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
      /* Primitive Buffer */
      r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,15 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev)
      amdgpu_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5));
      amdgpu_ring_write(ring, (PACKET3_DMA_DATA_CP_SYNC |
+                PACKET3_DMA_DATA_DST_SEL(0) |
                  PACKET3_DMA_DATA_SRC_SEL(2)));
      amdgpu_ring_write(ring, 0);
      amdgpu_ring_write(ring, 0);
      amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_addr);
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_ngg_en(struct amdgpu_device *adev) · line 1195

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -2
      amdgpu_ring_write(ring, 0);
-    amdgpu_ring_write(ring, adev->gfx.ngg.gds_reserve_size);
-
+    amdgpu_ring_write(ring, PACKET3_DMA_DATA_CMD_DAS |
+                PACKET3_DMA_DATA_CMD_RAW_WAIT |
+                adev->gfx.ngg.gds_reserve_size);
      gfx_v9_0_write_data_to_reg(ring, 0, false,
                     SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0);

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