Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp875204pxk; Thu, 17 Sep 2020 20:00:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2d5+68U1YLCMt2HGzjtDuHcKFGWhelpJG/AdHoVD77OsibBvZo5CgVkA0x8aZ0X189HFV X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr32768702ejw.506.1600398047090; Thu, 17 Sep 2020 20:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398047; cv=none; d=google.com; s=arc-20160816; b=mC8G4wHiRI4POvexqvmatRXliTRMOMYppHdVzkHKfYUB+kWXljCV/y8AVJmQrcmBV9 XPihG7havZkskcoHsjqj7ulzT/Eh8rh84fB2fo5A4KUmEjLhQ/JzBJQY5QDcSRXSOIn3 HYA/njC0FwgqRmvNPtGO7I2tj5koH7cWRdXFmoz0jhqPcz77ZtmVE41rzhANf9lMcrg8 aQG3x7jgUhgJyxIT74w1b9LrcbMdVuqmjTvti2Usweb02MYll8KvKbPbr66Q0L+YEcmA 1CaedwlzXSdUBtCy7wxB8cARuD6VgiSJEDdYUmkBgmGN6tHAB+eHK8yYksg/+Mdg4Nlk yKFA== 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=yKl4dWh7lhP7IHYiXgw1IPZG86hlIrl+WTgb3DB5UDI=; b=uhtQ7pQ732vEgkgqMAgni+9JqewyUDQLT1eGetc87197tFvRBlJ07sQ6BpQzKyBHjm yrMq3QqCAHZIeTw8tXc8c3Q4ci9g4j1MP8ugZ9BfHkGcw5Vyrg5jfzYCG8zWKzGNBJ1+ COgh01M8Mj7HkyBMR3jDzCOvg8ooi4SbVe2gY9TPDBTU4aUaeWIG9O97imVZXHALXlBI dFC1Yirff3+YbSzrpblyRkk2mi9kVkFUQuBN/z6yg4Uz0rmGv71QRT5XyuRBnEYoP/As o7KcOtVdwJe9hPRrt3jhsnKUDUIpw5ikZbtoKw2KOAXR2aLT7r7ZiMGbSKBXqOypaKoA Kt3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ykbfgYFy; 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 f18si1141295edm.539.2020.09.17.20.00.23; Thu, 17 Sep 2020 20:00:47 -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=ykbfgYFy; 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 S1730382AbgIRC4j (ORCPT + 99 others); Thu, 17 Sep 2020 22:56:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:57128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726928AbgIRCHF (ORCPT ); Thu, 17 Sep 2020 22:07:05 -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 749EA239E5; Fri, 18 Sep 2020 02:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394812; bh=ZZNJK65ntMv3itHnvKIAkX4hgmrikXv/Ak/qwIrHRzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ykbfgYFye76ZD58NhLWPmz1KEC8nZ1SMLcrLQN/G3n4ZzfJFMhBstuwxFrax1oCs0 +ljBDbB4ENsZqmfiGf3LImKukxrsQxKl8gxnLMxojVUOW3t1Z2lZHARq8iiGkL6unU vVURt9VgBmR+fPICBLKL4yck+CfC9K0Kz4PsnujY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Philip Yang , Felix Kuehling , Alex Deucher , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 279/330] drm/amdkfd: fix restore worker race condition Date: Thu, 17 Sep 2020 22:00:19 -0400 Message-Id: <20200918020110.2063155-279-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: Philip Yang [ Upstream commit f7646585a30ed8ef5ab300d4dc3b0c1d6afbe71d ] In free memory of gpu path, remove bo from validate_list to make sure restore worker don't access the BO any more, then unregister bo MMU interval notifier. Otherwise, the restore worker will crash in the middle of validating BO user pages if MMU interval notifer is gone. Signed-off-by: Philip Yang Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index edb561baf8b90..f3fa271e3394c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1247,15 +1247,15 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( * be freed anyway */ - /* No more MMU notifiers */ - amdgpu_mn_unregister(mem->bo); - /* Make sure restore workers don't access the BO any more */ bo_list_entry = &mem->validate_list; mutex_lock(&process_info->lock); list_del(&bo_list_entry->head); mutex_unlock(&process_info->lock); + /* No more MMU notifiers */ + amdgpu_mn_unregister(mem->bo); + ret = reserve_bo_and_cond_vms(mem, NULL, BO_VM_ALL, &ctx); if (unlikely(ret)) return ret; -- 2.25.1