Skip to contentSkip to conversation

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

PATCH In review Junwei Zhang 3 participants 4 messages Jan 11, 2018 3 messages not in the archive

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

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

v2: fix register access

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5 -4
index ae976e3..6db3645 100644
@@ -1068,8 +1068,8 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
 	adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40);
 	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 = RREG32_SOC15(GC, 0, mmGDS_VMID0_BASE);
+	adev->gfx.ngg.gds_reserve_addr += RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
 
 	/* Primitive Buffer */
 	r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,14 @@ 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(1) |
 				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_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): 1515637852-2238-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Could I how to verify this is valid fix?

Regards,

David Zhou

Quoted 29 lines · Junwei Zhang

v2: fix register access

---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -2
index ae976e3..6db3645 100644
@@ -1068,8 +1068,8 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
  	adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40);
  	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 = RREG32_SOC15(GC, 0, mmGDS_VMID0_BASE);
+	adev->gfx.ngg.gds_reserve_addr += RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
 
  	/* Primitive Buffer */
  	r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,14 @@ 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(1) |
  				PACKET3_DMA_DATA_SRC_SEL(2)));
  	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 1194

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
  	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_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): 5585fbaf-d71f-3892-18e7-b6a2ea0a4e1b-5C7GfCeVMHo@public.gmane.org

#4 lore raw
Quoted 1 line · Chunming Zhou

Could I how to verify this is valid fix?

For now, check if there is no vm fault or any other side effect when loading amdgpu with ngg=1.

Later development will be implemented with OGL team together.

Jerry

Quoted 36 lines

Regards,

David Zhou

Quoted 29 lines · Junwei Zhang

v2: fix register access

---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -2
index ae976e3..6db3645 100644
@@ -1068,8 +1068,8 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev)
      adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40);
      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 = RREG32_SOC15(GC, 0, mmGDS_VMID0_BASE);
+    adev->gfx.ngg.gds_reserve_addr += RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
      /* Primitive Buffer */
      r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
@@ -1181,13 +1181,14 @@ 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(1) |
                  PACKET3_DMA_DATA_SRC_SEL(2)));
      amdgpu_ring_write(ring, 0);
      amdgpu_ring_write(ring, 0);
Quoted 9 lines

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -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_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): [email protected]

#6 lore raw

Can't judge the other changes, but replacing the SOC15 macro with a register read looks like a valid fix to me.

For now the patch is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 11.01.2018 um 03:57 schrieb Zhang, Jerry (Junwei):

Quoted 60 lines · Chunming Zhou
Quoted 1 line

Could I how to verify this is valid fix?

For now, check if there is no vm fault or any other side effect when loading amdgpu with ngg=1.

Later development will be implemented with OGL team together.

Jerry

Quoted 42 lines

Regards,

David Zhou

Quoted 35 lines · Junwei Zhang

v2: fix register access

---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 9 +++++----

  1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -2
index ae976e3..6db3645 100644
@@ -1068,8 +1068,8 @@ static int gfx_v9_0_ngg_init(struct 
 amdgpu_device *adev)
       adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40);
       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 = RREG32_SOC15(GC, 0, 

mmGDS_VMID0_BASE);
+    adev->gfx.ngg.gds_reserve_addr += RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
      /* Primitive Buffer */
      r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
@@ -1181,13 +1181,14 @@ 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(1) | PACKET3_DMA_DATA_SRC_SEL(2))); amdgpu_ring_write(ring, 0); amdgpu_ring_write(ring, 0);

Quoted 9 lines
Quoted 8 lines

      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_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);

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