Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4479575ybz; Tue, 21 Apr 2020 01:08:18 -0700 (PDT) X-Google-Smtp-Source: APiQypI9N5/KkIvGEtQGVEc6ZayIRSGKFFo92CvCJaCafx/L+v/+h5/DKA8SxtJFl0kxSDWl6h8S X-Received: by 2002:a50:d0d5:: with SMTP id g21mr18298404edf.92.1587456498280; Tue, 21 Apr 2020 01:08:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587456498; cv=pass; d=google.com; s=arc-20160816; b=S+60TQrg2TH4BeGwf90hFpDjruaevWrbGXdTCciLxuUJh8VtwMSygZXp7gXJly6r55 z6msZ7QiQ4UhE9dULGrrXtuHDJubBkFV7ZPziCFtwg0FeskHoN+YVJYr4JHz1eCh50QW dKrKhjUei+/ICQf4vWv2evv7v7j0I/fGwOflo1yYqEVziU57zuEzZNM9nrN8ZQiensfB 3irBNkHFn879fbSKUY8Xxzv3SUUy6rxIa3zQWslse2rmyOC2Gyoecx88aSkPstyypt8O WdYnTL8+C01tiAFaLMk216pjoaqmhlZv7UYijltyCDC28UGCz9GE/AN0rBaLdNj1Gk7u D+jg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=ZmGyXfqp3pO5hlG9k/kcutzACFbGyOSdX/InZKoaXao=; b=TV4+TyYRGjUETlt2dIS+TtNPHgxiLfn5dy8b59NOM7x1XQ1ABcYk/aPXIf4CjJykfG /8MhXoXpGx4edyMJJZjliYIdUVyPxZpjXBT5azx83YRGprBXrwyi3HKyRRQoJ4Gp0RvL 8ifnpjUPzWTN2dFEz96UlPekNIYAPmqGacvVBHZwT4fNfwK8y60L0UX71xnKLc8OBYmB GQeh2Zq2Eh54EJ770tFJ61qT8AW2kFdns8HLvN5tYOAXdPJdMHw0xw5kTOrqEe08YOhJ RfaVn//PPXAnyII+9SG/7QqQwsWRans/0GvHZ3Qaho8lLtTXlL9nZoKMPknntBr0iL8A +ybA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=qT3F3Ti3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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 m29si1188056eda.592.2020.04.21.01.07.54; Tue, 21 Apr 2020 01:08:18 -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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=qT3F3Ti3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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 S1728354AbgDUIGX (ORCPT + 99 others); Tue, 21 Apr 2020 04:06:23 -0400 Received: from mail-dm6nam12on2067.outbound.protection.outlook.com ([40.107.243.67]:53313 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728276AbgDUIGP (ORCPT ); Tue, 21 Apr 2020 04:06:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G503qkxpD2uTASDkSse71fzp72Y1jy3AVEg4BL5rzHCOj5MYrt+qLnG+ZLjw1oFiD3vXv+KcRRsHs38tgJ1Eyq2n45dFdveFy8kT4ceq0/LPKoaPlNIWg0Lozc4Vc0oviR1BvjcA+v5int180s3L5pfgCxuWcmijl4tRc/h3XQ+sCp8xyZ2nxqq4Zyg40dDLu/4QUFH0eFczkU3AZAfrpdostErK1RlxP7WA6+TMUzeLey07lt17u8mgM0bFohepIEn6oAc2xY3Tvqwi5z4xuAcwGUvGVhxvuAHm/Q8XYbJgS5Sv2iGe9xHcvlaNfYZFzQCplh74UecKzqAux6wO8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZmGyXfqp3pO5hlG9k/kcutzACFbGyOSdX/InZKoaXao=; b=OEyl2ocCt7w13AZNK8RGTZuZGdrYzGPsJnkRm6v28kkO4WvJcSqVnuJKvGzWwESkvs00OlZpKQF7abahKYDiGa+5niiJh/WCKbViJ0xYwd74FTgpwfVJOwvlUCs6cb2wb10VTgZ9/a7sFUHjlX0auOER6mejgCcuCIw2FUVYG35Fuigkd62qv/n4coJ4303cOxl3ghKY3jKXaRsgbw28yJQcHbuGbzV4HbKOGak59POF3drL0c4Y2wWiOapdgFTUogc215/ZMRJQ9GztYvHUmeiPWFKPgrac3kveLCm7MIMZwIqSs1qF37RhtqCGLLIqDfw5/vG4oENW0iBVHKOCIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZmGyXfqp3pO5hlG9k/kcutzACFbGyOSdX/InZKoaXao=; b=qT3F3Ti3bHJ8Y0DEs/HPhLHU5A2A9CQoEXMEn3KCokToUCsHLKeqLeRhax1+UmTfrpOFNr/8AVbA3DlrByyq3ET7Napiz77XL/g+7C3HWtOhecxR6Sqw7BBde9LeFEc9ESIokNlJ9oj59pr+a3Jr2NQv1vMbMa9J1vaQn8gegNI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Received: from DM6PR12MB4401.namprd12.prod.outlook.com (20.180.254.79) by DM6PR12MB3867.namprd12.prod.outlook.com (10.255.175.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Tue, 21 Apr 2020 08:06:12 +0000 Received: from DM6PR12MB4401.namprd12.prod.outlook.com ([fe80::7949:b580:a2d5:f766]) by DM6PR12MB4401.namprd12.prod.outlook.com ([fe80::7949:b580:a2d5:f766%3]) with mapi id 15.20.2921.030; Tue, 21 Apr 2020 08:06:12 +0000 Subject: Re: [PATCH V3] amdgpu: remove unnecessary condition check To: 1587180037-113840-1-git-send-email-bernard@vivo.com, Felix Kuehling , Alex Deucher , "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 References: <20200421080324.130104-1-bernard@vivo.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <4c027bd0-c2ff-b587-6389-62a3d25dec1b@amd.com> Date: Tue, 21 Apr 2020 10:06:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 In-Reply-To: <20200421080324.130104-1-bernard@vivo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: AM3PR05CA0125.eurprd05.prod.outlook.com (2603:10a6:207:2::27) To DM6PR12MB4401.namprd12.prod.outlook.com (2603:10b6:5:2a9::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7] (2a02:908:1252:fb60:be8a:bd56:1f94:86e7) by AM3PR05CA0125.eurprd05.prod.outlook.com (2603:10a6:207:2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.30 via Frontend Transport; Tue, 21 Apr 2020 08:06:08 +0000 X-Originating-IP: [2a02:908:1252:fb60:be8a:bd56:1f94:86e7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 08f116e8-4f73-48f6-909c-08d7e5cadb6b X-MS-TrafficTypeDiagnostic: DM6PR12MB3867:|DM6PR12MB3867: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-Forefront-PRVS: 038002787A X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4401.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(366004)(39860400002)(136003)(376002)(396003)(346002)(316002)(66476007)(66556008)(110136005)(2616005)(66946007)(8676002)(186003)(52116002)(31686004)(478600001)(45080400002)(16526019)(81156014)(36756003)(8936002)(6666004)(6486002)(2906002)(86362001)(5660300002)(31696002)(4326008);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y3AUnwIXYYOsWe2Tx2gwxuJ2fXAZH5Wg4SAXezJ0p5Qz1Kxtgkl+qaph9MLvv6PcqYZdm1W8iYolwKprPzUz3vcnD6NuEMobh6tPgszmMgEVSJccKQTgJzhQub/H3kSzwfSNhaEi0eWzyo47dwQpu3Glx+QPRjRBNJ9jTkywb3lpYTe+Y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KuByWnXohStZ5ptLh0VJQWvt/7vqOG9kGFU5XXSH8AVWdVYSV6ZRjb0/SmaReyehaz77mCXyrE8NtKjAneg0q+oiKtlP6kuzW5STZgPHBC2ohphnKS3Nbgm6EL3JlfY24NNjVhl8xiAPMtR5WpJB6hSfw= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08f116e8-4f73-48f6-909c-08d7e5cadb6b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2020 08:06:12.5201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YEW1r7Q7CRio9PC3byuI6FC5IffsHxv7msm0+dd3B3wA0euiMNXGSOPCl7Z9tLI1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3867 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 21.04.20 um 10:03 schrieb Bernard Zhao: > 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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226587%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7C0b8fffafb715474289b208d7e5ca7f6c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230530201280350&sdata=Sewv5ESX%2B0B4DbFbE03uM5sifrEcmJllC8pt7J42I7M%3D&reserved=0 > --- > .../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; That is still not correct coding style. In general when one branch of an if/else uses {} the other one should use it as well. But I agree with Felix that this change looks rather superfluous to me as well. Regards, Christian. > > 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; > }