Skip to content

Commit cc7818d

Browse files
Yang Wangalexdeucher
authored andcommitted
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) Signed-off-by: Yang Wang <[email protected]> Reviewed-by: Guchun Chen <[email protected]> Reviewed-by: Lijo Lazar <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 23eb492 commit cc7818d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev)
248248

249249
offset = offsetof(struct binary_header, binary_checksum) +
250250
sizeof(bhdr->binary_checksum);
251-
size = bhdr->binary_size - offset;
252-
checksum = bhdr->binary_checksum;
251+
size = le16_to_cpu(bhdr->binary_size) - offset;
252+
checksum = le16_to_cpu(bhdr->binary_checksum);
253253

254254
if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
255255
size, checksum)) {
@@ -270,7 +270,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev)
270270
}
271271

272272
if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
273-
ihdr->size, checksum)) {
273+
le16_to_cpu(ihdr->size), checksum)) {
274274
DRM_ERROR("invalid ip discovery data table checksum\n");
275275
r = -EINVAL;
276276
goto out;
@@ -282,7 +282,7 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev)
282282
ghdr = (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
283283

284284
if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
285-
ghdr->size, checksum)) {
285+
le32_to_cpu(ghdr->size), checksum)) {
286286
DRM_ERROR("invalid gc data table checksum\n");
287287
r = -EINVAL;
288288
goto out;
@@ -489,10 +489,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
489489
le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));
490490

491491
for (i = 0; i < 32; i++) {
492-
if (le32_to_cpu(harvest_info->list[i].hw_id) == 0)
492+
if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
493493
break;
494494

495-
switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
495+
switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
496496
case VCN_HWID:
497497
vcn_harvest_count++;
498498
if (harvest_info->list[i].number_instance == 0)

0 commit comments

Comments
 (0)