Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2860238lqz; Wed, 3 Apr 2024 10:30:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdIiYd28gWgS00UL12jHjPe5MUmTjCeKkkh0cDAl2T9MKpeiPXiCmQUzEbs30xOWQhupiExNjVqglqvy7tYxKVdxYj1lXJShqAf5iF0A== X-Google-Smtp-Source: AGHT+IEpSJqWE5kmVWN8lL53DpfxjkKq7650K9LbY8WV0U5aL9f2ulECrONdJw4CSfPx9cennYy/ X-Received: by 2002:ad4:45a3:0:b0:690:b2c3:bfd0 with SMTP id y3-20020ad445a3000000b00690b2c3bfd0mr2924619qvu.57.1712165404185; Wed, 03 Apr 2024 10:30:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712165404; cv=pass; d=google.com; s=arc-20160816; b=Xp+rt9MAHW1OS0Rk3inM1LlMvIhBD5lZRAHOPKqH6kET4hek+SfClD7V/nDcwTIzfG KJn/hrrfbD7soMMgYICkcL6upjVFHAUgwgVfB7u+veTN3P+pONm9TxfkLpGgjbqfEVi7 t23c6MCya2UpAwd0P2VB94OcQ8XVxdnQWJahOt+TPk6aSB8FSlWasom+9PH2tdBqDyqV TBZT+8i+T0lu0pJln0q+FjtjSMoXVHUkG3sCFuT6+iohxj/2Lm9YdnXxMr/Qx88OXbNu 6QvoWC1jZueXC/o/mG10TVe28bXGvaBTK6N/hzbkekbtQjhsgsGu0oqnQCdnbqZUj+Od PxHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3VtYIzve2icaSgEJ0h9bNu7PTV5UEm4qQiIoFa7vXp8=; fh=8EivfXKkHdNGPilbvAm8k+8kY0azW7iyRIVl/Nww6q8=; b=q5rpyH+PwJj5KOhjQPPmHunbF5so7QpBWMarAw9PD/3Og/OVP2uWuas9Hvph+n8X3o jJaEssWBstdKK+Vm+KMZBS5Ua3nDtHkIODUhdF0YDFZ2UZjDEZ39F7nE9GgsP+mqVb5M FVQOeVqSTLaD8CeMjJ8lddN5wVtSKOc/cKb2yX2hWBcc5sHYRzK1jGs7lgr8GWy6k18s CElEnyXvDtzkyasAEXgOFoOOwY5mQ8hxiwmEVozN2Ggbmuj/y4qPPXQHMyg1RPNY/aHK KZr8K44GC9+CjcaSvivFhjptq/Tj54sNOSFrhBkVjj0zgE4XL/kjg8PfBrytZ5qi1Mlc aSDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dVyzG2/j"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130302-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ee1-20020a0562140a4100b0069928b75dc7si1685233qvb.347.2024.04.03.10.30.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 10:30:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130302-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dVyzG2/j"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130302-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4595E1C2117B for ; Wed, 3 Apr 2024 17:27:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5799D158A1F; Wed, 3 Apr 2024 17:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dVyzG2/j" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E210158A11; Wed, 3 Apr 2024 17:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712164678; cv=none; b=i+o/UStcMmj7CZGN+pVqkpV5vpYOfKW8yBM3XDVfPe4mbhgh8VYkjMpkrztaggrbTj6nUIsczlTCnVcwd1ki7WZ6k9BdkVej+i+ahe6D7yZR525PPq7rxztPtkZLcNGSj8VLXuZbfQUF/xtR4HJvo1Oe+TtrZOv/bbUVmKOznR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712164678; c=relaxed/simple; bh=vNzntSBU+b6TfbGOfyJBQ1n0n6FBTCdqcV6dpTvL1f8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RRdzFWlUUOvIcbZZYRl3lSTwhOzTaQ+5DJhyUc7dADUxfk+2A7Nq4uNemkI7O4VmY6gTJbJisIa1V5bf0RPvWvp0R+GjxAVSBHEzPHqGO5zP9hLSkeyW+qh3IMcf6MejIEWhxUm/QNOMweL+iqU+hNEMA5siNllnusN7D6l+ppM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dVyzG2/j; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D505C433C7; Wed, 3 Apr 2024 17:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712164678; bh=vNzntSBU+b6TfbGOfyJBQ1n0n6FBTCdqcV6dpTvL1f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVyzG2/jt/yjTVatHeGAd6vMH2yKsa3v7qx7Z/E3HvTlLEpGRDNgsPqSjBLn2WdJX afa0ZXTbQxTCrt5BWRJfiTbvLSRANCy3PbHbLtk77t//sps/BipNU08Q4jRhW39lYb 9dRh8WE8x5HDrmbJexcCdFfgfaDSVFQXhhEJQPK8YzW8NnuSRQw1M5gLP5BiU555yC 1KG2A8GouBX8nh+LVBaDv9uuud709dekT+M+ISP3mIWF6q+6O0Jyh3hwIQAYoIHZFa 7Z+KbRP+yQvMJw5/i150fdM2v5MP+PdwvUlMXunBLLRul8pM3pYW6cqpWGXebXevjU N/Bts6Ns0i7GQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ahmad Rehman , Felix Kuehling , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, mario.limonciello@amd.com, lijo.lazar@amd.com, le.ma@amd.com, srinivasan.shanmugam@amd.com, andrealmeid@igalia.com, Jun.Ma2@amd.com, James.Zhu@amd.com, hamza.mahfooz@amd.com, aurabindo.pillai@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.8 28/28] drm/amdgpu: Init zone device and drm client after mode-1 reset on reload Date: Wed, 3 Apr 2024 13:16:30 -0400 Message-ID: <20240403171656.335224-28-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240403171656.335224-1-sashal@kernel.org> References: <20240403171656.335224-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.3 Content-Transfer-Encoding: 8bit From: Ahmad Rehman [ Upstream commit f679fd6057fbf5ab34aaee28d58b7f81af0cbf48 ] In passthrough environment, when amdgpu is reloaded after unload, mode-1 is triggered after initializing the necessary IPs, That init does not include KFD, and KFD init waits until the reset is completed. KFD init is called in the reset handler, but in this case, the zone device and drm client is not initialized, causing app to create kernel panic. v2: Removing the init KFD condition from amdgpu_amdkfd_drm_client_create. As the previous version has the potential of creating DRM client twice. v3: v2 patch results in SDMA engine hung as DRM open causes VM clear to SDMA before SDMA init. Adding the condition to in drm client creation, on top of v1, to guard against drm client creation call multiple times. Signed-off-by: Ahmad Rehman Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 41db030ddc4ee..131983ed43465 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -146,7 +146,7 @@ int amdgpu_amdkfd_drm_client_create(struct amdgpu_device *adev) { int ret; - if (!adev->kfd.init_complete) + if (!adev->kfd.init_complete || adev->kfd.client.dev) return 0; ret = drm_client_init(&adev->ddev, &adev->kfd.client, "kfd", diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 586f4d03039df..64b1bb2404242 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2451,8 +2451,11 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work) } for (i = 0; i < mgpu_info.num_dgpu; i++) { adev = mgpu_info.gpu_ins[i].adev; - if (!adev->kfd.init_complete) + if (!adev->kfd.init_complete) { + kgd2kfd_init_zone_device(adev); amdgpu_amdkfd_device_init(adev); + amdgpu_amdkfd_drm_client_create(adev); + } amdgpu_ttm_set_buffer_funcs_status(adev, true); } } -- 2.43.0