Skip to contentSkip to conversation

drm/i915/bdw: Check for slice, subslice and EU count for BDW

PATCH Superseded Łukasz Daniluk 5 participants 13 messages Aug 13, 2015 – Sep 29, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/bdw: Check for slice, subslice and EU count for BDW

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 35 +++++++++++++--
 drivers/gpu/drm/i915/i915_dma.c     | 89 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 19 +++++++-
 3 files changed, 138 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +32 -3
index 23a69307..a17f912 100644
@@ -4838,7 +4838,6 @@ struct sseu_dev_status {
 static void cherryview_sseu_device_status(struct drm_device *dev,
 					  struct sseu_dev_status *stat)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	const int ss_max = 2;
 	int ss;
 	u32 sig1[ss_max], sig2[ss_max];
@@ -4870,7 +4869,6 @@ static void cherryview_sseu_device_status(struct drm_device *dev,
 static void gen9_sseu_device_status(struct drm_device *dev,
 				    struct sseu_dev_status *stat)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	int s_max = 3, ss_max = 4;
 	int s, ss;
 	u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
@@ -4932,13 +4930,42 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	int s;
+	u32 slice_info = I915_READ(GEN8_R_PWR_CLK_STATE);
+
+	/*
+	 * If first bit of slice_info is 0, there is no specific power
+	 * state set. Otherwise we read the count of enabled slices
+	 * from it.
+	 */
+	if (slice_info & (1<<31))
+		stat->slice_total = (slice_info & GEN8_RPCS_S_CNT_MASK)
+			>> GEN8_RPCS_S_CNT_SHIFT;
+	else
+		stat->slice_total = INTEL_INFO(dev)->slice_total;
+
+	stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+	stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+	stat->subslice_total = stat->slice_total * stat->subslice_per_slice;
+	stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+	/* subtract fused off EU(s) from enabled slice(s) */
+	for (s = 0; s < stat.slice_total; s++) {
+		u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+		stat->eu_total -= hweight8(subslice_7eu);
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if ((INTEL_INFO(dev)->gen < 8))
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -4963,6 +4990,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +89 -0

101 lines not on this page · raw message

drivers/gpu/drm/i915/i915_reg.h +17 -2
index be87e3b..77e043e 100644
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
Signature · 6 lines
Lukasz Daniluk

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 180 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This
information is filled in intel_device_info and is available to user with
GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 35 +++++++++++++--
 drivers/gpu/drm/i915/i915_dma.c     | 89 
+++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 19 +++++++-
 3 files changed, 138 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -2
index 23a69307..a17f912 100644
@@ -4838,7 +4838,6 @@ struct sseu_dev_status {
 static void cherryview_sseu_device_status(struct drm_device *dev,
                                        struct sseu_dev_status *stat)
 {
-     struct drm_i915_private *dev_priv = dev->dev_private;
      const int ss_max = 2;
      int ss;
      u32 sig1[ss_max], sig2[ss_max];
@@ -4870,7 +4869,6 @@ static void 
 cherryview_sseu_device_status(struct drm_device *dev,
 static void gen9_sseu_device_status(struct drm_device *dev,
                                  struct sseu_dev_status *stat)
 {
-     struct drm_i915_private *dev_priv = dev->dev_private;
      int s_max = 3, ss_max = 4;
      int s, ss;
      u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
drivers/gpu/drm/i915/i915_debugfs.c +30 -1
@@ -4932,13 +4930,42 @@ static void gen9_sseu_device_status(struct 
 drm_device *dev,
      }
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+                                      struct sseu_dev_status *stat)
+{
+     int s;
+     u32 slice_info = I915_READ(GEN8_R_PWR_CLK_STATE);
+
+     /*
+      * If first bit of slice_info is 0, there is no specific power
+      * state set. Otherwise we read the count of enabled slices
+      * from it.
+      */
+     if (slice_info & (1<<31))
+             stat->slice_total = (slice_info & GEN8_RPCS_S_CNT_MASK)
+                     >> GEN8_RPCS_S_CNT_SHIFT;
+     else
+             stat->slice_total = INTEL_INFO(dev)->slice_total;
+
+     stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+     stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+     stat->subslice_total = stat->slice_total * stat-
 >subslice_per_slice;
+     stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+     /* subtract fused off EU(s) from enabled slice(s) */
+     for (s = 0; s < stat.slice_total; s++) {
+             u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+             stat->eu_total -= hweight8(subslice_7eu);
+     }
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
      struct drm_info_node *node = (struct drm_info_node *) m->private;
      struct drm_device *dev = node->minor->dev;
      struct sseu_dev_status stat;
 
-     if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+     if ((INTEL_INFO(dev)->gen < 8))
              return -ENODEV;
 
      seq_puts(m, "SSEU Device Info\n");
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
@@ -4963,6 +4990,8 @@ static int i915_sseu_status(struct seq_file 
 *m, void *unused)
      memset(&stat, 0, sizeof(stat));
      if (IS_CHERRYVIEW(dev)) {
              cherryview_sseu_device_status(dev, &stat);
+     } else if (IS_BROADWELL(dev)) {
+             broadwell_sseu_device_status(dev, &stat);
      } else if (INTEL_INFO(dev)->gen >= 9) {
              gen9_sseu_device_status(dev, &stat);
      }
drivers/gpu/drm/i915/i915_dma.c +72 -0
index ab37d11..2d52b1e 100644
@@ -705,6 +705,93 @@ static void gen9_sseu_info_init(struct 
 drm_device *dev)
      info->has_eu_pg = (info->eu_per_subslice > 2);
 }
 
+static void broadwell_sseu_info_init(struct drm_device *dev)
+{
+     struct drm_i915_private *dev_priv = dev->dev_private;
+     struct intel_device_info *info;
+     const int s_max = 3, ss_max = 3, eu_max = 8;
+     int s, ss;
+     u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+     fuse2 = I915_READ(GEN8_FUSE2);
+     s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
+             GEN8_F2_S_ENA_SHIFT;
+     ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >>
+             GEN8_F2_SS_DIS_SHIFT;
+
+     eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) &
+             GEN8_EU_DIS0_S0_MASK;
+     eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >>
+                     GEN8_EU_DIS0_S1_SHIFT) |
+             ((I915_READ(GEN8_EU_DISABLE1) &
+               GEN8_EU_DIS1_S1_MASK) <<
+              (32 - GEN8_EU_DIS0_S1_SHIFT));
+     eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >>
+                     GEN8_EU_DIS1_S2_SHIFT) |
+             ((I915_READ(GEN8_EU_DISABLE2) &
+               GEN8_EU_DIS2_S2_MASK) <<
+              (32 - GEN8_EU_DIS1_S2_SHIFT));
+
+
+     info = (struct intel_device_info *)&dev_priv->info;
+     info->slice_total = hweight32(s_enable);
+
+     /*
+      * The subslice disable field is global, i.e. it applies
+      * to each of the enabled slices.
+      */
+     info->subslice_per_slice = ss_max - hweight32(ss_disable);
+     info->subslice_total = info->slice_total *
+             info->subslice_per_slice;
+
+     /*
+      * Iterate through enabled slices and subslices to
+      * count the total enabled EU.
+      */
+     for (s = 0; s < s_max; s++) {
+             if (!(s_enable & (0x1 << s)))
+                     /* skip disabled slice */
+                     continue;
+
+             for (ss = 0; ss < ss_max; ss++) {
+                     u32 n_disabled;
+
+                     if (ss_disable & (0x1 << ss))
+                             /* skip disabled subslice */
+                             continue;
+
+                     n_disabled = hweight8(eu_disable[s] >>
+                                     (ss * eu_max));
+
+                     /*
+                      * Record which subslice(s) has(have) 7 EUs. we
+                      * can tune the hash used to spread work among
+                      * subslices if they are unbalanced.
+                      */
+                     if (eu_max - n_disabled == 7)
+                             info->subslice_7eu[s] |= 1 << ss;
+
+                     info->eu_total += eu_max - n_disabled;
+             }
+     }
+
+     /*
+      * BDW is expected to always have a uniform distribution of EU 
Quoted 4 lines

across
+ * subslices with the exception that any one EU in any one
subslice may
+ * be fused off for die recovery.

I like comments but wondering if fused off for die recovery is ok. W ould it be better to indicate for sku options or something?

Quoted 51 lines
drivers/gpu/drm/i915/i915_dma.c +15 -0
+      */
+     info->eu_per_subslice = info->subslice_total ?
+             DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+     /*
+      * BDW supports slice power gating on devices with more than
+      * one slice.
+      */
+     info->has_slice_pg = (info->slice_total > 1);
+     info->has_subslice_pg = 0;
+     info->has_eu_pg = 0;
+}
+
 /*
  * Determine various intel_device_info fields at runtime.
  *
@@ -775,6 +862,8 @@ static void 
 intel_device_info_runtime_init(struct drm_device *dev)
      /* Initialize slice/subslice/EU info */
      if (IS_CHERRYVIEW(dev))
              cherryview_sseu_info_init(dev);
+     else if (IS_BROADWELL(dev))
+             broadwell_sseu_info_init(dev);
      else if (INTEL_INFO(dev)->gen >= 9)
              gen9_sseu_info_init(dev);
drivers/gpu/drm/i915/i915_reg.h +9 -2
index be87e3b..77e043e 100644
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK (0xf << 
 CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2                   0x9120
+#define   GEN8_F2_SS_DIS_SHIFT               21
+#define   GEN8_F2_SS_DIS_MASK                (0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT                25
 #define   GEN8_F2_S_ENA_MASK         (0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT               20
-#define   GEN9_F2_SS_DIS_MASK                (0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0             0x9134
+#define   GEN8_EU_DIS0_S0_MASK               0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT              24
+#define   GEN8_EU_DIS0_S1_MASK               (0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1             0x9138
+#define   GEN8_EU_DIS1_S1_MASK               0xffff

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1866

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +8 -0
+#define   GEN8_EU_DIS1_S2_SHIFT              16
+#define   GEN8_EU_DIS1_S2_MASK               (0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2             0x913c
+#define   GEN8_EU_DIS2_S2_MASK               0xff
+
+#define GEN9_F2_SS_DIS_SHIFT         20
+#define GEN9_F2_SS_DIS_MASK          (0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)               (0x9134 + (slice)*0x4)

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

#2 lore raw
In reply to Łukasz Daniluk
Quoted 22 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 35 +++++++++++++--
 drivers/gpu/drm/i915/i915_dma.c     | 89 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 19 +++++++-
 3 files changed, 138 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 23a69307..a17f912 100644

drivers/gpu/drm/i915/i915_debugfs.c struct sseu_dev_status { · line 4841

Quoted 4 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -1
@@ -4838,7 +4838,6 @@ struct sseu_dev_status {
 static void cherryview_sseu_device_status(struct drm_device *dev,
 					  struct sseu_dev_status *stat)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;

Did you compile this? I915_READ macro requires dev_priv.

drivers/gpu/drm/i915/i915_debugfs.c static void cherryview_sseu_device_status(struct drm_device *dev, · line 4873

Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -1
 	const int ss_max = 2;
 	int ss;
 	u32 sig1[ss_max], sig2[ss_max];
@@ -4870,7 +4869,6 @@ static void cherryview_sseu_device_status(struct drm_device *dev,
 static void gen9_sseu_device_status(struct drm_device *dev,
 				    struct sseu_dev_status *stat)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;

Did you compile this? I915_READ macro requires dev_priv.

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4937

Quoted 12 lines
drivers/gpu/drm/i915/i915_debugfs.c +5 -0
 	int s_max = 3, ss_max = 4;
 	int s, ss;
 	u32 s_reg[s_max], eu_reg[2*s_max], eu_mask[2];
@@ -4932,13 +4930,42 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	int s;
+	u32 slice_info = I915_READ(GEN8_R_PWR_CLK_STATE);

RPCS register only shows what slice state was requested, not the actual slice state. You need to use the GEN8_GT_SLICE_INFO register that I shared with you in my original patch for this.

Quoted 187 lines
drivers/gpu/drm/i915/i915_debugfs.c +27 -1
+
+	/*
+	 * If first bit of slice_info is 0, there is no specific power
+	 * state set. Otherwise we read the count of enabled slices
+	 * from it.
+	 */
+	if (slice_info & (1<<31))
+		stat->slice_total = (slice_info & GEN8_RPCS_S_CNT_MASK)
+			>> GEN8_RPCS_S_CNT_SHIFT;
+	else
+		stat->slice_total = INTEL_INFO(dev)->slice_total;
+
+	stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+	stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+	stat->subslice_total = stat->slice_total * stat->subslice_per_slice;
+	stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+	/* subtract fused off EU(s) from enabled slice(s) */
+	for (s = 0; s < stat.slice_total; s++) {
+		u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+		stat->eu_total -= hweight8(subslice_7eu);
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if ((INTEL_INFO(dev)->gen < 8))
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -4963,6 +4990,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +89 -0
index ab37d11..2d52b1e 100644
@@ -705,6 +705,93 @@ static void gen9_sseu_info_init(struct drm_device *dev)
 	info->has_eu_pg = (info->eu_per_subslice > 2);
 }
 
+static void broadwell_sseu_info_init(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
+		GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >>
+		GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) &
+		GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >>
+			GEN8_EU_DIS0_S1_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE1) &
+		  GEN8_EU_DIS1_S1_MASK) <<
+		 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >>
+			GEN8_EU_DIS1_S2_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE2) &
+		  GEN8_EU_DIS2_S2_MASK) <<
+		 (32 - GEN8_EU_DIS1_S2_SHIFT));
+
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total *
+		info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >>
+					(ss * eu_max));
+
+			/*
+			 * Record which subslice(s) has(have) 7 EUs. we
+			 * can tune the hash used to spread work among
+			 * subslices if they are unbalanced.
+			 */
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
 /*
  * Determine various intel_device_info fields at runtime.
  *
@@ -775,6 +862,8 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
 	/* Initialize slice/subslice/EU info */
 	if (IS_CHERRYVIEW(dev))
 		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
 	else if (INTEL_INFO(dev)->gen >= 9)
 		gen9_sseu_info_init(dev);
 
drivers/gpu/drm/i915/i915_reg.h +17 -2
index be87e3b..77e043e 100644
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
Signature · 1 line
Lukasz Daniluk

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

#3 lore raw

PATCH v2 1/1 drm/i915/bdw: Check for slice, subslice and EU count for BDW

In reply to Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 89 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 22 ++++++++-
 3 files changed, 137 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +28 -1
index 23a69307..e8a62ef 100644
@@ -4932,13 +4932,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total)
+	{
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat->subslice_per_slice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -4963,6 +4988,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +89 -0

101 lines not on this page · raw message

drivers/gpu/drm/i915/i915_reg.h +20 -2
index be87e3b..37f658f 100644
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
@@ -6822,6 +6837,9 @@ enum skl_disp_power_wells {
 #define   GEN6_RC6			3
 #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
 #define CHV_POWER_SS0_SIG1		0xa720
 #define CHV_POWER_SS1_SIG1		0xa728
 #define   CHV_SS_PG_ENABLE		(1<<1)
Signature · 6 lines
Lukasz Daniluk

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 1 line · Łukasz Daniluk

+static void broadwell_sseu_device_status(struct drm_device *dev,

Why pass in dev if you only use dev_priv (and commit the sin of repeatedly retrieving dev->dev_priv)?

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4946

Quoted 11 lines
drivers/gpu/drm/i915/i915_debugfs.c +11 -0
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total)
+	{

Missed.

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4956

Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +10 -0
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat->subslice_per_slice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}

So why are we computing this twice? Is the debugfs to show the hw registers or the sw tracking? Where do I see what we actually report? If it is for the hw registers, report them. A perfect function here would report the actual register values (possibly decoding them) and show what the internal values are.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 8 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Wednesday, September 2, 2015 16:03
To: Daniluk, Lukasz
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/bdw: Check for slice, subslice and EU count for BDW

Quoted 5 lines
Quoted 1 line · Łukasz Daniluk

+static void broadwell_sseu_device_status(struct drm_device *dev,

Why pass in dev if you only use dev_priv (and commit the sin of repeatedly retrieving dev->dev_priv)?

I was following the style of other _sseu_device_status functions. Also, I use INTEL_INFO that wants dev argument.

Quoted 13 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4946

Quoted 12 lines
drivers/gpu/drm/i915/i915_debugfs.c +11 -0
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total)
+	{

Missed.

Do you mean anything else than bracket here?

Quoted 19 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4956

Quoted 12 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat-

subslice_per_slice;

drivers/gpu/drm/i915/i915_debugfs.c +7 -0
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}

So why are we computing this twice? Is the debugfs to show the hw registers or the sw tracking? Where do I see what we actually report? If it is for the hw registers, report them. A perfect function here would report the actual register values (possibly decoding them) and show what the internal values are. -Chris

Quoted 2 lines

--
Chris Wilson, Intel Open Source Technology Centre

Nothing is computed twice here - all values that are unchanged are read using INTEL_INFO macro. What is computed however is amount of active (not simply present on the system) subslices and EUs. These values depend on number of active slices. The for loop checks if the one of the active slice is the one with EU fused off for die recovery. When you read i915_sseu_status the first part (SSEU Device Info) gives you information on general capabilities (things that can be read using INTEL_INFO(dev)), the second part (SSEU Device Status) is giving you the contents of stat struct.

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

#6 lore raw
In reply to Łukasz Daniluk
Quoted 29 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

---
  drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++-
  drivers/gpu/drm/i915/i915_dma.c     | 89 +++++++++++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/i915_reg.h     | 22 ++++++++-
  3 files changed, 137 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 23a69307..e8a62ef 100644

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4940

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
@@ -4932,13 +4932,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
  	}
  }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);

I don't see this register (0x138064 as defined below) in bdw spec.

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4943

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);

why not in a single line, seems to fit under 80 chars.

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4951

Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
+
+	if (stat->slice_total)
+	{
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat->subslice_per_slice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+

Please reorder such that all subslice values are populated first followed by EUs to follow an order.

Quoted 33 lines
drivers/gpu/drm/i915/i915_debugfs.c +11 -1
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
  static int i915_sseu_status(struct seq_file *m, void *unused)
  {
  	struct drm_info_node *node = (struct drm_info_node *) m->private;
  	struct drm_device *dev = node->minor->dev;
  	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
  		return -ENODEV;
 
  	seq_puts(m, "SSEU Device Info\n");
@@ -4963,6 +4988,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
  	memset(&stat, 0, sizeof(stat));
  	if (IS_CHERRYVIEW(dev)) {
  		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
  	} else if (INTEL_INFO(dev)->gen >= 9) {
  		gen9_sseu_device_status(dev, &stat);
  	}
drivers/gpu/drm/i915/i915_dma.c +0 -0
index ab37d11..2d52b1e 100644

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 712

Quoted 8 lines
drivers/gpu/drm/i915/i915_dma.c +5 -0
@@ -705,6 +705,93 @@ static void gen9_sseu_info_init(struct drm_device *dev)
  	info->has_eu_pg = (info->eu_per_subslice > 2);
  }
 
+static void broadwell_sseu_info_init(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;

I only see max of 2 slices for bdw in spec.

Quoted 12 lines
drivers/gpu/drm/i915/i915_dma.c +12 -0
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
+		GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >>
+		GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) &
+		GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >>

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 734

Quoted 10 lines
drivers/gpu/drm/i915/i915_dma.c +10 -0
+			GEN8_EU_DIS0_S1_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE1) &
+		  GEN8_EU_DIS1_S1_MASK) <<
+		 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >>
+			GEN8_EU_DIS1_S2_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE2) &
+		  GEN8_EU_DIS2_S2_MASK) <<
+		 (32 - GEN8_EU_DIS1_S2_SHIFT));
+

GEN9_EU_DISABLE(slice) is already available, since the register addresses are same maybe it can be reused after renaming it to GEN8 instead of creating new definitions? ofcourse shift/mask are different.

Indentation is off, in general please use () to force indentation. first two statements can fit in single line.

regards
Arun

Quoted 107 lines
drivers/gpu/drm/i915/i915_dma.c +62 -0
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total *
+		info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >>
+					(ss * eu_max));
+
+			/*
+			 * Record which subslice(s) has(have) 7 EUs. we
+			 * can tune the hash used to spread work among
+			 * subslices if they are unbalanced.
+			 */
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
  /*
   * Determine various intel_device_info fields at runtime.
   *
@@ -775,6 +862,8 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
  	/* Initialize slice/subslice/EU info */
  	if (IS_CHERRYVIEW(dev))
  		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
  	else if (INTEL_INFO(dev)->gen >= 9)
  		gen9_sseu_info_init(dev);
 
drivers/gpu/drm/i915/i915_reg.h +17 -2
index be87e3b..37f658f 100644
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
  #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
  #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
  #define   GEN8_F2_S_ENA_SHIFT		25
  #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
  #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 6845

Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
@@ -6822,6 +6837,9 @@ enum skl_disp_power_wells {
  #define   GEN6_RC6			3
  #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
  #define CHV_POWER_SS0_SIG1		0xa720
  #define CHV_POWER_SS1_SIG1		0xa728
  #define   CHV_SS_PG_ENABLE		(1<<1)

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

#7 lore raw
Quoted 43 lines

-----Original Message-----
From: Arun Siluvery [mailto:[email protected]]
Sent: Wednesday, September 2, 2015 17:08
To: Daniluk, Lukasz; [email protected]
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/bdw: Check for slice, subslice and EU count for BDW

Quoted 16 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

Quoted 5 lines
---
  drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++-
  drivers/gpu/drm/i915/i915_dma.c     | 89

+++++++++++++++++++++++++++++++++++++

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct

Quoted 9 lines
  drivers/gpu/drm/i915/i915_reg.h     | 22 ++++++++-
  3 files changed, 137 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 23a69307..e8a62ef 100644
@@ -4932,13 +4932,38 @@ static void gen9_sseu_device_status(struct

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
  	}
  }
 
Quoted 8 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4940

Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);

I don't see this register (0x138064 as defined below) in bdw spec.

Yes, this register isn't listed in spec. I am unsure when the full spec for this register will be published.

Quoted 6 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4943

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);

why not in a single line, seems to fit under 80 chars.

I was using longer define name and didn't recheck if this line fits under 80. Thanks for catch.

Quoted 12 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4951

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
+
+	if (stat->slice_total)
+	{
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat-
 subslice_per_slice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+

Please reorder such that all subslice values are populated first followed by EUs to follow an order.

Okay. My idea was to order them based on where value comes from (is it computed here or simply read with INTEL_INFO).

Quoted 35 lines

drivers/gpu/drm/i915/i915_debugfs.c static int i915_sseu_status(struct seq_file *m, void

Quoted 20 lines
drivers/gpu/drm/i915/i915_debugfs.c +9 -1
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
  static int i915_sseu_status(struct seq_file *m, void *unused)
  {
  	struct drm_info_node *node = (struct drm_info_node *) m->private;
  	struct drm_device *dev = node->minor->dev;
  	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
  		return -ENODEV;
 
  	seq_puts(m, "SSEU Device Info\n");
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
@@ -4963,6 +4988,8 @@ static int i915_sseu_status(struct seq_file *m, void

*unused)

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device

Quoted 13 lines
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
  	memset(&stat, 0, sizeof(stat));
  	if (IS_CHERRYVIEW(dev)) {
  		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
  	} else if (INTEL_INFO(dev)->gen >= 9) {
  		gen9_sseu_device_status(dev, &stat);
  	}
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_dma.c index ab37d11..2d52b1e 100644

drivers/gpu/drm/i915/i915_dma.c +0 -0
@@ -705,6 +705,93 @@ static void gen9_sseu_info_init(struct drm_device

*dev)

Quoted 9 lines

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 712

Quoted 7 lines
drivers/gpu/drm/i915/i915_dma.c +4 -0
  	info->has_eu_pg = (info->eu_per_subslice > 2);
  }
 
+static void broadwell_sseu_info_init(struct drm_device *dev) {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;

I only see max of 2 slices for bdw in spec.

Register values assume that there can be 3 slices (slice 0,1 and 2) and that’s why I used 3 here as max slices count.

Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/i915/i915_dma.c +18 -0
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
+		GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >>
+		GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) &
+		GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >>
+			GEN8_EU_DIS0_S1_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE1) &
+		  GEN8_EU_DIS1_S1_MASK) <<
+		 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >>
+			GEN8_EU_DIS1_S2_SHIFT) |
Quoted 8 lines

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 734

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +4 -0
+		((I915_READ(GEN8_EU_DISABLE2) &
+		  GEN8_EU_DIS2_S2_MASK) <<
+		 (32 - GEN8_EU_DIS1_S2_SHIFT));
+

GEN9_EU_DISABLE(slice) is already available, since the register addresses are same maybe it can be reused after renaming it to GEN8 instead of creating new definitions? ofcourse shift/mask are different.

I wouldn't use renaming of register from other generation. Since contents of this register are read in different way I treated these as different registers and that’s why I choose to create new define without any references to GEN9 register. However, if the renaming (or even using existing define) is preferred approach I will modify the patch.

Quoted 7 lines

Indentation is off, in general please use () to force indentation. first two statements can fit in single line.

regards
Arun

Thank you for questions and style suggestions. I will reformat the lines before submitting updated patch.

---
Łukasz Daniluk

Quoted 117 lines

drivers/gpu/drm/i915/i915_dma.c static void intel_device_info_runtime_init(struct

Quoted 64 lines
drivers/gpu/drm/i915/i915_dma.c +60 -0
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total *
+		info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >>
+					(ss * eu_max));
+
+			/*
+			 * Record which subslice(s) has(have) 7 EUs. we
+			 * can tune the hash used to spread work among
+			 * subslices if they are unbalanced.
+			 */
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
  /*
   * Determine various intel_device_info fields at runtime.
   *
@@ -775,6 +862,8 @@ static void intel_device_info_runtime_init(struct

drm_device *dev)

Quoted 13 lines
drivers/gpu/drm/i915/i915_dma.c +2 -0
  	/* Initialize slice/subslice/EU info */
  	if (IS_CHERRYVIEW(dev))
  		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
  	else if (INTEL_INFO(dev)->gen >= 9)
  		gen9_sseu_info_init(dev);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h index be87e3b..37f658f 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1841

Quoted 1 line
drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
  #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf <<

CHV_FGT_EU_DIS_SS1_R1_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
  #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 <<

GEN8_F2_SS_DIS_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1846

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
  #define   GEN8_F2_S_ENA_SHIFT		25
  #define   GEN8_F2_S_ENA_MASK		(0x7 <<

GEN8_F2_S_ENA_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1846

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf <<

GEN9_F2_SS_DIS_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff <<

GEN8_EU_DIS0_S1_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff <<

GEN8_EU_DIS1_S2_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +6 -0
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf <<

GEN9_F2_SS_DIS_SHIFT)

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
  #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
@@ -6822,6 +6837,9 @@ enum skl_disp_power_wells {
  #define   GEN6_RC6			3
  #define   GEN6_RC7			4
 
Quoted 7 lines

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 6845

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
  #define CHV_POWER_SS0_SIG1		0xa720
  #define CHV_POWER_SS1_SIG1		0xa728
  #define   CHV_SS_PG_ENABLE		(1<<1)

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

#8 lore raw
Quoted 155 lines · Lukasz
Quoted 43 lines

-----Original Message-----
From: Arun Siluvery [mailto:[email protected]]
Sent: Wednesday, September 2, 2015 17:08
To: Daniluk, Lukasz; [email protected]
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/bdw: Check for slice, subslice and EU count for BDW

Quoted 16 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

Quoted 5 lines
---
   drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++-
   drivers/gpu/drm/i915/i915_dma.c     | 89

+++++++++++++++++++++++++++++++++++++

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct

Quoted 9 lines
   drivers/gpu/drm/i915/i915_reg.h     | 22 ++++++++-
   3 files changed, 137 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index 23a69307..e8a62ef 100644
@@ -4932,13 +4932,38 @@ static void gen9_sseu_device_status(struct

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
   	}
   }
 
Quoted 8 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4940

Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);

I don't see this register (0x138064 as defined below) in bdw spec.

Yes, this register isn't listed in spec. I am unsure when the full spec for this register will be published.

Quoted 6 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4943

Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -0
+
+	stat->slice_total =
+		hweight32(slice_info & GEN8_LSLICESTAT_MASK);

why not in a single line, seems to fit under 80 chars.

I was using longer define name and didn't recheck if this line fits under 80. Thanks for catch.

Quoted 12 lines

drivers/gpu/drm/i915/i915_debugfs.c static void gen9_sseu_device_status(struct drm_device *dev, · line 4951

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
+
+	if (stat->slice_total)
+	{
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->subslice_total = stat->slice_total * stat-
 subslice_per_slice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+

Please reorder such that all subslice values are populated first followed by EUs to follow an order.

Okay. My idea was to order them based on where value comes from (is it computed here or simply read with INTEL_INFO).

Quoted 35 lines

drivers/gpu/drm/i915/i915_debugfs.c static int i915_sseu_status(struct seq_file *m, void

Quoted 20 lines
drivers/gpu/drm/i915/i915_debugfs.c +9 -1
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
   static int i915_sseu_status(struct seq_file *m, void *unused)
   {
   	struct drm_info_node *node = (struct drm_info_node *) m->private;
   	struct drm_device *dev = node->minor->dev;
   	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
   		return -ENODEV;
 
   	seq_puts(m, "SSEU Device Info\n");
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
@@ -4963,6 +4988,8 @@ static int i915_sseu_status(struct seq_file *m, void

*unused)

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device

Quoted 13 lines
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
   	memset(&stat, 0, sizeof(stat));
   	if (IS_CHERRYVIEW(dev)) {
   		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
   	} else if (INTEL_INFO(dev)->gen >= 9) {
   		gen9_sseu_device_status(dev, &stat);
   	}
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_dma.c index ab37d11..2d52b1e 100644

drivers/gpu/drm/i915/i915_dma.c +0 -0
@@ -705,6 +705,93 @@ static void gen9_sseu_info_init(struct drm_device

*dev)

Quoted 9 lines

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 712

Quoted 7 lines
drivers/gpu/drm/i915/i915_dma.c +4 -0
   	info->has_eu_pg = (info->eu_per_subslice > 2);
   }
 
+static void broadwell_sseu_info_init(struct drm_device *dev) {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;

I only see max of 2 slices for bdw in spec.

Register values assume that there can be 3 slices (slice 0,1 and 2) and that’s why I used 3 here as max slices count.

Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/i915/i915_dma.c +18 -0
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
+		GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >>
+		GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) &
+		GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >>
+			GEN8_EU_DIS0_S1_SHIFT) |
+		((I915_READ(GEN8_EU_DISABLE1) &
+		  GEN8_EU_DIS1_S1_MASK) <<
+		 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >>
+			GEN8_EU_DIS1_S2_SHIFT) |
Quoted 8 lines

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 734

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +4 -0
+		((I915_READ(GEN8_EU_DISABLE2) &
+		  GEN8_EU_DIS2_S2_MASK) <<
+		 (32 - GEN8_EU_DIS1_S2_SHIFT));
+

GEN9_EU_DISABLE(slice) is already available, since the register addresses are same maybe it can be reused after renaming it to GEN8 instead of creating new definitions? ofcourse shift/mask are different.

Quoted 4 lines

I wouldn't use renaming of register from other generation. Since contents of this register are read in different way I treated these as different registers and that’s why I choose to create new define without any references to GEN9 register. However, if the renaming (or even using existing define) is preferred approach I will modify the patch.

Normally we create a new define for newer Gen if the existing one cannot be reused, in this case it is the opposite, I am not sure what is best way to handle this, better to check with Daniel.

regards
Arun

Quoted 132 lines
Quoted 8 lines

Indentation is off, in general please use () to force indentation. first two statements can fit in single line.

regards
Arun

Thank you for questions and style suggestions. I will reformat the lines before submitting updated patch.

---
Łukasz Daniluk

Quoted 117 lines

drivers/gpu/drm/i915/i915_dma.c static void intel_device_info_runtime_init(struct

Quoted 64 lines
drivers/gpu/drm/i915/i915_dma.c +60 -0
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total *
+		info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >>
+					(ss * eu_max));
+
+			/*
+			 * Record which subslice(s) has(have) 7 EUs. we
+			 * can tune the hash used to spread work among
+			 * subslices if they are unbalanced.
+			 */
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
   /*
    * Determine various intel_device_info fields at runtime.
    *
@@ -775,6 +862,8 @@ static void intel_device_info_runtime_init(struct

drm_device *dev)

Quoted 13 lines
drivers/gpu/drm/i915/i915_dma.c +2 -0
   	/* Initialize slice/subslice/EU info */
   	if (IS_CHERRYVIEW(dev))
   		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
   	else if (INTEL_INFO(dev)->gen >= 9)
   		gen9_sseu_info_init(dev);
 
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_reg.h index be87e3b..37f658f 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1841

Quoted 1 line
drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -1841,11 +1841,26 @@ enum skl_disp_power_wells {
   #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf <<

CHV_FGT_EU_DIS_SS1_R1_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
   #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 <<

GEN8_F2_SS_DIS_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1846

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
   #define   GEN8_F2_S_ENA_SHIFT		25
   #define   GEN8_F2_S_ENA_MASK		(0x7 <<

GEN8_F2_S_ENA_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1846

Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +0 -2
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf <<

GEN9_F2_SS_DIS_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +4 -0
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff <<

GEN8_EU_DIS0_S1_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 5 lines
drivers/gpu/drm/i915/i915_reg.h +5 -0
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff <<

GEN8_EU_DIS1_S2_SHIFT)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells {

Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +6 -0
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf <<

GEN9_F2_SS_DIS_SHIFT)

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
   #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
@@ -6822,6 +6837,9 @@ enum skl_disp_power_wells {
   #define   GEN6_RC6			3
   #define   GEN6_RC7			4
 
Quoted 8 lines
Quoted 7 lines

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 6845

Quoted 7 lines
drivers/gpu/drm/i915/i915_reg.h +3 -0
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
   #define CHV_POWER_SS0_SIG1		0xa720
   #define CHV_POWER_SS1_SIG1		0xa728
   #define   CHV_SS_PG_ENABLE		(1<<1)

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

#9 lore raw

PATCH v3 1/1 drm/i915/bdw: Check for slice, subslice and EU count for BDW

In reply to Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

v3:
- Fix style issues

Cc Jeff Mcgee <[email protected]>
Cc Arun Siluvery <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 80 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 22 +++++++++-
 3 files changed, 128 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +28 -1
index 72ae347..d0f784d 100644
@@ -5037,13 +5037,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total) {
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->subslice_total = stat->slice_total *
+				       stat->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -5068,6 +5093,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +80 -0

92 lines not on this page · raw message

drivers/gpu/drm/i915/i915_reg.h +20 -2
index 67bf205..da84488 100644
@@ -1876,11 +1876,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
@@ -6867,6 +6882,9 @@ enum skl_disp_power_wells {
 #define   GEN6_RC6			3
 #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
 #define CHV_POWER_SS0_SIG1		0xa720
 #define CHV_POWER_SS1_SIG1		0xa728
 #define   CHV_SS_PG_ENABLE		(1<<1)
Signature · 6 lines
Lukasz Daniluk

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw
Quoted 133 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

v3:
- Fix style issues

Cc Jeff Mcgee <[email protected]>
Cc Arun Siluvery <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 80 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 22 +++++++++-
 3 files changed, 128 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +28 -1
index 72ae347..d0f784d 100644
@@ -5037,13 +5037,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total) {
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->subslice_total = stat->slice_total *
+				       stat->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -5068,6 +5093,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +44 -0
index 066a0ef..6ec3ed6 100644
@@ -713,6 +713,84 @@ static void gen9_sseu_info_init(struct drm_device *dev)
 	info->has_eu_pg = (info->eu_per_subslice > 2);
 }
 
+static void broadwell_sseu_info_init(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >> GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
+			((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
+			 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
+			((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
+			 (32 - GEN8_EU_DIS1_S2_SHIFT));
+
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total * info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))

drivers/gpu/drm/i915/i915_dma.c static void gen9_sseu_info_init(struct drm_device *dev) · line 769

Quoted 10 lines
drivers/gpu/drm/i915/i915_dma.c +10 -0
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
+
+			/*
+			 * Record which subslice(s) has(have) 7 EUs. we
+			 * can tune the hash used to spread work among
+			 * subslices if they are unbalanced.
+			 */

Should probably remove the part of the above comment which refers to hash tuning since this doesn't seem to apply for BDW, only SKL.

Quoted 41 lines
drivers/gpu/drm/i915/i915_dma.c +26 -0
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
 /*
  * Determine various intel_device_info fields at runtime.
  *
@@ -783,6 +861,8 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
 	/* Initialize slice/subslice/EU info */
 	if (IS_CHERRYVIEW(dev))
 		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
 	else if (INTEL_INFO(dev)->gen >= 9)
 		gen9_sseu_info_init(dev);
 
drivers/gpu/drm/i915/i915_reg.h +0 -0
index 67bf205..da84488 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 1883

Quoted 10 lines
drivers/gpu/drm/i915/i915_reg.h +2 -2
@@ -1876,11 +1876,26 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
-#define   GEN9_F2_SS_DIS_SHIFT		20
-#define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)

I think it is helpful to keep the above two macros here rather than move them down below the GEN8_EU_DISABLEX definitions. Having them here makes it more clear that they are Gen9-specific field definitions for the GEN8_FUSE2 register.

Quoted 31 lines
drivers/gpu/drm/i915/i915_reg.h +18 -0
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
+#define GEN9_F2_SS_DIS_SHIFT		20
+#define GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
@@ -6867,6 +6882,9 @@ enum skl_disp_power_wells {
 #define   GEN6_RC6			3
 #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
 #define CHV_POWER_SS0_SIG1		0xa720
 #define CHV_POWER_SS1_SIG1		0xa728
 #define   CHV_SS_PG_ENABLE		(1<<1)
Signature · 1 line
Lukasz Daniluk

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

#11 lore raw

PATCH v4 1/1 drm/i915/bdw: Check for slice, subslice and EU count for BDW

In reply to Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

v3:
- Fix style issues

v4:
- Corrected comment
- Reverted reordering of defines

Cc Jeff Mcgee <[email protected]>
Cc Arun Siluvery <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 78 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 18 +++++++++
 3 files changed, 124 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +28 -1
index 72ae347..d0f784d 100644
@@ -5037,13 +5037,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total) {
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->subslice_total = stat->slice_total *
+				       stat->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -5068,6 +5093,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +78 -0

90 lines not on this page · raw message

drivers/gpu/drm/i915/i915_reg.h +18 -0
index 67bf205..10761a3 100644
@@ -1876,12 +1876,27 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
 #define   GEN9_F2_SS_DIS_SHIFT		20
 #define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
 #define GEN6_BSD_SLEEP_PSMI_CONTROL	0x12050
@@ -6867,6 +6882,9 @@ enum skl_disp_power_wells {
 #define   GEN6_RC6			3
 #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
 #define CHV_POWER_SS0_SIG1		0xa720
 #define CHV_POWER_SS1_SIG1		0xa728
 #define   CHV_SS_PG_ENABLE		(1<<1)
Signature · 6 lines
Lukasz Daniluk

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v4 1/1
#12 lore raw
Quoted 226 lines · Łukasz Daniluk

Added checks for available slices, subslices and EUs for Broadwell. This information is filled in intel_device_info and is available to user with GET_PARAM.
Added checks for enabled slices, subslices and EU for Broadwell. This information is based on available counts but takes power gated slices into account. It can be read in debugfs.
Introduce new register defines that contain information on slices on Broadwell.

v2:
- Introduce GT_SLICE_INFO register
- Change Broadwell sseu_device_status function to use GT_SLICE_INFO register instead of RPCS register
- Undo removal of dev_priv variables in Cherryview and Gen9 sseu_device_satus functions

v3:
- Fix style issues

v4:
- Corrected comment
- Reverted reordering of defines

Cc Jeff Mcgee <[email protected]>
Cc Arun Siluvery <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 +++++++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 78 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     | 18 +++++++++
 3 files changed, 124 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +28 -1
index 72ae347..d0f784d 100644
@@ -5037,13 +5037,38 @@ static void gen9_sseu_device_status(struct drm_device *dev,
 	}
 }
 
+static void broadwell_sseu_device_status(struct drm_device *dev,
+					 struct sseu_dev_status *stat)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int s;
+	u32 slice_info = I915_READ(GEN8_GT_SLICE_INFO);
+
+	stat->slice_total = hweight32(slice_info & GEN8_LSLICESTAT_MASK);
+
+	if (stat->slice_total) {
+		stat->subslice_per_slice = INTEL_INFO(dev)->subslice_per_slice;
+		stat->subslice_total = stat->slice_total *
+				       stat->subslice_per_slice;
+		stat->eu_per_subslice = INTEL_INFO(dev)->eu_per_subslice;
+		stat->eu_total = stat->eu_per_subslice * stat->subslice_total;
+
+		/* subtract fused off EU(s) from enabled slice(s) */
+		for (s = 0; s < stat->slice_total; s++) {
+			u8 subslice_7eu = INTEL_INFO(dev)->subslice_7eu[s];
+
+			stat->eu_total -= hweight8(subslice_7eu);
+		}
+	}
+}
+
 static int i915_sseu_status(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct sseu_dev_status stat;
 
-	if ((INTEL_INFO(dev)->gen < 8) || IS_BROADWELL(dev))
+	if (INTEL_INFO(dev)->gen < 8)
 		return -ENODEV;
 
 	seq_puts(m, "SSEU Device Info\n");
@@ -5068,6 +5093,8 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	memset(&stat, 0, sizeof(stat));
 	if (IS_CHERRYVIEW(dev)) {
 		cherryview_sseu_device_status(dev, &stat);
+	} else if (IS_BROADWELL(dev)) {
+		broadwell_sseu_device_status(dev, &stat);
 	} else if (INTEL_INFO(dev)->gen >= 9) {
 		gen9_sseu_device_status(dev, &stat);
 	}
drivers/gpu/drm/i915/i915_dma.c +78 -0
index 066a0ef..72e2bbd 100644
@@ -713,6 +713,82 @@ static void gen9_sseu_info_init(struct drm_device *dev)
 	info->has_eu_pg = (info->eu_per_subslice > 2);
 }
 
+static void broadwell_sseu_info_init(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_device_info *info;
+	const int s_max = 3, ss_max = 3, eu_max = 8;
+	int s, ss;
+	u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
+
+	fuse2 = I915_READ(GEN8_FUSE2);
+	s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
+	ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >> GEN8_F2_SS_DIS_SHIFT;
+
+	eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
+	eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
+			((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
+			 (32 - GEN8_EU_DIS0_S1_SHIFT));
+	eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
+			((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
+			 (32 - GEN8_EU_DIS1_S2_SHIFT));
+
+
+	info = (struct intel_device_info *)&dev_priv->info;
+	info->slice_total = hweight32(s_enable);
+
+	/*
+	 * The subslice disable field is global, i.e. it applies
+	 * to each of the enabled slices.
+	 */
+	info->subslice_per_slice = ss_max - hweight32(ss_disable);
+	info->subslice_total = info->slice_total * info->subslice_per_slice;
+
+	/*
+	 * Iterate through enabled slices and subslices to
+	 * count the total enabled EU.
+	 */
+	for (s = 0; s < s_max; s++) {
+		if (!(s_enable & (0x1 << s)))
+			/* skip disabled slice */
+			continue;
+
+		for (ss = 0; ss < ss_max; ss++) {
+			u32 n_disabled;
+
+			if (ss_disable & (0x1 << ss))
+				/* skip disabled subslice */
+				continue;
+
+			n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
+
+			/*
+			 * Record which subslices have 7 EUs.
+			 */
+			if (eu_max - n_disabled == 7)
+				info->subslice_7eu[s] |= 1 << ss;
+
+			info->eu_total += eu_max - n_disabled;
+		}
+	}
+
+	/*
+	 * BDW is expected to always have a uniform distribution of EU across
+	 * subslices with the exception that any one EU in any one subslice may
+	 * be fused off for die recovery.
+	 */
+	info->eu_per_subslice = info->subslice_total ?
+		DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
+
+	/*
+	 * BDW supports slice power gating on devices with more than
+	 * one slice.
+	 */
+	info->has_slice_pg = (info->slice_total > 1);
+	info->has_subslice_pg = 0;
+	info->has_eu_pg = 0;
+}
+
 /*
  * Determine various intel_device_info fields at runtime.
  *
@@ -783,6 +859,8 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
 	/* Initialize slice/subslice/EU info */
 	if (IS_CHERRYVIEW(dev))
 		cherryview_sseu_info_init(dev);
+	else if (IS_BROADWELL(dev))
+		broadwell_sseu_info_init(dev);
 	else if (INTEL_INFO(dev)->gen >= 9)
 		gen9_sseu_info_init(dev);
 
drivers/gpu/drm/i915/i915_reg.h +18 -0
index 67bf205..10761a3 100644
@@ -1876,12 +1876,27 @@ enum skl_disp_power_wells {
 #define   CHV_FGT_EU_DIS_SS1_R1_MASK	(0xf << CHV_FGT_EU_DIS_SS1_R1_SHIFT)
 
 #define GEN8_FUSE2			0x9120
+#define   GEN8_F2_SS_DIS_SHIFT		21
+#define   GEN8_F2_SS_DIS_MASK		(0x7 << GEN8_F2_SS_DIS_SHIFT)
 #define   GEN8_F2_S_ENA_SHIFT		25
 #define   GEN8_F2_S_ENA_MASK		(0x7 << GEN8_F2_S_ENA_SHIFT)
 
 #define   GEN9_F2_SS_DIS_SHIFT		20
 #define   GEN9_F2_SS_DIS_MASK		(0xf << GEN9_F2_SS_DIS_SHIFT)
 
+#define GEN8_EU_DISABLE0		0x9134
+#define   GEN8_EU_DIS0_S0_MASK		0xffffff
+#define   GEN8_EU_DIS0_S1_SHIFT		24
+#define   GEN8_EU_DIS0_S1_MASK		(0xff << GEN8_EU_DIS0_S1_SHIFT)
+
+#define GEN8_EU_DISABLE1		0x9138
+#define   GEN8_EU_DIS1_S1_MASK		0xffff
+#define   GEN8_EU_DIS1_S2_SHIFT		16
+#define   GEN8_EU_DIS1_S2_MASK		(0xffff << GEN8_EU_DIS1_S2_SHIFT)
+
+#define GEN8_EU_DISABLE2		0x913c
+#define   GEN8_EU_DIS2_S2_MASK		0xff
+
 #define GEN9_EU_DISABLE(slice)		(0x9134 + (slice)*0x4)
 
 #define GEN6_BSD_SLEEP_PSMI_CONTROL	0x12050
@@ -6867,6 +6882,9 @@ enum skl_disp_power_wells {
 #define   GEN6_RC6			3
 #define   GEN6_RC7			4
 
+#define GEN8_GT_SLICE_INFO		0x138064
+#define   GEN8_LSLICESTAT_MASK		0x7
+
 #define CHV_POWER_SS0_SIG1		0xa720
 #define CHV_POWER_SS1_SIG1		0xa728
 #define   CHV_SS_PG_ENABLE		(1<<1)
Signature · 1 line
Lukasz Daniluk

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