Skip to contentSkip to conversation

drm-intel-collector - update

PATCH Applied Rodrigo Vivi 9 participants 24 messages Apr 7, 2014 – Apr 14, 2014

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

cover drm-intel-collector - update

This is another drm-intel-collector updated notice:
http://cgit.freedesktop.org/~vivijim/drm-intel/log/?h=drm-intel-collector

Here goes the update list in order for better reviewers assignment:

Patch drm/i915: Bring UP Power Wells before disabling RC6. - Reviewer:
Patch drm/i915: dma_buf_vunmap is presumed not to fail, don't let it - Reviewer:
Patch drm/i915: Add support for stealing purgable stolen pages - Reviewer:
Patch drm/i915: add flag to prevent dmesg spam on context banning - Reviewer:
Patch drm/i915: Do not allow a pending forcewake put to unbalance across reset - Reviewer:
Patch drm/i915: Don't save/restore RS when not used - Reviewer:

Overall Process:

drm-intel-collector - review request
1. Daniel pushs drm-intel-testing (every 2 weeks)
2. I rebase drm-intel-collector onto drm-intel-testing
3. Add Reviewer: tag with voluntered reviewers. If you don't believe you should be assigned on a particular patch please don't get mad just tell you wont review or volunteer someone else.
4. I resubmit remaining patches for review without picking any new (drm-intel-collector - review request)

drm-intel-collector - updated
5. One week later I collect all simple (1-2) patches that wasn't yet reviewed and not queued by Daniel from one testing update until another.
6. Request automated QA's PRTS automated i-g-t tests comparing drm-intel-testing x drm-intel-collector
7. If tests are ok I send the update notification or the patches as a series to intel-gfx mailing list for better tracking and to be reviewed. (drm-intel-collector - updated)
8. Let me know volunteers for review new patches and also let me know if I've picked any patch that I shouldn't.

There are some reasons that some patches can be left behind:
1. Your patch didn't applied cleanly and I couldn't easily solve the conflicts.
2. Kernel didn't compiled with your patch.
3. I simply missed it. If you believe this is the case please warn me.

Please help me to get these patches reviewed and queued by Daniel.

Also, please let me know if you have further ideas how to improve this process.

Thanks in advance,
Rodrigo.

Ben Widawsky (1):
drm/i915: Don't save/restore RS when not used

Chris Wilson (3):
drm/i915: dma_buf_vunmap is presumed not to fail, don't let it drm/i915: Add support for stealing purgable stolen pages drm/i915: Do not allow a pending forcewake put to unbalance across
reset

Deepak S (1):
drm/i915: Bring UP Power Wells before disabling RC6.

Mika Kuoppala (1):
drm/i915: add flag to prevent dmesg spam on context banning

 drivers/gpu/drm/i915/i915_drv.h         |  18 ++++-
 drivers/gpu/drm/i915/i915_gem.c         |   5 +-
 drivers/gpu/drm/i915/i915_gem_context.c |  12 ++--
 drivers/gpu/drm/i915/i915_gem_dmabuf.c  |   6 +-
 drivers/gpu/drm/i915/i915_gem_stolen.c  | 119 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_pm.c         |   6 ++
 drivers/gpu/drm/i915/intel_ringbuffer.c |   2 +-
 drivers/gpu/drm/i915/intel_uncore.c     |   5 +-
 8 files changed, 146 insertions(+), 27 deletions(-)
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/6 drm/i915: Bring UP Power Wells before disabling RC6.

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +6 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 
Signature · 1 line
1.9.0
#2 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 22 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +1 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5 -0
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

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

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
  drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
  {
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
  	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
  	gen6_disable_rps_interrupts(dev);
  }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

#5 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 48 lines · Deepak
Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

Quoted 6 lines

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

Ville was totally right. I do think a POSTING_READ is still sufficient. Don't care much either way.

Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 52 lines · Ben Widawsky
Quoted 51 lines · Deepak
Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
  drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
  {
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
  	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
  	gen6_disable_rps_interrupts(dev);
  }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

Quoted 7 lines
Quoted 3 lines

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

Ville was totally right. I do think a POSTING_READ is still sufficient. Don't care much either way.

If feel this patch is not adding any value. I OK dropping this patch.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 59 lines · Deepak
Quoted 56 lines · Ben Widawsky
Quoted 54 lines · Deepak
Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

Quoted 5 lines
Quoted 3 lines

Ville was totally right. I do think a POSTING_READ is still sufficient. Don't care much either way.

If feel this patch is not adding any value. I OK dropping this patch.

I think it makes a lot of sense - on the enable side we also grab the wells (in case the bios has enabled rc6 already) to make sure we change the rc6/rps state while everything is around.

Can you please update your patch to also roll this out for gen6/8 rps disable functions?

Thanks, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#8 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

Quoted 58 lines · Daniel Vetter
Quoted 50 lines · Deepak
Quoted 48 lines · Ben Widawsky
Quoted 47 lines · Deepak
Quoted 35 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
  drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
  {
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
  	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
  	gen6_disable_rps_interrupts(dev);
  }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

Ville was totally right. I do think a POSTING_READ is still sufficient. Don't care much either way.

If feel this patch is not adding any value. I OK dropping this patch.

Quoted 8 lines

I think it makes a lot of sense - on the enable side we also grab the wells (in case the bios has enabled rc6 already) to make sure we change the rc6/rps state while everything is around.

Can you please update your patch to also roll this out for gen6/8 rps disable functions?

Thanks, Daniel

Sure Daniel, I will add this to gen6/8 and submit the patch

#9 lore raw

Re: [PATCH 1/6] drm/i915: Bring UP Power Wells before disabling RC6.

In reply to S, Deepak
Quoted 59 lines · Deepak
Quoted 56 lines · Ben Widawsky
Quoted 54 lines · Deepak
Quoted 37 lines · Ville Syrjälä
Quoted 28 lines · Ben Widawsky
Quoted 27 lines · Rodrigo Vivi

From: Deepak S <[email protected]>

We need do forcewake before Disabling RC6, This is what the BIOS expects while going into suspend.

v2: updated commit message. (Daniel)

---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +4 -0
index 04af065..ad2ff99 100644
@@ -3198,8 +3198,14 @@ static void valleyview_disable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	/* we're doing forcewake before Disabling RC6,
+	 * This what the BIOS expects when going into suspend */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
 	I915_WRITE(GEN6_RC_CONTROL, 0);
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_pm.c static void valleyview_disable_rps(struct drm_device *dev) · line 3211

Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c +2 -0
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+
 	gen6_disable_rps_interrupts(dev);
 }
 

Isn't the forcewake done as part of I915_WRITE sufficient?

Quoted 7 lines

Writes don't do forcewake, nor is the register even part of the VLV forcewake ranges.

I guess the rationale for this patche is still a bit vague. But if it's really needed, I wonder whether we should do this same dance for !VLV too? Do we have any "GPU stuck in wrong power state after suspend" type of bugs still around?

One of suggestion form the HW team was to Bring the wells up before we disable RC6 at run-time. We did see some issue when we enabled D0ix.

I think the is a good practice to make sure we bring-up the wells before we disable RC6. At least this avoids the cases where wells are not up before we can access the Next register after disable.

Quoted 5 lines
Quoted 3 lines

Ville was totally right. I do think a POSTING_READ is still sufficient. Don't care much either way.

If feel this patch is not adding any value. I OK dropping this patch.

I didn't mean it's not adding value. In general I like to address what the spec is trying to tell us to do, instead of following the letter of the spec. Here is another example of a very much missing, "why" as Ville was saying. If there is a bug it currently fixes, then I have no question about how to proceed.

Signature · 5 lines
Ben Widawsky, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 2/6 drm/i915: dma_buf_vunmap is presumed not to fail, don't let it

In reply to Rodrigo Vivi

From: Chris Wilson <[email protected]>

Since dma_buf_vunmap() procedes blithely on ignorant of whether the driver failed to actually unmap the backing storage for the dma-buf, we need to make a best-effort to do so. This involves not allowing ourselves to be susceptible to signals causing us to leak the storage.

This should have been detectable with the current i-g-t as a misplaced signal should have left the pages pinned upon freeing the object where we have a warning in place.

---
 drivers/gpu/drm/i915/i915_gem_dmabuf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem_dmabuf.c +1 -5
index 9bb533e..321102a 100644
@@ -161,12 +161,8 @@ static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
 {
 	struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
 	struct drm_device *dev = obj->base.dev;
-	int ret;
-
-	ret = i915_mutex_lock_interruptible(dev);
-	if (ret)
-		return;
 
+	mutex_lock(&dev->struct_mutex);
 	if (--obj->vmapping_count == 0) {
 		vunmap(obj->dma_buf_vmapping);
 		obj->dma_buf_vmapping = NULL;
Signature · 1 line
1.9.0
#11 lore raw

Re: [PATCH 2/6] drm/i915: dma_buf_vunmap is presumed not to fail, don't let it

Quoted 10 lines · Rodrigo Vivi

From: Chris Wilson <[email protected]>

Since dma_buf_vunmap() procedes blithely on ignorant of whether the driver failed to actually unmap the backing storage for the dma-buf, we need to make a best-effort to do so. This involves not allowing ourselves to be susceptible to signals causing us to leak the storage.

This should have been detectable with the current i-g-t as a misplaced signal should have left the pages pinned upon freeing the object where we have a warning in place.

Apparently QA is asleep, or have I missed the bugzilla?

Quoted 3 lines

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

PATCH 3/6 drm/i915: Add support for stealing purgable stolen pages

In reply to Rodrigo Vivi

From: Chris Wilson <[email protected]>

If we run out of stolen memory when trying to allocate an object, see if we can reap enough purgeable objects to free up enough contiguous free space for the allocation. This is in principle very much like evicting objects to free up enough contiguous space in the vma when binding a new object - and you will be forgiven for thinking that the code looks very similar.

At the moment, we do not allow userspace to allocate objects in stolen, so there is neither the memory pressure to trigger stolen eviction nor any purgeable objects inside the stolen arena. However, this will change in the near future, and so better management and defragmentation of stolen memory will become a real issue.

Cc "Gupta, Sourab" <[email protected]>
Cc "Goel, Akash" <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_stolen.c | 119 ++++++++++++++++++++++++++++++---
 1 file changed, 108 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +108 -11
index 62ef55b..1fc1986 100644
@@ -329,18 +329,25 @@ cleanup:
 	return NULL;
 }
 
-struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
+static bool mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind)
+{
+	if (obj->stolen == NULL)
+		return false;
+
+	if (obj->madv != I915_MADV_DONTNEED)
+		return false;
+
+	list_add(&obj->obj_exec_link, unwind);
+	return drm_mm_scan_add_block(obj->stolen);
+}
+
+static struct drm_mm_node *stolen_alloc(struct drm_i915_private *dev_priv, u32 size)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct drm_i915_gem_object *obj;
 	struct drm_mm_node *stolen;
+	struct drm_i915_gem_object *obj;
+	struct list_head unwind, evict;
 	int ret;
 
-	if (!drm_mm_initialized(&dev_priv->mm.stolen))
-		return NULL;
-
-	DRM_DEBUG_KMS("creating stolen object: size=%x\n", size);
 	if (size == 0)
 		return NULL;
 
@@ -350,11 +357,101 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
 
 	ret = drm_mm_insert_node(&dev_priv->mm.stolen, stolen, size,
 				 4096, DRM_MM_SEARCH_DEFAULT);
-	if (ret) {
-		kfree(stolen);
-		return NULL;
+	if (ret == 0)
+		return stolen;
+
+	/* No more stolen memory available, or too fragmented.
+	 * Try evicting purgeable objects and search again.
+	 */
+
+	drm_mm_init_scan(&dev_priv->mm.stolen, size, 4096, 0);
+	INIT_LIST_HEAD(&unwind);
+
+	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
+		if (mark_free(obj, &unwind))
+			goto found;
+
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
+		if (mark_free(obj, &unwind))
+			goto found;
+
+found:
+	INIT_LIST_HEAD(&evict);
+	while (!list_empty(&unwind)) {
+		obj = list_first_entry(&unwind,
+				       struct drm_i915_gem_object,
+				       obj_exec_link);
+		list_del_init(&obj->obj_exec_link);
+
+		if (drm_mm_scan_remove_block(obj->stolen)) {
+			list_add(&obj->obj_exec_link, &evict);
+			drm_gem_object_reference(&obj->base);
+		}
 	}
 
+	ret = 0;
+	while (!list_empty(&evict)) {
+		obj = list_first_entry(&evict,
+				       struct drm_i915_gem_object,
+				       obj_exec_link);
+		list_del_init(&obj->obj_exec_link);
+
+		if (ret == 0) {
+			struct i915_vma *vma, *vma_next;
+
+			list_for_each_entry_safe(vma, vma_next,
+						 &obj->vma_list,
+						 vma_link)
+				if (i915_vma_unbind(vma))
+					break;
+
+			/* Stolen pins its pages to prevent the
+			 * normal shrinker from processing stolen
+			 * objects.
+			 */
+			i915_gem_object_unpin_pages(obj);
+
+			ret = i915_gem_object_put_pages(obj);
+			if (ret == 0) {
+				obj->madv = __I915_MADV_PURGED;
+
+				kfree(obj->stolen);
+				obj->stolen = NULL;
+			} else
+				i915_gem_object_pin_pages(obj);
+		}
+
+		drm_gem_object_unreference(&obj->base);
+	}
+
+	if (ret == 0)
+		ret = drm_mm_insert_node(&dev_priv->mm.stolen, stolen, size,
+					 4096, DRM_MM_SEARCH_DEFAULT);
+	if (ret == 0)
+		return stolen;
+
+	kfree(stolen);
+	return NULL;
+}
+
+struct drm_i915_gem_object *
+i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_gem_object *obj;
+	struct drm_mm_node *stolen;
+
+	lockdep_assert_held(&dev->struct_mutex);
+
+	if (!drm_mm_initialized(&dev_priv->mm.stolen))
+		return NULL;
+
+	DRM_DEBUG_KMS("creating stolen object: size=%x\n", size);
+
+	stolen = stolen_alloc(dev_priv, size);
+	if (stolen == NULL)
+		return NULL;
+
 	obj = _i915_gem_object_create_stolen(dev, stolen);
 	if (obj)
 		return obj;
Signature · 1 line
1.9.0
#13 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 156 lines · Rodrigo Vivi

From: Chris Wilson <[email protected]>

If we run out of stolen memory when trying to allocate an object, see if we can reap enough purgeable objects to free up enough contiguous free space for the allocation. This is in principle very much like evicting objects to free up enough contiguous space in the vma when binding a new object - and you will be forgiven for thinking that the code looks very similar.

At the moment, we do not allow userspace to allocate objects in stolen, so there is neither the memory pressure to trigger stolen eviction nor any purgeable objects inside the stolen arena. However, this will change in the near future, and so better management and defragmentation of stolen memory will become a real issue.

Cc "Gupta, Sourab" <[email protected]>
Cc "Goel, Akash" <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_stolen.c | 119 ++++++++++++++++++++++++++++++---
 1 file changed, 108 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_stolen.c +101 -11
index 62ef55b..1fc1986 100644
@@ -329,18 +329,25 @@ cleanup:
 	return NULL;
 }
 
-struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
+static bool mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind)
+{
+	if (obj->stolen == NULL)
+		return false;
+
+	if (obj->madv != I915_MADV_DONTNEED)
+		return false;
+
+	list_add(&obj->obj_exec_link, unwind);
+	return drm_mm_scan_add_block(obj->stolen);
+}
+
+static struct drm_mm_node *stolen_alloc(struct drm_i915_private *dev_priv, u32 size)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct drm_i915_gem_object *obj;
 	struct drm_mm_node *stolen;
+	struct drm_i915_gem_object *obj;
+	struct list_head unwind, evict;
 	int ret;
 
-	if (!drm_mm_initialized(&dev_priv->mm.stolen))
-		return NULL;
-
-	DRM_DEBUG_KMS("creating stolen object: size=%x\n", size);
 	if (size == 0)
 		return NULL;
 
@@ -350,11 +357,101 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
 
 	ret = drm_mm_insert_node(&dev_priv->mm.stolen, stolen, size,
 				 4096, DRM_MM_SEARCH_DEFAULT);
-	if (ret) {
-		kfree(stolen);
-		return NULL;
+	if (ret == 0)
+		return stolen;
+
+	/* No more stolen memory available, or too fragmented.
+	 * Try evicting purgeable objects and search again.
+	 */
+
+	drm_mm_init_scan(&dev_priv->mm.stolen, size, 4096, 0);
+	INIT_LIST_HEAD(&unwind);
+
+	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
+		if (mark_free(obj, &unwind))
+			goto found;
+
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
+		if (mark_free(obj, &unwind))
+			goto found;
+
+found:
+	INIT_LIST_HEAD(&evict);
+	while (!list_empty(&unwind)) {
+		obj = list_first_entry(&unwind,
+				       struct drm_i915_gem_object,
+				       obj_exec_link);
+		list_del_init(&obj->obj_exec_link);
+
+		if (drm_mm_scan_remove_block(obj->stolen)) {
+			list_add(&obj->obj_exec_link, &evict);
+			drm_gem_object_reference(&obj->base);
+		}
 	}
 
+	ret = 0;
+	while (!list_empty(&evict)) {
+		obj = list_first_entry(&evict,
+				       struct drm_i915_gem_object,
+				       obj_exec_link);
+		list_del_init(&obj->obj_exec_link);
+
+		if (ret == 0) {
+			struct i915_vma *vma, *vma_next;
+
+			list_for_each_entry_safe(vma, vma_next,
+						 &obj->vma_list,
+						 vma_link)
+				if (i915_vma_unbind(vma))
+					break;
+
+			/* Stolen pins its pages to prevent the
+			 * normal shrinker from processing stolen
+			 * objects.
+			 */
+			i915_gem_object_unpin_pages(obj);
+
+			ret = i915_gem_object_put_pages(obj);
+			if (ret == 0) {
+				obj->madv = __I915_MADV_PURGED;
+
+				kfree(obj->stolen);
+				obj->stolen = NULL;
+			} else
+				i915_gem_object_pin_pages(obj);
+		}
+
+		drm_gem_object_unreference(&obj->base);
+	}
+
+	if (ret == 0)
+		ret = drm_mm_insert_node(&dev_priv->mm.stolen, stolen, size,
+					 4096, DRM_MM_SEARCH_DEFAULT);
+	if (ret == 0)
+		return stolen;
+
+	kfree(stolen);
+	return NULL;
+}
+
+struct drm_i915_gem_object *
+i915_gem_object_create_stolen(struct drm_device *dev, u32 size)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_gem_object *obj;
+	struct drm_mm_node *stolen;
+
+	lockdep_assert_held(&dev->struct_mutex);
+
+	if (!drm_mm_initialized(&dev_priv->mm.stolen))
+		return NULL;

drivers/gpu/drm/i915/i915_gem_stolen.c i915_gem_object_create_stolen(struct drm_device *dev, u32 size) · line 457

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_stolen.c +7 -0
+
+	DRM_DEBUG_KMS("creating stolen object: size=%x\n", size);
+
+	stolen = stolen_alloc(dev_priv, size);
+	if (stolen == NULL)
+		return NULL;
+
 	obj = _i915_gem_object_create_stolen(dev, stolen);
 	if (obj)
 		return obj;

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Regards,
Sourab

#14 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 7 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#15 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 6 lines · Chris Wilson
Quoted 5 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

Quoted 6 lines
Quoted 2 lines

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Ok, Thanks Chris.

Regards,
Sourab

#16 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 7 lines · Sourab
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Ok, Thanks Chris.

I'd really prefer if someone would pick up all the stolen/create2_ioctl/whatever patches, pack them up into a polished series, add the testcases and submit this all for review and merging.

Otherwise this will linger forever and we'll get nowhere. Chris seems swamped with other stuff, so Sourab could you please take a look at this?

Please check with your manager that you have sufficient bandwidth to pull this through.

Rodrigo, I think you can drop this patch from -collector, it only really makes sense in the context of all the other stolen work.

Thanks, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#17 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 20 lines · Daniel Vetter
Quoted 7 lines · Sourab
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Ok, Thanks Chris.

I'd really prefer if someone would pick up all the stolen/create2_ioctl/whatever patches, pack them up into a polished series, add the testcases and submit this all for review and merging.

Quoted 6 lines

Otherwise this will linger forever and we'll get nowhere. Chris seems swamped with other stuff, so Sourab could you please take a look at this?

Please check with your manager that you have sufficient bandwidth to pull this through.

I'll be on vacation from next week, so I'll be able to gauge this better after coming back.
Nevertheless, I have some questions regarding the expectation of userspace code changes required for these patches (i.e. libdrm changes and igt testcases)

1) For libdrm , I am assuming, a counterpart of drm_intel_gem_bo_alloc_tiled() function would call the create2 ioctl and take in the parameters needed.
Should the caching of objects from libdrm need to take care of both the placement domains seperately (as in different sets of bo buckets)? Should libdrm be transparent to all the combinations of different parameters being passed by user or should the prohibited combinations be disallowed from libdrm side?

2) For the igt, since we have a lot of parameters exposed to user, the number of subtests required may be huge and still they may not test out everything.
So, Is the expectation here to have exhaustive test cases for all the parameters (tiling/cache/domain/madvise/offset etc.) going in as input to the create2 ioctl?
For eg. let us say we are going to check the render copy operation of src and dest bo's. Do we need to provide all possible combinations of different (create2 ioctl) input parameters to these src and dest bo's and then run the render copy test for all these combinations. Any guiding pointers from your side as to how we may go about the igt testcases?

Thanks,
sourab

Quoted 4 lines

Rodrigo, I think you can drop this patch from -collector, it only really makes sense in the context of all the other stolen work.

Thanks, Daniel

#18 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 34 lines · Sourab
Quoted 20 lines · Daniel Vetter
Quoted 7 lines · Sourab
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Ok, Thanks Chris.

I'd really prefer if someone would pick up all the stolen/create2_ioctl/whatever patches, pack them up into a polished series, add the testcases and submit this all for review and merging.

Quoted 6 lines

Otherwise this will linger forever and we'll get nowhere. Chris seems swamped with other stuff, so Sourab could you please take a look at this?

Please check with your manager that you have sufficient bandwidth to pull this through.

I'll be on vacation from next week, so I'll be able to gauge this better after coming back.
Nevertheless, I have some questions regarding the expectation of userspace code changes required for these patches (i.e. libdrm changes and igt testcases)

Quoted 8 lines

1) For libdrm , I am assuming, a counterpart of drm_intel_gem_bo_alloc_tiled() function would call the create2 ioctl and take in the parameters needed.
Should the caching of objects from libdrm need to take care of both the placement domains seperately (as in different sets of bo buckets)? Should libdrm be transparent to all the combinations of different parameters being passed by user or should the prohibited combinations be disallowed from libdrm side?

I'm not sure whether we need a cache implemented in libdrm. Since stolen objects are fairly special it's probably easier to just have a simple linear cache tailor-made in the respective UMD. So just exposing create2_ioctl should be good enough.

Quoted 4 lines

2) For the igt, since we have a lot of parameters exposed to user, the number of subtests required may be huge and still they may not test out everything.
So, Is the expectation here to have exhaustive test cases for all the

Quoted 8 lines

parameters (tiling/cache/domain/madvise/offset etc.) going in as input to the create2 ioctl?
For eg. let us say we are going to check the render copy operation of src and dest bo's. Do we need to provide all possible combinations of different (create2 ioctl) input parameters to these src and dest bo's and then run the render copy test for all these combinations. Any guiding pointers from your side as to how we may go about the igt testcases?

At a high-level there's two parts for igt tests:
- First is functional tests, where we try to make sure that the feature actually works. I.e. allocate some stolen memory and then do something with it, making sure that data access for the gpu and similar things work. For this we just want some reasonable base coverage so that when we hit a bug somewhere it's easy to extend the testcase to cover that bug with a specific subtest.

- Then there's interface testing. kernel/userspace is a trust barrier, so we need to make sure that evil userspace can't make the kernel crash with some crazy invalid combination of flags or operations (like create a stolen object and then try to mmap it). Since this is security relevant and also since we can't ever change established userspace ABI I want full coverage of all cases. But this is just about detecting abuse correctly, no functional tests here.

For details see my two blog posts on the topic:

http://blog.ffwll.ch/2013/11/botching-up-ioctls.html

http://blog.ffwll.ch/2013/11/testing-requirements-for-drmi915.html

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#19 lore raw

Re: [PATCH 3/6] drm/i915: Add support for stealing purgable stolen pages

Quoted 78 lines · Daniel Vetter
Quoted 34 lines · Sourab
Quoted 20 lines · Daniel Vetter
Quoted 7 lines · Sourab
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Sourab

Hi Rodrigo,
In this patch, while freeing the purgeable stolen object, the memory node also has to be freed, so as to make space for new object. We need to call drm_mm_remove_node while freeing obj.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The below modification patch was floated earlier for this purpose:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041282.html

Right, I have a v2 locally with the fix you identified. -Chris

Ok, Thanks Chris.

I'd really prefer if someone would pick up all the stolen/create2_ioctl/whatever patches, pack them up into a polished series, add the testcases and submit this all for review and merging.

Quoted 6 lines

Otherwise this will linger forever and we'll get nowhere. Chris seems swamped with other stuff, so Sourab could you please take a look at this?

Please check with your manager that you have sufficient bandwidth to pull this through.

I'll be on vacation from next week, so I'll be able to gauge this better after coming back.
Nevertheless, I have some questions regarding the expectation of userspace code changes required for these patches (i.e. libdrm changes and igt testcases)

Quoted 8 lines

1) For libdrm , I am assuming, a counterpart of drm_intel_gem_bo_alloc_tiled() function would call the create2 ioctl and take in the parameters needed.
Should the caching of objects from libdrm need to take care of both the placement domains seperately (as in different sets of bo buckets)? Should libdrm be transparent to all the combinations of different parameters being passed by user or should the prohibited combinations be disallowed from libdrm side?

I'm not sure whether we need a cache implemented in libdrm. Since stolen objects are fairly special it's probably easier to just have a simple linear cache tailor-made in the respective UMD. So just exposing create2_ioctl should be good enough.

Quoted 4 lines

2) For the igt, since we have a lot of parameters exposed to user, the number of subtests required may be huge and still they may not test out everything.
So, Is the expectation here to have exhaustive test cases for all the

Quoted 8 lines

parameters (tiling/cache/domain/madvise/offset etc.) going in as input to the create2 ioctl?
For eg. let us say we are going to check the render copy operation of src and dest bo's. Do we need to provide all possible combinations of different (create2 ioctl) input parameters to these src and dest bo's and then run the render copy test for all these combinations. Any guiding pointers from your side as to how we may go about the igt testcases?

At a high-level there's two parts for igt tests:
- First is functional tests, where we try to make sure that the feature actually works. I.e. allocate some stolen memory and then do something with it, making sure that data access for the gpu and similar things work. For this we just want some reasonable base coverage so that when we hit a bug somewhere it's easy to extend the testcase to cover that bug with a specific subtest.

- Then there's interface testing. kernel/userspace is a trust barrier, so we need to make sure that evil userspace can't make the kernel crash with some crazy invalid combination of flags or operations (like create a stolen object and then try to mmap it). Since this is security relevant and also since we can't ever change established userspace ABI I want full coverage of all cases. But this is just about detecting abuse correctly, no functional tests here.

Quoted 7 lines

For details see my two blog posts on the topic:

http://blog.ffwll.ch/2013/11/botching-up-ioctls.html

http://blog.ffwll.ch/2013/11/testing-requirements-for-drmi915.html

Cheers, Daniel

Thanks Daniel,
We'll take care of the above points for libdrm changes and igt.

Regards,
Sourab

#20 lore raw

PATCH 4/6 drm/i915: add flag to prevent dmesg spam on context banning

In reply to Rodrigo Vivi

From: Mika Kuoppala <[email protected]>

Piglit runner and QA are both looking at the dmesg for DRM_ERRORs with test cases.

Add flag to stop_rings debugfs interface to prevent DRM_ERROR output when default context banning is being tested.

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

---
 drivers/gpu/drm/i915/i915_drv.h         | 18 ++++++++++++++++--
 drivers/gpu/drm/i915/i915_gem.c         |  5 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +16 -2
index 55addaa..d5cd981 100644
@@ -1099,8 +1099,12 @@ struct i915_gpu_error {
 	 */
 	wait_queue_head_t reset_queue;
 
-	/* For gpu hang simulation. */
-	unsigned int stop_rings;
+	/* For gpu hang simulation.
+	 * MSB for controlling DRM_ERROR with ctx bans
+	 */
+	u32 stop_rings;
+
+#define I915_SQUELCH_CTX_BAN_ERROR (1 << 31)
 
 	/* For missed irq/seqno simulation. */
 	unsigned int test_irq_rings;
@@ -2146,6 +2150,16 @@ static inline u32 i915_reset_count(struct i915_gpu_error *error)
 	return ((atomic_read(&error->reset_counter) & ~I915_WEDGED) + 1) / 2;
 }
 
+static inline u32 i915_stopped_rings(struct drm_i915_private *dev_priv)
+{
+	return dev_priv->gpu_error.stop_rings & ~I915_SQUELCH_CTX_BAN_ERROR;
+}
+
+static inline bool i915_squelch_ban_error(struct drm_i915_private *dev_priv)
+{
+	return dev_priv->gpu_error.stop_rings & I915_SQUELCH_CTX_BAN_ERROR;
+}
+
 void i915_gem_reset(struct drm_device *dev);
 bool i915_gem_clflush_object(struct drm_i915_gem_object *obj, bool force);
 int __must_check i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj);
drivers/gpu/drm/i915/i915_gem.c +3 -2
index c70121d..7598e86 100644
@@ -2277,8 +2277,9 @@ static bool i915_context_is_banned(struct drm_i915_private *dev_priv,
 		if (!i915_gem_context_is_default(ctx)) {
 			DRM_DEBUG("context hanging too fast, banning!\n");
 			return true;
-		} else if (dev_priv->gpu_error.stop_rings == 0) {
-			DRM_ERROR("gpu hanging too fast, banning!\n");
+		} else if (!i915_stopped_rings(dev_priv)) {
+			if (!i915_squelch_ban_error(dev_priv))
+				DRM_ERROR("gpu hanging too fast, banning!\n");
 			return true;
 		}
 	}
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 3d76ce1..275afa5 100644
@@ -46,7 +46,7 @@ void __intel_ring_advance(struct intel_ring_buffer *ring)
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
 	ring->tail &= ring->size - 1;
-	if (dev_priv->gpu_error.stop_rings & intel_ring_flag(ring))
+	if (i915_stopped_rings(dev_priv) & intel_ring_flag(ring))
 		return;
 	ring->write_tail(ring, ring->tail);
 }
Signature · 1 line
1.9.0
#21 lore raw

Re: [PATCH 4/6] drm/i915: add flag to prevent dmesg spam on context banning

Quoted 11 lines · Rodrigo Vivi

From: Mika Kuoppala <[email protected]>

Piglit runner and QA are both looking at the dmesg for DRM_ERRORs with test cases.

Add flag to stop_rings debugfs interface to prevent DRM_ERROR output when default context banning is being tested.

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

This can be dropped. Superseded by:

[email protected]

-Mika

#22 lore raw

PATCH 5/6 drm/i915: Do not allow a pending forcewake put to unbalance across reset

In reply to Rodrigo Vivi

From: Chris Wilson <[email protected]>

Across a device reset, we try to restore and user forcewake reference counts. This is complicated by our deferred forcewake put adding an extra reference, that may or may not be flushed when we call del_timer_sync. So we have to take that pending reference into account when restoring the forcewake.

---
 drivers/gpu/drm/i915/intel_uncore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_uncore.c +4 -1
index 2a72bab..c8969e3 100644
@@ -317,8 +317,9 @@ static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
+	int pending;
 
-	del_timer_sync(&dev_priv->uncore.force_wake_timer);
+	pending = del_timer_sync(&dev_priv->uncore.force_wake_timer);
 
 	/* Hold uncore.lock across reset to prevent any register access
 	 * with forcewake not set correctly
@@ -336,6 +337,8 @@ static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
 	if (restore) { /* If reset with a user forcewake, try to restore */
 		unsigned fw = 0;
 
+		dev_priv->uncore.forcewake_count -= pending;
+
 		if (IS_VALLEYVIEW(dev)) {
 			if (dev_priv->uncore.fw_rendercount)
 				fw |= FORCEWAKE_RENDER;
Signature · 1 line
1.9.0
#23 lore raw

PATCH 6/6 drm/i915: Don't save/restore RS when not used

In reply to Rodrigo Vivi

From: Ben Widawsky <[email protected]>

---
 drivers/gpu/drm/i915/i915_gem_context.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +7 -5
index 8827892..74369b7 100644
@@ -589,6 +589,7 @@ mi_set_context(struct intel_ring_buffer *ring,
 	       struct i915_hw_context *new_context,
 	       u32 hw_flags)
 {
+	u32 flags = hw_flags | MI_MM_SPACE_GTT;
 	int ret;
 
 	/* w/a: If Flush TLB Invalidation Mode is enabled, driver must do a TLB
@@ -602,6 +603,10 @@ mi_set_context(struct intel_ring_buffer *ring,
 			return ret;
 	}
 
+	/* These flags are for resource streamer on HSW+ */
+	if (!IS_HASWELL(ring->dev) && INTEL_INFO(ring->dev)->gen < 8)
+		flags |= (MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN);
+
 	ret = intel_ring_begin(ring, 6);
 	if (ret)
 		return ret;
@@ -614,11 +619,8 @@ mi_set_context(struct intel_ring_buffer *ring,
 
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_emit(ring, MI_SET_CONTEXT);
-	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(new_context->obj) |
-			MI_MM_SPACE_GTT |
-			MI_SAVE_EXT_STATE_EN |
-			MI_RESTORE_EXT_STATE_EN |
-			hw_flags);
+	intel_ring_emit(ring,
+			i915_gem_obj_ggtt_offset(new_context->obj) | flags);
 	/*
 	 * w/a: MI_SET_CONTEXT must always be followed by MI_NOOP
 	 * WaMiSetContext_Hang:snb,ivb,vlv
Signature · 1 line
1.9.0