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

drm/amdgpu:determine if vPost is needed indeed

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Monk Liu and committed by
Alex Deucher
bec86378 4e99a44e

+44 -4
+44 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 50 50 #include "vi.h" 51 51 #include "bif/bif_4_1_d.h" 52 52 #include <linux/pci.h> 53 + #include <linux/firmware.h> 53 54 54 55 static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); 55 56 static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); ··· 650 649 651 650 return false; 652 651 652 + } 653 + 654 + static bool amdgpu_vpost_needed(struct amdgpu_device *adev) 655 + { 656 + if (amdgpu_sriov_vf(adev)) 657 + return false; 658 + 659 + if (amdgpu_passthrough(adev)) { 660 + /* for FIJI: In whole GPU pass-through virtualization case 661 + * old smc fw won't clear some registers (e.g. MEM_SIZE, BIOS_SCRATCH) 662 + * so amdgpu_card_posted return false and driver will incorrectly skip vPost. 663 + * but if we force vPost do in pass-through case, the driver reload will hang. 664 + * whether doing vPost depends on amdgpu_card_posted if smc version is above 665 + * 00160e00 for FIJI. 666 + */ 667 + if (adev->asic_type == CHIP_FIJI) { 668 + int err; 669 + uint32_t fw_ver; 670 + err = request_firmware(&adev->pm.fw, "amdgpu/fiji_smc.bin", adev->dev); 671 + /* force vPost if error occured */ 672 + if (err) 673 + return true; 674 + 675 + fw_ver = *((uint32_t *)adev->pm.fw->data + 69); 676 + if (fw_ver >= 0x00160e00) 677 + return !amdgpu_card_posted(adev); 678 + } 679 + } else { 680 + /* in bare-metal case, amdgpu_card_posted return false 681 + * after system reboot/boot, and return true if driver 682 + * reloaded. 683 + * we shouldn't do vPost after driver reload otherwise GPU 684 + * could hang. 685 + */ 686 + if (amdgpu_card_posted(adev)) 687 + return false; 688 + } 689 + 690 + /* we assume vPost is neede for all other cases */ 691 + return true; 653 692 } 654 693 655 694 /** ··· 1690 1649 amdgpu_device_detect_sriov_bios(adev); 1691 1650 1692 1651 /* Post card if necessary */ 1693 - if (!amdgpu_sriov_vf(adev) && 1694 - (!amdgpu_card_posted(adev) || amdgpu_passthrough(adev))) { 1652 + if (amdgpu_vpost_needed(adev)) { 1695 1653 if (!adev->bios) { 1696 - dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n"); 1654 + dev_err(adev->dev, "no vBIOS found\n"); 1697 1655 r = -EINVAL; 1698 1656 goto failed; 1699 1657 } 1700 - DRM_INFO("GPU not posted. posting now...\n"); 1658 + DRM_INFO("GPU posting now...\n"); 1701 1659 r = amdgpu_atom_asic_init(adev->mode_info.atom_context); 1702 1660 if (r) { 1703 1661 dev_err(adev->dev, "gpu post error!\n");