[PATCH] drm/amdgpu: Check kernel version for 'hypervisor_is_type'
Yongqiang Sun
yongqiang.sun at amd.com
Mon May 9 17:07:32 UTC 2022
hypervisor_is_type is added since kernel 4.15, dkms package failed to
install on older kernel e.g. 3.10.
Use marcro check kernel version to determine whether the function is
used.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 4 +++-
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 88b852b3a2cb..963b2e68205e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -28,7 +28,7 @@
#ifdef CONFIG_X86
#include <asm/hypervisor.h>
#endif
-
+#include <linux/version.h>
#include "amdgpu.h"
#include "amdgpu_gmc.h"
#include "amdgpu_ras.h"
@@ -653,10 +653,12 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)
* VEGA10 SRIOV VF with MS_HYPERV host needs some firmware reserved area.
*/
#ifdef CONFIG_X86
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
if (amdgpu_sriov_vf(adev) && hypervisor_is_type(X86_HYPER_MS_HYPERV)) {
adev->mman.stolen_reserved_offset = 0x500000;
adev->mman.stolen_reserved_size = 0x200000;
}
+#endif
#endif
break;
case CHIP_RAVEN:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 02b161a1287b..5a50122a1161 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -26,7 +26,7 @@
#ifdef CONFIG_X86
#include <asm/hypervisor.h>
#endif
-
+#include <linux/version.h>
#include <drm/drm_drv.h>
#include <xen/xen.h>
@@ -728,8 +728,10 @@ void amdgpu_detect_virtualization(struct amdgpu_device *adev)
case CHIP_VEGA10:
soc15_set_virt_ops(adev);
#ifdef CONFIG_X86
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
/* not send GPU_INIT_DATA with MS_HYPERV*/
if (!hypervisor_is_type(X86_HYPER_MS_HYPERV))
+#endif
#endif
/* send a dummy GPU_INIT_DATA request to host on vega10 */
amdgpu_virt_request_init_data(adev);
--
2.25.1
More information about the amd-gfx
mailing list