diff mbox

drm/i915: prevent generating unusable gvt build which no mpt module is selected

Message ID 1495615839-20797-1-git-send-email-changbin.du@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Du, Changbin May 24, 2017, 8:50 a.m. UTC
From: Changbin Du <changbin.du@intel.com>

At least we need one MPT module (currently only have one) selected
to get GVTg functional. When GVTg is enabled while no MPT selected,
the build just includes useless GVTg code. This doesn't make sense.

With this patch, a submenut is created under i915 as below:
  -*- Enable Intel GVT-g graphics virtualization host support
  <M> Enable KVM/VFIO support for Intel GVT-g

If no MPT is selected, GVTg will be disabled automatically.
  < > Enable KVM/VFIO support for Intel GVT-g

Signed-off-by: Changbin Du <changbin.du@intel.com>
---
 drivers/gpu/drm/i915/Kconfig | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Zhenyu Wang May 24, 2017, 9:17 a.m. UTC | #1
On 2017.05.24 16:50:39 +0800, changbin.du@intel.com wrote:
> From: Changbin Du <changbin.du@intel.com>
> 
> At least we need one MPT module (currently only have one) selected
> to get GVTg functional. When GVTg is enabled while no MPT selected,
> the build just includes useless GVTg code. This doesn't make sense.
>

The reason was that we tried to merge gvt device model in upstream
first while finishing KVMGT part later. I'm ok with this now.

> With this patch, a submenut is created under i915 as below:
>   -*- Enable Intel GVT-g graphics virtualization host support
>   <M> Enable KVM/VFIO support for Intel GVT-g
> 
> If no MPT is selected, GVTg will be disabled automatically.
>   < > Enable KVM/VFIO support for Intel GVT-g
> 
> Signed-off-by: Changbin Du <changbin.du@intel.com>
> ---
>  drivers/gpu/drm/i915/Kconfig | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
> index a5cd5da..e380a5d 100644
> --- a/drivers/gpu/drm/i915/Kconfig
> +++ b/drivers/gpu/drm/i915/Kconfig
> @@ -91,12 +91,15 @@ config DRM_I915_USERPTR
>  
>  	  If in doubt, say "Y".
>  
> +menu "Intel GVT-g graphics virtualization host support"
> +	depends on DRM_I915
> +	depends on 64BIT
> +
>  config DRM_I915_GVT
> -        bool "Enable Intel GVT-g graphics virtualization host support"
> -        depends on DRM_I915
> -        depends on 64BIT
> -        default n
> -        help
> +	bool "Enable Intel GVT-g graphics virtualization host support"
> +	default n
> +	depends on DRM_I915_GVT_KVMGT
> +	help
>  	  Choose this option if you want to enable Intel GVT-g graphics
>  	  virtualization technology host support with integrated graphics.
>  	  With GVT-g, it's possible to have one integrated graphics
> @@ -116,13 +119,14 @@ config DRM_I915_GVT
>  
>  config DRM_I915_GVT_KVMGT
>  	tristate "Enable KVM/VFIO support for Intel GVT-g"
> -	depends on DRM_I915_GVT
> +	select DRM_I915_GVT
>  	depends on KVM
>  	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
>  	default n
>  	help
>  	  Choose this option if you want to enable KVMGT support for
>  	  Intel GVT-g.
> +endmenu
>  
>  menu "drm/i915 Debugging"
>  depends on DRM_I915
> -- 
> 2.7.4
>
Chris Wilson May 24, 2017, 9:21 a.m. UTC | #2
On Wed, May 24, 2017 at 04:50:39PM +0800, changbin.du@intel.com wrote:
> From: Changbin Du <changbin.du@intel.com>
> 
> At least we need one MPT module (currently only have one) selected
> to get GVTg functional. When GVTg is enabled while no MPT selected,
> the build just includes useless GVTg code. This doesn't make sense.

See the Kconfig "choice" directive.
-Chris
Du, Changbin May 24, 2017, 9:36 a.m. UTC | #3
On Wed, May 24, 2017 at 10:21:31AM +0100, Chris Wilson wrote:
> On Wed, May 24, 2017 at 04:50:39PM +0800, changbin.du@intel.com wrote:
> > From: Changbin Du <changbin.du@intel.com>
> > 
> > At least we need one MPT module (currently only have one) selected
> > to get GVTg functional. When GVTg is enabled while no MPT selected,
> > the build just includes useless GVTg code. This doesn't make sense.
> 
> See the Kconfig "choice" directive.
> -Chris
> 
I was thought about "choice" as in mind firstly and that is good. But I think
this is better since it make it totaly impossible that GVT is enabled while no
MPT. With "choice", if we forget disable GVT after unselect all MPTs, we still
compile GVT in but will never not use it.

> -- 
> Chris Wilson, Intel Open Source Technology Centre
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
Jani Nikula May 24, 2017, 11:35 a.m. UTC | #4
On Wed, 24 May 2017, changbin.du@intel.com wrote:
> From: Changbin Du <changbin.du@intel.com>
>
> At least we need one MPT module (currently only have one) selected
> to get GVTg functional. When GVTg is enabled while no MPT selected,
> the build just includes useless GVTg code. This doesn't make sense.
>
> With this patch, a submenut is created under i915 as below:
>   -*- Enable Intel GVT-g graphics virtualization host support
>   <M> Enable KVM/VFIO support for Intel GVT-g
>
> If no MPT is selected, GVTg will be disabled automatically.
>   < > Enable KVM/VFIO support for Intel GVT-g
>
> Signed-off-by: Changbin Du <changbin.du@intel.com>
> ---
>  drivers/gpu/drm/i915/Kconfig | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
> index a5cd5da..e380a5d 100644
> --- a/drivers/gpu/drm/i915/Kconfig
> +++ b/drivers/gpu/drm/i915/Kconfig
> @@ -91,12 +91,15 @@ config DRM_I915_USERPTR
>  
>  	  If in doubt, say "Y".
>  
> +menu "Intel GVT-g graphics virtualization host support"
> +	depends on DRM_I915
> +	depends on 64BIT
> +
>  config DRM_I915_GVT
> -        bool "Enable Intel GVT-g graphics virtualization host support"
> -        depends on DRM_I915
> -        depends on 64BIT
> -        default n
> -        help
> +	bool "Enable Intel GVT-g graphics virtualization host support"
> +	default n
> +	depends on DRM_I915_GVT_KVMGT
> +	help

With this change, you can't actually change this config option. It's
purely subject to CONFIG_DRM_I915_GVT_KVMGT. You need to enable KVMGT to
even see this option, but enabling it will enable this one too. You
can't disable this before you disable KVMGT, but then disabling KVMGT
will disable this one too. This config option becomes pointless as a
visible option. Which isn't all that bad, considering
Documentation/kbuild/kconfig-language.txt:

  Note:
	select should be used with care. select will force
	a symbol to a value without visiting the dependencies.
	By abusing select you are able to select a symbol FOO even
	if FOO depends on BAR that is not set.
	In general use select only for non-visible symbols
	(no prompts anywhere) and for symbols with no dependencies.
	That will limit the usefulness but on the other hand avoid
	the illegal configurations all over.

BR,
Jani.

>  	  Choose this option if you want to enable Intel GVT-g graphics
>  	  virtualization technology host support with integrated graphics.
>  	  With GVT-g, it's possible to have one integrated graphics
> @@ -116,13 +119,14 @@ config DRM_I915_GVT
>  
>  config DRM_I915_GVT_KVMGT
>  	tristate "Enable KVM/VFIO support for Intel GVT-g"
> -	depends on DRM_I915_GVT
> +	select DRM_I915_GVT
>  	depends on KVM
>  	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
>  	default n
>  	help
>  	  Choose this option if you want to enable KVMGT support for
>  	  Intel GVT-g.
> +endmenu
>  
>  menu "drm/i915 Debugging"
>  depends on DRM_I915
Du, Changbin May 25, 2017, 6:09 a.m. UTC | #5
Hi, Jani, just relized you are in i915 team. :)

> > +menu "Intel GVT-g graphics virtualization host support"
> > +	depends on DRM_I915
> > +	depends on 64BIT
> > +
> >  config DRM_I915_GVT
> > -        bool "Enable Intel GVT-g graphics virtualization host support"
> > -        depends on DRM_I915
> > -        depends on 64BIT
> > -        default n
> > -        help
> > +	bool "Enable Intel GVT-g graphics virtualization host support"
> > +	default n
> > +	depends on DRM_I915_GVT_KVMGT
> > +	help
> 
> With this change, you can't actually change this config option. It's
> purely subject to CONFIG_DRM_I915_GVT_KVMGT. You need to enable KVMGT to
> even see this option, but enabling it will enable this one too. You
> can't disable this before you disable KVMGT, but then disabling KVMGT
> will disable this one too. This config option becomes pointless as a
> visible option. Which isn't all that bad, considering
> Documentation/kbuild/kconfig-language.txt:
>
Jani, this is by design in this patch. We will add another xengt hypervisor glue
layer to support XenGT. After that, enable DRM_I915_GVT only if at least one of
KVMGT or XENGT enabled or both. Also it doesn't make sense that we only build
KVMGT/XenGT module without DRM_I915_GVT.

Such mechanism is not as straigforward as two simple 'choice', so I agree with
'choice' if you prefer it. As you said, it is not a big problem.

>   Note:
> 	select should be used with care. select will force
> 	a symbol to a value without visiting the dependencies.
> 	By abusing select you are able to select a symbol FOO even
> 	if FOO depends on BAR that is not set.
> 	In general use select only for non-visible symbols
> 	(no prompts anywhere) and for symbols with no dependencies.
> 	That will limit the usefulness but on the other hand avoid
> 	the illegal configurations all over.
> 
Yes, we should always be carefull with 'select' and should not use it if
possible. So here I must create a 'menu' to ensure its safety.

> BR,
> Jani.
> 
> >  	  Choose this option if you want to enable Intel GVT-g graphics
> >  	  virtualization technology host support with integrated graphics.
> >  	  With GVT-g, it's possible to have one integrated graphics
> > @@ -116,13 +119,14 @@ config DRM_I915_GVT
> >  
> >  config DRM_I915_GVT_KVMGT
> >  	tristate "Enable KVM/VFIO support for Intel GVT-g"
> > -	depends on DRM_I915_GVT
> > +	select DRM_I915_GVT
> >  	depends on KVM
> >  	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
> >  	default n
> >  	help
> >  	  Choose this option if you want to enable KVMGT support for
> >  	  Intel GVT-g.
> > +endmenu
> >  
> >  menu "drm/i915 Debugging"
> >  depends on DRM_I915
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
Jani Nikula May 26, 2017, 9:58 a.m. UTC | #6
On Thu, 25 May 2017, "Du, Changbin" <changbin.du@intel.com> wrote:
> Hi, Jani, just relized you are in i915 team. :)
>
>> > +menu "Intel GVT-g graphics virtualization host support"
>> > +	depends on DRM_I915
>> > +	depends on 64BIT
>> > +
>> >  config DRM_I915_GVT
>> > -        bool "Enable Intel GVT-g graphics virtualization host support"
>> > -        depends on DRM_I915
>> > -        depends on 64BIT
>> > -        default n
>> > -        help
>> > +	bool "Enable Intel GVT-g graphics virtualization host support"
>> > +	default n
>> > +	depends on DRM_I915_GVT_KVMGT
>> > +	help
>> 
>> With this change, you can't actually change this config option. It's
>> purely subject to CONFIG_DRM_I915_GVT_KVMGT. You need to enable KVMGT to
>> even see this option, but enabling it will enable this one too. You
>> can't disable this before you disable KVMGT, but then disabling KVMGT
>> will disable this one too. This config option becomes pointless as a
>> visible option. Which isn't all that bad, considering
>> Documentation/kbuild/kconfig-language.txt:
>>
> Jani, this is by design in this patch. We will add another xengt hypervisor glue
> layer to support XenGT. After that, enable DRM_I915_GVT only if at least one of
> KVMGT or XENGT enabled or both. Also it doesn't make sense that we only build
> KVMGT/XenGT module without DRM_I915_GVT.
>
> Such mechanism is not as straigforward as two simple 'choice', so I agree with
> 'choice' if you prefer it. As you said, it is not a big problem.
>
>>   Note:
>> 	select should be used with care. select will force
>> 	a symbol to a value without visiting the dependencies.
>> 	By abusing select you are able to select a symbol FOO even
>> 	if FOO depends on BAR that is not set.
>> 	In general use select only for non-visible symbols
>> 	(no prompts anywhere) and for symbols with no dependencies.
>> 	That will limit the usefulness but on the other hand avoid
>> 	the illegal configurations all over.
>> 
> Yes, we should always be carefull with 'select' and should not use it if
> possible. So here I must create a 'menu' to ensure its safety.

I'm trying to say, why do you make DRM_I915_GVT visible in menuconfig at
all when you can't actually change it in menuconfig?

BR,
Jani.



>
>> BR,
>> Jani.
>> 
>> >  	  Choose this option if you want to enable Intel GVT-g graphics
>> >  	  virtualization technology host support with integrated graphics.
>> >  	  With GVT-g, it's possible to have one integrated graphics
>> > @@ -116,13 +119,14 @@ config DRM_I915_GVT
>> >  
>> >  config DRM_I915_GVT_KVMGT
>> >  	tristate "Enable KVM/VFIO support for Intel GVT-g"
>> > -	depends on DRM_I915_GVT
>> > +	select DRM_I915_GVT
>> >  	depends on KVM
>> >  	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
>> >  	default n
>> >  	help
>> >  	  Choose this option if you want to enable KVMGT support for
>> >  	  Intel GVT-g.
>> > +endmenu
>> >  
>> >  menu "drm/i915 Debugging"
>> >  depends on DRM_I915
>> 
>> -- 
>> Jani Nikula, Intel Open Source Technology Center
>> _______________________________________________
>> intel-gvt-dev mailing list
>> intel-gvt-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
Du, Changbin May 26, 2017, 10:27 a.m. UTC | #7
On Fri, May 26, 2017 at 12:58:55PM +0300, Jani Nikula wrote:
> On Thu, 25 May 2017, "Du, Changbin" <changbin.du@intel.com> wrote:
> >>   Note:
> >> 	select should be used with care. select will force
> >> 	a symbol to a value without visiting the dependencies.
> >> 	By abusing select you are able to select a symbol FOO even
> >> 	if FOO depends on BAR that is not set.
> >> 	In general use select only for non-visible symbols
> >> 	(no prompts anywhere) and for symbols with no dependencies.
> >> 	That will limit the usefulness but on the other hand avoid
> >> 	the illegal configurations all over.
> >> 
> > Yes, we should always be carefull with 'select' and should not use it if
> > possible. So here I must create a 'menu' to ensure its safety.
> 
> I'm trying to say, why do you make DRM_I915_GVT visible in menuconfig at
> all when you can't actually change it in menuconfig?
> 
ok, that is to info the user that GVT is enabled, since DRM_I915_GVT apply to
seperated i915 module. I saw similar behaviour in some driver, but cannot recall
its name now...

> BR,
> Jani.
> 
> 
> 
> >
> >> BR,
> >> Jani.
> >> 
> >> >  	  Choose this option if you want to enable Intel GVT-g graphics
> >> >  	  virtualization technology host support with integrated graphics.
> >> >  	  With GVT-g, it's possible to have one integrated graphics
> >> > @@ -116,13 +119,14 @@ config DRM_I915_GVT
> >> >  
> >> >  config DRM_I915_GVT_KVMGT
> >> >  	tristate "Enable KVM/VFIO support for Intel GVT-g"
> >> > -	depends on DRM_I915_GVT
> >> > +	select DRM_I915_GVT
> >> >  	depends on KVM
> >> >  	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
> >> >  	default n
> >> >  	help
> >> >  	  Choose this option if you want to enable KVMGT support for
> >> >  	  Intel GVT-g.
> >> > +endmenu
> >> >  
> >> >  menu "drm/i915 Debugging"
> >> >  depends on DRM_I915
> >> 
> >> -- 
> >> Jani Nikula, Intel Open Source Technology Center
> >> _______________________________________________
> >> intel-gvt-dev mailing list
> >> intel-gvt-dev@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index a5cd5da..e380a5d 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -91,12 +91,15 @@  config DRM_I915_USERPTR
 
 	  If in doubt, say "Y".
 
+menu "Intel GVT-g graphics virtualization host support"
+	depends on DRM_I915
+	depends on 64BIT
+
 config DRM_I915_GVT
-        bool "Enable Intel GVT-g graphics virtualization host support"
-        depends on DRM_I915
-        depends on 64BIT
-        default n
-        help
+	bool "Enable Intel GVT-g graphics virtualization host support"
+	default n
+	depends on DRM_I915_GVT_KVMGT
+	help
 	  Choose this option if you want to enable Intel GVT-g graphics
 	  virtualization technology host support with integrated graphics.
 	  With GVT-g, it's possible to have one integrated graphics
@@ -116,13 +119,14 @@  config DRM_I915_GVT
 
 config DRM_I915_GVT_KVMGT
 	tristate "Enable KVM/VFIO support for Intel GVT-g"
-	depends on DRM_I915_GVT
+	select DRM_I915_GVT
 	depends on KVM
 	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
 	default n
 	help
 	  Choose this option if you want to enable KVMGT support for
 	  Intel GVT-g.
+endmenu
 
 menu "drm/i915 Debugging"
 depends on DRM_I915