Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3387069pxb; Mon, 17 Jan 2022 19:19:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxD7Za9T/oy5Z34tr+0lg6jG5uO1kCGJK2ZIfsVro4be6UMjWRNrBberw7OOJ3WuwpgO0cE X-Received: by 2002:a17:902:8bc5:b0:149:88fc:5560 with SMTP id r5-20020a1709028bc500b0014988fc5560mr25707861plo.144.1642475955205; Mon, 17 Jan 2022 19:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475955; cv=none; d=google.com; s=arc-20160816; b=ukqi9xVxhEHi6nd+aox0mm53ACBnR37MMxTCIAhsVR2oV7SDPFSeAgaZQESlGRWzB2 Umzvv10ccoktY6ED0vW955oSW8eKdmPaqx2ytVW4MKGJpoFrrO0a1IDpTgpAFyQZbp/Y o5qnVyI9OBCXmNwBo4soqAY3+C74o0VOA2G8POdW0MZ/2KmCOVOOqyA+h8X65fxbu/Os EHYHTh+NJDnabyckuQKJd/pE0aMKQEBkbxPE8yZEymuj6r5wBiaSgoVGpDdGiePqE/G5 0HUs3yLBsNdq3yYk/rxzjI/toL51wi+x82dnn4yLmTTKaY1qZe6+kvZC44hKm94qBzlZ wFKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f8n8n07ZyVL5anydBLybfp8z1uX8bLQv7DiNx1h+5V4=; b=eqSXuM0pQalqAzIZEns0uJn05SMijbmL+BiS1Nx7pte3ap35A2I55ne7/UMNP18/iP BxcklJNLDsJbwf9bwDjmFsN9p4KwN7WyDvYfXphZhYtdJLlQR1XoQWkwq/YNoYGmvC6B sy4s7T+yfzzlLAEi1PuG5RjqVmrN248TrjcwpyJSp+jg6hkpCDcyLd2ttioo8AWyILBb 99ydgUGLUDvWIFF881btNKfGS0t0MC/SBxjqERFPpLM4Ng0KSLjoYD0YP8q/QUoekEFf Hva+3LG0tTk7U6ChEB/DLKjc3QuhnjyFBTROXCTAcupWHeSIUPZXD6XE0P6uUiJ/M8C+ PSdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iSFN+b1l; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d126si5339487pgc.533.2022.01.17.19.19.02; Mon, 17 Jan 2022 19:19:15 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=iSFN+b1l; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343705AbiARC3M (ORCPT + 99 others); Mon, 17 Jan 2022 21:29:12 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:40436 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239994AbiARC1C (ORCPT ); Mon, 17 Jan 2022 21:27:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CBCBB81232; Tue, 18 Jan 2022 02:27:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7423AC36AE3; Tue, 18 Jan 2022 02:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472819; bh=I1V/IFg+vIvu92mF4fyATCy5Y+5SKhi/PFtWjx0XmD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iSFN+b1lLjiwOHxCBjHLqLNui1ULIlNsizdPhN1fEmX9zl2Y1Vy7QyJs2VZAyjOfC 6D259GlBhQmvBGDJoqq5luWK4l8JDTzhjOr61jSD+OldXvmHCLjsKAiaKVyjepFyDw h0V1tzFX0LPPfuq0orfNzVD5KRSnm2RvLpDFHk/w45RaumYVvHzqxC3Izbv4UnzfrC onUen+AE/ptKjXJA1t30oF7fUYMyKN16IxV9CBz13ZDNl8UOcgWnRB9azJUA945nAf FTgmcIS77Fg/06tcvevFL63b4WOLNmnlVouXE2t7jMbFW3SLeHIijY8aWDZqCjhcsh exzi74DObR2Bw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jingwen Chen , Horace Chen , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, Hawking.Zhang@amd.com, ray.huang@amd.com, Felix.Kuehling@amd.com, Jack.Gui@amd.com, PengJu.Zhou@amd.com, Philip.Yang@amd.com, Yuliang.Shi@amd.com, Xiaomeng.Hou@amd.com, aaron.liu@amd.com, victor.skvortsov@amd.com, John.Clements@amd.com, Oak.Zeng@amd.com, alex.sierra@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.16 141/217] drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV Date: Mon, 17 Jan 2022 21:18:24 -0500 Message-Id: <20220118021940.1942199-141-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jingwen Chen [ Upstream commit 948e7ce01413b71395723aaf846015062aea3a43 ] [Why] gmc bo will be pinned during loading amdgpu and reset in SRIOV while only unpinned in unload amdgpu [How] add amdgpu_in_reset and sriov judgement to skip pin bo v2: fix wrong judgement Signed-off-by: Jingwen Chen Reviewed-by: Horace Chen Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c index 3ec5ff5a6dbe6..61ec6145bbb16 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c @@ -992,10 +992,14 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev) return -EINVAL; } + if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev)) + goto skip_pin_bo; + r = amdgpu_gart_table_vram_pin(adev); if (r) return r; +skip_pin_bo: r = adev->gfxhub.funcs->gart_enable(adev); if (r) return r; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index d84523cf5f759..4420c264c554c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -1714,10 +1714,14 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev) return -EINVAL; } + if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev)) + goto skip_pin_bo; + r = amdgpu_gart_table_vram_pin(adev); if (r) return r; +skip_pin_bo: r = adev->gfxhub.funcs->gart_enable(adev); if (r) return r; -- 2.34.1