From: Frank Li <Frank.li@oss.nxp.com>
To: Daniel Byrne <daniel1.byrne@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>,
dmaengine@vger.kernel.org,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Dave Jiang <dave.jiang@intel.com>, Frank Li <Frank.Li@kernel.org>,
Dan Williams <djbw@kernel.org>, Ruoyu Wang <ruoyuw560@gmail.com>,
Zhejun Huang <zhejun_huang@linux.alibaba.com>,
Changyul Lee <lcy8047@gmail.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 3/4] dmaengine: idxd: unlink a channel under dma_list_mutex before removing it
Date: Mon, 30 Nov 2026 15:32:22 -0600 [thread overview]
Message-ID: <aw3rZp3Oz_ZsOZmn@SMW015318> (raw)
In-Reply-To: <20261130195203.1901143-4-daniel1.byrne@intel.com>
On Mon, Nov 30, 2026 at 11:52:02AM -0800, Daniel Byrne wrote:
> The unbind of a work queue unlinks its channel from the dma_device's
> channel list after the core has unregistered the channel, and without
> dma_list_mutex. A channel request walks that list under the mutex and
> may hand out any listed channel without a client, so it can still take a
> channel whose sysfs device is gone and whose idxd_chan the unbind is
> about to free, and the unlocked list_del() races the locked link of
> another queue's channel. The quiesce that precedes the unregistration
> kills the queue's submissions, not the channel's presence on the list.
>
> Add dma_async_device_channel_remove(), the counterpart of
> dma_async_device_channel_add(). It unlinks the channel under the mutex
> first and unregisters it afterwards, which the core can do and the
> driver cannot, since the mutex is private to it. Use it in the unbind.
> After the locked unlink no walker under the mutex finds the channel.
>
> A client that took the channel between the quiesce and the unlink still
> holds idxd_chan across the kfree(). This is a broader lifetime problem
> of a channel unbound under its clients, and is left for the change that
> reworks the unbind for channels that clients still hold.
>
> Fixes: 397862855619 ("dmaengine: idxd: fix dma device lifetime")
> Cc: stable@vger.kernel.org # 5.13+
> Signed-off-by: Daniel Byrne <daniel1.byrne@intel.com>
> ---
> New in v2.
>
> drivers/dma/dmaengine.c | 26 ++++++++++++++++++++++++++
> drivers/dma/dmaengine.h | 2 ++
combine dma_async_device_channel_remove() and _add() to one prepare patch.
Frank
> drivers/dma/idxd/dma.c | 3 +--
> 3 files changed, 29 insertions(+), 2 deletions(-)
next prev parent reply other threads:[~2026-11-30 21:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 19:51 [PATCH v2 0/4] dmaengine: fixes for channels registered and removed at run time Daniel Byrne
2026-11-30 19:52 ` [PATCH v2 1/4] dmaengine: put a channel device whose registration failed Daniel Byrne
2026-11-30 21:13 ` Frank Li
2026-11-30 19:52 ` [PATCH v2 2/4] dmaengine: idxd: list a new channel only once it is complete Daniel Byrne
2026-11-30 21:30 ` Frank Li
2026-11-30 19:52 ` [PATCH v2 3/4] dmaengine: idxd: unlink a channel under dma_list_mutex before removing it Daniel Byrne
2026-11-30 21:32 ` Frank Li [this message]
2026-11-30 19:52 ` [PATCH v2 4/4] dmaengine: rebalance a dynamically registered channel under dma_list_mutex Daniel Byrne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw3rZp3Oz_ZsOZmn@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=daniel1.byrne@intel.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=lcy8047@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ruoyuw560@gmail.com \
--cc=stable@vger.kernel.org \
--cc=vinicius.gomes@intel.com \
--cc=vkoul@kernel.org \
--cc=zhejun_huang@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox