Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796069371; b=gEAMKHlJfXx0AtGSAcf/oOQCP9aHLGfiQ2pZM64djsEwnf76MpP8umUfoaRzUMppdnzC tpug3qFhRMgxIc2voXasHAnmChKawAJe7hRfNYAr3RrhAHTRf8ioE4EDdGD25s42KayN3 a0ngS+LcSmvS0RddnarGS/5VzbikEF4uXltHSY4A74YPWVHlBThOSYw043vjHNLuyQSxo ge//P5cvarjfY4oJkazJXiRRkQs8Vg5LerQDi5IHP3fj4ue256+4+8sFwUQHWcNmxbQQG K14PIKwV6ptF0kLDyFTXgn5OJApCZLLoFoNX5/kYm/T01rRo1P0U4bo/5DrTBp2vnJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796069371; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ykLYZMCgjVfKr/znoK3gjHoefwaZojf4rWILOI7PYGg=; b=0XRF//lK7OnrRsQjF4Bxtw858yiVqUjj9hGaHKMy/Ur9qNeqx9/GebHsWwpKb2m98/mc WFDA21QOP0pGsWCPagjNImh/L7+U1qBBwqokw+fVoqvLdwjUYY6ax9VrdawVC6Hcvu6E1 NI7Yv7r/vZmdT7INktjPR7QeO4fbMu/XveHuktOrymaPcjpbeCUrjwCWcJsJiIFs+D6d1 rwtzJyAG2GDdjhHC6iKSJUs0yA0kj21KyPvKPPBUL6ocuNzZq7mpeN/oUVY6ku9NMtC5x bg6dCAc2blAX55SGiBjyjMHPby7FS0YfBPySBc8kXaMA/6MMX5kVz0dfHHmrbJw290Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eWlEmFq7; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46E25606A320 for ; Mon, 30 Nov 2026 20:09:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eWlEmFq7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2304B1F00899; Mon, 30 Nov 2026 20:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796069370; bh=ykLYZMCgjVfKr/znoK3gjHoefwaZojf4rWILOI7PYGg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eWlEmFq73KFi/0FrhW/pLKyyGkqINKOE/z2TTUsOW7tNINznQ4Vky53Zk8npSiuhz 00fsH1JpijuxzrnDvo65aMqNol7xoTP0J+Q7Giib8mHioH2AdiG+6PlfeDzCUpEcco wz5SBiGa4BuFJlgW4vBospsboC17WdP8QwEq1fBOVhsu7Gul/zW33FloL5FLEuXtFL sv9T3Y1yxdatQ2zi60eGeZxENzUn2IKq7Y2suUimeFNFrnRdY6aa/wz+1I/337pp1N 1ybgim52IHWPVnuYUEwux5WITV+qSWgVeKwb6B+j/lAh4ahStgrXe4NbkQQxxB/x8c DBkuPKIPjsL0w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 10/10] dmaengine: idxd: test a queue under its lock before quiescing it Reply-To: sashiko-reviews@lists.linux.dev To: "Daniel Byrne" , dmaengine@vger.kernel.org Cc: vkoul@kernel.org, Frank.Li@kernel.org In-Reply-To: <20261130194721.1900266-11-daniel1.byrne@intel.com> References: <20261130194721.1900266-1-daniel1.byrne@intel.com> <20261130194721.1900266-11-daniel1.byrne@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 20:09:29 +0000 X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] dmaengine: idxd: deadlock on wq_lock vs cmd_done in idxd_wqs_quiesce() -- commit 36a9678a1a099380b2c088bef490159f8c968311 Author: Daniel Byrne dmaengine: idxd: test a queue under its lock before quiescing it This commit re-checks wq->state and wq->type under wq->wq_lock in idxd_wqs_quiesce() before calling __idxd_wq_quiesce(), while keeping the unlocked check ahead of mutex_lock(&wq->wq_lock). > diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c > index 4b827a3297564..4f3693fb7975d 100644 > --- a/drivers/dma/idxd/init.c > +++ b/drivers/dma/idxd/init.c > @@ -1242,8 +1242,26 @@ void idxd_wqs_quiesce(struct idxd_device *idxd) > =20 > for (i =3D 0; i < idxd->max_wqs; i++) { > wq =3D idxd->wqs[i]; > + /* > + * Skip a queue that does not read as an enabled kernel > + * queue without taking its lock. This runs in the thread > + * that completes the device commands, and the enable of a > + * kernel queue and a cdev open hold the lock of such a > + * queue while they wait for a command. An unbind holds the > + * lock of an enabled kernel queue across its commands, and > + * this waits behind it. > + */ > + if (wq->state !=3D IDXD_WQ_ENABLED || wq->type !=3D IDXD_WQT_KERNEL) > + continue; > + /* > + * Test again under the lock. The enable and the disable of > + * a queue hold it from end to end, so a queue that reads > + * enabled here has its reference. > + */ > + mutex_lock(&wq->wq_lock); > if (wq->state =3D=3D IDXD_WQ_ENABLED && wq->type =3D=3D IDXD_WQT_KERNE= L) > - idxd_wq_quiesce(wq); > + __idxd_wq_quiesce(wq); > + mutex_unlock(&wq->wq_lock); > } > } [Severity: Medium] Can idxd_misc_thread() still deadlock on wq->wq_lock against a command waiter in idxd_drv_enable_wq() or idxd_drv_disable_wq()? idxd_drv_enable_wq() sets wq->state =3D IDXD_WQ_ENABLED inside idxd_wq_enable() while wq->type is already IDXD_WQT_KERNEL, and then issues IDXD_CMD_REQUEST_INT_HANDLE via idxd_wq_request_irq() (and IDXD_CMD_DRAIN_WQ / IDXD_CMD_RESET_WQ on its err_map_portal unwind path) while still holding wq->wq_lock. Likewise, idxd_drv_disable_wq() holds wq->wq_lock on an enabled kernel queue while issuing drain and reset commands. Because those commands wait in idxd_cmd_exec() for idxd_misc_thread() to complete idxd->cmd_done, the unlocked filter does not skip the queue and idxd_misc_thread() blocks on wq->wq_lock before reaching the IDXD_INTC_CMD check: CPU0 CPU1 (idxd_misc_thread) idxd_drv_enable_wq() mutex_lock(&wq->wq_lock) idxd_wq_enable() wq->state =3D IDXD_WQ_ENABLED idxd_wq_request_irq() ... idxd_cmd_exec() idxd_halt() idxd_wqs_quiesce() mutex_lock(&wq->wq_lock) wait_for_completion(&done) <-- deadlock complete(idxd->cmd_done) (never reached) --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130194721.1900= 266-1-daniel1.byrne@intel.com?part=3D10