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

Commit e6069ca8 authored by Imre Deak's avatar Imre Deak Committed by Daniel Vetter
Browse files

drm/i915: sanitize enable_rc6 option



Atm, an invalid enable_rc6 module option will be silently ignored, so
emit an info message about it. Doing an early sanitization we can also
reuse intel_enable_rc6() in a follow-up patch to see if RC6 is actually
enabled. Currently the caller would have to filter a non-zero return
value based on the platform we are running on. For example on VLV with
i915.enable_rc6 set to 2, RC6 won't be enabled but atm
intel_enable_rc6() would still return 2 in this case.

v2:
- simplify the platform check condition (Ville)

Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 14dd0ea8
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -3262,15 +3262,32 @@ static void intel_print_rc6_info(struct drm_device *dev, u32 mode)
		 (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
}

int intel_enable_rc6(const struct drm_device *dev)
static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
{
	/* No RC6 before Ironlake */
	if (INTEL_INFO(dev)->gen < 5)
		return 0;

	/* RC6 is only on Ironlake mobile not on desktop */
	if (INTEL_INFO(dev)->gen == 5 && !IS_IRONLAKE_M(dev))
		return 0;

	/* Respect the kernel parameter if it is set */
	if (i915.enable_rc6 >= 0)
		return i915.enable_rc6;
	if (enable_rc6 >= 0) {
		int mask;

		if (INTEL_INFO(dev)->gen == 6 || IS_IVYBRIDGE(dev))
			mask = INTEL_RC6_ENABLE | INTEL_RC6p_ENABLE |
			       INTEL_RC6pp_ENABLE;
		else
			mask = INTEL_RC6_ENABLE;

		if ((enable_rc6 & mask) != enable_rc6)
			DRM_INFO("Adjusting RC6 mask to %d (requested %d, valid %d)\n",
				 enable_rc6, enable_rc6 & mask, mask);

		return enable_rc6 & mask;
	}

	/* Disable RC6 on Ironlake */
	if (INTEL_INFO(dev)->gen == 5)
@@ -3282,6 +3299,11 @@ int intel_enable_rc6(const struct drm_device *dev)
	return INTEL_RC6_ENABLE;
}

int intel_enable_rc6(const struct drm_device *dev)
{
	return i915.enable_rc6;
}

static void gen6_enable_rps_interrupts(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4496,6 +4518,8 @@ static void intel_init_emon(struct drm_device *dev)

void intel_init_gt_powersave(struct drm_device *dev)
{
	i915.enable_rc6 = sanitize_rc6_option(dev, i915.enable_rc6);

	if (IS_VALLEYVIEW(dev))
		valleyview_setup_pctx(dev);
}