[PATCH] drm/amdgpu: Check kernel version for 'hypervisor_is_type'

Paul Menzel pmenzel at molgen.mpg.de
Tue May 10 07:12:46 UTC 2022


Dear Yongqiang,


Thank you for your patch.

Am 09.05.22 um 19:07 schrieb Yongqiang Sun:
> hypervisor_is_type is added since kernel 4.15, dkms package failed to

Also mention the commit hash and summary of the commit adding that.

> install on older kernel e.g. 3.10.
> 
> Use marcro check kernel version to determine whether the function is

macro (found by my spell checker)

> used.

Please reflow for 75 characters per line.

The Signed-off-by line is missing.

> ---
>   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

`scripts/checkpatch.pl` warns about using `LINUX_VERSION_CODE`.

>   #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);

Is this patch for inclusion to the Linux kernel or just for people 
building the newer code as module for older Linux kernel versions?


Kind regards,

Paul


More information about the amd-gfx mailing list