From nobody Sun May 24 20:33:10 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B729121B9F6 for ; Thu, 21 May 2026 12:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368142; cv=none; b=HeVmsXmX0MlehNbZPODER7HqhPDf9Keci0SVI1II36GkKlcYn9vcPl7mtR4wJJhr+z0+t1eS3n9fROqgoVWAyYqWECoXnIlfuhLo4U7Rc3FIzqaupDJx52cZlfT4GBVo8/2+L7zPn+AWTG0TJYKQkEcv+D7rFqUs9Tu+wCT27fU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779368142; c=relaxed/simple; bh=vNePoDgjXOXjfGfXwMagrex8hN96eOPf31HmJIjrXyo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=AI271v2DY/zWqZJsWaoD/2F/vFakBmjS1jcC6bibJSbyd/LXUTWMM0dabS977hUNBwBjO9RJ5p2SHxpR/+RX6/nwQhZTfY46h4/AYJEgm7iW05pK1M2BNpNJ5kO+OjcKyVj4c5dQ632Q1Uo6Pgl/Jq54Guibb+/s0N12t2BeUpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W3tcpBQc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W3tcpBQc" Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 79CE91F00A3C; Thu, 21 May 2026 12:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779368141; bh=LxGC1B7DAV1HdZqcMb7F/9K2fH3zWjguvwIMEgXj2es=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=W3tcpBQctoBmEWtjhxwuA0cIBfH8yIiZtsUSfyh3/cE9lsnHtVgly4zT/Ql/Dd00U 9i+R1r/q3bxE0RQy/Fk4DVr2ZyROnK11FbmFripRDdD+mdBZX8nancFGLQTWGRqnV2 tewSANC6jZIvC2rkUKOYMnr+uKtkwtQKYhZhSi6gT2wohQElrCUXk/rE3jE3Uo6JRH Tccy49lbV6VE+ElZhvkG+9mi2X2jlPCgrq7FAG6nBBipuagKSL4g214qwueSz34/8B hbnJT5tSvTf1tPV4Abx2ylKzWk0n5pzCebZVdYoF3hB34M8V96sbAYJsXKPCQEc8Xi 4IFjiqGAbfvcg== From: Thomas Gleixner To: Bert Karwatzki Cc: linux-kernel@vger.kernel.org, Alex Deucher , amd-gfx@lists.freedesktop.org, Felix Kuehling Subject: [PATCH] amd/amdkfd: Initialize kfd_dev::profiler lock early In-Reply-To: <878q9dvzh0.ffs@tglx> References: <20260520225245.2962-1-spasswolf@web.de> <4f548d61b2dd12e01f401ce4b8c865f238f7b23c.camel@web.de> <878q9dvzh0.ffs@tglx> Date: Thu, 21 May 2026 14:55:37 +0200 Message-ID: <87wlwwvs52.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bert reported the following lockdep splat: DEBUG_LOCKS_WARN_ON(lock->magic !=3D lock) WARNING: kernel/locking/mutex.c:625 at __mutex_lock+0x586/0x10c0, CPU#17: = (udev-worker)/331 RIP: 0010:__mutex_lock+0x58d/0x10c0 init_mqd+0x122/0x190 [amdgpu] init_mqd_hiq+0xd/0x20 [amdgpu] kq_initialize.constprop.0+0x2b8/0x370 [amdgpu] kernel_queue_init+0x3f/0x60 [amdgpu] pm_init+0x6b/0x100 [amdgpu] start_cpsch+0x1d6/0x270 [amdgpu] kgd2kfd_device_init.cold+0x7b9/0xa1a [amdgpu] amdgpu_amdkfd_device_init+0x190/0x260 [amdgpu] amdgpu_device_init.cold+0x1952/0x1c79 [amdgpu] amdgpu_driver_load_kms+0x14/0x80 [amdgpu] Some implementations of init_mqd() acquire kfd_dev->profile_lock, which is initialized in kgd2kfd_device_init() after init_mqd() was invoked via the above callchain. So init_mqd() tries to lock an uninitialized mutex. Move the initialization to the beginning of kgd2kfd_device_init() to cure that. Fixes: a789761de305 ("amd/amdkfd: Add kfd_ioctl_profiler to contain profile= r kernel driver changes") Reported-by: Bert Karwatzki Signed-off-by: Thomas Gleixner Cc: Benjamin Welton Closes: https://lore.kernel.org/lkml/4f548d61b2dd12e01f401ce4b8c865f238f7b2= 3c.camel@web.de/ --- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -744,6 +744,9 @@ bool kgd2kfd_device_init(struct kfd_dev KGD_ENGINE_SDMA1); kfd->shared_resources =3D *gpu_resources; =20 + kfd->profiler_process =3D NULL; + mutex_init(&kfd->profiler_lock); + kfd->num_nodes =3D amdgpu_xcp_get_num_xcp(kfd->adev->xcp_mgr); =20 if (kfd->num_nodes =3D=3D 0) { @@ -936,9 +939,6 @@ bool kgd2kfd_device_init(struct kfd_dev =20 svm_range_set_max_pages(kfd->adev); =20 - kfd->profiler_process =3D NULL; - mutex_init(&kfd->profiler_lock); - kfd->init_complete =3D true; dev_info(kfd_device, "added device %x:%x\n", kfd->adev->pdev->vendor, kfd->adev->pdev->device);