Slice shutdown is a power savings feature whereby parts of HW i.e. slice is shut off on boot or dynamically to save power. This patch introduces a sysfs interface to easily allow dynamically switch between full and half GT3 slices. Signed-off-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_sysfs.c | 50 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 4 +++- drivers/gpu/drm/i915/intel_pm.c | 31 ++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index c8c4112..ef66dff 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -93,6 +93,50 @@ static struct attribute_group rc6_attr_group = { .name = power_group_name, .attrs = rc6_attrs }; + +static ssize_t gt3_policy_show(struct device *kdev, + struct device_attribute *attr, char *buf) +{ + struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); + struct drm_device *dev = minor->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + int ret; + + return sprintf(buf, "%s\n", I915_READ(MI_PREDICATE_RESULT_2) == + LOWER_SLICE_ENABLED ? "full" : "half"); +} + +static ssize_t gt3_policy_store(struct device *kdev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); + struct drm_device *dev = minor->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + ssize_t ret; + + if (!strncmp(buf, "full", sizeof("full") - 1)) + intel_set_gt3_full(dev); + else if (!strncmp(buf, "half", sizeof("half") - 1)) + intel_set_gt3_half(dev); + else + return -EINVAL; + + return count; +} + +static DEVICE_ATTR(gt3_policy, S_IRUGO | S_IWUSR, gt3_policy_show, gt3_policy_store); + +static struct attribute *gt3_policy_attrs[] = { + &dev_attr_gt3_policy.attr, + NULL +}; + +static struct attribute_group gt3_policy_attr_group = { + .name = power_group_name, + .attrs = gt3_policy_attrs +}; + #endif static int l3_access_valid(struct drm_device *dev, loff_t offset) @@ -506,6 +550,12 @@ void i915_setup_sysfs(struct drm_device *dev) if (ret) DRM_ERROR("RC6 residency sysfs setup failed\n"); } + if (IS_HSW_GT3(dev)) { + ret = sysfs_merge_group(&dev->primary->kdev.kobj, + >3_policy_attr_group); + if (ret) + DRM_ERROR("GT3 policy sysfs setup failed\n"); + } #endif if (HAS_L3_GPU_CACHE(dev)) { ret = device_create_bin_file(&dev->primary->kdev, &dpf_attrs); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index ea97c23..57e0824 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -739,7 +739,9 @@ extern void intel_update_fbc(struct drm_device *dev); /* IPS */ extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv); extern void intel_gpu_ips_teardown(void); - +/* Slice Shutdown */ +extern void intel_set_gt3_full(struct drm_device *dev); +extern void intel_set_gt3_half(struct drm_device *dev); /* Power well */ extern int i915_init_power_well(struct drm_device *dev); extern void i915_remove_power_well(struct drm_device *dev); diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 5b58eee..6f67fe9 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -3617,6 +3617,37 @@ static void gen6_enable_rps(struct drm_device *dev) gen6_gt_force_wake_put(dev_priv); } +void intel_set_gt3_full(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + if (!IS_HSW_GT3(dev)) + return; + + I915_WRITE(HSW_GT_SLICE_INFO, SLICE_SEL_BOTH); + POSTING_READ(HSW_GT_SLICE_INFO); + + I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_ENABLED); + POSTING_READ(MI_PREDICATE_RESULT_2); +} + +void intel_set_gt3_half(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + if (!IS_HSW_GT3(dev)) + return; + + I915_WRITE(HSW_SLICESHUTDOWN, SLICE_SHUTDOWN); + POSTING_READ(HSW_SLICESHUTDOWN); + + I915_WRITE(HSW_GT_SLICE_INFO, ~SLICE_SEL_BOTH); + POSTING_READ(HSW_GT_SLICE_INFO); + + I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_DISABLED); + POSTING_READ(MI_PREDICATE_RESULT_2); +} + static void intel_init_gt3_slices(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; -- 1.8.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx