drm/amdgpu: add dummy read by engines for some GCVM status registers
Subsystems (2)
PATCH 1/1 drm/amdgpu: add dummy read by engines for some GCVM status registers
From: changzhu <[email protected]>
The GRBM register interface is now capable of bursting 1 cycle per register wr->wr, wr->rd much faster than previous muticycle per transaction done interface. This has caused a problem where status registers requiring HW to update have a 1 cycle delay, due to the register update having to go through GRBM.
For cp ucode, it has realized dummy read in cp firmware.It covers the use of WAIT_REG_MEM operation 1 case only.So it needs to call gfx_v10_0_wait_reg_mem in gfx10. Besides it also needs to add warning to update firmware in case firmware is too old to have function to realize dummy read in cp firmware.
For sdma ucode, it hasn't realized dummy read in sdma firmware. sdma is moved to gfxhub in gfx10. So it needs to add dummy read in driver between amdgpu_ring_emit_wreg and amdgpu_ring_emit_reg_wait for sdma_v5_0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 50 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 8 ++-- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 13 ++++++- 5 files changed, 73 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -267,6 +267,7 @@ struct amdgpu_gfx {uint32_t mec2_feature_version;bool mec_fw_write_wait;bool me_fw_write_wait; +bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ];unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ];
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +50 -0
74 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7 -0
@@ -982,6 +982,13 @@ static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) adev->gfx.me_fw_write_wait = false; adev->gfx.mec_fw_write_wait = false; +if ((adev->gfx.mec_fw_version <0x000001a5 ) || + (adev->gfx.mec_feature_version <46 ) || + (adev->gfx.pfp_fw_version <0x000000b7 ) || + (adev->gfx.pfp_feature_version <46 )) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); +switch (adev->asic_type) {case CHIP_VEGA10 : if ((adev->gfx.me_fw_version >= 0x0000009c) &&
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +3 -5
@@ -344,11 +344,9 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,amdgpu_ring_emit_wreg (ring, hub->ctx0_ptb_addr_hi32 + (2 * vmid),upper_32_bits (pd_addr)); -amdgpu_ring_emit_wreg (ring, hub->vm_inv_eng0_req + eng, req); - -/* wait for the invalidate to complete */ -amdgpu_ring_emit_reg_wait (ring, hub->vm_inv_eng0_ack + eng, -1 << vmid,1 << vmid); +amdgpu_ring_emit_reg_write_reg_wait (ring, hub->vm_inv_eng0_req + eng, + hub->vm_inv_eng0_ack, + req,1 << vmid);return pd_addr; }
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +12 -1
@@ -1170,6 +1170,16 @@ static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); } +static void sdma_v5_0_ring_emit_reg_write_reg_wait (struct amdgpu_ring *ring, +uint32_t reg0,uint32_t reg1, +uint32_t ref,uint32_t mask) +{ +amdgpu_ring_emit_wreg (ring, reg0, ref); +/* wait for a cycle to reset vm_inv_eng*_ack */ +amdgpu_ring_emit_reg_wait (ring, reg0, mask, mask); +amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); +} +static int sdma_v5_0_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -1585,7 +1595,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {6 +/* sdma_v5_0_ring_emit_pipeline_sync */ /* sdma_v5_0_ring_emit_vm_flush */ SOC15_FLUSH_GPU_TLB_NUM_WREG *3 + -SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 + +SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 *2 + 10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */ .emit_ib_size = 7 + 6, /* sdma_v5_0_ring_emit_ib */ .emit_ib = sdma_v5_0_ring_emit_ib,
@@ -1599,6 +1609,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { .pad_ib = sdma_v5_0_ring_pad_ib, .emit_wreg = sdma_v5_0_ring_emit_wreg, .emit_reg_wait = sdma_v5_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait, .init_cond_exec = sdma_v5_0_ring_init_cond_exec, .patch_cond_exec = sdma_v5_0_ring_patch_cond_exec, .preempt_ib = sdma_v5_0_ring_preempt_ib,
Signature · 6 lines
2.17.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): 20191105063228.28185-1-changfeng.zhu-5C7GfCeVMHo@public.gmane.org
Am 05.11.19 um 07:32 schrieb Zhu, Changfeng:
Quoted 14 lines
From: changzhu <[email protected]>
The GRBM register interface is now capable of bursting 1 cycle per register
wr->wr,wr->rdmuch faster than previous muticycle per transaction done interface. This has caused a problem where status registers requiring HW to update have a 1 cycle delay, due to the register update having to go through GRBM.For cp ucode, it has realized dummy read in cp firmware.It covers the use of
WAIT_REG_MEMoperation 1 case only.So it needs to callgfx_v10_0_wait_reg_memin gfx10. Besides it also needs to add warning to update firmware in case firmware is too old to have function to realize dummy read in cp firmware.
Quoted 3 lines
For sdma ucode, it hasn't realized dummy read in sdma firmware. sdma is moved to gfxhub in gfx10. So it needs to add dummy read in driver between
amdgpu_ring_emit_wregandamdgpu_ring_emit_reg_waitforsdma_v5_0.
First of all thanks for getting your environment setup properly, we are finally making progress with that issue.
A bunch of nice to have comments below and two major bugs/typos which really needs to be fixed.
Quoted 66 lines
Change-Id Ie028f37eb789966d4593984bd661b248ebeb1ac3Signed-off-by changzhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 50 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 8 ++-- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 13 ++++++- 5 files changed, 73 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -267,6 +267,7 @@ struct amdgpu_gfx {uint32_t mec2_feature_version;bool mec_fw_write_wait;bool me_fw_write_wait; +bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ];unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ];drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +28
-0@@ -561,6 +561,32 @@ static void gfx_v10_0_free_microcode(struct amdgpu_device *adev)kfree (adev->gfx.rlc.register_list_format); } +static void gfx_v10_0_check_fw_write_wait (struct amdgpu_device *adev) +{ + adev->gfx.cp_fw_write_wait = false; + +switch (adev->asic_type) { +case CHIP_NAVI10 : +case CHIP_NAVI12 : +case CHIP_NAVI14 : +if ((adev->gfx.me_fw_version >=0x00000046 ) && + (adev->gfx.me_feature_version >=27 ) && + (adev->gfx.pfp_fw_version >=0x00000068 ) && + (adev->gfx.pfp_feature_version >=27 ) && + (adev->gfx.mec_fw_version >=0x0000005b ) && + (adev->gfx.mec_feature_version >=27 )) + adev->gfx.cp_fw_write_wait = true; +break ; +default : +break ; + } + +if (adev->gfx.cp_fw_write_wait == false) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); +} + +static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) {const struct rlc_firmware_header_v2_1 *rlc_hdr;@@ -4768,6 +4794,28 @@ static void gfx_v10_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg,gfx_v10_0_wait_reg_mem (ring,0 ,0 ,0 , reg,0 , val, mask,0x20 ); } +static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, + uint32_t reg0, uint32_t reg1,
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static void gfx_v10_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 4808
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10
-0+ uint32_t ref, uint32_t mask) +{ + int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); +struct amdgpu_device *adev = ring->adev; +bool fw_version_ok = false; + +gfx_v10_0_check_fw_write_wait (adev); + +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE )
That check is probably superfluous. A few lines below you are using the function in the gfx_v10_0_ring_funcs_gfx and gfx_v10_0_ring_funcs_compute, so the ring->funcs->type is always constant.
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +12
-0+ fw_version_ok = adev->gfx.cp_fw_write_wait; + +if (fw_version_ok) +gfx_v10_0_wait_reg_mem (ring, usepfp,0 ,1 , reg0, reg1, + ref, mask,0x20 ); +else +amdgpu_ring_emit_reg_write_reg_wait_helper (ring, reg0, reg1, + ref, mask); +} + static void gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe,@@ -5158,6 +5206,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_tmz = gfx_v10_0_ring_emit_tmz, .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, };static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = {@@ -5191,6 +5240,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = { .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, };static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = {drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) · line 991
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7
-0@@ -982,6 +982,13 @@ static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) adev->gfx.me_fw_write_wait = false; adev->gfx.mec_fw_write_wait = false; +if ((adev->gfx.mec_fw_version <0x000001a5 ) || + (adev->gfx.mec_feature_version <46 ) || + (adev->gfx.pfp_fw_version <0x000000b7 ) || + (adev->gfx.pfp_feature_version <46 )) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); +
Not a hard requirement, but it would be nice to have this in a separate patch. So that gfx9 and gfx10 changes are clearly separated.
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0switch (adev->asic_type) {case CHIP_VEGA10 : if ((adev->gfx.me_fw_version >= 0x0000009c) &&drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, · line 348
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-5@@ -344,11 +344,9 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,amdgpu_ring_emit_wreg (ring, hub->ctx0_ptb_addr_hi32 + (2 * vmid),upper_32_bits (pd_addr)); -amdgpu_ring_emit_wreg (ring, hub->vm_inv_eng0_req + eng, req); - -/* wait for the invalidate to complete */ -amdgpu_ring_emit_reg_wait (ring, hub->vm_inv_eng0_ack + eng, -1 << vmid,1 << vmid); + amdgpu_ring_emit_reg_write_reg_wait(ring, hub->vm_inv_eng0_req + eng, + hub->vm_inv_eng0_ack,
That register offset is wrong! This needs to be "hub->vm_inv_eng0_ack + eng".
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+ req, 1 << vmid);return pd_addr; }drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 1179
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +7
-0@@ -1170,6 +1170,16 @@ static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); } +static void sdma_v5_0_ring_emit_reg_write_reg_wait (struct amdgpu_ring *ring, +uint32_t reg0,uint32_t reg1, +uint32_t ref,uint32_t mask) +{ +amdgpu_ring_emit_wreg (ring, reg0, ref); +/* wait for a cycle to reset vm_inv_eng*_ack */ +amdgpu_ring_emit_reg_wait (ring, reg0, mask, mask);
Well, that's exactly what won't work. Please use the following instead:
amdgpu_ring_emit_reg_wait(ring, reg1, 0, 0);
Regards,
Christian.
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +4
-1+amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); +} +static int sdma_v5_0_early_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -1585,7 +1595,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {6 +/* sdma_v5_0_ring_emit_pipeline_sync */ /* sdma_v5_0_ring_emit_vm_flush */ SOC15_FLUSH_GPU_TLB_NUM_WREG *3 + -SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 + +SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 *2 + 10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */ .emit_ib_size = 7 + 6, /* sdma_v5_0_ring_emit_ib */ .emit_ib = sdma_v5_0_ring_emit_ib,
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { · line 1615
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +1
-0@@ -1599,6 +1609,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { .pad_ib = sdma_v5_0_ring_pad_ib, .emit_wreg = sdma_v5_0_ring_emit_wreg, .emit_reg_wait = sdma_v5_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait, .init_cond_exec = sdma_v5_0_ring_init_cond_exec, .patch_cond_exec = sdma_v5_0_ring_patch_cond_exec, .preempt_ib = sdma_v5_0_ring_preempt_ib,
_______________________________________________
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): ee976d12-bed0-a3b2-92da-2c8d63cdf90a-5C7GfCeVMHo@public.gmane.org
Hi Chris,
Maybe it's better to use amdgpu_ring_emit_reg_wait(ring, reg0, 0, 0); to replace amdgpu_ring_emit_reg_wait(ring, reg1, 0, 0); ?
http://ontrack-internal.amd.com/browse/SWDEV-192660
Jira ticket recommends to read VM_INVALIDATE_ENG*_REQ.
BR,
Changfeng.
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, November 5, 2019 5:13 PM
To: Zhu, Changfeng <[email protected]>; [email protected]; Tuikov, Luben <[email protected]>; Huang, Ray <[email protected]>; Huang, Shimmer <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add dummy read by engines for some GCVM status registers
Am 05.11.19 um 07:32 schrieb Zhu, Changfeng:
Quoted 14 lines
From: changzhu <[email protected]>
The GRBM register interface is now capable of bursting 1 cycle per register
wr->wr,wr->rdmuch faster than previous muticycle per transaction done interface. This has caused a problem where status registers requiring HW to update have a 1 cycle delay, due to the register update having to go through GRBM.For cp ucode, it has realized dummy read in cp firmware.It covers the use of
WAIT_REG_MEMoperation 1 case only.So it needs to callgfx_v10_0_wait_reg_memin gfx10. Besides it also needs to add warning to update firmware in case firmware is too old to have function to realize dummy read in cp firmware.
Quoted 3 lines
For sdma ucode, it hasn't realized dummy read in sdma firmware. sdma is moved to gfxhub in gfx10. So it needs to add dummy read in driver between
amdgpu_ring_emit_wregandamdgpu_ring_emit_reg_waitforsdma_v5_0.
First of all thanks for getting your environment setup properly, we are finally making progress with that issue.
A bunch of nice to have comments below and two major bugs/typos which really needs to be fixed.
Quoted 67 lines
Change-Id Ie028f37eb789966d4593984bd661b248ebeb1ac3Signed-off-by changzhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 50 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 8 ++-- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 13 ++++++- 5 files changed, 73 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -267,6 +267,7 @@ struct amdgpu_gfx {uint32_t mec2_feature_version;bool mec_fw_write_wait;bool me_fw_write_wait; +bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ];unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ];drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +25
-0@@ -561,6 +561,32 @@ static void gfx_v10_0_free_microcode(struct amdgpu_device *adev)kfree (adev->gfx.rlc.register_list_format); } +static void gfx_v10_0_check_fw_write_wait (struct amdgpu_device *adev) +{ + adev->gfx.cp_fw_write_wait = false; + +switch (adev->asic_type) { +case CHIP_NAVI10 : +case CHIP_NAVI12 : +case CHIP_NAVI14 : +if ((adev->gfx.me_fw_version >=0x00000046 ) && + (adev->gfx.me_feature_version >=27 ) && + (adev->gfx.pfp_fw_version >=0x00000068 ) && + (adev->gfx.pfp_feature_version >=27 ) && + (adev->gfx.mec_fw_version >=0x0000005b ) && + (adev->gfx.mec_feature_version >=27 )) + adev->gfx.cp_fw_write_wait = true; +break ; +default : +break ; + } + +if (adev->gfx.cp_fw_write_wait == false) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); } + +static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) { const struct rlc_firmware_header_v2_1 *rlc_hdr; @@ -4768,6 +4794,28@@ static void gfx_v10_0_ring_emit_reg_wait(struct
amdgpu_ring*ring,uint32_treg,
gfx_v10_0_wait_reg_mem(ring, 0, 0, 0, reg, 0, val, mask, 0x20);
}drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-0+static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, + uint32_t reg0, uint32_t reg1,
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static void gfx_v10_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 4808
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10
-0+ uint32_t ref, uint32_t mask) +{ + int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); +struct amdgpu_device *adev = ring->adev; +bool fw_version_ok = false; + +gfx_v10_0_check_fw_write_wait (adev); + +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE )
That check is probably superfluous. A few lines below you are using the function in the gfx_v10_0_ring_funcs_gfx and gfx_v10_0_ring_funcs_compute, so the ring->funcs->type is always constant.
Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10
-0+ fw_version_ok = adev->gfx.cp_fw_write_wait; + +if (fw_version_ok) +gfx_v10_0_wait_reg_mem (ring, usepfp,0 ,1 , reg0, reg1, + ref, mask,0x20 ); +else +amdgpu_ring_emit_reg_write_reg_wait_helper (ring, reg0, reg1, + ref, mask); +} + static void gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe, @@ -5158,6 +5206,7 @@ staticconst struct
amdgpu_ring_funcsgfx_v10_0_ring_funcs_gfx= {
.emit_tmz =gfx_v10_0_ring_emit_tmz, .emit_wreg =gfx_v10_0_ring_emit_wreg, .emit_reg_wait =gfx_v10_0_ring_emit_reg_wait,drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, }; static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute ={ @@ -5191,6 +5240,7 @@ static const struct
amdgpu_ring_funcsgfx_v10_0_ring_funcs_compute= {
.pad_ib =amdgpu_ring_generic_pad_ib,
.emit_wreg =gfx_v10_0_ring_emit_wreg,
.emit_reg_wait =gfx_v10_0_ring_emit_reg_wait,drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, };static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = {drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) · line 991
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7
-0@@ -982,6 +982,13 @@ static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) adev->gfx.me_fw_write_wait = false; adev->gfx.mec_fw_write_wait = false; +if ((adev->gfx.mec_fw_version <0x000001a5 ) || + (adev->gfx.mec_feature_version <46 ) || + (adev->gfx.pfp_fw_version <0x000000b7 ) || + (adev->gfx.pfp_feature_version <46 )) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); +
Not a hard requirement, but it would be nice to have this in a separate patch. So that gfx9 and gfx10 changes are clearly separated.
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0switch (adev->asic_type) {case CHIP_VEGA10 : if ((adev->gfx.me_fw_version >= 0x0000009c) && diff --git
a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cb/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index3b00bce14cfb..9ff3ec1531ed100644
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, · line 348
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-5@@ -344,11 +344,9 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,amdgpu_ring_emit_wreg (ring, hub->ctx0_ptb_addr_hi32 + (2 * vmid),upper_32_bits (pd_addr)); -amdgpu_ring_emit_wreg (ring, hub->vm_inv_eng0_req + eng, req); - -/* wait for the invalidate to complete */ -amdgpu_ring_emit_reg_wait (ring, hub->vm_inv_eng0_ack + eng, -1 << vmid,1 << vmid); + amdgpu_ring_emit_reg_write_reg_wait(ring, hub->vm_inv_eng0_req + eng, + hub->vm_inv_eng0_ack,
That register offset is wrong! This needs to be "hub->vm_inv_eng0_ack + eng".
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+ req, 1 << vmid);return pd_addr; }drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 1178
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +6
-0@@ -1170,6 +1170,16 @@ static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); } +static void sdma_v5_0_ring_emit_reg_write_reg_wait (struct amdgpu_ring *ring, +uint32_t reg0,uint32_t reg1, +uint32_t ref,uint32_t mask) { +amdgpu_ring_emit_wreg (ring, reg0, ref); +/* wait for a cycle to reset vm_inv_eng*_ack */ +amdgpu_ring_emit_reg_wait (ring, reg0, mask, mask);
Well, that's exactly what won't work. Please use the following instead:
amdgpu_ring_emit_reg_wait(ring, reg1, 0, 0);
Regards,
Christian.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +3
-2+amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +static int sdma_v5_0_early_init (void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; @@ -1585,7 +1595,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {6 +/* sdma_v5_0_ring_emit_pipeline_sync */ /* sdma_v5_0_ring_emit_vm_flush */ SOC15_FLUSH_GPU_TLB_NUM_WREG *3 + -SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 + +SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 *2 + 10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */ .emit_ib_size = 7 + 6, /* sdma_v5_0_ring_emit_ib */ .emit_ib = sdma_v5_0_ring_emit_ib,
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { · line 1615
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +1
-0@@ -1599,6 +1609,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { .pad_ib = sdma_v5_0_ring_pad_ib, .emit_wreg = sdma_v5_0_ring_emit_wreg, .emit_reg_wait = sdma_v5_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait, .init_cond_exec = sdma_v5_0_ring_init_cond_exec, .patch_cond_exec = sdma_v5_0_ring_patch_cond_exec, .preempt_ib = sdma_v5_0_ring_preempt_ib,
_______________________________________________
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): MN2PR12MB2896229161BE3B28B8189690FD7E0-rweVpJHSKToIQ/pRnFqe/[email protected]
Am 05.11.19 um 11:21 schrieb Zhu, Changfeng:
Quoted 4 lines
Hi Chris,
Maybe it's better to use
amdgpu_ring_emit_reg_wait(ring, reg0, 0, 0); to replaceamdgpu_ring_emit_reg_wait(ring, reg1, 0, 0); ?
Good point. I've mixed up request and acknowledge register.
Important is that you need 0 as mask and value, or otherwise we could potentially wait forever.
Regards,
Christian.
Quoted 221 lines
http://ontrack-internal.amd.com/browse/SWDEV-192660
Jira ticket recommends to read VM_INVALIDATE_ENG*_REQ.BR,
Changfeng.-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, November 5, 2019 5:13 PM
To: Zhu, Changfeng <[email protected]>; [email protected]; Tuikov, Luben <[email protected]>; Huang, Ray <[email protected]>; Huang, Shimmer <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add dummy read by engines for some GCVM status registersAm 05.11.19 um 07:32 schrieb Zhu, Changfeng:
Quoted 14 lines
From: changzhu <[email protected]>
The GRBM register interface is now capable of bursting 1 cycle per register
wr->wr,wr->rdmuch faster than previous muticycle per transaction done interface. This has caused a problem where status registers requiring HW to update have a 1 cycle delay, due to the register update having to go through GRBM.For cp ucode, it has realized dummy read in cp firmware.It covers the use of
WAIT_REG_MEMoperation 1 case only.So it needs to callgfx_v10_0_wait_reg_memin gfx10. Besides it also needs to add warning to update firmware in case firmware is too old to have function to realize dummy read in cp firmware.Quoted 3 lines
For sdma ucode, it hasn't realized dummy read in sdma firmware. sdma is moved to gfxhub in gfx10. So it needs to add dummy read in driver between
amdgpu_ring_emit_wregandamdgpu_ring_emit_reg_waitforsdma_v5_0.First of all thanks for getting your environment setup properly, we are finally making progress with that issue.
A bunch of nice to have comments below and two major bugs/typos which really needs to be fixed.
Quoted 66 lines
Change-Id Ie028f37eb789966d4593984bd661b248ebeb1ac3Signed-off-by changzhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 50 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 8 ++-- drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 13 ++++++- 5 files changed, 73 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1
-0@@ -267,6 +267,7 @@ struct amdgpu_gfx {uint32_t mec2_feature_version;bool mec_fw_write_wait;bool me_fw_write_wait; +bool cp_fw_write_wait;struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS ];unsigned num_gfx_rings;struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS ];drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +25
-0@@ -561,6 +561,32 @@ static void gfx_v10_0_free_microcode(struct amdgpu_device *adev)kfree (adev->gfx.rlc.register_list_format); } +static void gfx_v10_0_check_fw_write_wait (struct amdgpu_device *adev) +{ + adev->gfx.cp_fw_write_wait = false; + +switch (adev->asic_type) { +case CHIP_NAVI10 : +case CHIP_NAVI12 : +case CHIP_NAVI14 : +if ((adev->gfx.me_fw_version >=0x00000046 ) && + (adev->gfx.me_feature_version >=27 ) && + (adev->gfx.pfp_fw_version >=0x00000068 ) && + (adev->gfx.pfp_feature_version >=27 ) && + (adev->gfx.mec_fw_version >=0x0000005b ) && + (adev->gfx.mec_feature_version >=27 )) + adev->gfx.cp_fw_write_wait = true; +break ; +default : +break ; + } + +if (adev->gfx.cp_fw_write_wait == false) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); } + +static void gfx_v10_0_init_rlc_ext_microcode (struct amdgpu_device *adev) { const struct rlc_firmware_header_v2_1 *rlc_hdr; @@ -4768,6 +4794,28@@ static void gfx_v10_0_ring_emit_reg_wait(struct
amdgpu_ring*ring,uint32_treg,gfx_v10_0_wait_reg_mem(ring, 0, 0, 0, reg, 0, val, mask, 0x20); }drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-0+static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, + uint32_t reg0, uint32_t reg1,drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static void gfx_v10_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 4808
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10
-0+ uint32_t ref, uint32_t mask) +{ + int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); +struct amdgpu_device *adev = ring->adev; +bool fw_version_ok = false; + +gfx_v10_0_check_fw_write_wait (adev); + +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE )That check is probably superfluous. A few lines below you are using the function in the
gfx_v10_0_ring_funcs_gfxandgfx_v10_0_ring_funcs_compute, so thering->funcs->typeis always constant.Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10
-0+ fw_version_ok = adev->gfx.cp_fw_write_wait; + +if (fw_version_ok) +gfx_v10_0_wait_reg_mem (ring, usepfp,0 ,1 , reg0, reg1, + ref, mask,0x20 ); +else +amdgpu_ring_emit_reg_write_reg_wait_helper (ring, reg0, reg1, + ref, mask); +} + static void gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe, @@ -5158,6 +5206,7 @@ staticconst struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_tmz = gfx_v10_0_ring_emit_tmz, .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait,drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, }; static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute ={ @@ -5191,6 +5240,7 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = { .pad_ib = amdgpu_ring_generic_pad_ib, .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait,drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, };static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_kiq = {drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) · line 991
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7
-0@@ -982,6 +982,13 @@ static void gfx_v9_0_check_fw_write_wait(struct amdgpu_device *adev) adev->gfx.me_fw_write_wait = false; adev->gfx.mec_fw_write_wait = false; +if ((adev->gfx.mec_fw_version <0x000001a5 ) || + (adev->gfx.mec_feature_version <46 ) || + (adev->gfx.pfp_fw_version <0x000000b7 ) || + (adev->gfx.pfp_feature_version <46 )) +DRM_WARN_ONCE ("Warning: check cp_fw_version and update it to realize \ +GRBM requires 1-cycle delay in cp firmware\n" ); +Not a hard requirement, but it would be nice to have this in a separate patch. So that gfx9 and gfx10 changes are clearly separated.
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0switch (adev->asic_type) {case CHIP_VEGA10 : if ((adev->gfx.me_fw_version >= 0x0000009c) && diff --git
a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cb/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index3b00bce14cfb..9ff3ec1531ed100644drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, · line 348
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-5@@ -344,11 +344,9 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,amdgpu_ring_emit_wreg (ring, hub->ctx0_ptb_addr_hi32 + (2 * vmid),upper_32_bits (pd_addr)); -amdgpu_ring_emit_wreg (ring, hub->vm_inv_eng0_req + eng, req); - -/* wait for the invalidate to complete */ -amdgpu_ring_emit_reg_wait (ring, hub->vm_inv_eng0_ack + eng, -1 << vmid,1 << vmid); + amdgpu_ring_emit_reg_write_reg_wait(ring, hub->vm_inv_eng0_req + eng, + hub->vm_inv_eng0_ack,That register offset is wrong! This needs to be "
hub->vm_inv_eng0_ack+ eng".Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+ req, 1 << vmid);return pd_addr; }drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +0
-0drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, · line 1178
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +6
-0@@ -1170,6 +1170,16 @@ static void sdma_v5_0_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg, SDMA_PKT_POLL_REGMEM_DW5_INTERVAL(10)); } +static void sdma_v5_0_ring_emit_reg_write_reg_wait (struct amdgpu_ring *ring, +uint32_t reg0,uint32_t reg1, +uint32_t ref,uint32_t mask) { +amdgpu_ring_emit_wreg (ring, reg0, ref); +/* wait for a cycle to reset vm_inv_eng*_ack */ +amdgpu_ring_emit_reg_wait (ring, reg0, mask, mask);Well, that's exactly what won't work. Please use the following instead:
amdgpu_ring_emit_reg_wait(ring, reg1, 0, 0);Regards,
Christian.Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +3
-2+amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +static int sdma_v5_0_early_init (void *handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle; @@ -1585,7 +1595,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = {6 +/* sdma_v5_0_ring_emit_pipeline_sync */ /* sdma_v5_0_ring_emit_vm_flush */ SOC15_FLUSH_GPU_TLB_NUM_WREG *3 + -SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 + +SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT *6 *2 + 10 + 10 + 10, /* sdma_v5_0_ring_emit_fence x3 for user fence, vm fence */ .emit_ib_size = 7 + 6, /* sdma_v5_0_ring_emit_ib */ .emit_ib = sdma_v5_0_ring_emit_ib,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { · line 1615
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +1
-0@@ -1599,6 +1609,7 @@ static const struct amdgpu_ring_funcs sdma_v5_0_ring_funcs = { .pad_ib = sdma_v5_0_ring_pad_ib, .emit_wreg = sdma_v5_0_ring_emit_wreg, .emit_reg_wait = sdma_v5_0_ring_emit_reg_wait, + .emit_reg_write_reg_wait = sdma_v5_0_ring_emit_reg_write_reg_wait, .init_cond_exec = sdma_v5_0_ring_init_cond_exec, .patch_cond_exec = sdma_v5_0_ring_patch_cond_exec, .preempt_ib = sdma_v5_0_ring_preempt_ib,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx