On Wed, 2025-10-22 at 18:17 +0300, Jani Nikula wrote:
> Add intel_display_utils.c for display utilities that need more than a
> header.
> 
> Start off with intel_display_run_as_guest(). The implementation is
> intentional duplication of the i915_utils.h i915_run_as_guest(), with
> the idea that it's small enough to not matter.
> 
> Signed-off-by: Jani Nikula <[email protected]>
> ---



>  drivers/gpu/drm/i915/Makefile                  |  1 +
>  .../gpu/drm/i915/display/intel_display_utils.c | 18 ++++++++++++++++++
>  .../gpu/drm/i915/display/intel_display_utils.h |  6 ++++++
>  drivers/gpu/drm/i915/display/intel_pch.c       |  4 ++--
>  drivers/gpu/drm/xe/Makefile                    |  1 +
>  5 files changed, 28 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/gpu/drm/i915/display/intel_display_utils.c
> 
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 47bac9b2c611..046f9282fb65 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -255,6 +255,7 @@ i915-y += \
>       display/intel_display_rpm.o \
>       display/intel_display_rps.o \
>       display/intel_display_snapshot.o \
> +     display/intel_display_utils.o \
>       display/intel_display_wa.o \
>       display/intel_dmc.o \
>       display/intel_dmc_wl.o \
> diff --git a/drivers/gpu/drm/i915/display/intel_display_utils.c 
> b/drivers/gpu/drm/i915/display/intel_display_utils.c
> new file mode 100644
> index 000000000000..13d3999dd580
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_display_utils.c
> @@ -0,0 +1,18 @@
> +// SPDX-License-Identifier: MIT
> +/* Copyright © 2025 Intel Corporation */
> +
> +#ifdef CONFIG_X86
> +#include <asm/hypervisor.h>
> +#endif
> +
> +#include "intel_display_utils.h"
> +
> +bool intel_display_run_as_guest(struct intel_display *display)
> +{
> +#if IS_ENABLED(CONFIG_X86)
> +     return !hypervisor_is_type(X86_HYPER_NATIVE);
> +#else
> +     /* Not supported yet */
> +     return false;
> +#endif
> +}

Why can't this be an inline in the header file?

--
Cheers,
Luca.


> diff --git a/drivers/gpu/drm/i915/display/intel_display_utils.h 
> b/drivers/gpu/drm/i915/display/intel_display_utils.h
> index 0a2b603ea856..e54e69afd959 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_utils.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_utils.h
> @@ -4,7 +4,13 @@
>  #ifndef __INTEL_DISPLAY_UTILS__
>  #define __INTEL_DISPLAY_UTILS__
>  
> +#include <linux/types.h>
> +
> +struct intel_display;
> +
>  #define KHz(x) (1000 * (x))
>  #define MHz(x) KHz(1000 * (x))
>  
> +bool intel_display_run_as_guest(struct intel_display *display);
> +
>  #endif /* __INTEL_DISPLAY_UTILS__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_pch.c 
> b/drivers/gpu/drm/i915/display/intel_pch.c
> index 469e8a3cfb49..65359a36df48 100644
> --- a/drivers/gpu/drm/i915/display/intel_pch.c
> +++ b/drivers/gpu/drm/i915/display/intel_pch.c
> @@ -5,8 +5,8 @@
>  
>  #include <drm/drm_print.h>
>  
> -#include "i915_utils.h"
>  #include "intel_display_core.h"
> +#include "intel_display_utils.h"
>  #include "intel_pch.h"
>  
>  #define INTEL_PCH_DEVICE_ID_MASK             0xff80
> @@ -328,7 +328,7 @@ void intel_pch_detect(struct intel_display *display)
>                           "Display disabled, reverting to NOP PCH\n");
>               display->pch_type = PCH_NOP;
>       } else if (!pch) {
> -             if (i915_run_as_guest() && HAS_DISPLAY(display)) {
> +             if (intel_display_run_as_guest(display) && 
> HAS_DISPLAY(display)) {
>                       intel_virt_detect_pch(display, &id, &pch_type);
>                       display->pch_type = pch_type;
>               } else {
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index 82c6b3d29676..feb8225d4d79 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -257,6 +257,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
>       i915-display/intel_display_power_map.o \
>       i915-display/intel_display_power_well.o \
>       i915-display/intel_display_trace.o \
> +     i915-display/intel_display_utils.o \
>       i915-display/intel_display_wa.o \
>       i915-display/intel_dkl_phy.o \
>       i915-display/intel_dmc.o \

Reply via email to