[PATCH 2/2] drm/i915/gvt: Expose opregion in vgpu open

Zhang, Tina tina.zhang at intel.com
Thu Feb 1 00:21:05 UTC 2018



> -----Original Message-----
> From: intel-gvt-dev [mailto:intel-gvt-dev-bounces at lists.freedesktop.org] On
> Behalf Of Zhenyu Wang
> Sent: Wednesday, January 31, 2018 3:25 PM
> To: Zhang, Tina <tina.zhang at intel.com>
> Cc: intel-gvt-dev at lists.freedesktop.org
> Subject: Re: [PATCH 2/2] drm/i915/gvt: Expose opregion in vgpu open
> 
> On 2018.01.31 14:42:45 +0800, Tina Zhang wrote:
> > Opregion, fully virtualized by device model, is needed by hypervisors
> > for display. That's why the emulated opregion is created and destroyed
> > in MPT interface. For different hypervisors, this piece of memory
> > might be wrapped into different interfaces. E.g. for KVM/VFIO, it is
> > wrapped into a VFIO region during vGPU opening.
> >
> > This patch puts the opregion registration in vgpu_open for KVM/VFIO.
> >
> > Signed-off-by: Tina Zhang <tina.zhang at intel.com>
> > ---
> >  drivers/gpu/drm/i915/gvt/hypercall.h |  1 -
> >  drivers/gpu/drm/i915/gvt/kvmgt.c     |  3 ++-
> >  drivers/gpu/drm/i915/gvt/mpt.h       | 15 ---------------
> >  drivers/gpu/drm/i915/gvt/vgpu.c      |  4 ----
> >  4 files changed, 2 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gvt/hypercall.h
> > b/drivers/gpu/drm/i915/gvt/hypercall.h
> > index f8e77e1..5544b27 100644
> > --- a/drivers/gpu/drm/i915/gvt/hypercall.h
> > +++ b/drivers/gpu/drm/i915/gvt/hypercall.h
> > @@ -55,7 +55,6 @@ struct intel_gvt_mpt {
> >  			      unsigned long mfn, unsigned int nr, bool map);
> >  	int (*set_trap_area)(unsigned long handle, u64 start, u64 end,
> >  			     bool map);
> > -	int (*set_opregion)(void *vgpu);
> >  	int (*get_vfio_device)(void *vgpu);
> >  	void (*put_vfio_device)(void *vgpu);
> >  	bool (*is_valid_gfn)(unsigned long handle, unsigned long gfn); diff
> > --git a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > index 70f03e9..df1d44f 100644
> > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > @@ -550,6 +550,8 @@ static int intel_vgpu_open(struct mdev_device
> *mdev)
> >  	if (ret)
> >  		goto undo_group;
> >
> > +	kvmgt_set_opregion(vgpu);
> > +
> 
> Require error return check and fail back.
I thought about it when writing this patch. "kvmgt_set_opregion" could return "ENOMEM" when system has few available memory.
But it is only critical to dma-buf usage. Other usage can totally ignore this error.
So, how about printing some error message here?

BR,
Tina

> 
> >  	intel_gvt_ops->vgpu_activate(vgpu);
> >
> >  	atomic_set(&vgpu->vdev.released, 0); @@ -1602,7 +1604,6 @@
> struct
> > intel_gvt_mpt kvmgt_mpt = {
> >  	.read_gpa = kvmgt_read_gpa,
> >  	.write_gpa = kvmgt_write_gpa,
> >  	.gfn_to_mfn = kvmgt_gfn_to_pfn,
> > -	.set_opregion = kvmgt_set_opregion,
> >  	.get_vfio_device = kvmgt_get_vfio_device,
> >  	.put_vfio_device = kvmgt_put_vfio_device,
> >  	.is_valid_gfn = kvmgt_is_valid_gfn,
> > diff --git a/drivers/gpu/drm/i915/gvt/mpt.h
> > b/drivers/gpu/drm/i915/gvt/mpt.h index 81aff4e..2abe8b3 100644
> > --- a/drivers/gpu/drm/i915/gvt/mpt.h
> > +++ b/drivers/gpu/drm/i915/gvt/mpt.h
> > @@ -295,21 +295,6 @@ static inline int
> > intel_gvt_hypervisor_set_trap_area(
> >  }
> >
> >  /**
> > - * intel_gvt_hypervisor_set_opregion - Set opregion for guest
> > - * @vgpu: a vGPU
> > - *
> > - * Returns:
> > - * Zero on success, negative error code if failed.
> > - */
> > -static inline int intel_gvt_hypervisor_set_opregion(struct intel_vgpu
> > *vgpu) -{
> > -	if (!intel_gvt_host.mpt->set_opregion)
> > -		return 0;
> > -
> > -	return intel_gvt_host.mpt->set_opregion(vgpu);
> > -}
> > -
> > -/**
> >   * intel_gvt_hypervisor_get_vfio_device - increase vfio device ref count
> >   * @vgpu: a vGPU
> >   *
> > diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c
> > b/drivers/gpu/drm/i915/gvt/vgpu.c index a8784fa..72c2e93 100644
> > --- a/drivers/gpu/drm/i915/gvt/vgpu.c
> > +++ b/drivers/gpu/drm/i915/gvt/vgpu.c
> > @@ -395,10 +395,6 @@ static struct intel_vgpu
> *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
> >  	if (ret)
> >  		goto out_clean_sched_policy;
> >
> > -	ret = intel_gvt_hypervisor_set_opregion(vgpu);
> > -	if (ret)
> > -		goto out_clean_sched_policy;
> > -
> >  	mutex_unlock(&gvt->lock);
> >
> >  	return vgpu;
> > --
> > 2.7.4
> >
> 
> --
> Open Source Technology Center, Intel ltd.
> 
> $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827


More information about the intel-gvt-dev mailing list