drm/amdgpu: Add HDP flush to VCN v4.0.3
Subsystems (2)
PATCH 1/2 drm/amdgpu: Add HDP flush to VCN v4.0.3
VCN 4.0.3 cannot trigger HDP flush with RRMT enabled. Instead, trigger HDP flush from host side before ringing doorbell.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +25 -0
@@ -36,6 +36,7 @@#include "vcn/vcn_4_0_3_offset.h" #include "vcn/vcn_4_0_3_sh_mask.h" #include "ivsrcid/vcn/irqsrcs_vcn_4_0.h" +#include <uapi/linux/kfd_ioctl.h> #define mmUVD_DPG_LMA_CTL regUVD_DPG_LMA_CTL#define mmUVD_DPG_LMA_CTL_BASE_IDX regUVD_DPG_LMA_CTL_BASE_IDX
@@ -1380,6 +1381,26 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_ring_emit_hdp_flush (struct amdgpu_ring *ring) +{ +/* VCN engine access for HDP flush doesn't work when RRMT is enabled. +* This is a workaround to avoid any HDP flush through VCN ring. Instead +* HDP flush will be done by driver while submitting doorbell. +*/ +} + +static void vcn_v4_0_3_flush_hdp (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +#ifdef CONFIG_X86_64 +if ((adev->flags &AMD_IS_APU ) && !amdgpu_passthrough (adev)) +return ; +#endif +if (ring->wptr) +WREG32_NO_KIQ ((adev->rmmio_remap.reg_offset +KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL ) >>2 ,0 ); +} +/** * vcn_v4_0_3_unified_ring_set_wptr - set enc write pointer *
@@ -1394,6 +1415,9 @@ static void vcn_v4_0_3_unified_ring_set_wptr(struct amdgpu_ring *ring)if (ring != &adev->vcn.inst[ring->me].ring_enc[0 ])DRM_ERROR ("wrong ring id is identified in %s" , __func__); +/* Flush HDP before ringing doorbell */ +vcn_v4_0_3_flush_hdp (ring); +if (ring->use_doorbell) { *ring->wptr_cpu_addr =lower_32_bits (ring->wptr);WDOORBELL32 (ring->doorbell_index,lower_32_bits (ring->wptr));
@@ -1420,6 +1444,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib, .insert_nop = amdgpu_ring_insert_nop,
Signature · 1 line
2.25.1
PATCH 2/2 drm/amdgpu: Use offsets local to VCN in VF
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +19 -1
@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_enc_ring_emit_vm_flush (struct amdgpu_ring *ring, +unsigned int vmid,uint64_t pd_addr) +{ +struct amdgpu_vmhub *hub; + +/* For VF, only local offsets should be used */ +if (amdgpu_sriov_vf (ring->adev)) + ring->vm_hub =AMDGPU_MMHUB0 (0 ); + hub = &ring->adev->vmhub[ring->vm_hub]; + + pd_addr =amdgpu_gmc_emit_flush_gpu_tlb (ring, vmid, pd_addr); + +/* wait for reg writes */ +vcn_v2_0_enc_ring_emit_reg_wait (ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, +lower_32_bits (pd_addr),0xffffffff ); +} +static void vcn_v4_0_3_ring_emit_hdp_flush (struct amdgpu_ring *ring) {/* VCN engine access for HDP flush doesn't work when RRMT is enabled.
@@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib_size = 5, /* vcn_v2_0_enc_ring_emit_ib */ .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush = vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib,
Signature · 1 line
2.25.1
Re: [PATCH 2/2] drm/amdgpu: Use offsets local to VCN in VF
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 14 lines
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR);
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) · line 1391
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +8
-0} +static void vcn_v4_0_3_enc_ring_emit_vm_flush (struct amdgpu_ring *ring, +unsigned int vmid,uint64_t pd_addr) +{ +struct amdgpu_vmhub *hub; + +/* For VF, only local offsets should be used */ +if (amdgpu_sriov_vf (ring->adev)) + ring->vm_hub =AMDGPU_MMHUB0 (0 );
That is clearly a no-go since the vm_hub must be statically and can't be changed here.
Regards,
Christian.
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +11
-1+ hub = &ring->adev->vmhub[ring->vm_hub]; + + pd_addr =amdgpu_gmc_emit_flush_gpu_tlb (ring, vmid, pd_addr); + +/* wait for reg writes */ +vcn_v2_0_enc_ring_emit_reg_wait (ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, +lower_32_bits (pd_addr),0xffffffff ); +} +static void vcn_v4_0_3_ring_emit_hdp_flush (struct amdgpu_ring *ring) {/* VCN engine access for HDP flush doesn't work when RRMT is enabled. @@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib_size = 5, /* vcn_v2_0_enc_ring_emit_ib */ .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush = vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib,
Re: [PATCH 2/2] drm/amdgpu: Use offsets local to VCN in VF
Quoted 24 lines · Christian König
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 21 lines
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c| 20 +++++++++++++++++++-1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); }+static void vcn_v4_0_3_enc_ring_emit_vm_flush(struct
amdgpu_ring*ring,
+ unsigned int vmid,uint64_tpd_addr)
+{
Quoted 9 lines
Quoted 5 lines
+ struct
amdgpu_vmhub*hub;
+
+ /* For VF, only local offsets should be used */ + if (amdgpu_sriov_vf(ring->adev))
+ring->vm_hub=AMDGPU_MMHUB0(0);That is clearly a no-go since the
vm_hubmust be statically and can't be changed here.
After HUB allocation, the only usage of this hub pointer is to calculate use the right offset. We still want VCN to use the right hub, only thing is register offsets in MMHUB(0) are equal to 'local offsets'.
Thanks,
Lijo
Quoted 28 lines
Regards,
Christian.Quoted 24 lines
+ hub = &ring->adev->vmhub[ring->vm_hub];
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +9
-0+ + pd_addr = amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr); + + /* wait for reg writes */ + vcn_v2_0_enc_ring_emit_reg_wait(ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, + lower_32_bits(pd_addr), 0xffffffff); +} +static void
vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring){
/* VCN engine access for HDP flush doesn't work when RRMT is enabled.drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = {.emit_ib_size = 5, /*
vcn_v2_0_enc_ring_emit_ib*/ .emit_ib =vcn_v2_0_enc_ring_emit_ib, .emit_fence =vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush =vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush =vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush =vcn_v4_0_3_ring_emit_hdp_flush, .test_ring =amdgpu_vcn_enc_ring_test_ring, .test_ib =amdgpu_vcn_unified_ring_test_ib,
Re: [PATCH 2/2] drm/amdgpu: Use offsets local to VCN in VF
Am 05.03.24 um 10:03 schrieb Lazar, Lijo:
Quoted 33 lines · Christian König
Quoted 22 lines
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 20 lines
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-0@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_enc_ring_emit_vm_flush(struct amdgpu_ring *ring, + unsigned int vmid, uint64_t pd_addr)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) · line 1391
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +6
-0+{ + struct amdgpu_vmhub *hub; + + /* For VF, only local offsets should be used */ + if (amdgpu_sriov_vf(ring->adev)) + ring->vm_hub = AMDGPU_MMHUB0(0);That is clearly a no-go since the
vm_hubmust be statically and can't be changed here.
Quoted 3 lines
After HUB allocation, the only usage of this hub pointer is to calculate use the right offset. We still want VCN to use the right hub, only thing is register offsets in MMHUB(0) are equal to 'local offsets'.
The vm_hub is a static setup describing how the engine works. You basically just insert an illegal value here to fix your register offset calculation.
That is absolutely *not* something you can do.
What exactly is the requirement?
Regards,
Christian.
Quoted 31 lines
Thanks,
LijoQuoted 27 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +10
-0+ hub = &ring->adev->vmhub[ring->vm_hub]; + + pd_addr = amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr); + + /* wait for reg writes */ + vcn_v2_0_enc_ring_emit_reg_wait(ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, + lower_32_bits(pd_addr), 0xffffffff); +} + static void vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring) { /* VCN engine access for HDP flush doesn't work when RRMT isenabled.
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-1@@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib_size = 5, /* vcn_v2_0_enc_ring_emit_ib */ .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush = vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring,.test_ib =
amdgpu_vcn_unified_ring_test_ib,
Re: [PATCH 2/2] drm/amdgpu: Use offsets local to VCN in VF
Quoted 38 lines · Christian König
Am 05.03.24 um 10:03 schrieb Lazar, Lijo:
Quoted 33 lines · Christian König
Quoted 22 lines
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 20 lines
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c| 20 +++++++++++++++++++-1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); }+static void vcn_v4_0_3_enc_ring_emit_vm_flush(struct
amdgpu_ring*ring,
+ unsigned int vmid,uint64_tpd_addr)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) · line 1391
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +6
-0+{ + struct amdgpu_vmhub *hub; + + /* For VF, only local offsets should be used */ + if (amdgpu_sriov_vf(ring->adev)) + ring->vm_hub = AMDGPU_MMHUB0(0);That is clearly a no-go since the
vm_hubmust be statically and can't be changed here.Quoted 3 lines
After HUB allocation, the only usage of this hub pointer is to calculate use the right offset. We still want VCN to use the right hub, only thing is register offsets in MMHUB(0) are equal to 'local offsets'.
Quoted 8 lines
The
vm_hubis a static setup describing how the engine works. You basically just insert an illegal value here to fix your register offset calculation.That is absolutely *not* something you can do.
What exactly is the requirement?
The requirement is this way -
We have multiple MMHUBs and each VCN can talk only to the local MMHUB.
The absolute register offsets we store for each for an example reg at offset x is
HUB0 = x, HUB1 = x + Y (stride), HUB2 = x + 2Y and so forth.
However VCN cannot use the absolute register offset in the packet in VF mode, instead it should use a local offset for the local HUB in VF mode. A local offset of a register in the HUB is exactly the same as offset of HUB0 = x.
What we do here is assign the HUB as regular here
ring->vm_hub = AMDGPU_MMHUB0(adev->vcn.inst[i].aid_id);
so that amdgpu_gmc_allocate_vm_inv_eng is allocated in the right way.
Then at the time of flush, switch it back to point to HUB0 so that it uses the offsets of HUB0 in the packet. Actually, it's not required to switch this every time, one-time is fine after amdgpu_gmc_allocate_vm_inv_eng() is complete.
Thanks,
Lijo
Quoted 35 lines
Regards,
Christian.Quoted 31 lines
Thanks,
LijoQuoted 27 lines
Regards,
Christian.Quoted 24 lines
+ hub = &ring->adev->vmhub[ring->vm_hub];
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +9
-0+ + pd_addr = amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr); + + /* wait for reg writes */ + vcn_v2_0_enc_ring_emit_reg_wait(ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, + lower_32_bits(pd_addr), 0xffffffff); +} +static void
vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring){
/* VCN engine access for HDP flush doesn't work when RRMT is enabled.drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = {.emit_ib_size = 5, /*
vcn_v2_0_enc_ring_emit_ib*/ .emit_ib =vcn_v2_0_enc_ring_emit_ib, .emit_fence =vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush =vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush =vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush =vcn_v4_0_3_ring_emit_hdp_flush, .test_ring =amdgpu_vcn_enc_ring_test_ring, .test_ib =amdgpu_vcn_unified_ring_test_ib,
Re: [PATCH 2/2] drm/amdgpu: Use offsets local to VCN in VF
Am 05.03.24 um 10:33 schrieb Lazar, Lijo:
Quoted 58 lines · Christian König
Quoted 35 lines
Am 05.03.24 um 10:03 schrieb Lazar, Lijo:
Quoted 31 lines · Christian König
Quoted 21 lines
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 20 lines
For VCN 4.0.3, use only the local addressing scheme while in VF mode. This includes addressing scheme used for HUB offsets.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-0@@ -1381,6 +1381,24 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_enc_ring_emit_vm_flush(struct amdgpu_ring *ring, + unsigned int vmid, uint64_t pd_addr)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) · line 1391
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +6
-0+{ + struct amdgpu_vmhub *hub; + + /* For VF, only local offsets should be used */ + if (amdgpu_sriov_vf(ring->adev)) + ring->vm_hub = AMDGPU_MMHUB0(0);That is clearly a no-go since the
vm_hubmust be statically and can't be changed here.Quoted 3 lines
After HUB allocation, the only usage of this hub pointer is to calculate use the right offset. We still want VCN to use the right hub, only thing is register offsets in MMHUB(0) are equal to 'local offsets'.
Quoted 8 lines
The
vm_hubis a static setup describing how the engine works. You basically just insert an illegal value here to fix your register offset calculation.That is absolutely *not* something you can do.
What exactly is the requirement?
The requirement is this way -
We have multiple MMHUBs and each VCN can talk only to the local MMHUB.
The absolute register offsets we store for each for an example reg at offset x is
HUB0 = x, HUB1 = x + Y (stride), HUB2 = x + 2Y and so forth.However VCN cannot use the absolute register offset in the packet in VF mode, instead it should use a local offset for the local HUB in VF mode. A local offset of a register in the HUB is exactly the same as offset of HUB0 = x.
What we do here is assign the HUB as regular here
Quoted 8 lines
ring->vm_hub = AMDGPU_MMHUB0(adev->vcn.inst[i].aid_id);so that
amdgpu_gmc_allocate_vm_inv_engis allocated in the right way.Then at the time of flush, switch it back to point to HUB0 so that it uses the offsets of HUB0 in the packet. Actually, it's not required to switch this every time, one-time is fine after
amdgpu_gmc_allocate_vm_inv_eng()is complete.
Yeah, but that is not something we can do. vm_hub is a constant and should never be manipulated to fulfill a requirement like that.
If the VCN engines requires that we don't use the aid offsets in the VCN_ENC_CMD_REG_WRITE and VCN_ENC_CMD_REG_WAIT packets then we need to adjust those packets and not the vm_hub.
Also please sync up such with with Leo, he is responsible for coordinating all MM work on the kernel. In general the VCN team should never contact your team directly with such requirements.
Regards,
Christian.
Quoted 37 lines
Thanks,
LijoQuoted 33 lines
Regards,
Christian.Quoted 30 lines
Thanks,
LijoQuoted 27 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +10
-0+ hub = &ring->adev->vmhub[ring->vm_hub]; + + pd_addr = amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr); + + /* wait for reg writes */ + vcn_v2_0_enc_ring_emit_reg_wait(ring, hub->ctx0_ptb_addr_lo32 + + vmid * hub->ctx_addr_distance, + lower_32_bits(pd_addr), 0xffffffff); +} + static void vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring) { /* VCN engine access for HDP flush doesn't work when RRMT isenabled.
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-1@@ -1443,7 +1461,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib_size = 5, /* vcn_v2_0_enc_ring_emit_ib */ .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, - .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_vm_flush = vcn_v4_0_3_enc_ring_emit_vm_flush, .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring,.test_ib =
amdgpu_vcn_unified_ring_test_ib,
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 2 lines
VCN 4.0.3 cannot trigger HDP flush with RRMT enabled. Instead, trigger HDP flush from host side before ringing doorbell.
Well that won't work like that.
The HDP flush is supposed to be emitted into the ring buffer of the engine. If you just "emulate" it by a register write than that write comes at the wrong time.
This code here is seriously broken.
Regards,
Christian.
Quoted 63 lines
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +25
-0@@ -36,6 +36,7 @@#include "vcn/vcn_4_0_3_offset.h" #include "vcn/vcn_4_0_3_sh_mask.h" #include "ivsrcid/vcn/irqsrcs_vcn_4_0.h" +#include <uapi/linux/kfd_ioctl.h> #define mmUVD_DPG_LMA_CTL regUVD_DPG_LMA_CTL#define mmUVD_DPG_LMA_CTL_BASE_IDX regUVD_DPG_LMA_CTL_BASE_IDX@@ -1380,6 +1381,26 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_ring_emit_hdp_flush (struct amdgpu_ring *ring) +{ +/* VCN engine access for HDP flush doesn't work when RRMT is enabled. +* This is a workaround to avoid any HDP flush through VCN ring. Instead +* HDP flush will be done by driver while submitting doorbell. +*/ +} + +static void vcn_v4_0_3_flush_hdp (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; + +#ifdef CONFIG_X86_64 +if ((adev->flags &AMD_IS_APU ) && !amdgpu_passthrough (adev)) +return ; +#endif +if (ring->wptr) +WREG32_NO_KIQ ((adev->rmmio_remap.reg_offset +KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL ) >>2 ,0 ); +} +/** * vcn_v4_0_3_unified_ring_set_wptr - set enc write pointer * @@ -1394,6 +1415,9 @@ static void vcn_v4_0_3_unified_ring_set_wptr(struct amdgpu_ring *ring)if (ring != &adev->vcn.inst[ring->me].ring_enc[0 ])DRM_ERROR ("wrong ring id is identified in %s" , __func__); +/* Flush HDP before ringing doorbell */ +vcn_v4_0_3_flush_hdp (ring); +if (ring->use_doorbell) { *ring->wptr_cpu_addr =lower_32_bits (ring->wptr);WDOORBELL32 (ring->doorbell_index,lower_32_bits (ring->wptr));@@ -1420,6 +1444,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib, .insert_nop = amdgpu_ring_insert_nop,
Quoted 4 lines · Christian König
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 2 lines
VCN 4.0.3 cannot trigger HDP flush with RRMT enabled. Instead, trigger HDP flush from host side before ringing doorbell.
Quoted 8 lines
Well that won't work like that.
The HDP flush is supposed to be emitted into the ring buffer of the engine. If you just "emulate" it by a register write than that write comes at the wrong time.
This code here is seriously broken.
This approach was in fact suggested by VCN IP and FW team since RRMT is not working from VCN side to do a remote flush of HDP (HDP is active only in one of the AIDs). They mentioned that VCN doesn't need to flush HDP at the time of processing.
Thanks,
Lijo
Quoted 71 lines
Regards,
Christian.Quoted 67 lines
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c| 25 +++++++++++++++++++++++++1 file changed, 25 insertions(+)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +3
-0@@ -36,6 +36,7 @@ #include "vcn/vcn_4_0_3_offset.h" #include "vcn/vcn_4_0_3_sh_mask.h" #include "ivsrcid/vcn/irqsrcs_vcn_4_0.h" +#include <uapi/linux/kfd_ioctl.h> #define mmUVD_DPG_LMA_CTL regUVD_DPG_LMA_CTL #define mmUVD_DPG_LMA_CTL_BASE_IDX regUVD_DPG_LMA_CTL_BASE_IDX@@ -1380,6 +1381,26 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring) +{ + /* VCN engine access for HDP flush doesn't work when RRMT isenabled.
+ * This is a workaround to avoid any HDP flush through VCN ring. Instead
+ * HDP flush will be done by driver while submitting doorbell. + */drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +12
-0+} + +static void vcn_v4_0_3_flush_hdp (struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + +#ifdef CONFIG_X86_64 + if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) + return; +#endif + if (ring->wptr) + WREG32_NO_KIQ((adev->rmmio_remap.reg_offset +
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +2
-0+} +/**
*vcn_v4_0_3_unified_ring_set_wptr- set enc write pointer *drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1394,6 +1415,9 @@ static void vcn_v4_0_3_unified_ring_set_wptr(struct amdgpu_ring *ring) if (ring != &adev->vcn.inst[ring->me].ring_enc[0]) DRM_ERROR("wrong ring id is identified in %s", __func__);+ /* Flush HDP before ringing doorbell */
+vcn_v4_0_3_flush_hdp(ring);
+
if (ring->use_doorbell) {
*ring->wptr_cpu_addr=lower_32_bits(ring->wptr);WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-0@@ -1420,6 +1444,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib,.insert_nop =
amdgpu_ring_insert_nop,
Am 05.03.24 um 10:01 schrieb Lazar, Lijo:
Quoted 10 lines · Christian König
Quoted 9 lines
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 2 lines
VCN 4.0.3 cannot trigger HDP flush with RRMT enabled. Instead, trigger HDP flush from host side before ringing doorbell.
Well that won't work like that.
The HDP flush is supposed to be emitted into the ring buffer of the engine. If you just "emulate" it by a register write than that write comes at the wrong time.
Quoted 6 lines
Quoted 2 lines
This code here is seriously broken.
This approach was in fact suggested by VCN IP and FW team since RRMT is not working from VCN side to do a remote flush of HDP (HDP is active only in one of the AIDs). They mentioned that VCN doesn't need to flush HDP at the time of processing.
In this case you don't need to implement anything here.
See amdgpu_device_flush_hdp(), we already have the CPU fallback for the engines which don't have access to the HDP:
#ifdef CONFIG_X86_64
if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) return;
#endif
if (adev->gmc.xgmi.connected_to_cpu)
return;
if (ring && ring->funcs->emit_hdp_flush) amdgpu_ring_emit_hdp_flush(ring); else
amdgpu_asic_flush_hdp(adev, ring);
Regards,
Christian.
Quoted 73 lines
Thanks,
LijoQuoted 69 lines
Regards,
Christian.Quoted 66 lines
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +3
-0@@ -36,6 +36,7 @@ #include "vcn/vcn_4_0_3_offset.h" #include "vcn/vcn_4_0_3_sh_mask.h" #include "ivsrcid/vcn/irqsrcs_vcn_4_0.h" +#include <uapi/linux/kfd_ioctl.h> #define mmUVD_DPG_LMA_CTL regUVD_DPG_LMA_CTL #define mmUVD_DPG_LMA_CTL_BASE_IDX regUVD_DPG_LMA_CTL_BASE_IDX@@ -1380,6 +1381,26 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); } +static void vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring) +{ + /* VCN engine access for HDP flush doesn't work when RRMT isenabled.
+ * This is a workaround to avoid any HDP flush through VCN ring. Instead
+ * HDP flush will be done by driver while submitting doorbell. + */drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +12
-0+} + +static void vcn_v4_0_3_flush_hdp (struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + +#ifdef CONFIG_X86_64 + if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) + return; +#endif + if (ring->wptr) + WREG32_NO_KIQ((adev->rmmio_remap.reg_offset +
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +5
-0+} + /*** vcn_v4_0_3_unified_ring_set_wptr - set enc write pointer * @@ -1394,6 +1415,9 @@ static void vcn_v4_0_3_unified_ring_set_wptr(struct amdgpu_ring *ring) if (ring != &adev->vcn.inst[ring->me].ring_enc[0]) DRM_ERROR("wrong ring id is identified in %s", __func__); + /* Flush HDP before ringing doorbell */ + vcn_v4_0_3_flush_hdp(ring); + if (ring->use_doorbell) { *ring->wptr_cpu_addr = lower_32_bits(ring->wptr); WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));@@ -1420,6 +1444,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib,.insert_nop =
amdgpu_ring_insert_nop,
Quoted 30 lines · Christian König
Am 05.03.24 um 10:01 schrieb Lazar, Lijo:
Quoted 10 lines · Christian König
Quoted 9 lines
Am 05.03.24 um 07:40 schrieb Lijo Lazar:
Quoted 2 lines
VCN 4.0.3 cannot trigger HDP flush with RRMT enabled. Instead, trigger HDP flush from host side before ringing doorbell.
Well that won't work like that.
The HDP flush is supposed to be emitted into the ring buffer of the engine. If you just "emulate" it by a register write than that write comes at the wrong time.
Quoted 6 lines
Quoted 2 lines
This code here is seriously broken.
This approach was in fact suggested by VCN IP and FW team since RRMT is not working from VCN side to do a remote flush of HDP (HDP is active only in one of the AIDs). They mentioned that VCN doesn't need to flush HDP at the time of processing.
In this case you don't need to implement anything here.
See
amdgpu_device_flush_hdp(), we already have the CPU fallback for the engines which don't have access to the HDP:#ifdef
CONFIG_X86_64
if ((adev->flags&AMD_IS_APU) && !amdgpu_passthrough(adev)) return;
#endif
if (adev->gmc.xgmi.connected_to_cpu)
return;
Quoted 5 lines
if (ring &&
ring->funcs->emit_hdp_flush)amdgpu_ring_emit_hdp_flush(ring); else
amdgpu_asic_flush_hdp(adev, ring);
The recommendation was to do a HDP flush at the time of packet submission before write pointer update. Hence we added a dummy emit_hdp_flush() to the ring which does nothing at this point and does a flush only before it updates write pointer.
Thanks,
Lijo
Quoted 80 lines
Regards,
Christian.Quoted 76 lines
Thanks,
LijoQuoted 72 lines
Regards,
Christian.Quoted 69 lines
Signed-off-by Lijo Lazar <[email protected]>---
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c| 25
+++++++++++++++++++++++++1 file changed, 25 insertions(+)drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-0@@ -36,6 +36,7 @@ #include "vcn/vcn_4_0_3_offset.h" #include "vcn/vcn_4_0_3_sh_mask.h" #include "ivsrcid/vcn/irqsrcs_vcn_4_0.h" +#include <uapi/linux/kfd_ioctl.h> #define mmUVD_DPG_LMA_CTL regUVD_DPG_LMA_CTL #define mmUVD_DPG_LMA_CTL_BASE_IDX regUVD_DPG_LMA_CTL_BASE_IDX@@ -1380,6 +1381,26 @@ static uint64_t vcn_v4_0_3_unified_ring_get_wptr(struct amdgpu_ring *ring) regUVD_RB_WPTR); }+static void
vcn_v4_0_3_ring_emit_hdp_flush(struct amdgpu_ring *ring)
+{
+ /* VCN engine access for HDP flush doesn't work when RRMT is enabled.
+ * This is a workaround to avoid any HDP flush through VCN ring. Instead
+ * HDP flush will be done by driver while submitting doorbell. + */drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +12
-0+} + +static void vcn_v4_0_3_flush_hdp (struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + +#ifdef CONFIG_X86_64 + if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) + return; +#endif + if (ring->wptr) + WREG32_NO_KIQ((adev->rmmio_remap.reg_offset +
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +2
-0+} +/**
*vcn_v4_0_3_unified_ring_set_wptr- set enc write pointer *drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +0
-0@@ -1394,6 +1415,9 @@ static void vcn_v4_0_3_unified_ring_set_wptr(struct amdgpu_ring *ring) if (ring != &adev->vcn.inst[ring->me].ring_enc[0]) DRM_ERROR("wrong ring id is identified in %s", __func__);+ /* Flush HDP before ringing doorbell */
+vcn_v4_0_3_flush_hdp(ring);
+
if (ring->use_doorbell) {*ring->wptr_cpu_addr=lower_32_bits(ring->wptr);WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr));drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +1
-0@@ -1420,6 +1444,7 @@ static const struct amdgpu_ring_funcs vcn_v4_0_3_unified_ring_vm_funcs = { .emit_ib = vcn_v2_0_enc_ring_emit_ib, .emit_fence = vcn_v2_0_enc_ring_emit_fence, .emit_vm_flush = vcn_v2_0_enc_ring_emit_vm_flush, + .emit_hdp_flush = vcn_v4_0_3_ring_emit_hdp_flush, .test_ring = amdgpu_vcn_enc_ring_test_ring, .test_ib = amdgpu_vcn_unified_ring_test_ib,.insert_nop =
amdgpu_ring_insert_nop,