Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853448pxk; Thu, 17 Sep 2020 19:08:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEQheE3SJaXj3Pik2L7ujbAoT38mObWNrKwu5cZp408m8ph37KR2pgJL1e2DOjpQj83xq5 X-Received: by 2002:aa7:dcc1:: with SMTP id w1mr34887200edu.360.1600394908176; Thu, 17 Sep 2020 19:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394908; cv=none; d=google.com; s=arc-20160816; b=cS+NWB9QaSr+MFHAF7+E3dDHd+HbnjITXasLYvz5m9u5FOGhM9RjgL5fcC5zB7UohH Aru0iKn8+hbVT+wt6Pw9rTihRuXmd1t3p16V2yYPM8HOE6AUEYlWyPJ42+gUH/219Khv rgvjup6iQeRMCgEb42xn4dvK0kT272Fj+xZucOpUKzTIsYwFfnRGfwgP3/pJxNm3HqGz s3V/Ze8SAVw4Jsnw1JXxjnJfEKiie6f+2C+/Z3/YjnJQcg/6uGE/6g3Xk33k3PsFuy4p yEUwSwXynypRj2yiIzimCmgSPuU55JEFazmDE7gaOES2f7TCgPDyjiAseocm2bqvuXUC cvsA== 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=Dvr18SYmON6QDlQqhWYV7cMtR53ZL+cKcMVxG0rFZjI=; b=SfKrx3rFdb5FZGJlJS4fQuaynLpc7+itKpsfVM7k7nPYrB9L2VF8dq32p6nWrTwCCG QnlJV8cxYoyLhM66O0z1z3sObvVSQbrDwoJkQHGpHAm3Vxq1o8f4OhZKZ8mNcZaS7q1Y vuISRXD4NG+Tb6F7oOXdMggInhioLlNPIc8fq8cisz3kGyUlFuS9Iqt9+KjSGJMNhzsz Gxjrd5OJ80g6M+q6Bs71AMZcjKnozeWIoVw7PKMtc5e17YxfwZxtY6+EbfzONeNWlfFQ KwR8boOZbvpnVTHz2lX61mHOIut9uoxahE9K5y0HmtKiI4FcJH7sE6+75mvOUdgpSd9J l/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Re3jG2nG; 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 bc11si1141774edb.532.2020.09.17.19.08.04; Thu, 17 Sep 2020 19:08:28 -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=@kernel.org header.s=default header.b=Re3jG2nG; 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 S1727689AbgIRCGA (ORCPT + 99 others); Thu, 17 Sep 2020 22:06:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbgIRCF4 (ORCPT ); Thu, 17 Sep 2020 22:05:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F06122388B; Fri, 18 Sep 2020 02:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394754; bh=9P09pX9CSmsoGNHoVEW3b11httRKm6P+siZpoeibr/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Re3jG2nGHOTwgjJ690a6isM6VaYZuoTHURWoj2KY4AXByI2RJyDI82gC7tG5SH4mh 97dbEAcBINRH+XN0d+1/LNtnz5N6vbqBBeQmklL4UTYTuAsXIGX3qCqoCitrJwSMIn lO3SPlfKcdxrU/11TZ/D2w2ncUhdMiRpNIdI6fN0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jack Zhang , Monk Liu , Alex Deucher , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 232/330] drm/amdgpu/sriov add amdgpu_amdkfd_pre_reset in gpu reset Date: Thu, 17 Sep 2020 21:59:32 -0400 Message-Id: <20200918020110.2063155-232-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-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: Jack Zhang [ Upstream commit 04bef61e5da18c2b301c629a209ccdba4d4c6fbb ] kfd_pre_reset will free mem_objs allocated by kfd_gtt_sa_allocate Without this change, sriov tdr code path will never free those allocated memories and get memory leak. v2:add a bugfix for kiq ring test fail Signed-off-by: Jack Zhang Reviewed-by: Monk Liu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c index d10f483f5e273..ce30d4e8bf25f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c @@ -644,6 +644,9 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t temp; struct v10_compute_mqd *m = get_mqd(mqd); + if (amdgpu_sriov_vf(adev) && adev->in_gpu_reset) + return 0; + #if 0 unsigned long flags; int retry; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index e262f2ac07a35..92754cfb98086 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c @@ -540,6 +540,9 @@ int kgd_gfx_v9_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t temp; struct v9_mqd *m = get_mqd(mqd); + if (amdgpu_sriov_vf(adev) && adev->in_gpu_reset) + return 0; + if (adev->in_gpu_reset) return -EIO; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 5e1dce4241547..4105fbf571674 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3466,6 +3466,8 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev, if (r) return r; + amdgpu_amdkfd_pre_reset(adev); + /* Resume IP prior to SMC */ r = amdgpu_device_ip_reinit_early_sriov(adev); if (r) -- 2.25.1