drm/amdgpu: fix byteorder error in amdgpu discovery
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix byteorder error in amdgpu discovery
fix some byteorder issues about amdgpu discovery.
This will result in running errors on the big end system. (e.g:MIPS)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +6 -6
@@ -248,8 +248,8 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) offset = offsetof(struct binary_header , binary_checksum) +sizeof (bhdr->binary_checksum); - size = bhdr->binary_size - offset; - checksum = bhdr->binary_checksum; + size =le16_to_cpu (bhdr->binary_size) - offset; + checksum =le16_to_cpu (bhdr->binary_checksum);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, size, checksum)) {
@@ -270,7 +270,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) }if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ihdr->size, checksum)) { +le16_to_cpu (ihdr->size), checksum)) {DRM_ERROR ("invalid ip discovery data table checksum\n" ); r = -EINVAL ; goto out;
@@ -282,7 +282,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) ghdr = (struct gpu_info_header *)(adev->mman.discovery_bin + offset);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ghdr->size, checksum)) { +le32_to_cpu (ghdr->size), checksum)) {DRM_ERROR ("invalid gc data table checksum\n" ); r = -EINVAL ; goto out;
@@ -489,10 +489,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev) le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));for (i =0 ; i <32 ; i++) { -if (le32_to_cpu (harvest_info->list[i].hw_id) ==0 ) +if (le16_to_cpu (harvest_info->list[i].hw_id) ==0 )break ; -switch (le32_to_cpu (harvest_info->list[i].hw_id)) { +switch (le16_to_cpu (harvest_info->list[i].hw_id)) {case VCN_HWID : vcn_harvest_count++;if (harvest_info->list[i].number_instance ==0 )
Signature · 1 line
2.25.1
Quoted 4 lines · Yang Wang
fix some byteorder issues about amdgpu discovery.
This will result in running errors on the big end system. (e.g:MIPS)Signed-off-by Yang Wang <[email protected]>
Thanks,
Lijo
Quoted 51 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +6
-6@@ -248,8 +248,8 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) offset = offsetof(struct binary_header , binary_checksum) +sizeof (bhdr->binary_checksum); - size = bhdr->binary_size - offset; - checksum = bhdr->binary_checksum; + size =le16_to_cpu (bhdr->binary_size) - offset; + checksum =le16_to_cpu (bhdr->binary_checksum);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, size, checksum)) {@@ -270,7 +270,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) }if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ihdr->size, checksum)) { +le16_to_cpu (ihdr->size), checksum)) {DRM_ERROR ("invalid ip discovery data table checksum\n" ); r = -EINVAL ; goto out;@@ -282,7 +282,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) ghdr = (struct gpu_info_header *)(adev->mman.discovery_bin + offset);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ghdr->size, checksum)) { +le32_to_cpu (ghdr->size), checksum)) {DRM_ERROR ("invalid gc data table checksum\n" ); r = -EINVAL ; goto out;@@ -489,10 +489,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev) le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));for (i =0 ; i <32 ; i++) { -if (le32_to_cpu (harvest_info->list[i].hw_id) ==0 ) +if (le16_to_cpu (harvest_info->list[i].hw_id) ==0 )break ; -switch (le32_to_cpu (harvest_info->list[i].hw_id)) { +switch (le16_to_cpu (harvest_info->list[i].hw_id)) {case VCN_HWID : vcn_harvest_count++;if (harvest_info->list[i].number_instance ==0 )
[Public]
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yang Wang
Sent: Wednesday, November 24, 2021 12:37 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH] drm/amdgpu: fix byteorder error in amdgpu discovery
fix some byteorder issues about amdgpu discovery.
This will result in running errors on the big end system. (e.g:MIPS)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +6 -6
@@ -248,8 +248,8 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) offset = offsetof(struct binary_header , binary_checksum) +sizeof (bhdr->binary_checksum); - size = bhdr->binary_size - offset; - checksum = bhdr->binary_checksum; + size =le16_to_cpu (bhdr->binary_size) - offset; + checksum =le16_to_cpu (bhdr->binary_checksum);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, size, checksum)) {
@@ -270,7 +270,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) }if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ihdr->size, checksum)) { +le16_to_cpu (ihdr->size), checksum)) {DRM_ERROR ("invalid ip discovery data table checksum\n" ); r = -EINVAL ; goto out;
@@ -282,7 +282,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) ghdr = (struct gpu_info_header *)(adev->mman.discovery_bin + offset);if (!amdgpu_discovery_verify_checksum (adev->mman.discovery_bin + offset, - ghdr->size, checksum)) { +le32_to_cpu (ghdr->size), checksum)) {DRM_ERROR ("invalid gc data table checksum\n" ); r = -EINVAL ; goto out;
@@ -489,10 +489,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev) le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));for (i =0 ; i <32 ; i++) { -if (le32_to_cpu (harvest_info->list[i].hw_id) ==0 ) +if (le16_to_cpu (harvest_info->list[i].hw_id) ==0 )break ; -switch (le32_to_cpu (harvest_info->list[i].hw_id)) { +switch (le16_to_cpu (harvest_info->list[i].hw_id)) {case VCN_HWID : vcn_harvest_count++;if (harvest_info->list[i].number_instance ==0 )
Signature · 1 line
2.25.1