Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b3343b7 authored by Jike Song's avatar Jike Song Committed by Zhenyu Wang
Browse files

drm/i915/gvt: allow several MPT methods to be NULL



Hypervisors are different, the MPT ops is a only superset of
all possibly supported hypervisors. There might be other way
out of the MPT to achieve same target. e.g. vfio-based kvmgt
won't provide map_gfn_to_mfn method to establish guest EPT
mapping for aperture, since it will be done in QEMU/KVM, MMIO
is also trapped elsewhere, etc.

Signed-off-by: default avatarJike Song <jike.song@intel.com>
Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
parent 40df6ea0
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,10 @@ static inline int intel_gvt_hypervisor_detect_host(void)
static inline int intel_gvt_hypervisor_host_init(struct device *dev,
static inline int intel_gvt_hypervisor_host_init(struct device *dev,
			void *gvt, const void *ops)
			void *gvt, const void *ops)
{
{
	/* optional to provide */
	if (!intel_gvt_host.mpt->host_init)
		return 0;

	return intel_gvt_host.mpt->host_init(dev, gvt, ops);
	return intel_gvt_host.mpt->host_init(dev, gvt, ops);
}
}


@@ -73,6 +77,10 @@ static inline int intel_gvt_hypervisor_host_init(struct device *dev,
static inline void intel_gvt_hypervisor_host_exit(struct device *dev,
static inline void intel_gvt_hypervisor_host_exit(struct device *dev,
			void *gvt)
			void *gvt)
{
{
	/* optional to provide */
	if (!intel_gvt_host.mpt->host_exit)
		return;

	intel_gvt_host.mpt->host_exit(dev, gvt);
	intel_gvt_host.mpt->host_exit(dev, gvt);
}
}


@@ -85,6 +93,10 @@ static inline void intel_gvt_hypervisor_host_exit(struct device *dev,
 */
 */
static inline int intel_gvt_hypervisor_attach_vgpu(struct intel_vgpu *vgpu)
static inline int intel_gvt_hypervisor_attach_vgpu(struct intel_vgpu *vgpu)
{
{
	/* optional to provide */
	if (!intel_gvt_host.mpt->attach_vgpu)
		return 0;

	return intel_gvt_host.mpt->attach_vgpu(vgpu, &vgpu->handle);
	return intel_gvt_host.mpt->attach_vgpu(vgpu, &vgpu->handle);
}
}


@@ -97,6 +109,10 @@ static inline int intel_gvt_hypervisor_attach_vgpu(struct intel_vgpu *vgpu)
 */
 */
static inline void intel_gvt_hypervisor_detach_vgpu(struct intel_vgpu *vgpu)
static inline void intel_gvt_hypervisor_detach_vgpu(struct intel_vgpu *vgpu)
{
{
	/* optional to provide */
	if (!intel_gvt_host.mpt->detach_vgpu)
		return;

	intel_gvt_host.mpt->detach_vgpu(vgpu->handle);
	intel_gvt_host.mpt->detach_vgpu(vgpu->handle);
}
}


@@ -261,6 +277,10 @@ static inline int intel_gvt_hypervisor_map_gfn_to_mfn(
		unsigned long mfn, unsigned int nr,
		unsigned long mfn, unsigned int nr,
		bool map)
		bool map)
{
{
	/* a MPT implementation could have MMIO mapped elsewhere */
	if (!intel_gvt_host.mpt->map_gfn_to_mfn)
		return 0;

	return intel_gvt_host.mpt->map_gfn_to_mfn(vgpu->handle, gfn, mfn, nr,
	return intel_gvt_host.mpt->map_gfn_to_mfn(vgpu->handle, gfn, mfn, nr,
						  map);
						  map);
}
}
@@ -278,6 +298,10 @@ static inline int intel_gvt_hypervisor_map_gfn_to_mfn(
static inline int intel_gvt_hypervisor_set_trap_area(
static inline int intel_gvt_hypervisor_set_trap_area(
		struct intel_vgpu *vgpu, u64 start, u64 end, bool map)
		struct intel_vgpu *vgpu, u64 start, u64 end, bool map)
{
{
	/* a MPT implementation could have MMIO trapped elsewhere */
	if (!intel_gvt_host.mpt->set_trap_area)
		return 0;

	return intel_gvt_host.mpt->set_trap_area(vgpu->handle, start, end, map);
	return intel_gvt_host.mpt->set_trap_area(vgpu->handle, start, end, map);
}
}