diff mbox

drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer()

Message ID F3B0350DF4CB6849A642218320DE483D7D669849@SHSMSX104.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Zhi A Oct. 24, 2017, 6:56 p.m. UTC
Thanks for the patch! Actually I would prefer that we can have different error messages here. E.g. like copy_gma_to_hva fail in which part of ring buffer. Or we can directly remove the error message since usually if it fails it means a bug of MPT module when GVT-g is accessing the guest memory by Xen/KVM functions and it shouldn’t happen unless MPT modules has a bug, :( so I wish the error message can be reported in MPT module. :)

Thanks for the patch.  :)

Thanks,
Zhi.

-----Original Message-----
From: SF Markus Elfring [mailto:elfring@users.sourceforge.net] 
Sent: Tuesday, October 24, 2017 3:26 PM
To: dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; intel-gvt-dev@lists.freedesktop.org; David Airlie <airlied@linux.ie>; Jani Nikula <jani.nikula@linux.intel.com>; Joonas Lahtinen <joonas.lahtinen@linux.intel.com>; Vivi, Rodrigo <rodrigo.vivi@intel.com>; Zhenyu Wang <zhenyuw@linux.intel.com>; Wang, Zhi A <zhi.a.wang@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org
Subject: [PATCH] drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer()

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Oct 2017 14:20:06 +0200

Add a jump target so that a call of the function "gvt_vgpu_err" is stored only once at the end of this function implementation.
Replace two calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/i915/gvt/cmd_parser.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

--
2.14.3
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index 2c0ccbb817dc..caa181380958 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -2640,10 +2640,9 @@  static int shadow_workload_ring_buffer(struct intel_vgpu_workload *workload)
 	if (gma_head > gma_tail) {
 		ret = copy_gma_to_hva(vgpu, vgpu->gtt.ggtt_mm,
 				      gma_head, gma_top, shadow_ring_buffer_va);
-		if (ret < 0) {
-			gvt_vgpu_err("fail to copy guest ring buffer\n");
-			return ret;
-		}
+		if (ret < 0)
+			goto report_failure;
+
 		shadow_ring_buffer_va += ret;
 		gma_head = workload->rb_start;
 	}
@@ -2651,11 +2650,14 @@  static int shadow_workload_ring_buffer(struct intel_vgpu_workload *workload)
 	/* copy head or start <-> tail */
 	ret = copy_gma_to_hva(vgpu, vgpu->gtt.ggtt_mm, gma_head, gma_tail,
 				shadow_ring_buffer_va);
-	if (ret < 0) {
-		gvt_vgpu_err("fail to copy guest ring buffer\n");
-		return ret;
-	}
+	if (ret < 0)
+		goto report_failure;
+
 	return 0;
+
+report_failure:
+	gvt_vgpu_err("fail to copy guest ring buffer\n");
+	return ret;
 }
 
 int intel_gvt_scan_and_shadow_ringbuffer(struct intel_vgpu_workload *workload)