Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp254564lqr; Wed, 5 Jun 2024 05:20:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxMrAFmLQgKZlzo03ouSf+shLowFPF2aJGqad/kx0v2neZBrkLIjqf3sRp42E6nHpSiVmVnpIdU7Q93rM2whg/nb0NGY09OtTCdRACzw== X-Google-Smtp-Source: AGHT+IGBBWWDkQ74um0Wlbvm8WfH76xBCcrwlV7t2D+QaZXpIkVbg7r2ZjriVo2wWktAn/VBKAxe X-Received: by 2002:a81:4e05:0:b0:627:cfa3:bde5 with SMTP id 00721157ae682-62cbb62a4ffmr22504477b3.44.1717590015377; Wed, 05 Jun 2024 05:20:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717590015; cv=pass; d=google.com; s=arc-20160816; b=qTrLennR/vH1QzoHzp9GULU0Kh7pxhZUSkH1OwHTp2rlAl3Q2WKjD7yV2gdc6yGVg6 Ib8/iRBGZBUlP0xBMsRVIk6Lmzo4C3asfBxltTTfGDJewTwSB03wdg3MQ4kGS8LpYIW5 6dIfwhWTaZOzgZFigp/sXm3DZoWjmJXyFMOklj39v3/QtSdDauLLOeE2y3iL2qNhJlfH UpckmrwVk9vvmkarnJa4FMtGbTCJTYA0rQAfPrpOZnuh+LyhvmwHZeNla1UGqjR6guPE zSH5j7Q8rHILzbXKIYDfN1L5IFmZQQ9xkmqOeoy66SL13wJxfV5Dd8Lyrz/AdUohPb8w SuZw== 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=afsfjGmHO0r/08M8mKrFwS2VQ+0/JoKN0POuzCpk7gI=; fh=v9wq7dboZ64jWyee73s7vUomL3rRsBGzKDtJ69Ug7KI=; b=yGPUTGKm/uYlnLsGG+jZZdZIgPgRNb58Wvm2nUkE19AfQ5AklXNIZcdDLWXhzIxV+2 k/2Qit/W2dlMnhMaTHPJFHOwW+xD1a6/bY7JzOO9u5+kbBBnmEawNTQyGrTGqP932Xm8 aHoSXzJtGX8B4NaaOjIfsKZ+hiQrU0kp0XyKumVB8JqtnaHGoFcbJVfiA9HXQSh9Fr/L YAyhZ7RPxXnEiA4CgbAO6tR8WIHrmKCgvLchwcKvAb3ZZh3pnHKHuhmikLGd9BVAvoJY v/Xa2XKOiZ9FIFDT9dsvFY7a+ysD7oNVRABC/elcCvhA8zyPYZzXAKRjLds8zMtVjHQb 7sBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ApGyFYRE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202420-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 6a1803df08f44-6ae4b4150f7si135151786d6.360.2024.06.05.05.20.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202420-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=ApGyFYRE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202420-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 1A7DE1C20BC0 for ; Wed, 5 Jun 2024 12:20:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AE911B5811; Wed, 5 Jun 2024 11:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ApGyFYRE" 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 50DBB19A296; Wed, 5 Jun 2024 11:55:50 +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=1717588550; cv=none; b=YtaABt3age6IMV374r6G+o9Eb4YNY2P4xRmrvP4a8Zn5Pba1u7X0ZnShW/oDLc+/CAKGBJxnDAPowF3x8weyfY+ynRSH2HDjMtFMaKdv62FSnpjpx6+EkaIhX/lSv9rcomF2GHyLJrHHOQpibhFMajFeCCRt4kqxeApAJ7hxLzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588550; c=relaxed/simple; bh=r/TxFmQurUNkYZX6dPJDl9HeZ5o1sG+vL2h0tXP5DPM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nJPNfWWHKlk2NRvm4BdLDx6nHdd/BD607sgliUradPj6lpTPwjBix4bybobiSXr+0jzwC/Rbp9mtzka/SIKWnoSSKt2Rizw+aimGIw1uQuclW+W8luW+jTQrFtRmlNFVntu1DGdT2/EbR6veDOJWYvgsTD+H6b0AHDkgL4D85RU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ApGyFYRE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3471C3277B; Wed, 5 Jun 2024 11:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588550; bh=r/TxFmQurUNkYZX6dPJDl9HeZ5o1sG+vL2h0tXP5DPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApGyFYREVTOQ1wBNAogya5DIcSFe+xrF7mCFbs7tNnBqkL8PQjgoIWqANKT2whnaY VQcIyvREU3fyEr8FyXoMGO/RbnTrlKcX1msLEolRHcV6+MEYW2xvfq8KGyiKdQzBZS Q5By3DlhFdwXXK5ExVA2kXkd6Xs14Gk6NW6YcbVH92vlJJjrQYJCCxll/ggs/VRQBr 7+AxfLWFoIYv0cyLEo0+rNMRNHTwiJ+XdkJzJT41KWtYxfapkWycUrj5SN+wPGTtdS EefAfZy0aZOpDuiuG8q3Nt52LdAhicoD7rPjmGcajN7YzpIfpKtSMaA79I9eXy1b88 gnWrUvLsdv+mQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lang Yu , Felix Kuehling , Alex Deucher , Sasha Levin , Felix.Kuehling@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.9 3/6] drm/amdkfd: handle duplicate BOs in reserve_bo_and_cond_vms Date: Wed, 5 Jun 2024 07:55:38 -0400 Message-ID: <20240605115545.2964850-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605115545.2964850-1-sashal@kernel.org> References: <20240605115545.2964850-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.9.3 Content-Transfer-Encoding: 8bit From: Lang Yu [ Upstream commit 2a705f3e49d20b59cd9e5cc3061b2d92ebe1e5f0 ] Observed on gfx8 ASIC where KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM is used. Two attachments use the same VM, root PD would be locked twice. [ 57.910418] Call Trace: [ 57.793726] ? reserve_bo_and_cond_vms+0x111/0x1c0 [amdgpu] [ 57.793820] amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu+0x6c/0x1c0 [amdgpu] [ 57.793923] ? idr_get_next_ul+0xbe/0x100 [ 57.793933] kfd_process_device_free_bos+0x7e/0xf0 [amdgpu] [ 57.794041] kfd_process_wq_release+0x2ae/0x3c0 [amdgpu] [ 57.794141] ? process_scheduled_works+0x29c/0x580 [ 57.794147] process_scheduled_works+0x303/0x580 [ 57.794157] ? __pfx_worker_thread+0x10/0x10 [ 57.794160] worker_thread+0x1a2/0x370 [ 57.794165] ? __pfx_worker_thread+0x10/0x10 [ 57.794167] kthread+0x11b/0x150 [ 57.794172] ? __pfx_kthread+0x10/0x10 [ 57.794177] ret_from_fork+0x3d/0x60 [ 57.794181] ? __pfx_kthread+0x10/0x10 [ 57.794184] ret_from_fork_asm+0x1b/0x30 Signed-off-by: Lang Yu Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index e4d4e55c08ad5..0535b07987d9d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1188,7 +1188,8 @@ static int reserve_bo_and_cond_vms(struct kgd_mem *mem, int ret; ctx->sync = &mem->sync; - drm_exec_init(&ctx->exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); + drm_exec_init(&ctx->exec, DRM_EXEC_INTERRUPTIBLE_WAIT | + DRM_EXEC_IGNORE_DUPLICATES, 0); drm_exec_until_all_locked(&ctx->exec) { ctx->n_vms = 0; list_for_each_entry(entry, &mem->attachments, list) { -- 2.43.0