DMA Engine development
 help / color / mirror / Atom feed
From: Daniel Byrne <daniel1.byrne@intel.com>
To: Vinod Koul <vkoul@kernel.org>, dmaengine@vger.kernel.org
Cc: 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,
	Daniel Byrne <daniel1.byrne@intel.com>
Subject: [PATCH v2 0/4] dmaengine: fixes for channels registered and removed at run time
Date: Mon, 30 Nov 2026 11:51:59 -0800	[thread overview]
Message-ID: <20261130195203.1901143-1-daniel1.byrne@intel.com> (raw)

These four patches change the dmaengine core. Patches 2 and 3 add core
helpers for a channel that is registered or removed at run time and
convert idxd to them. One of the four was patch 4 of v1 of "dmaengine:
idxd: fixes found by an in-kernel polling client", and the other three
are new. The other idxd fixes do not depend on them, so they go as a
series of their own. They apply to v7.4-rc2 on top of two fixes from
the list that are not applied yet, see "Patches on the list" below.
The patches meant for stable carry a Cc: stable line with the first
affected release. Patches 1 and 4 have a Fixes tag and no stable line.

A dmaengine channel can be registered and removed while its device
stays registered. idxd does that for every work queue that is bound to
its dmaengine driver or unbound from it.

In short, one patch each:
 1. a channel device whose registration failed is put, not freed with
    kfree();
 2. a new dma_async_device_channel_add() lists a channel only once it
    is registered, and idxd uses it;
 3. a new dma_async_device_channel_remove() unlinks a channel under
    dma_list_mutex before it is unregistered, and idxd uses it;
 4. the rebalance of a dynamically registered channel is done under
    dma_list_mutex.

v1 was one series of 17 patches. v2 is posted as three series:
 - "dmaengine: idxd: event log, cdev and prep fixes", ten fixes that
   stand alone, posted with this one;
 - "dmaengine: fixes for channels registered and removed at run time",
   this series;
 - "dmaengine: idxd: fixes found by an in-kernel polling client", on
   the device commands, terminate_all, the teardown, halts and
   resets. It applies on top of the first and is not posted yet. Two
   of its patches overlap patches 7 and 8 of Vinicius Costa Gomes'
   "dmaengine: idxd: More error handling fixes" v2, and it follows
   when that is resolved. This series applies with that one or
   without it.
   https://lore.kernel.org/r/20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@intel.com

The channel lifetime series, posted after the three, builds on this
one. It makes dma_async_device_channel_remove() detach a channel that
clients still hold.

Link to v1: https://lore.kernel.org/dmaengine/20261019150630.4026341-1-daniel1.byrne@intel.com/

Changes since v1:

v1's 17 patches were reviewed by Frank Li, by sashiko.dev and by a local
run of the same reviewer. v1's patch 4 is patch 2 here, and the other
three are new. The per-patch changes are under the --- line of each
patch.

What the reviews found, as far as it concerns this series:
 - sashiko.dev had no finding on v1's patch 4.
 - The local run found the other three in its review of that patch,
   all in code that v7.3 has already: a channel unlinked after its
   unregistration and without dma_list_mutex (3), the rebalance and
   the channel count without the mutex (4), and a channel device freed
   with kfree() after device_register() had initialized it (1). It
   also found the channel id freed while the channel's name is still
   in sysfs, which a patch from the list fixes now, see below.
 - The v2 patches were reviewed by a local run of the same reviewer as
   well. Its last run reports no issue on the four. In earlier runs it
   noted on patch 3 what the changelog of that patch says too: a
   client that took the channel before the unlink still holds it
   across the kfree(). The patch does not introduce that, and the
   channel lifetime series closes it.

Patches on the list:

Two fixes by other authors are reviewed and not applied yet. Each makes
a change that a patch of this series made too, so the series is now
based on them:
 - "dmaengine: idxd: Remove channel from list on registration failure",
   Ruoyu Wang, two Reviewed-by. It unlinks a channel whose registration
   failed. Patch 2 never links such a channel and removes that unlink
   again.
   https://lore.kernel.org/r/20260709062303.4167624-1-ruoyuw560@gmail.com
 - "dmaengine: Free channel ID after device_unregister()", Zhejun Huang,
   two Reviewed-by. It was the main change of patch 1, which keeps its
   other change. Changyul Lee's "dmaengine: Free channel and device IDs
   correctly" makes the same change and also frees the ids on an error
   path of dma_async_device_register().
   https://lore.kernel.org/r/20261110101607.13784-1-zhejun_huang@linux.alibaba.com
   https://lore.kernel.org/r/20261106005154.1669214-1-lcy8047@gmail.com

Testing:

The three series were tested as one stack, and were one series for most
of the rounds. The cover letter of the third, "dmaengine: idxd: fixes
found by an in-kernel polling client", will describe them: a test
module's scenarios on a dmaengine channel, dmatest, iaa_crypto with
zswap, user queues, resets and halts, under KASAN with lockdep and
DMA-API debugging and under KCSAN, on v7.3 and on v7.4-rc2. Every
scenario passes.

Of this series those rounds run the registration and the removal of a
channel on every bind and unbind of a work queue, with dmatest's and
the test module's channel requests and releases around them, and
dmatest started and stopped against the unbind in both orders. The
failed registration of patch 1 was not provoked in these rounds.


Tools:

I used Claude Opus/Fable model to review (sashiko and local reviews)
the code, suggest fixes, and edit the changelogs. I also used it to
run the builds and the test rounds described above. I reviewed the
results and fixes it suggested and I am responsible for them.

Daniel Byrne (4):
  dmaengine: put a channel device whose registration failed
  dmaengine: idxd: list a new channel only once it is complete
  dmaengine: idxd: unlink a channel under dma_list_mutex before removing
    it
  dmaengine: rebalance a dynamically registered channel under
    dma_list_mutex

 drivers/dma/dmaengine.c | 87 +++++++++++++++++++++++++++++++++++++++--
 drivers/dma/dmaengine.h |  4 ++
 drivers/dma/idxd/dma.c  | 16 +++++---
 3 files changed, 97 insertions(+), 10 deletions(-)


base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
prerequisite-patch-id: 97748f72eb2738963faecb0a1b611532641acd94
prerequisite-patch-id: 5c96dea1a1c642b3c619d6291cf7741eebd0977d
-- 
2.43.0


             reply	other threads:[~2026-11-30 19:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 19:51 Daniel Byrne [this message]
2026-11-30 19:52 ` [PATCH v2 1/4] dmaengine: put a channel device whose registration failed Daniel Byrne
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 19:52 ` [PATCH v2 3/4] dmaengine: idxd: unlink a channel under dma_list_mutex before removing it Daniel Byrne
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=20261130195203.1901143-1-daniel1.byrne@intel.com \
    --to=daniel1.byrne@intel.com \
    --cc=Frank.Li@kernel.org \
    --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=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