From patchwork Tue Oct 24 12:25:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10024175 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 5EA8B60245 for ; Tue, 24 Oct 2017 12:26:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CC1328900 for ; Tue, 24 Oct 2017 12:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41A5B289F6; Tue, 24 Oct 2017 12:26:11 +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=ham 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 6464B28900 for ; Tue, 24 Oct 2017 12:26:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 928D66E454; Tue, 24 Oct 2017 12:26:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [217.72.192.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id B98EA6E454 for ; Tue, 24 Oct 2017 12:26:05 +0000 (UTC) Received: from [192.168.1.2] ([92.227.117.134]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Ldn6l-1dOFo81w7H-00j4vv; Tue, 24 Oct 2017 14:25:55 +0200 To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Zhenyu Wang , Zhi Wang From: SF Markus Elfring Subject: [PATCH] drm/i915/gvt: Use common error handling code in shadow_workload_ring_buffer() Message-ID: Date: Tue, 24 Oct 2017 14:25:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:S8Th+Emm7XIzUTGPhOkx3PuxYzaDB6y8HBxY+/6niwyPDMW4SVX /cxylJT33fSn1E+wXxSw0ntQnfX5LgYc5LNLRb7WhwUVvD5URhDy3RHq52dUUQkpqinnmtN 1pIaLWYxa0O5xheCzgTkllIxojDgfsUQ98PehGd17BFAe+G3a4NK3plr4dOjd36NIiV8NVa GIlE4gGDPegYY3g4nEZCw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fDNeGwtmCLo=:xoQ7SdLMK0EodGHbyms+Zn 99Q7HS+wGoVCP/Wp1d/ysCRyrRyFmkuUT48ukD2BpgfKsp2awY7dzwNzuo0M3bd7rCwXHpfPb E/BM5Ncu+Y4w9cOn8QJ7tpmMlkP8+OBjUKZv9DYKg4tnwubIaVBzKrogHjicq1DEWjJfR1/Eb Xau8xBuSukM72NBzPgvyRGSK3mgOebtRUL1DpCoqfQK9SVuQnHeMuAq4gz6pCO5V6fqKJvWAO 6+7yZg+Nug5Q5hFy2aAsb4i20Knp4nXA9ra7UGoAKNeshLoz0ZSsPSitki7edUPLFeO8ymc3P IRyag6id1e2AVUvACmG790txfXLA5FN6bPX/NFkPPmm6tZLx+nCIfoit63LdRBIF8ZeEXNWfx 0aQQQFtfOiJlNpFNF3mbP/o8ABEt61BaJieMcc7iJv///jX+A6lbLFEnx75dJj0aSY6fbFiJX BpInJ+48MV9g71R/OFnxiICFpvbWiYoZNzyJA+bi6FguuEplEll29AjE4nLjZdBnmEWErak8E lHroyWVdso3YYgWYddvVV6ti5MU+WscZPQSR7UumL19zujNYzr7mu8P+NO+w1uxZLmlGlVR0T Nf3SApQQTYsafOsgmr1Ik/rqKe0ZPWMDxZQUl4I4PquwEPY2OuYCEcQBbRInZM20WLZ5wBJ2u xyIzgIR6vrR78JGmod7s9lYMCvEhKSgAVdJwkONtFuB7O7OkxW6Am14iRkYBOR2nnq1qkhfzU SbiM2edPNQ/4bECXpa5mHa4KTUOG8mP7Vn0bFWsUy/StY/Ej8KI/ckQ5PqtkKMWS2BT7BYXS5 LNVtDOQGP7W5FhVL/QNp5vv4I9nhKrGr2OucAjqk5SJl/BhfGk= 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 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(-) 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)