Skip to contentSkip to conversation

drm/amdgpu: Don't flush HDP on A+A

PATCH In review Eric Huang 3 participants 4 messages May 25, 2021 – May 27, 2021

Subsystems (2)
lore
Share & tools
lore

Eric Huang

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Don't flush HDP on A+A

With XGMI connection flushing HDP on PCIe is unnecessary, it is also to optimize memory allocation latency.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
index ac45d9c7a4e9..aefb3d2927d5 100644
@@ -108,6 +108,8 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,

 static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p, struct dma_fence **fence) {
+       if (p->adev->gmc.xgmi.connected_to_cpu)
+               return 0;
        /* Flush HDP */
        mb();
        amdgpu_asic_flush_hdp(p->adev, NULL);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#1 lore raw

Am 2021-05-25 um 1:56 p.m. schrieb Eric Huang:

Quoted 11 lines

With XGMI connection flushing HDP on PCIe is unnecessary, it is also to optimize memory allocation latency.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
index ac45d9c7a4e9..aefb3d2927d5 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct · line 113

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +2 -0
@@ -108,6 +108,8 @@ static int amdgpu_vm_cpu_update(struct
 amdgpu_vm_update_params *p,
  static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p,
                                 struct dma_fence **fence)
  {
+       if (p->adev->gmc.xgmi.connected_to_cpu)
+               return 0;

I wonder if this check should be inside hdp_v4_0_flush_hdp instead so it catches all unnecessary HDP flushing. On the other hand, that would still leave the mb(). But that mb() is probably needed anyway to ensure that the GPU will see any previous memory writes.

Regards,
  Felix

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
         /* Flush HDP */
         mb();

        amdgpu_asic_flush_hdp(p->adev, NULL);
_______________________________________________
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

#2 lore raw

Am 26.05.21 um 15:55 schrieb Felix Kuehling:

Quoted 6 lines

Am 2021-05-25 um 1:56 p.m. schrieb Eric Huang:

Quoted 5 lines

With XGMI connection flushing HDP on PCIe is unnecessary, it is also to optimize memory allocation latency.

Quoted 16 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct · line 113

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +2 -0
index ac45d9c7a4e9..aefb3d2927d5 100644
@@ -108,6 +108,8 @@ static int amdgpu_vm_cpu_update(struct
 amdgpu_vm_update_params *p,
  static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p,
                                 struct dma_fence **fence)
  {
+       if (p->adev->gmc.xgmi.connected_to_cpu)
+               return 0;

I wonder if this check should be inside hdp_v4_0_flush_hdp instead so it catches all unnecessary HDP flushing. On the other hand, that would still leave the mb(). But that mb() is probably needed anyway to ensure that the GPU will see any previous memory writes.

Yes, that was also my concern. But it looks like my reply never made it to the mailing list.

I think we should have a function in amdgpu_device.c to decide if HDP flush/Invalidate are necessary or not.

This should then be used at all the different places where we trigger this (CS, GART and here).

Regards,
Christian.

Quoted 12 lines

Regards,
  Felix

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
         /* Flush HDP */
         mb();

        amdgpu_asic_flush_hdp(p->adev, NULL);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

#3 lore raw
In reply to Eric Huang

Am 25.05.21 um 19:56 schrieb Eric Huang:

Quoted 10 lines

With XGMI connection flushing HDP on PCIe is unnecessary, it is also to optimize memory allocation latency.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
index ac45d9c7a4e9..aefb3d2927d5 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct · line 113

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +2 -0
@@ -108,6 +108,8 @@ static int amdgpu_vm_cpu_update(struct 
 amdgpu_vm_update_params *p,
  static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p,
                                 struct dma_fence **fence)
  {
+       if (p->adev->gmc.xgmi.connected_to_cpu)
+               return 0;

You still need at least the memory barrier and I suggest to add a common flag/function to check if HDP flushing is needed or not.

We also have a bunch of cases in the IB submission code as well.

Christian.

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
         /* Flush HDP */
         mb();

        amdgpu_asic_flush_hdp(p->adev, NULL);
_______________________________________________
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