[2/2] drm/i915: Add ring_mask module parameter
diff mbox series

Message ID 20190827231435.398-3-stuart.summers@intel.com
State New
Headers show
Series
  • Add module parameter to reduce engine instances
Related show

Commit Message

Summers, Stuart Aug. 27, 2019, 11:14 p.m. UTC
Add a new module parameter, ring_mask, to allow for disabling
engines during i915 load. This mask follows the intel_engine_id
enum and can be used to hide specified engines from i915 and
from userspace.

Signed-off-by: Stuart Summers <stuart.summers@intel.com>
---
 drivers/gpu/drm/i915/i915_params.c       | 3 +++
 drivers/gpu/drm/i915/i915_params.h       | 3 ++-
 drivers/gpu/drm/i915/intel_device_info.c | 6 ++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

Comments

Chris Wilson Aug. 28, 2019, 9:34 a.m. UTC | #1
Quoting Stuart Summers (2019-08-28 00:14:35)
> Add a new module parameter, ring_mask, to allow for disabling
> engines during i915 load. This mask follows the intel_engine_id
> enum and can be used to hide specified engines from i915 and
> from userspace.
> 
> Signed-off-by: Stuart Summers <stuart.summers@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_params.c       | 3 +++
>  drivers/gpu/drm/i915/i915_params.h       | 3 ++-
>  drivers/gpu/drm/i915/intel_device_info.c | 6 ++++++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
> index 296452f9efe4..6a17fe6ea3a2 100644
> --- a/drivers/gpu/drm/i915/i915_params.c
> +++ b/drivers/gpu/drm/i915/i915_params.c
> @@ -178,6 +178,9 @@ i915_param_named(enable_gvt, bool, 0400,
>         "Enable support for Intel GVT-g graphics virtualization host support(default:false)");
>  #endif
>  
> +i915_param_named_unsafe(ring_mask, uint, 0400,
> +       "Mask of engine rings to enable. (default: all supported engines enabled)");
> +
>  static __always_inline void _print_param(struct drm_printer *p,
>                                          const char *name,
>                                          const char *type,
> diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
> index d29ade3b7de6..d803bf5faac4 100644
> --- a/drivers/gpu/drm/i915/i915_params.h
> +++ b/drivers/gpu/drm/i915/i915_params.h
> @@ -77,7 +77,8 @@ struct drm_printer;
>         param(bool, verbose_state_checks, true) \
>         param(bool, nuclear_pageflip, false) \
>         param(bool, enable_dp_mst, true) \
> -       param(bool, enable_gvt, false)
> +       param(bool, enable_gvt, false) \
> +       param(unsigned int, ring_mask, (unsigned int)-1)
>  
>  #define MEMBER(T, member, ...) T member;
>  struct i915_params {
> diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
> index caef01b1da23..f833280f2ef6 100644
> --- a/drivers/gpu/drm/i915/intel_device_info.c
> +++ b/drivers/gpu/drm/i915/intel_device_info.c
> @@ -993,10 +993,16 @@ void intel_device_info_init_mmio(struct drm_i915_private *dev_priv)
>         u32 media_fuse;
>         u16 vdbox_mask;
>         u16 vebox_mask;
> +       u32 orig_engine_mask = info->engine_mask;
>  
>         if (INTEL_GEN(dev_priv) < 11)
>                 return;
>  
> +       info->engine_mask &= i915_modparams.ring_mask;

The challenge is we can't use our engine_mask for this as that is an
internal bitfield that may change overtime -- and we definitely don't
want the modparam to disable different engines on different kernel
releases.

> +       if (info->engine_mask != orig_engine_mask)
> +               DRM_WARN("loading with reduced engine mask 0x%x\n",
> +                        info->engine_mask);

It's operating under direct control from the user, so dev_notice (as we
treat it as a quirk).
-Chris
Summers, Stuart Aug. 28, 2019, 3:13 p.m. UTC | #2
On Wed, 2019-08-28 at 10:34 +0100, Chris Wilson wrote:
> Quoting Stuart Summers (2019-08-28 00:14:35)
> > Add a new module parameter, ring_mask, to allow for disabling
> > engines during i915 load. This mask follows the intel_engine_id
> > enum and can be used to hide specified engines from i915 and
> > from userspace.
> > 
> > Signed-off-by: Stuart Summers <stuart.summers@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_params.c       | 3 +++
> >  drivers/gpu/drm/i915/i915_params.h       | 3 ++-
> >  drivers/gpu/drm/i915/intel_device_info.c | 6 ++++++
> >  3 files changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_params.c
> > b/drivers/gpu/drm/i915/i915_params.c
> > index 296452f9efe4..6a17fe6ea3a2 100644
> > --- a/drivers/gpu/drm/i915/i915_params.c
> > +++ b/drivers/gpu/drm/i915/i915_params.c
> > @@ -178,6 +178,9 @@ i915_param_named(enable_gvt, bool, 0400,
> >         "Enable support for Intel GVT-g graphics virtualization
> > host support(default:false)");
> >  #endif
> >  
> > +i915_param_named_unsafe(ring_mask, uint, 0400,
> > +       "Mask of engine rings to enable. (default: all supported
> > engines enabled)");
> > +
> >  static __always_inline void _print_param(struct drm_printer *p,
> >                                          const char *name,
> >                                          const char *type,
> > diff --git a/drivers/gpu/drm/i915/i915_params.h
> > b/drivers/gpu/drm/i915/i915_params.h
> > index d29ade3b7de6..d803bf5faac4 100644
> > --- a/drivers/gpu/drm/i915/i915_params.h
> > +++ b/drivers/gpu/drm/i915/i915_params.h
> > @@ -77,7 +77,8 @@ struct drm_printer;
> >         param(bool, verbose_state_checks, true) \
> >         param(bool, nuclear_pageflip, false) \
> >         param(bool, enable_dp_mst, true) \
> > -       param(bool, enable_gvt, false)
> > +       param(bool, enable_gvt, false) \
> > +       param(unsigned int, ring_mask, (unsigned int)-1)
> >  
> >  #define MEMBER(T, member, ...) T member;
> >  struct i915_params {
> > diff --git a/drivers/gpu/drm/i915/intel_device_info.c
> > b/drivers/gpu/drm/i915/intel_device_info.c
> > index caef01b1da23..f833280f2ef6 100644
> > --- a/drivers/gpu/drm/i915/intel_device_info.c
> > +++ b/drivers/gpu/drm/i915/intel_device_info.c
> > @@ -993,10 +993,16 @@ void intel_device_info_init_mmio(struct
> > drm_i915_private *dev_priv)
> >         u32 media_fuse;
> >         u16 vdbox_mask;
> >         u16 vebox_mask;
> > +       u32 orig_engine_mask = info->engine_mask;
> >  
> >         if (INTEL_GEN(dev_priv) < 11)
> >                 return;
> >  
> > +       info->engine_mask &= i915_modparams.ring_mask;
> 
> The challenge is we can't use our engine_mask for this as that is an
> internal bitfield that may change overtime -- and we definitely don't
> want the modparam to disable different engines on different kernel
> releases.

Yeah, it's a valid concern. I was thinking we might just put this
expectation on the user/debugger given this should really only be used
under duress. I'll rethink it and see if I can come up with something a
little safer.

> 
> > +       if (info->engine_mask != orig_engine_mask)
> > +               DRM_WARN("loading with reduced engine mask 0x%x\n",
> > +                        info->engine_mask);
> 
> It's operating under direct control from the user, so dev_notice (as
> we
> treat it as a quirk).

Makes sense. I'll make the change in the next revision.

Thanks,
Stuart

> -Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index 296452f9efe4..6a17fe6ea3a2 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -178,6 +178,9 @@  i915_param_named(enable_gvt, bool, 0400,
 	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
 #endif
 
+i915_param_named_unsafe(ring_mask, uint, 0400,
+	"Mask of engine rings to enable. (default: all supported engines enabled)");
+
 static __always_inline void _print_param(struct drm_printer *p,
 					 const char *name,
 					 const char *type,
diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
index d29ade3b7de6..d803bf5faac4 100644
--- a/drivers/gpu/drm/i915/i915_params.h
+++ b/drivers/gpu/drm/i915/i915_params.h
@@ -77,7 +77,8 @@  struct drm_printer;
 	param(bool, verbose_state_checks, true) \
 	param(bool, nuclear_pageflip, false) \
 	param(bool, enable_dp_mst, true) \
-	param(bool, enable_gvt, false)
+	param(bool, enable_gvt, false) \
+	param(unsigned int, ring_mask, (unsigned int)-1)
 
 #define MEMBER(T, member, ...) T member;
 struct i915_params {
diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index caef01b1da23..f833280f2ef6 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -993,10 +993,16 @@  void intel_device_info_init_mmio(struct drm_i915_private *dev_priv)
 	u32 media_fuse;
 	u16 vdbox_mask;
 	u16 vebox_mask;
+	u32 orig_engine_mask = info->engine_mask;
 
 	if (INTEL_GEN(dev_priv) < 11)
 		return;
 
+	info->engine_mask &= i915_modparams.ring_mask;
+	if (info->engine_mask != orig_engine_mask)
+		DRM_WARN("loading with reduced engine mask 0x%x\n",
+			 info->engine_mask);
+
 	media_fuse = ~I915_READ(GEN11_GT_VEBOX_VDBOX_DISABLE);
 
 	vdbox_mask = media_fuse & GEN11_GT_VDBOX_DISABLE_MASK;