Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3715729pxb; Mon, 24 Jan 2022 16:09:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ5eh4sPkuO/zYTO0yxfEligay0ESarFMel1zGeeDZOG8ANhfPufiDvFpq1CDniUpQ3r01 X-Received: by 2002:a17:90a:8548:: with SMTP id a8mr774817pjw.126.1643069371766; Mon, 24 Jan 2022 16:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069371; cv=none; d=google.com; s=arc-20160816; b=c5yXpLzI8QmKluupGQQu4GK8vUDl6eaTQ/wTzw/M3wnDNDR1pXmRa2MDhyOfOpS2Pe 38/caoPUHz+hveHv3Sfjes2FHKfoSMND+2ukx56jrq5f+dkdClhVGnAYtyHrApRKrQZy qG4OY7DSFsin4V47Lf9f6mCDU5D1bhgpUbeyRHnYFAlW5ob5yL1fQxUEBuwHSSIQBJTd la+Taz9a9Y8ji39eBbLsN83qWYfutfkQiZ7MrmoQPbM1tmG3ihuut4dxvkXhIAUG6l2D qo2KUxA7vaC483v1qHPB+ilA+K8GPm/J63co04+aiOZInfMBe246e4u91wdjjkEpgHLY Jnsw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f8n8n07ZyVL5anydBLybfp8z1uX8bLQv7DiNx1h+5V4=; b=tm0tdWGL2Wdv+p+LxM5TawI7Zi+nwFHB/qqTbr/F6U2GsH7aaCHUN19Yh90fM6UxCC SNYuTqOcKTIg19/r+ctzDW7/gEN+KeSNQQyR1dfNzGNYo9DfNUyF2vEjr7OWCbTN2dsH Ezh88WLKDdbLxoeMZXpL6kohkf6WO2QVxl1duNCLEa32X3tsf2SZql+u9NpZd/4iYjG3 brIz2R5eMjbDD+Sjw0iDwjlyCj63CPtzj6HvxZS/o86yrgYpolvUjKrmofGujmUAXRQX UmzViMXsf3/v1j0JnS8uaGPt/qefIFu9pSGG7u531XyGjmbCL6LcVc9rJn03O0l8DGcm EvPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PW9BXlYf; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si13526064pgo.616.2022.01.24.16.09.19; Mon, 24 Jan 2022 16:09:31 -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=@linuxfoundation.org header.s=korg header.b=PW9BXlYf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2370717AbiAYAGB (ORCPT + 99 others); Mon, 24 Jan 2022 19:06:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1847527AbiAXXUA (ORCPT ); Mon, 24 Jan 2022 18:20:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40850C08E8AC; Mon, 24 Jan 2022 13:27:48 -0800 (PST) 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 F2C72B81257; Mon, 24 Jan 2022 21:27:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2492EC340E4; Mon, 24 Jan 2022 21:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059665; bh=I1V/IFg+vIvu92mF4fyATCy5Y+5SKhi/PFtWjx0XmD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PW9BXlYfoRcCqRYVO80Go9uCV5fX/SaW4b4DEGFGTihZZ6cZaoeg6+zMDiiCvNr4B O5M7N0isTqRZb8C3Kwv5y3CJGK99Z61VPoETuYXUTDnLqRCFAnSEf8R2Y21OW/ZmJo nqBM0g8klskmJfFcdulaLzs9LUlDWdxmSaX52UV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jingwen Chen , Horace Chen , Alex Deucher , Sasha Levin Subject: [PATCH 5.16 0659/1039] drm/amd/amdgpu: fix gmc bo pin count leak in SRIOV Date: Mon, 24 Jan 2022 19:40:48 +0100 Message-Id: <20220124184147.516227710@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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