Skip to contentSkip to conversation

drm/i915: Fix VCS2's ring name.

PATCH Applied Rodrigo Vivi 6 participants 15 messages Jun 30, 2014 – Jul 7, 2014

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/3 drm/i915: Fix VCS2's ring name.

It just fix a typo.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 2faef26..c3f96a1 100644
@@ -2224,7 +2224,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->name = "bds2_ring";
+	ring->name = "bsd2_ring";
 	ring->id = VCS2;
 
 	ring->write_tail = ring_write_tail;
Signature · 1 line
1.9.3
author maintainer
#1 lore raw

PATCH 2/3 drm/i915: Introduce dual_bsd_ring parameter.

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 8cea596..7b6614f 100644
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600);
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
Signature · 1 line
1.9.3
#2 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 7 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

I think going the debugfs route is the right thing to do if this should move forward. If the goal is only for test, then I'm not really in favor of moving it forward.

Quoted 55 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 8cea596..7b6614f 100644
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;

drivers/gpu/drm/i915/i915_gem_execbuffer.c static int gen8_dispatch_bsd_ring(struct drm_device *dev, · line 1062

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +9 -0
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);

Don't warn if this is valid module parameter people can use.

Quoted 17 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +1 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,

drivers/gpu/drm/i915/i915_params.c MODULE_PARM_DESC(semaphores, · line 78

Quoted 8 lines
drivers/gpu/drm/i915/i915_params.c +5 -0
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600);
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+

It looks like life would be a lot easier if you did 0 = VCS
1 = VCS2
2 = BOTH

drivers/gpu/drm/i915/i915_params.c MODULE_PARM_DESC(semaphores, · line 81

Quoted 3 lines
drivers/gpu/drm/i915/i915_params.c +0 -0
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "

Can't spot anything wrong, but again, I don't think the patch is worth merging unless we can find a good use case.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#3 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

In reply to Rodrigo Vivi
Quoted 5 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

Hi, rodrigo

Could you use a mechanism to specify the ring at runtime ? If so, it is flexible for us to use VCS ?

Thanks
Haihao

Quoted 95 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 8cea596..7b6614f 100644
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600);
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
#4 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

In reply to Rodrigo Vivi
Quoted 5 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

If it is mainly used for the test/validation, can we add one override
flag so that the user-space app can explicitly declare which BSD ring is used to dispatch the corresponding BSD commands? In such case it will force to dispatch the corresponding commands on the ring passed by user-application.

At the same time this patch is not helpful under the following
scenario. For example: One application hopes to use the BSD Ring 0 while another application hopes to use the BSD ring 1.

Quoted 95 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 8cea596..7b6614f 100644
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600);
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
author maintainer
#5 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

It seems the flexibility on rings is more wanted and needed than I imagined. Please ignore this patch here...

I liked both execution flag or debugfs, but exec flag would cover this case of different applications using different command streamers.

With flags Would it be something like:
Execution without flag = ping-pong
Flag BSD1 use only VCS1
Flag BSD2 use only VCS2

Haihao, what do you think?

With debugfs would be something like i195_dual_bsd_ring file with 3 options: all bsd1 bsd2

Thanks,
Rodrigo.

-----Original Message-----
From: Zhao, Yakui
Sent: Monday, June 30, 2014 6:37 PM
To: Vivi, Rodrigo
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 5 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

If it is mainly used for the test/validation, can we add one override flag so that the user-space app can explicitly declare which BSD ring is used to dispatch the corresponding BSD commands? In such case it will force to dispatch the corresponding commands on the ring passed by user-application.

At the same time this patch is not helpful under the following scenario. For example: One application hopes to use the BSD Ring 0 while another application hopes to use the BSD ring 1.

Quoted 97 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 8cea596..7b6614f 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct 
 drm_device *dev,  {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600); 
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);  
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
#6 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 10 lines · Rodrigo

It seems the flexibility on rings is more wanted and needed than I imagined. Please ignore this patch here...

I liked both execution flag or debugfs, but exec flag would cover this case of different applications using different command streamers.

With flags Would it be something like:
Execution without flag = ping-pong
Flag BSD1 use only VCS1
Flag BSD2 use only VCS2

IMO the execution flag looks reasonable. It can cover the flexibility of different applications. In such case it can determine which ring is used to dispatch command at runtime.

Quoted 124 lines

Haihao, what do you think?

With debugfs would be something like i195_dual_bsd_ring file with 3 options: all bsd1 bsd2

Thanks,
Rodrigo.

-----Original Message-----
From: Zhao, Yakui
Sent: Monday, June 30, 2014 6:37 PM
To: Vivi, Rodrigo
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 5 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

If it is mainly used for the test/validation, can we add one override flag so that the user-space app can explicitly declare which BSD ring is used to dispatch the corresponding BSD commands? In such case it will force to dispatch the corresponding commands on the ring passed by user-application.

At the same time this patch is not helpful under the following scenario. For example: One application hopes to use the BSD Ring 0 while another application hopes to use the BSD ring 1.

Quoted 97 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 8cea596..7b6614f 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct 
 drm_device *dev,  {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600); 
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);  
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
#7 lore raw

Re: [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 12 lines · Yakui
Quoted 10 lines · Rodrigo

It seems the flexibility on rings is more wanted and needed than I imagined. Please ignore this patch here...

I liked both execution flag or debugfs, but exec flag would cover this case of different applications using different command streamers.

With flags Would it be something like:
Execution without flag = ping-pong
Flag BSD1 use only VCS1
Flag BSD2 use only VCS2

Quoted 4 lines

IMO the execution flag looks reasonable. It can cover the flexibility of different applications. In such case it can determine which ring is used to dispatch command at runtime.

I prefer the execution flag too.

Thanks
Haihao

Quoted 126 lines
Quoted 124 lines

Haihao, what do you think?

With debugfs would be something like i195_dual_bsd_ring file with 3 options: all bsd1 bsd2

Thanks,
Rodrigo.

-----Original Message-----
From: Zhao, Yakui
Sent: Monday, June 30, 2014 6:37 PM
To: Vivi, Rodrigo
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 2/3] drm/i915: Introduce dual_bsd_ring parameter.

Quoted 5 lines · Rodrigo Vivi

On Broadwell GT3 we have 2 Video Command Streamers (VCS), but userspace has no control when using VCS1 or VCS2. So we cannot test, validate or debug specific changes or workaround that might affect only one or another ring. So this patch introduces a mechanism to avoid the ping-pong selection and use one specific ring given at boot time.

If it is mainly used for the test/validation, can we add one override flag so that the user-space app can explicitly declare which BSD ring is used to dispatch the corresponding BSD commands? In such case it will force to dispatch the corresponding commands on the ring passed by user-application.

At the same time this patch is not helpful under the following scenario. For example: One application hopes to use the BSD Ring 0 while another application hopes to use the BSD ring 1.

Quoted 97 lines
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 ++++++++++++++++++------------
 drivers/gpu/drm/i915/i915_params.c         |  6 ++++++
 3 files changed, 27 insertions(+), 14 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 8cea596..7b6614f 100644

drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2069,6 +2069,7 @@ struct i915_params {
 	int panel_ignore_lid;
 	unsigned int powersave;
 	int semaphores;
+	int dual_bsd_ring;
 	unsigned int lvds_downclock;
 	int lvds_channel_mode;
 	int panel_use_ssc;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +20 -14
index d815ef5..09f350e 100644
@@ -1035,26 +1035,32 @@ static int gen8_dispatch_bsd_ring(struct 
 drm_device *dev,  {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	int ring_id;
+	int dual = i915.dual_bsd_ring;
 
 	/* Check whether the file_priv is using one ring */
 	if (file_priv->bsd_ring)
 		return file_priv->bsd_ring->id;
-	else {
-		/* If no, use the ping-pong mechanism to select one ring */
-		int ring_id;
 
-		mutex_lock(&dev->struct_mutex);
-		if (dev_priv->mm.bsd_ring_dispatch_index == 0) {
-			ring_id = VCS;
-			dev_priv->mm.bsd_ring_dispatch_index = 1;
-		} else {
-			ring_id = VCS2;
-			dev_priv->mm.bsd_ring_dispatch_index = 0;
-		}
-		file_priv->bsd_ring = &dev_priv->ring[ring_id];
-		mutex_unlock(&dev->struct_mutex);
-		return ring_id;
+	/* If no, use the parameter defined or ping-pong mechanism
+	 * to select one ring */
+	mutex_lock(&dev->struct_mutex);
+
+	if (dual == 1 || (dual != 2 &&
+			  dev_priv->mm.bsd_ring_dispatch_index == 0)) {
+		ring_id = VCS;
+		dev_priv->mm.bsd_ring_dispatch_index = 1;
+	} else {
+		ring_id = VCS2;
+		dev_priv->mm.bsd_ring_dispatch_index = 0;
 	}
+
+	file_priv->bsd_ring = &dev_priv->ring[ring_id];
+	mutex_unlock(&dev->struct_mutex);
+
+	WARN(dual, "Forcibly trying to use only one bsd ring. Using: %s\n",
+	     file_priv->bsd_ring->name);
+	return ring_id;
 }
 
 static struct drm_i915_gem_object *
drivers/gpu/drm/i915/i915_params.c +6 -0
index 8145729..d4871c8 100644
@@ -29,6 +29,7 @@ struct i915_params i915 __read_mostly = {
 	.panel_ignore_lid = 1,
 	.powersave = 1,
 	.semaphores = -1,
+	.dual_bsd_ring = 0,
 	.lvds_downclock = 0,
 	.lvds_channel_mode = 0,
 	.panel_use_ssc = -1,
@@ -70,6 +71,11 @@ MODULE_PARM_DESC(semaphores,
 	"Use semaphores for inter-ring sync "
 	"(default: -1 (use per-chip defaults))");
 
+module_param_named(dual_bsd_ring, i915.dual_bsd_ring, int, 0600); 
+MODULE_PARM_DESC(dual_bsd_ring,
+	 "Specify bds rings for VCS when there are multiple VCSs available."
+	 "(0=All available bsd rings [default], 1=only VCS1, 2=only VCS2)");
+
 module_param_named(enable_rc6, i915.enable_rc6, int, 0400);  
 MODULE_PARM_DESC(enable_rc6,
 	"Enable power-saving render C-state 6. "
author maintainer
#8 lore raw

PATCH 3/3 drm/i915: Updating comments.

In reply to Rodrigo Vivi

ring index calculation table was out of date after other rings were added, although the formula is flexible and scale when adding new rings.

So this patch just update the comments and add a brief explanation why to use sync_seqno[ring index].

---
 drivers/gpu/drm/i915/i915_gem.c         | 2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.h | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -0
index f6d1238..e85c85c 100644
@@ -2842,6 +2842,8 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,
 	idx = intel_ring_sync_index(from, to);
 
 	seqno = obj->last_read_seqno;
+	/* Optimization: Avoid semaphore sync when we are sure we already
+	 * waited for an object with higher seqno */
 	if (seqno <= from->semaphore.sync_seqno[idx])
 		return 0;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -3
index e72017b..2e8b516 100644
@@ -238,9 +238,11 @@ intel_ring_sync_index(struct intel_engine_cs *ring,
 	int idx;
 
 	/*
-	 * cs -> 0 = vcs, 1 = bcs
-	 * vcs -> 0 = bcs, 1 = cs,
-	 * bcs -> 0 = cs, 1 = vcs.
+	 * rcs -> 0 = vcs, 1 = bcs, 2 = vecs, 3 = vcs2;
+	 * vcs -> 0 = bcs, 1 = vecs, 2 = vcs2, 3 = rcs;
+	 * bcs -> 0 = vecs, 1 = vcs2. 2 = rcs, 3 = vcs;
+	 * vecs -> 0 = vcs2, 1 = rcs, 2 = vcs, 3 = bcs;
+	 * vcs2 -> 0 = rcs, 1 = vcs, 2 = bcs, 3 = vecs;
 	 */
 
 	idx = (other - ring) - 1;
Signature · 1 line
1.9.3
Reviewed-by on v1 3/3
#9 lore raw

Re: [PATCH 3/3] drm/i915: Updating comments.

Quoted 32 lines · Rodrigo Vivi

ring index calculation table was out of date after other rings were added, although the formula is flexible and scale when adding new rings.

So this patch just update the comments and add a brief explanation why to use sync_seqno[ring index].

---
 drivers/gpu/drm/i915/i915_gem.c         | 2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.h | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -0
index f6d1238..e85c85c 100644
@@ -2842,6 +2842,8 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,
 	idx = intel_ring_sync_index(from, to);
 
 	seqno = obj->last_read_seqno;
+	/* Optimization: Avoid semaphore sync when we are sure we already
+	 * waited for an object with higher seqno */
 	if (seqno <= from->semaphore.sync_seqno[idx])
 		return 0;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index e72017b..2e8b516 100644
@@ -238,9 +238,11 @@ intel_ring_sync_index(struct intel_engine_cs *ring,
 	int idx;
 

drivers/gpu/drm/i915/intel_ringbuffer.h intel_ring_sync_index(struct intel_engine_cs *ring, · line 246

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -3
 	/*
-	 * cs -> 0 = vcs, 1 = bcs
-	 * vcs -> 0 = bcs, 1 = cs,
-	 * bcs -> 0 = cs, 1 = vcs.
+	 * rcs -> 0 = vcs, 1 = bcs, 2 = vecs, 3 = vcs2;
+	 * vcs -> 0 = bcs, 1 = vecs, 2 = vcs2, 3 = rcs;
+	 * bcs -> 0 = vecs, 1 = vcs2. 2 = rcs, 3 = vcs;
+	 * vecs -> 0 = vcs2, 1 = rcs, 2 = vcs, 3 = bcs;
+	 * vcs2 -> 0 = rcs, 1 = vcs, 2 = bcs, 3 = vecs;
 	 */

I'd be a favor of dropping this table, and instead explaining the goal of the math (to save the dword)

drivers/gpu/drm/i915/intel_ringbuffer.h intel_ring_sync_index(struct intel_engine_cs *ring, · line 248

Quoted 2 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
 	idx = (other - ring) - 1;

I'm guessing this hunk is from your private branch?

In any event, the topmost comment is a nice addition:

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#10 lore raw

Re: [PATCH 3/3] drm/i915: Updating comments.

Quoted 33 lines · Ben Widawsky
Quoted 32 lines · Rodrigo Vivi

ring index calculation table was out of date after other rings were added, although the formula is flexible and scale when adding new rings.

So this patch just update the comments and add a brief explanation why to use sync_seqno[ring index].

---
 drivers/gpu/drm/i915/i915_gem.c         | 2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.h | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -0
index f6d1238..e85c85c 100644
@@ -2842,6 +2842,8 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,
 	idx = intel_ring_sync_index(from, to);
 
 	seqno = obj->last_read_seqno;
+	/* Optimization: Avoid semaphore sync when we are sure we already
+	 * waited for an object with higher seqno */
 	if (seqno <= from->semaphore.sync_seqno[idx])
 		return 0;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index e72017b..2e8b516 100644
@@ -238,9 +238,11 @@ intel_ring_sync_index(struct intel_engine_cs *ring,
 	int idx;
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_ringbuffer.h intel_ring_sync_index(struct intel_engine_cs *ring, · line 246

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -3
 	/*
-	 * cs -> 0 = vcs, 1 = bcs
-	 * vcs -> 0 = bcs, 1 = cs,
-	 * bcs -> 0 = cs, 1 = vcs.
+	 * rcs -> 0 = vcs, 1 = bcs, 2 = vecs, 3 = vcs2;
+	 * vcs -> 0 = bcs, 1 = vecs, 2 = vcs2, 3 = rcs;
+	 * bcs -> 0 = vecs, 1 = vcs2. 2 = rcs, 3 = vcs;
+	 * vecs -> 0 = vcs2, 1 = rcs, 2 = vcs, 3 = bcs;
+	 * vcs2 -> 0 = rcs, 1 = vcs, 2 = bcs, 3 = vecs;
 	 */

I'd be a favor of dropping this table, and instead explaining the goal of the math (to save the dword)

tbh I don't mind either way ...

Quoted 4 lines

drivers/gpu/drm/i915/intel_ringbuffer.h intel_ring_sync_index(struct intel_engine_cs *ring, · line 248

Quoted 2 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
 	idx = (other - ring) - 1;

I'm guessing this hunk is from your private branch?

Applied here without fuzz ...

Quoted 1 line

In any event, the topmost comment is a nice addition:

Indeed.

Quoted 1 line

Queued for -next, thanks for the patch.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#12 lore raw
In reply to Rodrigo Vivi
Quoted 29 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Rodrigo Vivi
Sent: Monday, June 30, 2014 5:51 PM
To: [email protected]
Cc: Vivi, Rodrigo
Subject: [Intel-gfx] [PATCH 1/3] drm/i915: Fix VCS2's ring name.

It just fix a typo.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 2faef26..c3f96a1 100644
@@ -2224,7 +2224,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device
 *dev)
 		return -EINVAL;
 	}
 
-	ring->name = "bds2_ring";
+	ring->name = "bsd2_ring";
 	ring->id = VCS2;
 
Quoted 1 line

ring->write_tail = ring_write_tail;

Jus nitpicking but, wouldn´t it be better without the underscore, like the other rings?: "bsd2 ring"

author maintainer
#13 lore raw

PATCH 1/1 drm/i915: Fix VCS2's ring name.

It just fix a typo.

v2: removing underscore to let this like all other ring names (Oscar)

Cc: Oscar Mateo <[email protected]> Reviewed-by (v1): Ben Widawsky <[email protected]>

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 2faef26..22c2b9a 100644
@@ -2224,7 +2224,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->name = "bds2_ring";
+	ring->name = "bsd2 ring";
 	ring->id = VCS2;
 
 	ring->write_tail = ring_write_tail;
Signature · 1 line
1.9.3
#14 lore raw
Quoted 7 lines · Rodrigo Vivi

It just fix a typo.

v2: removing underscore to let this like all other ring names (Oscar)

Cc: Oscar Mateo <[email protected]> Reviewed-by (v1): Ben Widawsky <[email protected]>

Queued for -next, thanks for the patch.
-Daniel

Quoted 24 lines
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 2faef26..22c2b9a 100644
@@ -2224,7 +2224,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->name = "bds2_ring";
+	ring->name = "bsd2 ring";
 	ring->id = VCS2;
 
 	ring->write_tail = ring_write_tail;
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