Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: Improve IP discovery checksum failure logging

Enhance the error logging in amdgpu_discovery_verify_checksum() to
print the calculated checksum, the expected checksum, the data size.

This extra context helps quickly identify if the issue is a data
corruption, a partially read binary, or an invalid table header without
requiring additional instrumentation.

Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Yifan Zhang <yifan1.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Perry Yuan and committed by
Alex Deucher
54f2fc76 5d42ee45

+21 -10
+21 -10
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 380 380 return checksum; 381 381 } 382 382 383 - static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size, 383 + static inline bool amdgpu_discovery_verify_checksum(struct amdgpu_device *adev, 384 + uint8_t *data, uint32_t size, 384 385 uint16_t expected) 385 386 { 386 - return !!(amdgpu_discovery_calculate_checksum(data, size) == expected); 387 + uint16_t calculated; 388 + 389 + calculated = amdgpu_discovery_calculate_checksum(data, size); 390 + 391 + if (calculated != expected) { 392 + dev_err(adev->dev, "Discovery checksum failed: calc 0x%04x != exp 0x%04x, size %u.\n", 393 + calculated, expected, size); 394 + return false; 395 + } 396 + 397 + return true; 387 398 } 388 399 389 400 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary) ··· 450 439 return -EINVAL; 451 440 } 452 441 453 - if (!amdgpu_discovery_verify_checksum(discovery_bin + offset, 442 + if (!amdgpu_discovery_verify_checksum(adev, discovery_bin + offset, 454 443 le32_to_cpu(nhdr->size_bytes), 455 444 checksum)) { 456 445 dev_dbg(adev->dev, "invalid nps info data table checksum\n"); ··· 540 529 size = le16_to_cpu(bhdr->binary_size) - offset; 541 530 checksum = le16_to_cpu(bhdr->binary_checksum); 542 531 543 - if (!amdgpu_discovery_verify_checksum(discovery_bin + offset, size, 532 + if (!amdgpu_discovery_verify_checksum(adev, discovery_bin + offset, size, 544 533 checksum)) { 545 534 dev_err(adev->dev, "invalid ip discovery binary checksum\n"); 546 535 r = -EINVAL; ··· 560 549 goto out; 561 550 } 562 551 563 - if (!amdgpu_discovery_verify_checksum(discovery_bin + offset, 552 + if (!amdgpu_discovery_verify_checksum(adev, discovery_bin + offset, 564 553 le16_to_cpu(ihdr->size), 565 554 checksum)) { 566 555 dev_err(adev->dev, "invalid ip discovery data table checksum\n"); ··· 583 572 goto out; 584 573 } 585 574 586 - if (!amdgpu_discovery_verify_checksum(discovery_bin + offset, 575 + if (!amdgpu_discovery_verify_checksum(adev, discovery_bin + offset, 587 576 le32_to_cpu(ghdr->size), 588 577 checksum)) { 589 578 dev_err(adev->dev, "invalid gc data table checksum\n"); ··· 606 595 goto out; 607 596 } 608 597 609 - if (!amdgpu_discovery_verify_checksum( 598 + if (!amdgpu_discovery_verify_checksum(adev, 610 599 discovery_bin + offset, 611 600 sizeof(struct harvest_table), checksum)) { 612 601 dev_err(adev->dev, "invalid harvest data table checksum\n"); ··· 629 618 goto out; 630 619 } 631 620 632 - if (!amdgpu_discovery_verify_checksum( 621 + if (!amdgpu_discovery_verify_checksum(adev, 633 622 discovery_bin + offset, 634 623 le32_to_cpu(vhdr->size_bytes), checksum)) { 635 624 dev_err(adev->dev, "invalid vcn data table checksum\n"); ··· 652 641 goto out; 653 642 } 654 643 655 - if (!amdgpu_discovery_verify_checksum( 644 + if (!amdgpu_discovery_verify_checksum(adev, 656 645 discovery_bin + offset, 657 646 le32_to_cpu(mhdr->size_bytes), checksum)) { 658 647 dev_err(adev->dev, "invalid mall data table checksum\n"); ··· 1878 1867 sizeof(*nps_data), false); 1879 1868 1880 1869 nhdr = (struct nps_info_header *)(nps_data); 1881 - if (!amdgpu_discovery_verify_checksum((uint8_t *)nps_data, 1870 + if (!amdgpu_discovery_verify_checksum(adev, (uint8_t *)nps_data, 1882 1871 le32_to_cpu(nhdr->size_bytes), 1883 1872 checksum)) { 1884 1873 dev_err(adev->dev, "nps data refresh, checksum mismatch\n");