diff options
author | Monk Liu <Monk.Liu@amd.com> | 2016-09-14 07:38:08 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-09-22 10:24:14 -0400 |
commit | bec86378befae4155b58f80bb9d0da50080291e6 (patch) | |
tree | 6ae90f25c5cf4a074bab59c60e6169e4442a3c49 /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |
parent | 4e99a44e37bfed8c4f25c94687e8e4ac4ae65086 (diff) |
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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 4acc92b9eec6..75f490f9bd8d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include "vi.h" | 50 | #include "vi.h" |
51 | #include "bif/bif_4_1_d.h" | 51 | #include "bif/bif_4_1_d.h" |
52 | #include <linux/pci.h> | 52 | #include <linux/pci.h> |
53 | #include <linux/firmware.h> | ||
53 | 54 | ||
54 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); | 55 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); |
55 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); | 56 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); |
@@ -651,6 +652,46 @@ bool amdgpu_card_posted(struct amdgpu_device *adev) | |||
651 | 652 | ||
652 | } | 653 | } |
653 | 654 | ||
655 | static bool amdgpu_vpost_needed(struct amdgpu_device *adev) | ||
656 | { | ||
657 | if (amdgpu_sriov_vf(adev)) | ||
658 | return false; | ||
659 | |||
660 | if (amdgpu_passthrough(adev)) { | ||
661 | /* for FIJI: In whole GPU pass-through virtualization case | ||
662 | * old smc fw won't clear some registers (e.g. MEM_SIZE, BIOS_SCRATCH) | ||
663 | * so amdgpu_card_posted return false and driver will incorrectly skip vPost. | ||
664 | * but if we force vPost do in pass-through case, the driver reload will hang. | ||
665 | * whether doing vPost depends on amdgpu_card_posted if smc version is above | ||
666 | * 00160e00 for FIJI. | ||
667 | */ | ||
668 | if (adev->asic_type == CHIP_FIJI) { | ||
669 | int err; | ||
670 | uint32_t fw_ver; | ||
671 | err = request_firmware(&adev->pm.fw, "amdgpu/fiji_smc.bin", adev->dev); | ||
672 | /* force vPost if error occured */ | ||
673 | if (err) | ||
674 | return true; | ||
675 | |||
676 | fw_ver = *((uint32_t *)adev->pm.fw->data + 69); | ||
677 | if (fw_ver >= 0x00160e00) | ||
678 | return !amdgpu_card_posted(adev); | ||
679 | } | ||
680 | } else { | ||
681 | /* in bare-metal case, amdgpu_card_posted return false | ||
682 | * after system reboot/boot, and return true if driver | ||
683 | * reloaded. | ||
684 | * we shouldn't do vPost after driver reload otherwise GPU | ||
685 | * could hang. | ||
686 | */ | ||
687 | if (amdgpu_card_posted(adev)) | ||
688 | return false; | ||
689 | } | ||
690 | |||
691 | /* we assume vPost is neede for all other cases */ | ||
692 | return true; | ||
693 | } | ||
694 | |||
654 | /** | 695 | /** |
655 | * amdgpu_dummy_page_init - init dummy page used by the driver | 696 | * amdgpu_dummy_page_init - init dummy page used by the driver |
656 | * | 697 | * |
@@ -1649,14 +1690,13 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1649 | amdgpu_device_detect_sriov_bios(adev); | 1690 | amdgpu_device_detect_sriov_bios(adev); |
1650 | 1691 | ||
1651 | /* Post card if necessary */ | 1692 | /* Post card if necessary */ |
1652 | if (!amdgpu_sriov_vf(adev) && | 1693 | if (amdgpu_vpost_needed(adev)) { |
1653 | (!amdgpu_card_posted(adev) || amdgpu_passthrough(adev))) { | ||
1654 | if (!adev->bios) { | 1694 | if (!adev->bios) { |
1655 | dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n"); | 1695 | dev_err(adev->dev, "no vBIOS found\n"); |
1656 | r = -EINVAL; | 1696 | r = -EINVAL; |
1657 | goto failed; | 1697 | goto failed; |
1658 | } | 1698 | } |
1659 | DRM_INFO("GPU not posted. posting now...\n"); | 1699 | DRM_INFO("GPU posting now...\n"); |
1660 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); | 1700 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
1661 | if (r) { | 1701 | if (r) { |
1662 | dev_err(adev->dev, "gpu post error!\n"); | 1702 | dev_err(adev->dev, "gpu post error!\n"); |