From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796068703; b=1dVAsYXrMqBWuvGTzoYzQqlyJfqYWfRsyNujTMhdkpH5+WDP1UzPMhejaZUpWwE11KAs Rbzg8HAgx6nq2mirQ/0qBAHw9sPwNxWJF14grmPGLn0ERprJPKJXzTa79ZtIlTLr6xblG FpAIYCEu85l6qS2KUDbJWVK+REo30clv1ncweaF/r/hBBGxm/lyHcJjTR/MNQAlMQ2eqK 3B1tFgI50Ted3+mpT1DzE5uLKvFs7tTiUz26skPbFxA12xCLUwP510+7RUlIPa7VseWYO Soir0b9CZXP+aOFL9E/OX0U6HScIJ8sevlB3o37nlYZqvrzKU3iPhGpv2bmzFW6RvDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796068703; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=zqZKxllSLt2x7Uzud2OoeHVKn2oobrHR+QVNLBfX9gk=; b=pyhKxPBBDaw3JDUOSwuInemikGQr1rgJrTfWCczXg8KBpCwVX/aanDJswdCPlidrjI/i hmuqHjNQgjPDXA+nAG543SuaNmj09Uc8nM40SmDu6ZUI0WNuaHTbhRvmE11rDNQzzAbiI v0lxJ/TbfhF9vb1ioYlPEz9Ikw/ekr1pPFF7sRHPUns/ugF8LvrG6+G6b9CusdxD8C8n2 dmWKhI4zsXwJjvNjdjKLyVErwJtuyw+j1FxIf8ggDvDFhM5uhbrCEXyARj1kRTfHKOMJI GQEEFjlIk2Y9QPwCEpdBoiZdfo/6VP6bHLee8Mi94DarsIiZaN5J6g0HTjCtPSo/9iQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BbVFXI+j; arc=none smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E6E0606A320; Mon, 30 Nov 2026 19:58:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E6E0606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BbVFXI+j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796068703; x=1827604703; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zqZKxllSLt2x7Uzud2OoeHVKn2oobrHR+QVNLBfX9gk=; b=BbVFXI+jxvK2TDe1P7wwyQxosfqVv+jGzpvzQ1IuHTxl8sS88hZFczwu iN/PbZ4WJM3upqC4RkfWFtbfdunge/E93yyOyIsLwY7+ny4e8auaMDfjy TQCfTV2nZqhb61snjZhvPdT7NsZ0RqBhfNuA7ZEQuj3AW+n71iqVrxzU7 MfPteF6x++dRaUrOHoo6w0dweE9PPs5UofqjViWwe9Q9I653dpj3rKl1d I8aTqWfYqrK/n5GYUNn21XhV5kfN63tyUpCjCl2hTMu+Vz6SQ7BJ7VgZU li+k04vwAUcX68Irt/VACpxG5o/5vhxd+jPoeOBhBRwDwyJ4qD1+ImHY2 A==; X-CSE-ConnectionGUID: rAKa/2UCTNChk/uaYFiL4w== X-CSE-MsgGUID: pe7UNhi5RUWfva0+9+W6nA== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4936887" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4936887" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 11:58:22 -0800 X-CSE-ConnectionGUID: zvNd+CK1TnGBh3Hf6yB71A== X-CSE-MsgGUID: 73LkqJMgQ6WlfFh8RuwPhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4517781" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by orviesa010.jf.intel.com with ESMTP; 30 Nov 2026 11:58:21 -0800 From: Daniel Byrne To: Vinod Koul , dmaengine@vger.kernel.org Cc: Vinicius Costa Gomes , Dave Jiang , Frank Li , Dan Williams , Ruoyu Wang , Zhejun Huang , Changyul Lee , linux-kernel@vger.kernel.org, Daniel Byrne Subject: [PATCH v2 0/4] dmaengine: fixes for channels registered and removed at run time Date: Mon, 30 Nov 2026 11:51:59 -0800 Message-ID: <20261130195203.1901143-1-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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