Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4477508ybz; Tue, 21 Apr 2020 01:05:36 -0700 (PDT) X-Google-Smtp-Source: APiQypIso/Js8c6vlXJ08oIDvhsrhy40iPyZWVYzasdBvg8Zj4wZR4pfFJt3dUpi+VIsZHPUP4Cz X-Received: by 2002:a17:906:7750:: with SMTP id o16mr7091168ejn.12.1587456336794; Tue, 21 Apr 2020 01:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587456336; cv=none; d=google.com; s=arc-20160816; b=dnUsDPDK0ZRphoHJA4iUL5HHS8r6t2ChQFqKAtTGBp9Ry9HhWbAELz8q3hA0OZo4KU t+YXbnST3ndfGMS1eL9LzFfRZQbSZuaAm7JBPL4MpB7TuqMDqaZA4opP8U+F2StorIgX fGszWmljFlaJspCUFR5l+fIuQdH1Sn5YtHRH3dskllQfxmQTTdx2F1BmEmIB6wYoWsQH CUoya51raeRTyvjB71MJb1rIUO+E4TJRGbLDbwd4Ye9CV3QQ138EhOzc/R95H+IlHEHI K2pwk25Om1CgW9ZRBZKGGzLg1s5ccO4PMo6ci10kYP0s5R1/bPbF/x5iZhCGBjhRkLOq dqqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :reply-to:message-id:date:subject:cc:to:from; bh=g7qv1llg4/NK27PvOyRUzf7+RjhIavLidfKpdmW/EmU=; b=IjI1WCUTyENBMO30P1a4ROGk+tjsQAg9RiT48rlDRq+5r1rjR7Ol4f8l+DsJo9WwKo xVZwaXueuRkLEX//GtJhDYQ9bKwW4FVXt39uiFH3Ofe3HloEnpn5ZWxFLKh09y3Cw9K3 Bzq1AszFJXYR+82WvQoX8Q2AERAlSxL35cWZ9Wfa7uueUUwebVPOtHDdL6mQcwQmER11 J+T7E3IBgtLiEGlvVcCspKQI4Hy56HIXlv4gIw4e9N7HaataYTrrnVI6p+tHDH+RCgiY watJnE+nmX0XHd2FwOFFjmSX+cR5d/5KydqRLweJmuotunYH1KXVn6QLCpeVTypRUCGt McrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a88si1174848edf.379.2020.04.21.01.05.12; Tue, 21 Apr 2020 01:05:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728525AbgDUIDg (ORCPT + 99 others); Tue, 21 Apr 2020 04:03:36 -0400 Received: from m176115.mail.qiye.163.com ([59.111.176.115]:41983 "EHLO m176115.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgDUIDf (ORCPT ); Tue, 21 Apr 2020 04:03:35 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id EFA83665946; Tue, 21 Apr 2020 16:03:30 +0800 (CST) From: Bernard Zhao To: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH V3] amdgpu: remove unnecessary condition check Date: Tue, 21 Apr 2020 01:03:24 -0700 Message-Id: <20200421080324.130104-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 Reply-To: 1587180037-113840-1-git-send-email-bernard@vivo.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVOTUhLS0tJS0lKTENCTVlXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PyI6UQw6ODgxAgNDMVEUIjMp SzAaChhVSlVKTkNMT05NSUpPSUNPVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSEtOQjcG X-HM-Tid: 0a719bc378d89373kuwsefa83665946 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no need to if check again, maybe we could merge into the above else branch. Signed-off-by: Bernard Zhao Changes since V1: *commit message improve *code style refactoring Changes since V2: *code style adjust Link for V1: *https://lore.kernel.org/patchwork/patch/1226587/ --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 9dff792c9290..5424bd921a7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -660,13 +660,12 @@ static int reserve_bo_and_vm(struct kgd_mem *mem, ret = ttm_eu_reserve_buffers(&ctx->ticket, &ctx->list, false, &ctx->duplicates); - if (!ret) - ctx->reserved = true; - else { - pr_err("Failed to reserve buffers in ttm\n"); + if (ret) { + pr_err("Failed to reserve buffers in ttm.\n"); kfree(ctx->vm_pd); ctx->vm_pd = NULL; - } + } else + ctx->reserved = true; return ret; } @@ -733,15 +732,12 @@ static int reserve_bo_and_cond_vms(struct kgd_mem *mem, ret = ttm_eu_reserve_buffers(&ctx->ticket, &ctx->list, false, &ctx->duplicates); - if (!ret) - ctx->reserved = true; - else - pr_err("Failed to reserve buffers in ttm.\n"); - if (ret) { + pr_err("Failed to reserve buffers in ttm.\n"); kfree(ctx->vm_pd); ctx->vm_pd = NULL; - } + } else + ctx->reserved = true; return ret; } -- 2.26.2