drm/amdgpu: fix invadate operation for umsch
Subsystems (2)
PATCH v2 1/4 drm/amdgpu: fix invadate operation for umsch
Since the type of data_size is uint32_t, adev->umsch_mm.data_size - 1 >> 16 >> 16 is 0 regardless of the values of its operands
So removing the operations upper_32_bits and lower_32_bits.
--- drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +2 -3
@@ -116,9 +116,8 @@ static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) upper_32_bits(adev->umsch_mm.data_start_addr));WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_LO, -lower_32_bits (adev->umsch_mm.data_size -1 )); -WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI, -upper_32_bits (adev->umsch_mm.data_size -1 )); + adev->umsch_mm.data_size -1 ); +WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI,0 ); data = adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ?0 : adev->umsch_mm.data_fw_gpu_addr;
Signature · 1 line
2.25.1
Quoted 16 lines · Jesse Zhang
Since the type of
data_sizeisuint32_t,adev->umsch_mm.data_size- 1 >> 16 >> 16 is 0 regardless of the values of its operandsSo removing the operations
upper_32_bitsandlower_32_bits.Signed-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) · line 120
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +2
-3@@ -116,9 +116,8 @@ static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) upper_32_bits(adev->umsch_mm.data_start_addr));WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_LO, -lower_32_bits (adev->umsch_mm.data_size -1 )); -WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI, -upper_32_bits (adev->umsch_mm.data_size -1 )); + adev->umsch_mm.data_size -1 ); +WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI,0 );
The original programming and the new one doesn't look correct.
I see the below field definitions as per the header. As per this, both LO/HI are 16-bit fields.
vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_HI__MASK0_HI__SHIFT
0x0
vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_HI__MASK0_HI_MASK
0x0000FFFFLvcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_LO__MASK0_LO__SHIFT
0x10
vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_LO__MASK0_LO_MASK
0xFFFF0000LThanks,
Lijo
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0data = adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ?0 : adev->umsch_mm.data_fw_gpu_addr;
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Lijo
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, May 21, 2024 4:20 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Yu, Lang <[email protected]>
Subject: Re: [PATCH 1/4 V2] drm/amdgpu: fix invadate operation for umsch
Quoted 17 lines · Jesse Zhang
Since the type of
data_sizeisuint32_t,adev->umsch_mm.data_size- 1Quoted 1 line
Quoted 1 line
16 >> 16 is 0 regardless of the values of its operands
So removing the operations
upper_32_bitsandlower_32_bits.Signed-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) · line 120
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +2
-3@@ -116,9 +116,8 @@ static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) upper_32_bits(adev->umsch_mm.data_start_addr));WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_LO, -lower_32_bits (adev->umsch_mm.data_size -1 )); -WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI, -upper_32_bits (adev->umsch_mm.data_size -1 )); + adev->umsch_mm.data_size -1 ); +WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI,0 );
The original programming and the new one doesn't look correct.
I see the below field definitions as per the header. As per this, both LO/HI are 16-bit fields.
vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_HI__MASK0_HI__SHIFT
0x0 vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_HI__MASK0_HI_MASK
0x0000FFFFLvcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_LO__MASK0_LO__SHIFT
0x10 vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_LO__MASK0_LO_MASK
0xFFFF0000L[Zhang, Jesse(Jie)]
The code seem to aligin with Windows side that have same issue. Here is the windows umsch_4_0 write register regVCN_MES_LOCAL_MASK0_LO/regVCN_MES_LOCAL_MASK0_HI
enum umsch_mm_status umsch_mm_engine_init_unsecure_4_0(struct umsch_mm_context* umsch_mm_ip) {
...
temp_data = (uint32_t)umsch_mm_ip->umsch_mm_fw.ucode_info[fw]->data_system_size - 1;
data = temp_data;
umsch_mm_cgs_write_register(umsch_mm_ip, umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_LO, regVCN_MES_LOCAL_MASK0_LO_BASE_IDX), data, HWBLOCK_VCN);
data = temp_data >> 32;
umsch_mm_cgs_write_register(umsch_mm_ip, umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_HI, regVCN_MES_LOCAL_MASK0_HI_BASE_IDX), data, HWBLOCK_VCN);
...
}struct umsch_mm_ucode_consts
{
...
uint32_t data_system_size;
...
}Thanks
Jesse
Thanks,
Lijo
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0data = adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ?0 : adev->umsch_mm.data_fw_gpu_addr;
Quoted 69 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Lijo
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, May 21, 2024 4:20 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Yu, Lang <[email protected]>
Subject: Re: [PATCH 1/4 V2] drm/amdgpu: fix invadate operation for umschQuoted 17 lines · Jesse Zhang
Since the type of
data_sizeisuint32_t,adev->umsch_mm.data_size- 1Quoted 1 line
Quoted 1 line
16 >> 16 is 0 regardless of the values of its operands
So removing the operations
upper_32_bitsandlower_32_bits.Signed-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) · line 120
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +2
-3@@ -116,9 +116,8 @@ static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) upper_32_bits(adev->umsch_mm.data_start_addr));WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_LO, -lower_32_bits (adev->umsch_mm.data_size -1 )); -WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI, -upper_32_bits (adev->umsch_mm.data_size -1 )); + adev->umsch_mm.data_size -1 ); +WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI,0 );cc LangThe original programming and the new one doesn't look correct.
I see the below field definitions as per the header. As per this, both LO/HI are 16-bit fields.
vcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_HI__MASK0_HI__SHIFT0x0 vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_HI__MASK0_HI_MASK 0x0000FFFFLvcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_LO__MASK0_LO__SHIFT0x10 vcn/vcn_4_0_5_sh_mask.h:#define VCN_MES_LOCAL_MASK0_LO__MASK0_LO_MASK 0xFFFF0000L[Zhang, Jesse(Jie)]
The code seem to aligin with Windows side that have same issue. Here is the windows
umsch_4_0write register regVCN_MES_LOCAL_MASK0_LO/regVCN_MES_LOCAL_MASK0_HIenum umsch_mm_status umsch_mm_engine_init_unsecure_4_0(struct umsch_mm_context* umsch_mm_ip) { ... temp_data = (uint32_t)umsch_mm_ip->umsch_mm_fw.ucode_info[fw]->data_system_size - 1; data = temp_data; umsch_mm_cgs_write_register(umsch_mm_ip, umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_LO, regVCN_MES_LOCAL_MASK0_LO_BASE_IDX), data, HWBLOCK_VCN); data = temp_data >> 32; umsch_mm_cgs_write_register(umsch_mm_ip, umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_HI, regVCN_MES_LOCAL_MASK0_HI_BASE_IDX), data, HWBLOCK_VCN); ... }
Quoted 7 lines
struct
umsch_mm_ucode_consts{ ... uint32_t data_system_size; ... }
Thanks, checked the MES spec. Looks like the mask field definitions are wrong. They look like copies of BASE_HI/LO fields which are used for keeping a 64k aligned 48-bit address.
Anyway, the mask fields are for indicating size of the local heap/stack, so most likely won't require usage of MASK0_HI.
Thanks,
Lijo
Quoted 10 lines
Thanks
JesseThanks,
LijoQuoted 3 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0data = adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ?0 : adev->umsch_mm.data_fw_gpu_addr;
[Public]
Quoted 111 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, May 22, 2024 12:57 PM
To: Zhang, Jesse(Jie) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Yu, Lang <[email protected]>
Subject: Re: [PATCH 1/4 V2] drm/amdgpu: fix invadate operation for umschQuoted 11 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Lijo
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, May 21, 2024 4:20 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Yu,Lang
Quoted 18 lines
<[email protected]>
Subject: Re: [PATCH 1/4 V2] drm/amdgpu: fix invadate operation for umschQuoted 11 lines · Jesse Zhang
Since the type of
data_sizeisuint32_t,adev->umsch_mm.data_size- 1Quoted 1 line
Quoted 1 line
16 >> 16 is 0 regardless of the values of its operands
So removing the operations
upper_32_bitsandlower_32_bits.Signed-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c static int
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0@@ -116,9 +116,8 @@ static int
umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c static int umsch_mm_v4_0_load_microcode(struct amdgpu_umsch_mm *umsch) · line 120
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +2
-3upper_32_bits(adev->umsch_mm.data_start_addr));WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_LO, -lower_32_bits (adev->umsch_mm.data_size -1 )); -WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI, -upper_32_bits (adev->umsch_mm.data_size -1 )); + adev->umsch_mm.data_size -1 ); +WREG32_SOC15_UMSCH (regVCN_MES_LOCAL_MASK0_HI,0 );Quoted 5 lines
cc LangThe original programming and the new one doesn't look correct.
I see the below field definitions as per the header. As per this, both LO/HI
are 16-bit fields.
Quoted 2 lines
vcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_HI__MASK0_HI__SHIFTQuoted 1 line
0x0 vcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_HI__MASK0_HI_MASKQuoted 4 lines
0x0000FFFFLvcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_LO__MASK0_LO__SHIFTQuoted 1 line
0x10 vcn/vcn_4_0_5_sh_mask.h:#define
VCN_MES_LOCAL_MASK0_LO__MASK0_LO_MASKQuoted 10 lines
0xFFFF0000L[Zhang, Jesse(Jie)]
The code seem to aligin with Windows side that have same issue. Here is the windows
umsch_4_0write register regVCN_MES_LOCAL_MASK0_LO/regVCN_MES_LOCAL_MASK0_HIenum
umsch_mm_statusumsch_mm_engine_init_unsecure_4_0(structumsch_mm_context*
umsch_mm_ip) {Quoted 10 lines
... temp_data = (uint32_t)umsch_mm_ip- umsch_mm_fw.ucode_info[fw]->data_system_size - 1; data = temp_data; umsch_mm_cgs_write_register(umsch_mm_ip,
umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_LO, regVCN_MES_LOCAL_MASK0_LO_BASE_IDX), data,HWBLOCK_VCN);data = temp_data >> 32; umsch_mm_cgs_write_register(umsch_mm_ip,
umsch_mm_reg_offset(hwip_info, regVCN_MES_LOCAL_MASK0_HI, regVCN_MES_LOCAL_MASK0_HI_BASE_IDX), data,HWBLOCK_VCN);Quoted 10 lines
... }struct
umsch_mm_ucode_consts{ ... uint32_t data_system_size; ... }
Quoted 6 lines
Thanks, checked the MES spec. Looks like the mask field definitions are wrong. They look like copies of BASE_HI/LO fields which are used for keeping a 64k aligned 48-bit address.
Anyway, the mask fields are for indicating size of the local heap/stack, so most likely won't require usage of
MASK0_HI.
Yes, the programing is aligned with windows side.
There is a typo " invadate " in the patch title.
Regards,
Lang
Quoted 13 lines
Thanks,
LijoQuoted 10 lines
Thanks
JesseThanks,
LijoQuoted 3 lines
drivers/gpu/drm/amd/amdgpu/umsch_mm_v4_0.c +0
-0data = adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ?0 : adev->umsch_mm.data_fw_gpu_addr;