public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Fix GVT balloon fail path handling
@ 2019-06-10  9:28 Zhenyu Wang
  2019-06-10 11:32 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhenyu Wang @ 2019-06-10  9:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: intel-gvt-dev

For any reason if GVT balloon failed, deballoon would be called.
This adds a simple mask to check validity of balloon spaces. When
failure happens, that mask is used to track for deballoon, so it
won't cause any invalid space reference in fail path, which fixed
kernel oops when balloon error happened.

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_vgpu.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_vgpu.c b/drivers/gpu/drm/i915/i915_vgpu.c
index 94d3992b599d..5aec34db1aaa 100644
--- a/drivers/gpu/drm/i915/i915_vgpu.c
+++ b/drivers/gpu/drm/i915/i915_vgpu.c
@@ -94,6 +94,7 @@ struct _balloon_info_ {
 	 * graphic memory, 2/3 for unmappable graphic memory.
 	 */
 	struct drm_mm_node space[4];
+	u8 valid;
 };
 
 static struct _balloon_info_ bl_info;
@@ -126,8 +127,12 @@ void intel_vgt_deballoon(struct drm_i915_private *dev_priv)
 
 	DRM_DEBUG("VGT deballoon.\n");
 
-	for (i = 0; i < 4; i++)
-		vgt_deballoon_space(&dev_priv->ggtt, &bl_info.space[i]);
+	for (i = 0; i < 4; i++) {
+		if (bl_info.valid & BIT(i)) {
+			vgt_deballoon_space(&dev_priv->ggtt, &bl_info.space[i]);
+			bl_info.valid &= ~(u8)BIT(i);
+		}
+	}
 }
 
 static int vgt_balloon_space(struct i915_ggtt *ggtt,
@@ -232,16 +237,17 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 	if (unmappable_base > ggtt->mappable_end) {
 		ret = vgt_balloon_space(ggtt, &bl_info.space[2],
 					ggtt->mappable_end, unmappable_base);
-
 		if (ret)
 			goto err;
+		bl_info.valid |= BIT(2);
 	}
 
 	if (unmappable_end < ggtt_end) {
 		ret = vgt_balloon_space(ggtt, &bl_info.space[3],
 					unmappable_end, ggtt_end);
 		if (ret)
-			goto err_upon_mappable;
+			goto err;
+		bl_info.valid |= BIT(3);
 	}
 
 	/* Mappable graphic memory ballooning */
@@ -250,7 +256,8 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 					0, mappable_base);
 
 		if (ret)
-			goto err_upon_unmappable;
+			goto err;
+		bl_info.valid |= BIT(0);
 	}
 
 	if (mappable_end < ggtt->mappable_end) {
@@ -258,19 +265,15 @@ int intel_vgt_balloon(struct drm_i915_private *dev_priv)
 					mappable_end, ggtt->mappable_end);
 
 		if (ret)
-			goto err_below_mappable;
+			goto err;
+		bl_info.valid |= BIT(1);
 	}
 
 	DRM_INFO("VGT balloon successfully\n");
 	return 0;
 
-err_below_mappable:
-	vgt_deballoon_space(ggtt, &bl_info.space[0]);
-err_upon_unmappable:
-	vgt_deballoon_space(ggtt, &bl_info.space[3]);
-err_upon_mappable:
-	vgt_deballoon_space(ggtt, &bl_info.space[2]);
 err:
+	intel_vgt_deballoon(dev_priv);
 	DRM_ERROR("VGT balloon fail\n");
 	return ret;
 }
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-11  7:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-10  9:28 [PATCH] drm/i915: Fix GVT balloon fail path handling Zhenyu Wang
2019-06-10 11:32 ` Chris Wilson
2019-06-10 13:14 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-06-11  7:40 ` ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox