Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp265833pxt; Wed, 4 Aug 2021 22:17:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhgs/ad1jJiKhMcAUYhWeJa5vhh8GcG0KbSK0qdOPnd2Wgz/4eFkyK/6+4HAvdGLAA3wTl X-Received: by 2002:a05:6e02:d0c:: with SMTP id g12mr497574ilj.230.1628140657850; Wed, 04 Aug 2021 22:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628140657; cv=none; d=google.com; s=arc-20160816; b=pea/SE7HwZzEVEc3y604ipSa0AMomxhGr2bLlStZ/FCXutOCZopUrX20JIDwpnMOI+ VBbN0jZ5EUxvbEzMlw/eVjRJ86ygqaazzZVzNOn13KugheY1y5hPjarnN2r/h9pq7HGQ c7IxSMrKv82rek20b0VuJLkb7FYEBBYVgMSJ9QK0nGOcvJ+92zGBNKqjiEb+p5xrFK11 GuUOgnJ6+O6kHQMtbrlwWBeaH52Wg2SPUpRoeELDZymuHNICB8jMnHzAd78hIcp2oJbV +gXvGZr+8AZYh9789OaUiNyxJG0RWf+ne+bI1KN8OrIlG6q5YQ/tN1DM1rykJ/tyqDmQ 10IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WPmSYKxM3hDxf4j2HGMY4KEBqM5rWpME+JCZGt0gVjw=; b=uG+hmtQTNqFCBkh36HKViJ1oD5uMqSx5pvL06jpW3yaT0uJSfdjwqIds+S58gh2ey3 i7GmEL1N4K8qmKEIl0fddURR6hHALEYya9Hd+rO/9pr5Kgti93PVHyE+UvSavW35Q9U/ o7cETWTto4wQwhs30FmsDoIlZdsiGyDNfFfUOuX+D8dx3Yz1Wpwm3fzLxLoecAffwcNg J7OmNS8xT9jko+Tv5fMaNicr5YLw0vD/KgIPINJsgd4S7A0XFM1QbXpb7DPkf/KUYwNn qbyOG1SEnhf2QH6UceK/xQxykBV9pcM8Pjw8v8hhmhcJtO9yup6wjfXhbj7QnOS/MOXa zeXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d6lgTlgZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si491421ilq.106.2021.08.04.22.17.26; Wed, 04 Aug 2021 22:17:37 -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=@gmail.com header.s=20161025 header.b=d6lgTlgZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235269AbhHEEdO (ORCPT + 99 others); Thu, 5 Aug 2021 00:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbhHEEdO (ORCPT ); Thu, 5 Aug 2021 00:33:14 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6ACC061765; Wed, 4 Aug 2021 21:32:59 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id g5-20020a9d6b050000b02904f21e977c3eso3919208otp.5; Wed, 04 Aug 2021 21:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WPmSYKxM3hDxf4j2HGMY4KEBqM5rWpME+JCZGt0gVjw=; b=d6lgTlgZ4XtRuTrGFwjnfu6FMANDeGYNkF3HVRgAEz3zNJWeXPay2/77o5xUFwchyy fZ+RxFE6PKyFPBCA/PrBqv7fb7Ru/8F66ANYljfjpCZek/EgK9BnwwHV0KtaiOXGOBHC awwvqO+5eU4YhGFJjXO4OaZpU6kBceP9x20lc/jksWMCQHnZ8orlDNKyp4wj86imwnCD 6YKPbF79Crl7D4d2jD8s0rV9wTcK0I3OjHVcLIxaFULDXF9ynJoOKulQ9ZfLCD/pGLv1 zFEDI6x2G+joB+ZOQckwYoiMZ1LQcX9rian6mNKcuPDevnN7/eoOCrSnqHj1w21TH/v7 BVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WPmSYKxM3hDxf4j2HGMY4KEBqM5rWpME+JCZGt0gVjw=; b=OwLFiVGMaYs2wDyCqgFTesxXRTkK0RCB+Nax1y40ep8X1Fg880NTtYddXvGDPbozet iUIifVJRDjG3WwF1pFn426gFY27IK2m2wYYojXuumNpa8/7YcYVZpob4/8tFLPA4D/Ks dr7F0lP+Xi+/77TxrvYSyY8vE+r/0NGHyVe+PR30ikvPBtHcYIhT1AlHSp1ecoQss8AH LAtk869RYvpanRiYpLOyGQhbQVSz5zJykVbf2s9A/C52vGvQGZvwLUrPOIpjIq0L72UN 166rzXaaUl06WsMgLbyqba+gFbtXX1GPQGePJJ4NCkL9qHptOPt55y/ruvwRpWp7Z5/a SY0Q== X-Gm-Message-State: AOAM5309XmTxbcm8DhxlzklWmMnfVp3IJ7gSh9JqbpAo4F9055//+dF+ Uxbgx7j+xgdUVNz17VMbML1lMD+0ct0+e5Zid5k= X-Received: by 2002:a9d:70c3:: with SMTP id w3mr2216613otj.311.1628137979011; Wed, 04 Aug 2021 21:32:59 -0700 (PDT) MIME-Version: 1.0 References: <20210804015132.29617-1-islituo@gmail.com> In-Reply-To: From: Alex Deucher Date: Thu, 5 Aug 2021 00:32:47 -0400 Message-ID: Subject: Re: [PATCH] drm/amdgpu: drop redundant null-pointer checks in amdgpu_ttm_tt_populate() and amdgpu_ttm_tt_unpopulate() To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Tuo Li , "Deucher, Alexander" , xinhui pan , Dave Airlie , Daniel Vetter , Sumit Semwal , Dave Airlie , "Kuehling, Felix" , Oak Zeng , Nirmoy Das , Thomas Zimmermann , "Yang, Philip" , amd-gfx list , Maling list - DRI developers , LKML , linux-media , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Jia-Ju Bai , TOTE Robot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied. Thanks! Alex On Wed, Aug 4, 2021 at 2:49 AM Christian K=C3=B6nig wrote: > > Am 04.08.21 um 03:51 schrieb Tuo Li: > > The varialbe gtt in the function amdgpu_ttm_tt_populate() and > > amdgpu_ttm_tt_unpopulate() is guaranteed to be not NULL in the context. > > Thus the null-pointer checks are redundant and can be dropped. > > > > Reported-by: TOTE Robot > > Signed-off-by: Tuo Li > > Reviewed-by: Christian K=C3=B6nig > > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_ttm.c > > index 3a55f08e00e1..719539bd6c44 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -1121,7 +1121,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_devi= ce *bdev, > > struct amdgpu_ttm_tt *gtt =3D (void *)ttm; > > > > /* user pages are bound by amdgpu_ttm_tt_pin_userptr() */ > > - if (gtt && gtt->userptr) { > > + if (gtt->userptr) { > > ttm->sg =3D kzalloc(sizeof(struct sg_table), GFP_KERNEL); > > if (!ttm->sg) > > return -ENOMEM; > > @@ -1146,7 +1146,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_d= evice *bdev, > > struct amdgpu_ttm_tt *gtt =3D (void *)ttm; > > struct amdgpu_device *adev; > > > > - if (gtt && gtt->userptr) { > > + if (gtt->userptr) { > > amdgpu_ttm_tt_set_user_pages(ttm, NULL); > > kfree(ttm->sg); > > ttm->sg =3D NULL; >