From patchwork Tue Oct 24 18:56:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Wang, Zhi A" X-Patchwork-Id: 10025387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFB0C601E8 for ; Tue, 24 Oct 2017 18:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A705928986 for ; Tue, 24 Oct 2017 18:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B90828999; Tue, 24 Oct 2017 18:56:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D64728986 for ; Tue, 24 Oct 2017 18:56:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9ECE86E5C7; Tue, 24 Oct 2017 18:56:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 214096E5BF; Tue, 24 Oct 2017 18:56:43 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 24 Oct 2017 11:56:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,429,1503385200"; d="scan'208"; a="1028871706" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 24 Oct 2017 11:56:32 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Oct 2017 11:56:31 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Oct 2017 11:56:31 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Wed, 25 Oct 2017 02:56:28 +0800 From: "Wang, Zhi A" To: SF Markus Elfring , "dri-devel@lists.freedesktop.org" , "intel-gfx@lists.freedesktop.org" , "intel-gvt-dev@lists.freedesktop.org" , David Airlie , Jani Nikula , Joonas Lahtinen , "Vivi, Rodrigo" , Zhenyu Wang Subject: RE: [PATCH] drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer() Thread-Topic: [PATCH] drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer() Thread-Index: AQHTTMNIXow8Ve7knkGxF73Fg4rOe6LzWJRA Date: Tue, 24 Oct 2017 18:56:27 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Cc: "kernel-janitors@vger.kernel.org" , LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 ; Jani Nikula ; Joonas Lahtinen ; Vivi, Rodrigo ; Zhenyu Wang ; Wang, Zhi A Cc: LKML ; kernel-janitors@vger.kernel.org Subject: [PATCH] drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer() From: Markus Elfring 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 --- drivers/gpu/drm/i915/gvt/cmd_parser.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.14.3 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)