This interface allows viewing the status of the PSR. Exposing this feature on sysfs interface would allow tools such as powertop to provide status of the Graphics subsystem and aid debugging RPM. Signed-off-by: Alexandra Yates <alexandra.yates@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/i915_sysfs.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 2d576b7..36f4aff 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -106,11 +106,28 @@ show_media_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); } +static ssize_t +show_psr(struct device *kdev, struct device_attribute *attr, char *buf) +{ + struct drm_minor *dminor = dev_to_drm_minor(kdev); + struct drm_device *dev = dminor->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + ssize_t ret; + + mutex_lock(&dev_priv->psr.lock); + ret = snprintf(buf, PAGE_SIZE, "%s\n", dev_priv->psr.enabled ? + "enabled":"disabled"); + mutex_unlock(&dev_priv->psr.lock); + return ret; +} + + static DEVICE_ATTR(rc6_enable, S_IRUGO, show_rc6_mask, NULL); static DEVICE_ATTR(rc6_residency_ms, S_IRUGO, show_rc6_ms, NULL); static DEVICE_ATTR(rc6p_residency_ms, S_IRUGO, show_rc6p_ms, NULL); static DEVICE_ATTR(rc6pp_residency_ms, S_IRUGO, show_rc6pp_ms, NULL); static DEVICE_ATTR(media_rc6_residency_ms, S_IRUGO, show_media_rc6_ms, NULL); +static DEVICE_ATTR(psr_enable, S_IRUGO, show_psr, NULL); static struct attribute *rc6_attrs[] = { &dev_attr_rc6_enable.attr, @@ -143,6 +160,17 @@ static struct attribute_group media_rc6_attr_group = { .name = power_group_name, .attrs = media_rc6_attrs }; + +static struct attribute *psr_attrs[] = { + &dev_attr_psr_enable.attr, + NULL +}; + +static struct attribute_group psr_attr_group = { + .name = power_group_name, + .attrs = psr_attrs +}; + #endif static int l3_access_valid(struct drm_device *dev, loff_t offset) @@ -614,6 +642,12 @@ void i915_setup_sysfs(struct drm_device *dev) if (ret) DRM_ERROR("Media RC6 residency sysfs setup failed\n"); } + if (HAS_PSR(dev)) { + ret = sysfs_merge_group(&dev->primary->kdev->kobj, + &psr_attr_group); + if (ret) + DRM_ERROR("PSR sysfs setup failed\n"); + } #endif if (HAS_L3_DPF(dev)) { ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs); @@ -654,5 +688,6 @@ void i915_teardown_sysfs(struct drm_device *dev) #ifdef CONFIG_PM sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6_attr_group); sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6p_attr_group); + sysfs_unmerge_group(&dev->primary->kdev->kobj, &psr_attr_group); #endif } -- 2.5.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx