Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4263433ybz; Mon, 20 Apr 2020 19:43:47 -0700 (PDT) X-Google-Smtp-Source: APiQypL6hyOEHJhtivCa+QiW8bS2pvQoH1eqhQDbxvhZEhgMjySoVqdXeu1sAuRBTFlex16kiUZu X-Received: by 2002:a17:906:f1c4:: with SMTP id gx4mr18461573ejb.171.1587437027490; Mon, 20 Apr 2020 19:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587437027; cv=none; d=google.com; s=arc-20160816; b=mllI+/HxVJHcvwwiAbUwkehcl30fWbYchRin+HAarsSKBQT3GQux3nx63FgeLJ/tgn SRemb6Vus1fEdUHk5LinzpTowvdKdvbal8IA/RJB922Oqs693QGKgZ/7XfQlG6MCcxXB zv/1BvbThQe1X+CZWp9zuNcvtpVAByXrwRlPIMoNU2pnfIo99HBRqQYYDJifETVsWI2Z gBVMBtfS+ejmeyEEiHRHPJRprVCghUJhTlQT5cqeyezA8ZW/3LdD93o6KVPY4OirBo/y dV6P2eeoHZcHqSE3UuaWW/lxV5s5re169CYGj3qObmiNKrzfY2K988hAABAKVwS6bWGX mUow== 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=IXwHSy7xpgxg4QmKl37TedfXVoh65KZ+ZGaHqy9G/mE=; b=TNOkaceZOn3GBV8m3kmJUWUln+kprNuhO5pWOwu0JrJzIsG7KVl8facukjycrhVPPh yt2sHK5zZUsGoB26K02edHTQJwDsI9dBTD5H3wbefp3aKQD6G9u5Eno4Dfsze5n2wUgx HH2Es1O33NTjXzGcuOTkFrXNmXI4UQ2pgyASgW1jSHu+XMVLTduAUxt91KYnFnR4IOhJ WnMb+KBJy7Th8hODpLKUoEQQl/pxHEXUlw6d3zBQwCtnvNo176mE/IofDiYSO7oSyAai Tz07ogyQuTY1xdeM1UJdy2Xlomj1KxaX601qBh9dCZFJ29zTdKGEavGN0R6OYX9rPoad M1Yw== 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 x17si694633ejn.21.2020.04.20.19.43.25; Mon, 20 Apr 2020 19:43:47 -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 S1727106AbgDUCmN (ORCPT + 99 others); Mon, 20 Apr 2020 22:42:13 -0400 Received: from m176115.mail.qiye.163.com ([59.111.176.115]:26947 "EHLO m176115.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbgDUCmM (ORCPT ); Mon, 20 Apr 2020 22:42:12 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id CAD0E664EC6; Tue, 21 Apr 2020 10:42:05 +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 V2] amdgpu: remove unnecessary condition check Date: Mon, 20 Apr 2020 19:41:59 -0700 Message-Id: <20200421024159.126753-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: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVPT05LS0tKTEpNTUpIQ1lXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6K006Kgw6KTgrFgMtAk4qCS5J ETpPCS9VSlVKTkNMT0hNQklCSUhIVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSUJDTjcG X-HM-Tid: 0a719a9d34659373kuwscad0e664ec6 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 Link for V1: * https://lore.kernel.org/patchwork/patch/1226587/ --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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..a64eeb07bec4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -660,13 +660,15 @@ 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 { + + 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 +735,15 @@ 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