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

drm/amdgpu:fix vf_error_put

1,it should not work on non-SR-IOV case
2,the NO_VBIOS error is incorrect, should
handle it under detect_sriov_bios.
3,wrap the whole detect_sriov_bios with sriov check

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
6867e1b5 ef4c166d

+17 -11
+11 -10
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 2032 2032 2033 2033 static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev) 2034 2034 { 2035 - if (adev->is_atom_fw) { 2036 - if (amdgpu_atomfirmware_gpu_supports_virtualization(adev)) 2037 - adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; 2038 - } else { 2039 - if (amdgpu_atombios_has_gpu_virtualization_table(adev)) 2040 - adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; 2035 + if (amdgpu_sriov_vf(adev)) { 2036 + if (adev->is_atom_fw) { 2037 + if (amdgpu_atomfirmware_gpu_supports_virtualization(adev)) 2038 + adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; 2039 + } else { 2040 + if (amdgpu_atombios_has_gpu_virtualization_table(adev)) 2041 + adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; 2042 + } 2043 + 2044 + if (!(adev->virt.caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS)) 2045 + amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_NO_VBIOS, 0, 0); 2041 2046 } 2042 2047 } 2043 2048 ··· 2212 2207 if (amdgpu_need_post(adev)) { 2213 2208 if (!adev->bios) { 2214 2209 dev_err(adev->dev, "no vBIOS found\n"); 2215 - amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_NO_VBIOS, 0, 0); 2216 2210 r = -EINVAL; 2217 2211 goto failed; 2218 2212 } ··· 2219 2215 r = amdgpu_atom_asic_init(adev->mode_info.atom_context); 2220 2216 if (r) { 2221 2217 dev_err(adev->dev, "gpu post error!\n"); 2222 - amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_GPU_POST_ERROR, 0, 0); 2223 2218 goto failed; 2224 2219 } 2225 2220 } else { ··· 3022 3019 } 3023 3020 } else { 3024 3021 dev_err(adev->dev, "asic resume failed (%d).\n", r); 3025 - amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_ASIC_RESUME_FAIL, 0, r); 3026 3022 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { 3027 3023 if (adev->rings[i] && adev->rings[i]->sched.thread) { 3028 3024 kthread_unpark(adev->rings[i]->sched.thread); ··· 3035 3033 if (r) { 3036 3034 /* bad news, how to tell it to userspace ? */ 3037 3035 dev_info(adev->dev, "GPU reset failed\n"); 3038 - amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_GPU_RESET_FAIL, 0, r); 3039 3036 } 3040 3037 else { 3041 3038 dev_info(adev->dev, "GPU reset successed!\n");
+6 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c
··· 31 31 uint64_t error_data) 32 32 { 33 33 int index; 34 - uint16_t error_code = AMDGIM_ERROR_CODE(AMDGIM_ERROR_CATEGORY_VF, sub_error_code); 34 + uint16_t error_code; 35 + 36 + if (!amdgpu_sriov_vf(adev)) 37 + return; 38 + 39 + error_code = AMDGIM_ERROR_CODE(AMDGIM_ERROR_CATEGORY_VF, sub_error_code); 35 40 36 41 mutex_lock(&adev->virt.vf_errors.lock); 37 42 index = adev->virt.vf_errors.write_count % AMDGPU_VF_ERROR_ENTRY_SIZE;