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>
···5050#include "vi.h"5151#include "bif/bif_4_1_d.h"5252#include <linux/pci.h>5353+#include <linux/firmware.h>53545455static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev);5556static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev);···650649651650 return false;652651652652+}653653+654654+static bool amdgpu_vpost_needed(struct amdgpu_device *adev)655655+{656656+ if (amdgpu_sriov_vf(adev))657657+ return false;658658+659659+ if (amdgpu_passthrough(adev)) {660660+ /* for FIJI: In whole GPU pass-through virtualization case661661+ * old smc fw won't clear some registers (e.g. MEM_SIZE, BIOS_SCRATCH)662662+ * so amdgpu_card_posted return false and driver will incorrectly skip vPost.663663+ * but if we force vPost do in pass-through case, the driver reload will hang.664664+ * whether doing vPost depends on amdgpu_card_posted if smc version is above665665+ * 00160e00 for FIJI.666666+ */667667+ if (adev->asic_type == CHIP_FIJI) {668668+ int err;669669+ uint32_t fw_ver;670670+ err = request_firmware(&adev->pm.fw, "amdgpu/fiji_smc.bin", adev->dev);671671+ /* force vPost if error occured */672672+ if (err)673673+ return true;674674+675675+ fw_ver = *((uint32_t *)adev->pm.fw->data + 69);676676+ if (fw_ver >= 0x00160e00)677677+ return !amdgpu_card_posted(adev);678678+ }679679+ } else {680680+ /* in bare-metal case, amdgpu_card_posted return false681681+ * after system reboot/boot, and return true if driver682682+ * reloaded.683683+ * we shouldn't do vPost after driver reload otherwise GPU684684+ * could hang.685685+ */686686+ if (amdgpu_card_posted(adev))687687+ return false;688688+ }689689+690690+ /* we assume vPost is neede for all other cases */691691+ return true;653692}654693655694/**···16901649 amdgpu_device_detect_sriov_bios(adev);1691165016921651 /* Post card if necessary */16931693- if (!amdgpu_sriov_vf(adev) &&16941694- (!amdgpu_card_posted(adev) || amdgpu_passthrough(adev))) {16521652+ if (amdgpu_vpost_needed(adev)) {16951653 if (!adev->bios) {16961696- dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n");16541654+ dev_err(adev->dev, "no vBIOS found\n");16971655 r = -EINVAL;16981656 goto failed;16991657 }17001700- DRM_INFO("GPU not posted. posting now...\n");16581658+ DRM_INFO("GPU posting now...\n");17011659 r = amdgpu_atom_asic_init(adev->mode_info.atom_context);17021660 if (r) {17031661 dev_err(adev->dev, "gpu post error!\n");