drm/i915: Do not export RC6p and RC6pp if they don't exist
authorRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 7 Oct 2014 14:06:50 +0000 (07:06 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 24 Oct 2014 14:34:00 +0000 (16:34 +0200)
Avoid to expose RC6 and RC6pp to the platforms that doesn't support it.
So powertop can be changed to show RC6p and RC6pp only on the platforms
they are available.

v2: Simplify by merging RC6p and RC6pp groups and respect the spec that
mentions deep and deepest RC6 on SNB and IVB although they keep disabled
by default.

v3: Remove unecessary space.

v4: RC6p and RC6pp is only for SNB and IVB; unify debug msg and use
    has_rc6p() on sanitize options instead of is gen 6 and ivb.

v5: yet another fix on has_rc6p macro. final is_gen6 or is_ivb! To make sure
    we are excluding hsw and baytrail.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524
Cc: Josh Triplett <josh.triplett@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_sysfs.c
drivers/gpu/drm/i915/intel_pm.c

index 1e476b5d9106c0a8dd5198594536a215e1db10f5..ac6232bc13416b63b3ff174c7693e097cdc13deb 100644 (file)
@@ -2184,6 +2184,8 @@ struct drm_i915_cmd_table {
 #define HAS_PSR(dev)           (IS_HASWELL(dev) || IS_BROADWELL(dev))
 #define HAS_RUNTIME_PM(dev)    (IS_GEN6(dev) || IS_HASWELL(dev) || \
                                 IS_BROADWELL(dev) || IS_VALLEYVIEW(dev))
+#define HAS_RC6(dev)           (INTEL_INFO(dev)->gen >= 6)
+#define HAS_RC6p(dev)          (INTEL_INFO(dev)->gen == 6 || IS_IVYBRIDGE(dev))
 
 #define INTEL_PCH_DEVICE_ID_MASK               0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE           0x3b00
index 503847f18fdd5a1252403ca44d85de7daab6fa82..4a5af695307eeaf6f9531ea658bbe3afadb3aa88 100644 (file)
@@ -139,8 +139,6 @@ static DEVICE_ATTR(rc6pp_residency_ms, S_IRUGO, show_rc6pp_ms, NULL);
 static struct attribute *rc6_attrs[] = {
        &dev_attr_rc6_enable.attr,
        &dev_attr_rc6_residency_ms.attr,
-       &dev_attr_rc6p_residency_ms.attr,
-       &dev_attr_rc6pp_residency_ms.attr,
        NULL
 };
 
@@ -148,6 +146,17 @@ static struct attribute_group rc6_attr_group = {
        .name = power_group_name,
        .attrs =  rc6_attrs
 };
+
+static struct attribute *rc6p_attrs[] = {
+       &dev_attr_rc6p_residency_ms.attr,
+       &dev_attr_rc6pp_residency_ms.attr,
+       NULL
+};
+
+static struct attribute_group rc6p_attr_group = {
+       .name = power_group_name,
+       .attrs =  rc6p_attrs
+};
 #endif
 
 static int l3_access_valid(struct drm_device *dev, loff_t offset)
@@ -595,12 +604,18 @@ void i915_setup_sysfs(struct drm_device *dev)
        int ret;
 
 #ifdef CONFIG_PM
-       if (INTEL_INFO(dev)->gen >= 6) {
+       if (HAS_RC6(dev)) {
                ret = sysfs_merge_group(&dev->primary->kdev->kobj,
                                        &rc6_attr_group);
                if (ret)
                        DRM_ERROR("RC6 residency sysfs setup failed\n");
        }
+       if (HAS_RC6p(dev)) {
+               ret = sysfs_merge_group(&dev->primary->kdev->kobj,
+                                       &rc6p_attr_group);
+               if (ret)
+                       DRM_ERROR("RC6p residency sysfs setup failed\n");
+       }
 #endif
        if (HAS_L3_DPF(dev)) {
                ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs);
@@ -640,5 +655,6 @@ void i915_teardown_sysfs(struct drm_device *dev)
        device_remove_bin_file(dev->primary->kdev,  &dpf_attrs);
 #ifdef CONFIG_PM
        sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6_attr_group);
+       sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6p_attr_group);
 #endif
 }
index a14be5d56c6b171e895906fa329a08cad00d15d8..daa99e7e805b96197d57f5149a0ec831627b0ff7 100644 (file)
@@ -3629,10 +3629,15 @@ static void intel_print_rc6_info(struct drm_device *dev, u32 mode)
                else
                        mode = 0;
        }
-       DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s, RC6p %s, RC6pp %s\n",
-                     (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off",
-                     (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off",
-                     (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
+       if (HAS_RC6p(dev))
+               DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s RC6p %s RC6pp %s\n",
+                             (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off",
+                             (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off",
+                             (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
+
+       else
+               DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+                             (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
@@ -3649,7 +3654,7 @@ static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
        if (enable_rc6 >= 0) {
                int mask;
 
-               if (INTEL_INFO(dev)->gen == 6 || IS_IVYBRIDGE(dev))
+               if (HAS_RC6p(dev))
                        mask = INTEL_RC6_ENABLE | INTEL_RC6p_ENABLE |
                               INTEL_RC6pp_ENABLE;
                else
This page took 0.031443 seconds and 5 git commands to generate.