Skip to contentSkip to conversation

drm/i915: Do not export RC6p and RC6pp if they don't exist

PATCH In review Rodrigo Vivi 4 participants 10 messages Sep 30, 2014 – Oct 7, 2014

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: Do not export RC6p and RC6pp if they don't exist

Avoid to expose RC6 and RC6pp to the platforms that doesn't support it. Although this doesn't really change powertop behaviour as described on the request.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/i915_sysfs.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 12 ++++++++----
 3 files changed, 47 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index d10b417..54b2aac 100644
@@ -2185,6 +2185,9 @@ 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)		(IS_GEN6(dev) || IS_IVYBRIDGE(dev))
+#define HAS_RC6pp(dev)		IS_GEN6(dev)
 
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +36 -3
index 503847f..879e889 100644
@@ -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,26 @@ 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,
+	NULL
+};
+
+static struct attribute_group rc6p_attr_group = {
+	.name = power_group_name,
+	.attrs =  rc6p_attrs
+};
+
+static struct attribute *rc6pp_attrs[] = {
+	&dev_attr_rc6pp_residency_ms.attr,
+	NULL
+};
+
+static struct attribute_group rc6pp_attr_group = {
+	.name = power_group_name,
+	.attrs =  rc6pp_attrs
+};
 #endif
 
 static int l3_access_valid(struct drm_device *dev, loff_t offset)
@@ -595,12 +613,25 @@ 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");
+	}
+
+	if (HAS_RC6pp(dev)) {
+		ret = sysfs_merge_group(&dev->primary->kdev->kobj,
+					&rc6pp_attr_group);
+		if (ret)
+			DRM_ERROR("RC6pp residency sysfs setup failed\n");
+	}
 #endif
 	if (HAS_L3_DPF(dev)) {
 		ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs);
@@ -640,5 +671,7 @@ 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);
+	sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6pp_attr_group);
 #endif
 }
drivers/gpu/drm/i915/intel_pm.c +8 -4
index 7553e47..fa1227e 100644
@@ -3632,10 +3632,14 @@ 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");
+	DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+		      (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+	if (HAS_RC6p(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s\n",
+			      (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off");
+	if (HAS_RC6pp(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6pp %s\n",
+			      (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
Signature · 1 line
1.9.3
#1 lore raw
Quoted 95 lines · Rodrigo Vivi

Avoid to expose RC6 and RC6pp to the platforms that doesn't support it. Although this doesn't really change powertop behaviour as described on the request.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/i915_sysfs.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 12 ++++++++----
 3 files changed, 47 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index d10b417..54b2aac 100644
@@ -2185,6 +2185,9 @@ 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)		(IS_GEN6(dev) || IS_IVYBRIDGE(dev))
+#define HAS_RC6pp(dev)		IS_GEN6(dev)
 
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +34 -3
index 503847f..879e889 100644
@@ -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,26 @@ 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,
+	NULL
+};
+
+static struct attribute_group rc6p_attr_group = {
+	.name = power_group_name,
+	.attrs =  rc6p_attrs
+};
+
+static struct attribute *rc6pp_attrs[] = {
+	&dev_attr_rc6pp_residency_ms.attr,
+	NULL
+};
+
+static struct attribute_group rc6pp_attr_group = {
+	.name = power_group_name,
+	.attrs =  rc6pp_attrs
+};
 #endif
 
 static int l3_access_valid(struct drm_device *dev, loff_t offset)
@@ -595,12 +613,25 @@ 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");
+	}
+
+	if (HAS_RC6pp(dev)) {
+		ret = sysfs_merge_group(&dev->primary->kdev->kobj,
+					&rc6pp_attr_group);
+		if (ret)
+			DRM_ERROR("RC6pp residency sysfs setup failed\n");
+	}
 #endif
 	if (HAS_L3_DPF(dev)) {
 		ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs);

drivers/gpu/drm/i915/i915_sysfs.c void i915_teardown_sysfs(struct drm_device *dev) · line 675

Quoted 5 lines
drivers/gpu/drm/i915/i915_sysfs.c +2 -0
@@ -640,5 +671,7 @@ 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);
+	sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6pp_attr_group);

I think we could do just one additional group here for both rc6p and rc6pp, simplifies the code a bit.
-Daniel

Quoted 32 lines
drivers/gpu/drm/i915/i915_sysfs.c +0 -0
 #endif
 }
drivers/gpu/drm/i915/intel_pm.c +8 -4
index 7553e47..fa1227e 100644
@@ -3632,10 +3632,14 @@ 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");
+	DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+		      (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+	if (HAS_RC6p(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s\n",
+			      (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off");
+	if (HAS_RC6pp(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6pp %s\n",
+			      (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
Quoted 96 lines · Daniel Vetter
Quoted 95 lines · Rodrigo Vivi

Avoid to expose RC6 and RC6pp to the platforms that doesn't support it. Although this doesn't really change powertop behaviour as described on the request.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/i915_sysfs.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 12 ++++++++----
 3 files changed, 47 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index d10b417..54b2aac 100644
@@ -2185,6 +2185,9 @@ 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)                (IS_GEN6(dev) || IS_IVYBRIDGE(dev))
+#define HAS_RC6pp(dev)               IS_GEN6(dev)
 
 #define INTEL_PCH_DEVICE_ID_MASK             0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE         0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +34 -3
index 503847f..879e889 100644
@@ -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,26 @@ 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,
+     NULL
+};
+
+static struct attribute_group rc6p_attr_group = {
+     .name = power_group_name,
+     .attrs =  rc6p_attrs
+};
+
+static struct attribute *rc6pp_attrs[] = {
+     &dev_attr_rc6pp_residency_ms.attr,
+     NULL
+};
+
+static struct attribute_group rc6pp_attr_group = {
+     .name = power_group_name,
+     .attrs =  rc6pp_attrs
+};
 #endif
 
 static int l3_access_valid(struct drm_device *dev, loff_t offset)
@@ -595,12 +613,25 @@ 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");
+     }
+
+     if (HAS_RC6pp(dev)) {
+             ret = sysfs_merge_group(&dev->primary->kdev->kobj,
+                                     &rc6pp_attr_group);
+             if (ret)
+                     DRM_ERROR("RC6pp residency sysfs setup failed\n");
+     }
 #endif
      if (HAS_L3_DPF(dev)) {
              ret = device_create_bin_file(dev->primary->kdev, &dpf_attrs);
@@ -640,5 +671,7 @@ void i915_teardown_sysfs(struct drm_device *dev)
Quoted 8 lines

drivers/gpu/drm/i915/i915_sysfs.c void i915_teardown_sysfs(struct drm_device *dev) · line 675

Quoted 5 lines
drivers/gpu/drm/i915/i915_sysfs.c +2 -0
      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);
+     sysfs_unmerge_group(&dev->primary->kdev->kobj, &rc6pp_attr_group);

I think we could do just one additional group here for both rc6p and rc6pp, simplifies the code a bit.

if both snb and ivb have both deep and deepest I agree... But I defined above rc6pp only on snb and rc6p on snb and ivb... am I wrong?

Quoted 43 lines

-Daniel

Quoted 28 lines
drivers/gpu/drm/i915/i915_sysfs.c +0 -0
 #endif
 }
drivers/gpu/drm/i915/intel_pm.c +8 -5
index 7553e47..fa1227e 100644
@@ -3632,10 +3632,14 @@ 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");
+     DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+                   (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+     if (HAS_RC6p(dev))
+             DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s\n",
+                           (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off");
+     if (HAS_RC6pp(dev))
+             DRM_DEBUG_KMS("Enabling RC6 states: RC6pp %s\n",
+                           (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
--

1.9.3

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 2 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
author maintainer
#3 lore raw

PATCH 1/1 drm/i915: Do not export RC6p and RC6pp if they don't exist

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 until HSW although they keep disabled by default.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

Cc Josh Triplett <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 10 ++++++----
 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5ba5524..e149f7b 100644
@@ -2185,6 +2185,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)		(HAS_RC6(dev) && INTEL_INFO(dev)->gen < 8)
 
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +6 -4
index 6a670ad..7749bfe 100644
@@ -3629,10 +3629,12 @@ 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");
+	DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+		      (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+	if (HAS_RC6p(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s RC6pp %s \n",
+			      (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off",
+			      (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH 1/1 drm/i915: Do not export RC6p and RC6pp if they don't exist

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 until HSW although they keep disabled by default.

v3: Remove unecessary space.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

Cc Josh Triplett <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 10 ++++++----
 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5ba5524..e149f7b 100644
@@ -2185,6 +2185,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)		(HAS_RC6(dev) && INTEL_INFO(dev)->gen < 8)
 
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +6 -4
index 6a670ad..cfdc666 100644
@@ -3629,10 +3629,12 @@ 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");
+	DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+		      (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+	if (HAS_RC6p(dev))
+		DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s RC6pp %s\n",
+			      (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off",
+			      (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
Signature · 1 line
1.9.3
#5 lore raw

2014-10-01 11:47 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 25 lines

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 until HSW although they keep disabled by default.

v3: Remove unecessary space.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

Cc Josh Triplett <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 10 ++++++----
 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 5ba5524..e149f7b 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table { · line 2189

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -2185,6 +2185,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)          (HAS_RC6(dev) && INTEL_INFO(dev)->gen < 8)

Required change:

I know you've already spotted this, but just to document it: HSW doesn't have RC6p, so you have to replace this with "< 7".

Quoted 35 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define INTEL_PCH_DEVICE_ID_MASK               0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE           0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +11 -2
index 503847f..4a5af69 100644
@@ -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)

drivers/gpu/drm/i915/i915_sysfs.c void i915_setup_sysfs(struct drm_device *dev) · line 607

Quoted 5 lines
drivers/gpu/drm/i915/i915_sysfs.c +1 -1
@@ -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)) {

Suggestion for another patch:

While this is correct and keeps backwards compatibility, I have to point out that RC6 is possible on Ironlake too, and we allow it if you pass the enable_rc6 flag, but it is never displayed on sysfs. So even if you pass the parameters to enable RC6 on ILK, powertop won't tell you its residency.

So, as a separate patch, you could change HAS_RC6 to be "gen >= 5" and HAS_RC6p to be "is_snb || is_ivb". But please do this in a separate patch since it's a different fix for a different problem.

Quoted 29 lines
drivers/gpu/drm/i915/i915_sysfs.c +7 -0
                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
 }
drivers/gpu/drm/i915/intel_pm.c +0 -0
index 6a670ad..cfdc666 100644
@@ -3629,10 +3629,12 @@ static void intel_print_rc6_info(struct drm_device *dev, u32 mode)
                else
                        mode = 0;
        }

drivers/gpu/drm/i915/intel_pm.c static void intel_print_rc6_info(struct drm_device *dev, u32 mode) · line 3637

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +6 -4
-       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");
+       DRM_DEBUG_KMS("Enabling RC6 states: RC6 %s\n",
+                     (mode & GEN6_RC_CTL_RC6_ENABLE) ? "on" : "off");
+       if (HAS_RC6p(dev))
+               DRM_DEBUG_KMS("Enabling RC6 states: RC6p %s RC6pp %s\n",
+                             (mode & GEN6_RC_CTL_RC6p_ENABLE) ? "on" : "off",
+                             (mode & GEN6_RC_CTL_RC6pp_ENABLE) ? "on" : "off");

Bikeshed:

We'll now have 2 lines containing "Enabling RC6 states:", which is weird and will make many developers wonder "wth? are we running this function twice?", so I would personally prefer "if (hasrc6p) DRM_DEBUG_KMS("rc6, rc6p, rc6pp etc"); else DRM_DEBUG_KMS("rc6"): it avoids confusing users since it doesn't mention rc6p and rc6pp on platforms that don't have them, and it also avoids printing two almost-identical lines.

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
 }
 
 static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
--

1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
author maintainer
#6 lore raw

PATCH 1/1 drm/i915: Do not export RC6p and RC6pp if they don't exist

In reply to Rodrigo Vivi

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 until BDW 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.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

Cc Josh Triplett <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 15 ++++++++++-----
 3 files changed, 31 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5ba5524..d5412af 100644
@@ -2185,6 +2185,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)		(HAS_RC6(dev) && INTEL_INFO(dev)->gen < 7)
 
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +10 -5
index 6a670ad..90eafa7 100644
@@ -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
Signature · 1 line
1.9.3
#7 lore raw

2014-10-07 10:36 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 29 lines

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 until BDW 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.

References: https://bugs.freedesktop.org/show_bug.cgi?id=84524

Cc Josh Triplett <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 15 ++++++++++-----
 3 files changed, 31 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 5ba5524..d5412af 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_cmd_table { · line 2189

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -2185,6 +2185,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)          (HAS_RC6(dev) && INTEL_INFO(dev)->gen < 7)

I know I'm the one who asked you to use "< 7", but this is wrong since IVB is gen7... I'm sorry for inducing the mistake here :(

Quoted 101 lines
drivers/gpu/drm/i915/i915_drv.h +0 -0
 #define INTEL_PCH_DEVICE_ID_MASK               0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE           0x3b00
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +10 -6
index 6a670ad..90eafa7 100644
@@ -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
--

1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni
author maintainer
#8 lore raw

PATCH 1/1 drm/i915: Do not export RC6p and RC6pp if they don't exist

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 <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 15 ++++++++++-----
 3 files changed, 31 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5ba5524..21625f2 100644
@@ -2185,6 +2185,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
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +10 -5
index 6a670ad..90eafa7 100644
@@ -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
Signature · 1 line
1.9.3
Reviewed-by on v1 1/1
#9 lore raw

2014-10-07 11:06 GMT-03:00 Rodrigo Vivi <[email protected]>:

Quoted 13 lines

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.

Quoted 8 lines

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 <[email protected]>
Cc Paulo Zanoni <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 117 lines
---
 drivers/gpu/drm/i915/i915_drv.h   |  2 ++
 drivers/gpu/drm/i915/i915_sysfs.c | 22 +++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c   | 15 ++++++++++-----
 3 files changed, 31 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5ba5524..21625f2 100644
@@ -2185,6 +2185,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
drivers/gpu/drm/i915/i915_sysfs.c +19 -3
index 503847f..4a5af69 100644
@@ -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
 }
drivers/gpu/drm/i915/intel_pm.c +10 -6
index 6a670ad..90eafa7 100644
@@ -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
--

1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni