Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2483270pxj; Mon, 10 May 2021 04:11:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB3RHNuLWp6m0ZWOjCeAFhLZjdRaQgDeysHpOMx3zLt4iXXWotHGe60T01RC+q+TdGyvv8 X-Received: by 2002:aa7:c610:: with SMTP id h16mr28348593edq.202.1620645072567; Mon, 10 May 2021 04:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645072; cv=none; d=google.com; s=arc-20160816; b=hWbg3owm5kUEgUMvnz72sWzsgM8GzdtVoto2z23/icwRi4wpoT29MHRmtXRBaliVoy JKykGlqN4c8eauOTXlTae+TAyGViIRdjov4f6ccXo/QxWfCwF2g6ZyDpTvCzCvgJALsn CDPSTPtHQwYezKK0f4Mt3oqWBjJlMo6gBnlvgSKfpVwBRWhVHzOIsVYWlbDvrf0p7WLk zh0tEVvw4X+Aa5+AjmnGUKm7uVB8yi0NlI9jS0LcZrzS6tzwvlADPcVNFFw3TYvXelPv efoB7bzt4Acj0aHBHHJ+jop4qt7eUzGrvVD02/tZ1uYKFDpSYnpxZh+JddT9O0Gp3M+K ZGOQ== 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=Rl1TqGytY+uveY4Uml+UdLOfDr6qGTZwrZ31lGIQmJI=; b=01GL+r7uEsOh8v+xPBZY23uLbtdD8p65z8mN3YGhAHqzBzM2R0ebWQgin9FF4Dun+v 3Dcm9XwDT8q4V3amgfc4OOwcIzTX+8zU6ovxFrI+vcpZE07+pBG7hMjRyGBw1VgiM06W nk5+IMGFTm5sxVRDuIyY78mOtGONs+mWiMta5YAkcNGu1vLfA8fKK41jYXBZxu1G02qF xTjfEIFgT783UmmTlqhZpxt74GU4W54On7BORgr7ZCj2TcQHSyGxDD96diO/KjY3k6OP n3QSj8TgDFncfAzMjZT9AVmVmpQ8E4/VnV3my7026L3iK3/nyFOK2IrS5u0JGdRWPH+W VKuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hIOoqqQh; 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 pg16si12341186ejb.269.2021.05.10.04.10.48; Mon, 10 May 2021 04:11:12 -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=@linuxfoundation.org header.s=korg header.b=hIOoqqQh; 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 S236371AbhEJLH4 (ORCPT + 99 others); Mon, 10 May 2021 07:07:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:33618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232270AbhEJKrp (ORCPT ); Mon, 10 May 2021 06:47:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 237CE619B2; Mon, 10 May 2021 10:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643057; bh=Lw6vE4UcBrY7WNNZ9dvZ6+mazSAp9vuX80l+b5VsBCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIOoqqQhzFFC4JdE08I7lHIlcNd2Oo9JOdIeM0C1Ub7OyxcQ0zJY9ZYjNcbiKQSm6 lzn5nIyIP/QWQGnt2p/iSx8htXKIEMe8Lm0jDpFkuK+q+5qWDt5Bx8gFDybDsH0RXW ufR9p9Z7wF2WODcBKLbjyACoEVwlYUwBcQ2ge3HA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emily Deng , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 125/299] drm/amdgpu: Fix some unload driver issues Date: Mon, 10 May 2021 12:18:42 +0200 Message-Id: <20210510102009.105715197@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Emily Deng [ Upstream commit bb0cd09be45ea457f25fdcbcb3d6cf2230f26c46 ] When unloading driver after killing some applications, it will hit sdma flush tlb job timeout which is called by ttm_bo_delay_delete. So to avoid the job submit after fence driver fini, call ttm_bo_lock_delayed_workqueue before fence driver fini. And also put drm_sched_fini before waiting fence. Signed-off-by: Emily Deng Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 76d10f1c579b..7f2689d4b86d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3551,6 +3551,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) { dev_info(adev->dev, "amdgpu: finishing device.\n"); flush_delayed_work(&adev->delayed_init_work); + ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); adev->shutdown = true; kfree(adev->pci_state); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index fe2d495d08ab..d07c458c0bed 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -532,6 +532,8 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) if (!ring || !ring->fence_drv.initialized) continue; + if (!ring->no_scheduler) + drm_sched_fini(&ring->sched); r = amdgpu_fence_wait_empty(ring); if (r) { /* no need to trigger GPU reset as we are unloading */ @@ -540,8 +542,7 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) if (ring->fence_drv.irq_src) amdgpu_irq_put(adev, ring->fence_drv.irq_src, ring->fence_drv.irq_type); - if (!ring->no_scheduler) - drm_sched_fini(&ring->sched); + del_timer_sync(&ring->fence_drv.fallback_timer); for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) dma_fence_put(ring->fence_drv.fences[j]); -- 2.30.2