drm/amdgpu: Don't flush/invalidate HDP for APUs and A+A
Subsystems (2)
PATCH v3 1/1 drm/amdgpu: Don't flush/invalidate HDP for APUs and A+A
Integrate two macros into two generic functions and add no_flush flag to determine if HDP flush is needed for all Asics.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 15 ++--------- 4 files changed, 37 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -4
@@ -1297,10 +1297,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_read_bios_from_rom (adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))#define amdgpu_asic_read_register (adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))#define amdgpu_asic_get_config_memsize (adev) (adev)->asic_funcs->get_config_memsize((adev)) -#define amdgpu_asic_flush_hdp (adev, r) \ - ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), (r)) : (adev)->hdp.funcs->flush_hdp((adev), (r))) -#define amdgpu_asic_invalidate_hdp (adev, r) \ - ((adev)->asic_funcs->invalidate_hdp ? (adev)->asic_funcs->invalidate_hdp((adev), (r)) : (adev)->hdp.funcs->invalidate_hdp((adev), (r)))#define amdgpu_asic_need_full_reset (adev) (adev)->asic_funcs->need_full_reset((adev))#define amdgpu_asic_init_doorbell_index (adev) (adev)->asic_funcs->init_doorbell_index((adev))#define amdgpu_asic_get_pcie_usage (adev, cnt0, cnt1) ((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))
@@ -1314,6 +1310,11 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring); +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring); +/* Common functions */ bool amdgpu_device_has_job_running (struct amdgpu_device *adev);bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +29 -0
@@ -3505,6 +3505,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,if (r) goto failed_unmap; +if ((adev->flags &AMD_IS_APU ) || adev->gmc.xgmi.connected_to_cpu) + adev->hdp.no_flush = true; +/* doorbell bar mapping and doorbell index init*/ amdgpu_device_doorbell_init (adev);
@@ -5548,3 +5551,29 @@ bool amdgpu_device_is_headless(struct amdgpu_device *adev)/* Check if it is NV's VGA class while VCN is harvest, it is headless*/ return nv_is_headless_sku (adev->pdev); } + +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring) +{ +if (adev->hdp.no_flush) +return ; + +if (ring->funcs->emit_hdp_flush) +amdgpu_ring_emit_hdp_flush (ring); +else if (adev->asic_funcs->flush_hdp) + adev->asic_funcs->flush_hdp (adev, ring); +else + adev->hdp.funcs->flush_hdp (adev, ring); +} + +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring) +{ +if (adev->hdp.no_flush) +return ; + +if (adev->asic_funcs->invalidate_hdp) + adev->asic_funcs->invalidate_hdp (adev, ring); +else + adev->hdp.funcs->invalidate_hdp (adev, ring); +}
drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h +1 -0
@@ -44,6 +44,7 @@ struct amdgpu_hdp {struct ras_common_if *ras_if;const struct amdgpu_hdp_funcs *funcs;const struct amdgpu_hdp_ras_funcs *ras_funcs; +bool no_flush; };int amdgpu_hdp_ras_late_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -13
@@ -222,15 +222,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (job && ring->funcs->init_cond_exec) patch_offset =amdgpu_ring_init_cond_exec (ring); -#ifdef CONFIG_X86_64 - if (!(adev->flags & AMD_IS_APU)) -#endif - { -if (ring->funcs->emit_hdp_flush) -amdgpu_ring_emit_hdp_flush (ring); -else -amdgpu_asic_flush_hdp (adev, ring); - } +amdgpu_asic_flush_hdp (adev, ring);if (need_ctx_switch) status |=AMDGPU_HAVE_CTX_SWITCH ;
@@ -267,10 +259,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (job && ring->funcs->emit_frame_cntl)amdgpu_ring_emit_frame_cntl (ring, false, secure); -#ifdef CONFIG_X86_64 - if (!(adev->flags & AMD_IS_APU)) -#endif -amdgpu_asic_invalidate_hdp (adev, ring); +amdgpu_asic_invalidate_hdp (adev, ring);if (ib->flags &AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE ) fence_flags |=AMDGPU_FENCE_FLAG_TC_WB_ONLY ;
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 02.06.21 um 04:04 schrieb Eric Huang:
Quoted 3 lines
Integrate two macros into two generic functions and add
no_flushflag to determine if HDP flush is needed for all Asics.
Yes that starts looks like it should work, just a few comments below.
Quoted 41 lines
Signed-off-by Eric Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 15 ++--------- 4 files changed, 37 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-4@@ -1297,10 +1297,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_read_bios_from_rom (adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))#define amdgpu_asic_read_register (adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))#define amdgpu_asic_get_config_memsize (adev) (adev)->asic_funcs->get_config_memsize((adev)) -#define amdgpu_asic_flush_hdp (adev, r) \ - ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), (r)) : (adev)->hdp.funcs->flush_hdp((adev), (r))) -#define amdgpu_asic_invalidate_hdp (adev, r) \ - ((adev)->asic_funcs->invalidate_hdp ? (adev)->asic_funcs->invalidate_hdp((adev), (r)) : (adev)->hdp.funcs->invalidate_hdp((adev), (r)))#define amdgpu_asic_need_full_reset (adev) (adev)->asic_funcs->need_full_reset((adev))#define amdgpu_asic_init_doorbell_index (adev) (adev)->asic_funcs->init_doorbell_index((adev))#define amdgpu_asic_get_pcie_usage (adev, cnt0, cnt1) ((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))@@ -1314,6 +1310,11 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring); +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring); +/* Common functions */ bool amdgpu_device_has_job_running (struct amdgpu_device *adev);bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 3510
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -3505,6 +3505,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,if (r) goto failed_unmap; +if ((adev->flags &AMD_IS_APU ) || adev->gmc.xgmi.connected_to_cpu) + adev->hdp.no_flush = true; +
This is not correct. We can only skip HDP flush on X86_64, but not on 32bit builds.
Additional to that we might want this somewhere in the GMC code and not here.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_is_headless(struct amdgpu_device *adev) · line 5556
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0/* doorbell bar mapping and doorbell index init*/ amdgpu_device_doorbell_init (adev);@@ -5548,3 +5551,29 @@ bool amdgpu_device_is_headless(struct amdgpu_device *adev)/* Check if it is NV's VGA class while VCN is harvest, it is headless*/ return nv_is_headless_sku (adev->pdev); } + +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring)
Please name the functions amdgpu_device_, the amdgpu_asic_ names are for callbacks only.
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_is_headless(struct amdgpu_device *adev) · line 5559
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0+{ +if (adev->hdp.no_flush) +return ;
Since we now have a function to check the different conditions I think we might want to check for X86_64 & APU and XGMI connection separately here.
But that is not a hard requirement, using the no_flush variable is fine with me if you think that this is better.
Quoted 40 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +20
-0+ +if (ring->funcs->emit_hdp_flush) +amdgpu_ring_emit_hdp_flush (ring); +else if (adev->asic_funcs->flush_hdp) + adev->asic_funcs->flush_hdp (adev, ring); +else + adev->hdp.funcs->flush_hdp (adev, ring); +} + +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, +struct amdgpu_ring *ring) +{ +if (adev->hdp.no_flush) +return ; + +if (adev->asic_funcs->invalidate_hdp) + adev->asic_funcs->invalidate_hdp (adev, ring); +else + adev->hdp.funcs->invalidate_hdp (adev, ring); +}drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h +1
-0@@ -44,6 +44,7 @@ struct amdgpu_hdp {struct ras_common_if *ras_if;const struct amdgpu_hdp_funcs *funcs;const struct amdgpu_hdp_ras_funcs *ras_funcs; +bool no_flush; };int amdgpu_hdp_ras_late_init (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -222,15 +222,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (job && ring->funcs->init_cond_exec) patch_offset =amdgpu_ring_init_cond_exec (ring);
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · line 225
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-9-#ifdef CONFIG_X86_64 - if (!(adev->flags & AMD_IS_APU)) -#endif - { -if (ring->funcs->emit_hdp_flush) -amdgpu_ring_emit_hdp_flush (ring); -else -amdgpu_asic_flush_hdp (adev, ring); - } +amdgpu_asic_flush_hdp (adev, ring);
We also have two more HDP flush cases in the GART code and the CPU based VM code IIRC.
Thanks,
Christian.
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0if (need_ctx_switch) status |=AMDGPU_HAVE_CTX_SWITCH ;@@ -267,10 +259,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,if (job && ring->funcs->emit_frame_cntl)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · line 265
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-4amdgpu_ring_emit_frame_cntl (ring, false, secure); -#ifdef CONFIG_X86_64 - if (!(adev->flags & AMD_IS_APU)) -#endif -amdgpu_asic_invalidate_hdp (adev, ring); +amdgpu_asic_invalidate_hdp (adev, ring);if (ib->flags &AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE ) fence_flags |=AMDGPU_FENCE_FLAG_TC_WB_ONLY ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 60 lines · Christian König
Am 02.06.21 um 04:04 schrieb Eric Huang:
Quoted 3 lines
Integrate two macros into two generic functions and add
no_flushflag to determine if HDP flush is needed for all Asics.Yes that starts looks like it should work, just a few comments below.
Quoted 43 lines
Signed-off-by Eric Huang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++++---drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 29 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 15 ++---------4 files changed, 37 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-4@@ -1297,10 +1297,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev); #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev)) -#define amdgpu_asic_flush_hdp (adev, r) \ - ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), (r)) : (adev)->hdp.funcs->flush_hdp((adev), (r))) -#define amdgpu_asic_invalidate_hdp (adev, r) \ - ((adev)->asic_funcs->invalidate_hdp ? (adev)->asic_funcs->invalidate_hdp((adev), (r)) : (adev)->hdp.funcs->invalidate_hdp((adev), (r)))#define
amdgpu_asic_need_full_reset(adev)(adev)->asic_funcs->need_full_reset((adev))
#defineamdgpu_asic_init_doorbell_index(adev)(adev)->asic_funcs->init_doorbell_index((adev)) #defineamdgpu_asic_get_pcie_usage(adev, cnt0, cnt1)((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-0@@ -1314,6 +1310,11 @@ int emu_soc_asic_init(struct amdgpu_device *adev); #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter)); +void amdgpu_asic_flush_hdp(struct amdgpu_device *adev, + struct amdgpu_ring *ring); +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring); + /* Common functions */ bool amdgpu_device_has_job_running(struct amdgpu_device *adev); bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 3509
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0@@ -3505,6 +3505,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, if (r) goto failed_unmap; + if ((adev->flags & AMD_IS_APU) || adev->gmc.xgmi.connected_to_cpu) + adev->hdp.no_flush = true; +This is not correct. We can only skip HDP flush on
X86_64, but not on 32bit builds.Additional to that we might want this somewhere in the GMC code and not here.
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_is_headless(struct amdgpu_device *adev) · line 5556
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* doorbell bar mapping and doorbell index init*/ amdgpu_device_doorbell_init(adev); @@ -5548,3 +5551,29 @@ bool amdgpu_device_is_headless(struct amdgpu_device *adev)/* Check if it is NV's VGA class while VCN is harvest, it is headless*/ return
nv_is_headless_sku(adev->pdev);
}drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0+ +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring)Please name the functions
amdgpu_device_, theamdgpu_asic_names are for callbacks only.
I was thinking about the naming you mention, then we have to change all the caller for amdgpu_asic_flush_hdp(). The idea here is to simplify changes. If you think changing name is necessary, I am fine with that.
Quoted 52 lines
Quoted 4 lines
+{
+ if (adev->hdp.no_flush)
+ return;Since we now have a function to check the different conditions I think we might want to check for
X86_64& APU and XGMI connection separately here.But that is not a hard requirement, using the
no_flushvariable is fine with me if you think that this is better.Quoted 43 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +20
-0+ + if (ring->funcs->emit_hdp_flush) + amdgpu_ring_emit_hdp_flush(ring); + else if (adev->asic_funcs->flush_hdp) + adev->asic_funcs->flush_hdp(adev, ring); + else + adev->hdp.funcs->flush_hdp(adev, ring); +} + +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring) +{ + if (adev->hdp.no_flush) + return; + + if (adev->asic_funcs->invalidate_hdp) + adev->asic_funcs->invalidate_hdp(adev, ring); + else + adev->hdp.funcs->invalidate_hdp(adev, ring); +}drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h +1
-0@@ -44,6 +44,7 @@ struct amdgpu_hdp { struct ras_common_if *ras_if; const struct amdgpu_hdp_funcs *funcs; const struct amdgpu_hdp_ras_funcs *ras_funcs; + bool no_flush; }; int amdgpu_hdp_ras_late_init(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -222,15 +222,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (job && ring->funcs->init_cond_exec) patch_offset = amdgpu_ring_init_cond_exec(ring);-#ifdef
CONFIG_X86_64
- if (!(adev->flags &AMD_IS_APU))
-#endif
- {
Quoted 8 lines
Quoted 6 lines
- if (
ring->funcs->emit_hdp_flush)
-amdgpu_ring_emit_hdp_flush(ring);
- else
-amdgpu_asic_flush_hdp(adev, ring);
- }
+amdgpu_asic_flush_hdp(adev, ring);We also have two more HDP flush cases in the GART code and the CPU based VM code IIRC.
Are there calling amdgpu_asic_flush_hdp() in function amdgpu_gart_unbind() and amdgpu_vm_cpu_commit()? if so, keeping the same name of amdgpu_asic_flush_hdp() will not need to change. That is the reason I don't change the name.
Regards,
Eric
Quoted 4 lines
Thanks,
Christian.
Quoted 14 lines
Quoted 6 lines
if (
need_ctx_switch)
status |=AMDGPU_HAVE_CTX_SWITCH;drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -267,10 +259,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (job && ring->funcs->emit_frame_cntl) amdgpu_ring_emit_frame_cntl(ring, false, secure);Quoted 7 lines
-#ifdef
CONFIG_X86_64
- if (!(adev->flags &AMD_IS_APU))
-#endif
-amdgpu_asic_invalidate_hdp(adev, ring);
+amdgpu_asic_invalidate_hdp(adev, ring);
if (ib->flags&AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE)fence_flags|=AMDGPU_FENCE_FLAG_TC_WB_ONLY;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 02.06.21 um 17:26 schrieb Eric Huang:
Quoted 77 lines · Christian König
Quoted 62 lines
Am 02.06.21 um 04:04 schrieb Eric Huang:
Quoted 3 lines
Integrate two macros into two generic functions and add
no_flushflag to determine if HDP flush is needed for all Asics.Yes that starts looks like it should work, just a few comments below.
Quoted 44 lines
Signed-off-by Eric Huang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ++++---drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 29
++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 15 ++---------4 files changed, 37 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-4@@ -1297,10 +1297,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev); #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev)) -#define amdgpu_asic_flush_hdp (adev, r) \ - ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), (r)) : (adev)->hdp.funcs->flush_hdp((adev), (r))) -#define amdgpu_asic_invalidate_hdp (adev, r) \ - ((adev)->asic_funcs->invalidate_hdp ? (adev)->asic_funcs->invalidate_hdp((adev), (r)) : (adev)->hdp.funcs->invalidate_hdp((adev), (r)))#define
amdgpu_asic_need_full_reset(adev)(adev)->asic_funcs->need_full_reset((adev))
#defineamdgpu_asic_init_doorbell_index(adev)(adev)->asic_funcs->init_doorbell_index((adev)) #defineamdgpu_asic_get_pcie_usage(adev, cnt0, cnt1)((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-0@@ -1314,6 +1310,11 @@ int emu_soc_asic_init(struct amdgpu_device *adev); #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter)); +void amdgpu_asic_flush_hdp(struct amdgpu_device *adev, + struct amdgpu_ring *ring); +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring); + /* Common functions */ bool amdgpu_device_has_job_running(struct amdgpu_device *adev); bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device · line 3510
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0@@ -3505,6 +3505,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, if (r) goto failed_unmap; + if ((adev->flags & AMD_IS_APU) || adev->gmc.xgmi.connected_to_cpu) + adev->hdp.no_flush = true; +This is not correct. We can only skip HDP flush on
X86_64, but not on 32bit builds.Additional to that we might want this somewhere in the GMC code and not here.
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_is_headless(struct amdgpu_device *adev) · line 5556
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0/* doorbell bar mapping and doorbell index init*/ amdgpu_device_doorbell_init(adev);@@ -5548,3 +5551,29 @@ bool
amdgpu_device_is_headless(struct amdgpu_device *adev)/* Check if it is NV's VGA class while VCN is harvest, it is headless*/ returnnv_is_headless_sku(adev->pdev);
}drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0+ +void amdgpu_asic_flush_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring)Please name the functions
amdgpu_device_, theamdgpu_asic_names are for callbacks only.
Quoted 1 line
I was thinking about the naming you mention, then we have to change all the caller for
amdgpu_asic_flush_hdp(). The idea here is to simplify changes. If you think changing name is necessary, I am fine with that.
I think we have reserved the _asic_ prefix for the macro wrappers only and to be honest I think _device_ makes more sense.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+{
+ if (adev->hdp.no_flush)
+ return;
Quoted 7 lines
Quoted 7 lines
Since we now have a function to check the different conditions I think we might want to check for
X86_64& APU and XGMI connection separately here.But that is not a hard requirement, using the
no_flushvariable is fine with me if you think that this is better.Quoted 3 lines
+
+ if (ring->funcs->emit_hdp_flush)
+amdgpu_ring_emit_hdp_flush(ring);
BTW: You should probably check "ring && ring->funcs->emit_hdp_flush" here, cause the ring is only an optional argument.
Christian.
Quoted 49 lines
Quoted 40 lines
Quoted 40 lines
+ else if (
adev->asic_funcs->flush_hdp)
+adev->asic_funcs->flush_hdp(adev, ring);
+ else
+adev->hdp.funcs->flush_hdp(adev, ring);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-0+} + +void amdgpu_asic_invalidate_hdp (struct amdgpu_device *adev, + struct amdgpu_ring *ring) +{ + if (adev->hdp.no_flush) + return; + + if (adev->asic_funcs->invalidate_hdp) + adev->asic_funcs->invalidate_hdp(adev, ring); + else + adev->hdp.funcs->invalidate_hdp(adev, ring); +}drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h +1
-0@@ -44,6 +44,7 @@ struct amdgpu_hdp { struct ras_common_if *ras_if; const struct amdgpu_hdp_funcs *funcs; const struct amdgpu_hdp_ras_funcs *ras_funcs; + bool no_flush; }; int amdgpu_hdp_ras_late_init(struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -222,15 +222,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (job && ring->funcs->init_cond_exec) patch_offset = amdgpu_ring_init_cond_exec(ring);-#ifdef
CONFIG_X86_64
- if (!(adev->flags &AMD_IS_APU))
-#endif
- {Quoted 8 lines
Quoted 6 lines
- if (
ring->funcs->emit_hdp_flush)
-amdgpu_ring_emit_hdp_flush(ring);
- else
-amdgpu_asic_flush_hdp(adev, ring);
- }
+amdgpu_asic_flush_hdp(adev, ring);We also have two more HDP flush cases in the GART code and the CPU based VM code IIRC.
Quoted 23 lines
Are there calling
amdgpu_asic_flush_hdp()in functionamdgpu_gart_unbind()andamdgpu_vm_cpu_commit()? if so, keeping the same name ofamdgpu_asic_flush_hdp()will not need to change. That is the reason I don't change the name.Regards,
EricQuoted 18 lines
Thanks,
Christian.Quoted 13 lines
if (
need_ctx_switch)
status |=AMDGPU_HAVE_CTX_SWITCH;drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -267,10 +259,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (job && ring->funcs->emit_frame_cntl) amdgpu_ring_emit_frame_cntl(ring, false, secure);-#ifdef
CONFIG_X86_64
- if (!(adev->flags &AMD_IS_APU))
-#endif
-amdgpu_asic_invalidate_hdp(adev, ring);
+amdgpu_asic_invalidate_hdp(adev, ring);
if (ib->flags&AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE)fence_flags|=AMDGPU_FENCE_FLAG_TC_WB_ONLY;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx