From nobody Fri Jul 24 22:55:04 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 494C14746A9; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; cv=none; b=lO3kGPMWSwkbq0lJhwBp8pFZ+EWiXWR1DqROku3dEqk2gJt+GyG0HN/aeAxT0NxD7j8/Y35PHzAXmDhumGtVj2BTi8FnDShOe3Y9JluBWXNs55m6HN9o07Jo4kCDTi/xWbV+QgtbFYZTS0FdCSdWNAjw9O8g8GSLScLuL/qkc/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; c=relaxed/simple; bh=w5Qar+QoG5RH8yAeQ9Y9wPVTkp9H94z3ypFFhg5ET1M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tbpJLf0ypyuHQE9lZPTObKd3iR7JfvYt1tTQegmeaw2Al/U0bSfYGfbNLHCevvadaivmyN0nli++M2kEVCtohyrd9THjU9cQzdrYf/LrnXimOjwHcmfYmiX42SCvqQAyzBP59IhkDwfwJccjR9erkZGeB7y9+3mv/lUDdFj3wN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CtJHG7gq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CtJHG7gq" Received: by smtp.kernel.org (Postfix) with ESMTPS id E2498C2BCB3; Wed, 22 Jul 2026 15:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1784735282; bh=w5Qar+QoG5RH8yAeQ9Y9wPVTkp9H94z3ypFFhg5ET1M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=CtJHG7gqy57hlFSnVFPalxNd3jtfl5JI4sUtbMCVkoB/yYw+oUyUFPfPCg/1JukuH Od5AlBTqkG7ifI5zlR+cwEJ/5B3X7aBi2pppWmp3WXD2/QkF1sMj86asPqYNomalEY m2SqgjVGYdnz4nlVpdrmxGLFSdgr8mAp6mG1gQonEsRCdq3pXRjyVPUZYy3FkWiaF5 pUwOXJREkR4DuT6AKD/Dqh+4E7o6zcHqwgG3dlb1T0coz5lj0N24aAyGkkQUxVVLMf mh4QHvEJ1PCfCy8Vbw7uGDsCuulvmiTpdC3e/omXSEPUBgmplJWsTpDDm4/rjH/ejk t9MWB5RIZvPwA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C31F5C44539; Wed, 22 Jul 2026 15:48:01 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Wed, 22 Jul 2026 10:47:46 -0500 Subject: [PATCH 1/4] dmaengine: dmatest: Don't forcibly terminate channel in polled mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-dmatest-fixes-and-fatal-errors-v1-1-8287709987ea@amd.com> References: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> In-Reply-To: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> To: Vinod Koul , Frank Li Cc: Tycho Andersen , Wei Huang , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Lynch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784735280; l=1508; i=nathan.lynch@amd.com; s=20260722; h=from:subject:message-id; bh=bgtcSNqMScacYr65kuIB7nzRdUTetKq2Oy8oDO2rtQI=; b=Uk5WS/4WEiqYz81XjlyzumJ4PJwdv1BZQ3iYnda/sghVKSOMhLxhyxMqDYaFT7bWwxRC5D8s2 aZVnIkcjovMB6d4nu9+R4IpJ7W1SQFmf/akwyDI3EYRJIgNVu5X1rNk X-Developer-Key: i=nathan.lynch@amd.com; a=ed25519; pk=pO5+BCw/TENGLvwX5NYZOZmZihcxjkxeFSMuk47erps= X-Endpoint-Received: by B4 Relay for nathan.lynch@amd.com/20260722 with auth_id=891 X-Original-From: Nathan Lynch Reply-To: nathan.lynch@amd.com From: Nathan Lynch Invoking dmaengine_terminate_sync() against the channel after each submitted descriptor is strange. It's benign when the test is single-threaded, but disruptive when multiple threads are submitting descriptors to the channel concurrently: # cd /sys/module/dmatest/parameters/ # echo 1 > polled # echo 2 > threads_per_chan # echo dma0chan0 > channel # echo 1 > run ... dmatest: Added 2 threads using dma0chan0 dmatest: Started 2 threads using dma0chan0 xilinx-zynqmp-dma ffa80000.dma: dma_sync_wait: timeout! xilinx-zynqmp-dma ffa80000.dma: dma_sync_wait: timeout! dmatest: dma0chan0-copy0: result #3: 'test timed out' with src_off=3D0x487 dst_off=3D0xf8 len=3D0x171b (0) dmatest: dma0chan0-copy1: result #6: 'test timed out' with src_off=3D0x227d dst_off=3D0xf99 len=3D0xf7a (0) Remove the call to dmaengine_terminate_sync() from the main thread loop. Fixes: fb9816f9d05f ("dmaengine: dmatest: Add support for completion pollin= g") Signed-off-by: Nathan Lynch --- drivers/dma/dmatest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 2ae3469397f3..60bc448f42ee 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -837,7 +837,6 @@ static int dmatest_func(void *data) =20 if (params->polled) { status =3D dma_sync_wait(chan, cookie); - dmaengine_terminate_sync(chan); if (status =3D=3D DMA_COMPLETE) done->done =3D true; } else { --=20 2.54.0 From nobody Fri Jul 24 22:55:04 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 49D4A480DF2; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; cv=none; b=jiiYQpi2AhZw8mkKwkA/LUcGQCfS8Y2ppBi2ej4cat4Tb9ZnV30CiawUbSGzK0/e1bfirxN32XHOmSCJq1FKEcOcXvYjUAxEAKhe7U/Eh7KWCb3UMhr5qOw8XTVvTAkRVWpmOL5Y88wMXui7VlcYwYDCKQSFgnbSWK3DhlJXlwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; c=relaxed/simple; bh=0a8saeb2riv5wmFya3P5CG3zStVFShSx8moctXGBusU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a5FKUgbBYYZfbGVe0UA0R6lQHDU+vNPDOyiTpKeg8CVIgfYRljksoUYQFOj3ifG7KIcnl0Tx+P5lzSng6u7XwjlZlpLbYboTh/Wh5ZJIx2V7qui0FplGXEl4oEKWJgmH1KovmW/EoCsOz1OUUH27GPkGoo0TDJ4hda3eSUQf19c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RIZJ2W5R; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RIZJ2W5R" Received: by smtp.kernel.org (Postfix) with ESMTPS id F39A5C2BCC6; Wed, 22 Jul 2026 15:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1784735282; bh=0a8saeb2riv5wmFya3P5CG3zStVFShSx8moctXGBusU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RIZJ2W5RjduEW3aHM91t3k8Uxku20PEysMdX2SYUbR8UzveThHFF/ya34Ko4U4lpd bbq/AEF4eyFZJE3Twj/4q9Qq2nGtd0DuQmXtXoBK6ctmhTGUtdbQn9hc/S0+hskx50 HRjvgSrfMMqPeSuSS7I6or9rCJODT9dVlMCndy1NoQn6IC1sOQjEKazP96kBvtIi9/ Hb2O0ILuDKtzWw4Wb26EMZNNeVlSqTJvSNHU7wRT3tizzaNe5SBk6F2kmjFsaM+RgM GSaj8nrN8vW1kc18rv9P8kgxAzKwL0fOShLO0XC9x9GlZllSBGEkTPj+HA3REffDgV SjNIeSrqXaQEg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5639C4453E; Wed, 22 Jul 2026 15:48:01 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Wed, 22 Jul 2026 10:47:47 -0500 Subject: [PATCH 2/4] dmaengine: dmatest: Suppress bogus failures when stopping a run Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-dmatest-fixes-and-fatal-errors-v1-2-8287709987ea@amd.com> References: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> In-Reply-To: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> To: Vinod Koul , Frank Li Cc: Tycho Andersen , Wei Huang , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Lynch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784735280; l=2864; i=nathan.lynch@amd.com; s=20260722; h=from:subject:message-id; bh=74Mzvk0OhTQ8oeyoxuGyU/WEbTMbhAo7r3eZp+EdkGI=; b=4g8nxKx42X48tlx8QmGzW5nnhlhEjili4Eu6/6VS627E/LbA8IYnyI7XWp6Wd8d2koduhYE93 C6SWXdM1dfcDP+Rm7nexzpCfha/avFLMxRCSURU2SzP3kdH3QQJHtt1 X-Developer-Key: i=nathan.lynch@amd.com; a=ed25519; pk=pO5+BCw/TENGLvwX5NYZOZmZihcxjkxeFSMuk47erps= X-Endpoint-Received: by B4 Relay for nathan.lynch@amd.com/20260722 with auth_id=891 X-Original-From: Nathan Lynch Reply-To: nathan.lynch@amd.com From: Nathan Lynch Writing 0 to the module 'run' attribute stops the test threads with kthread_stop(), waking threads out of wait_event_freezable_timeout() before the last transfer's completion callback has run. The stopping thread samples the transfer status and then checks done->done at two different instants, so the last transaction gets misreported two ways: - "test timed out": the wait returns early with done->done still clear even though the transfer is simply still finishing =E2=80=94 not a real timeout. - "completion busy status": status is read as DMA_IN_PROGRESS a moment before the transfer completes and latches done->done, so the stale status is reported as a failure against a transfer that actually succeeded. This is not a recent regression: the threads have used an interruptible, freezable timeout wait since long before the wait queue was moved into thread context by commit 6f6a23a213be ("dmaengine: dmatest: move callback wait queue to thread context"), so a stop has always been able to wake the wait before the final callback runs. When kthread_should_stop() returns true, use dma_sync_wait() to settle the pending transaction. Real errors still yield DMA_ERROR. Assisted-by: Claude:claude-opus-4-8 [Claude-Code] Signed-off-by: Nathan Lynch --- drivers/dma/dmatest.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 60bc448f42ee..3267c7e86f5d 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -702,6 +702,7 @@ static int dmatest_func(void *data) struct dmaengine_unmap_data *um; dma_addr_t *dsts; unsigned int len; + bool stopping; =20 total_tests++; =20 @@ -839,6 +840,7 @@ static int dmatest_func(void *data) status =3D dma_sync_wait(chan, cookie); if (status =3D=3D DMA_COMPLETE) done->done =3D true; + stopping =3D kthread_should_stop(); } else { dma_async_issue_pending(chan); =20 @@ -846,14 +848,19 @@ static int dmatest_func(void *data) done->done, msecs_to_jiffies(params->timeout)); =20 - status =3D dma_async_is_tx_complete(chan, cookie, NULL, - NULL); + stopping =3D kthread_should_stop(); + status =3D stopping ? + dma_sync_wait(chan, cookie) : + dma_async_is_tx_complete(chan, cookie, NULL, NULL); } =20 if (!done->done) { - result("test timed out", total_tests, src->off, dst->off, - len, 0); - goto error_unmap_continue; + /* stopping: dma_sync_wait() let the transfer finish, not a timeout */ + if (!stopping) { + result("test timed out", total_tests, src->off, + dst->off, len, 0); + goto error_unmap_continue; + } } else if (status !=3D DMA_COMPLETE && !(dma_has_cap(DMA_COMPLETION_NO_ORDER, dev->cap_mask) && --=20 2.54.0 From nobody Fri Jul 24 22:55:04 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 49E01480DF8; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; cv=none; b=VxVkOEFzTOqNuohXBRQzHqu55kS40MEO75wV2EHsIvUofkAC9VVw5+fmSBbHUvZlMxbvbSuqtGpVb8Pq+NH42hny4vidfyn8jczEQO9VVGFiOhdL2TpaGMex9JQoxbqui/rcCkvRvKz9oxP6bUDLw4jPCSObc1ytLSJVJlqrpkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; c=relaxed/simple; bh=efzaA7sedl1M6FoQei3qVECApE90OMYOiVlKOiXCMEA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FOcZm09nMc2PKK5QyNK4WiYa/RPciqdnZpnkFzg6DCkeRAGy7X4qXmh3KHfZpg+M23tIFsb9aE+aGMtNTz5wiLWfcJIBTJ70Il3Uvc1cmGXLAWf8xqO/0MUKhsPuORZTvCjdl+YfI7K59bZd4ydvGH6VklwZ/PawK/q9THhou7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V0q8fQxd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V0q8fQxd" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0D28EC2BCFB; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1784735282; bh=efzaA7sedl1M6FoQei3qVECApE90OMYOiVlKOiXCMEA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=V0q8fQxdy7m6QFAAviX4P61KCUCh3astd1iZwsIcmR3zwL2AApY9ONmY0oiljVzru t7lq1ody1LWic8uZEfa9MiOGBWapzLvaXsO5WZHF9fkX+jbEXYAM1hz0cBVV4T7oLL C3BE3wnbiC9q6jPhLPk84vn8LpC/ZnzAmNXgPTaolqUpLbQkQELb9Bl9dw794Rzor/ j9TsHoHlwyYj0fZ+noE7TQYOUlHh4lu9BRLoAFzOFunFJMCVr/KBA9MFVYw6AB3LDf InURFoAbwCcyGjV9U3pvBwLNN3bePr7k3obB+iaR/utSCodboZjG6zfi/s577zhkZx Kd+vdcySPVOJg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB0E1C4453C; Wed, 22 Jul 2026 15:48:01 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Wed, 22 Jul 2026 10:47:48 -0500 Subject: [PATCH 3/4] dmaengine: dmatest: Terminate channel before freeing threads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-dmatest-fixes-and-fatal-errors-v1-3-8287709987ea@amd.com> References: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> In-Reply-To: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> To: Vinod Koul , Frank Li Cc: Tycho Andersen , Wei Huang , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Lynch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784735280; l=1679; i=nathan.lynch@amd.com; s=20260722; h=from:subject:message-id; bh=/0q1Z1d1+2oGXvP2+BrsGqvG+5+zUlAtwDMzMF2C+Mk=; b=SOqPziyDMTrFeN9HfcYkh2T22cJ2YzcJccaRSZ37T2mP4Avx/UTiYyZLTAnE1Z9zXcUil87Gn G0T4wtcdJ9cBXiwf9qUbWWcvewEaFtHhSk5o1kgJZg8+SbY7IHAEjpR X-Developer-Key: i=nathan.lynch@amd.com; a=ed25519; pk=pO5+BCw/TENGLvwX5NYZOZmZihcxjkxeFSMuk47erps= X-Endpoint-Received: by B4 Relay for nathan.lynch@amd.com/20260722 with auth_id=891 X-Original-From: Nathan Lynch Reply-To: nathan.lynch@amd.com From: Nathan Lynch On a channel shared by multiple threads, the completion callbacks run from one tasklet, and dmaengine_terminate_sync() flushes it. Freeing a thread before that flush can leave a pending callback pointing at freed memory (dmatest_callback() reads thread->done). Stop all channel threads and then flush the channel before freeing the threads. Fixes: 6f6a23a213be ("dmaengine: dmatest: move callback wait queue to threa= d context") Assisted-by: Claude:claude-opus-4-8 [Claude-Code] Signed-off-by: Nathan Lynch --- drivers/dma/dmatest.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 3267c7e86f5d..0d7752c2451a 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -959,18 +959,23 @@ static void dmatest_cleanup_channel(struct dmatest_ch= an *dtc) struct dmatest_thread *_thread; int ret; =20 - list_for_each_entry_safe(thread, _thread, &dtc->threads, node) { + /* stop all threads first */ + list_for_each_entry(thread, &dtc->threads, node) { ret =3D kthread_stop(thread->task); pr_debug("thread %s exited with status %d\n", thread->task->comm, ret); + } + + /* flush the channel (e.g. vchan_synchronize() -> tasklet_kill()) */ + dmaengine_terminate_sync(dtc->chan); + + /* now it is safe to free the thread memory */ + list_for_each_entry_safe(thread, _thread, &dtc->threads, node) { list_del(&thread->node); put_task_struct(thread->task); kfree(thread); } =20 - /* terminate all transfers on specified channels */ - dmaengine_terminate_sync(dtc->chan); - kfree(dtc); } =20 --=20 2.54.0 From nobody Fri Jul 24 22:55:04 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5FB113E6DE0; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; cv=none; b=hCLjRHE1UCGobO5taagluRjcz6sVRcaMj/xoHTOwwfBvEGk9LEqi5qV7wfu4WoNJ9Sn2NJeetEs9+UuUykiU4/CVWLXM8c2ll1r/MBTVqCJar51j2y8CT3RyozrH34HHmy/qaavz6qFgr/NHcBGtQp5l5+jD4ckGlhekeGB5GSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784735282; c=relaxed/simple; bh=64xabAWb6b96UxIec7wnq6bHoMDXnZdqDarHAvAS0o0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BFCRnd7uHlzAu2TyOEpDWoYKs+ob8iOdW7AXvbuF0attBDI+yurmtXKsAcC2Hg1PAZW82A0X9w/Y+Gj8Ho41jvKjzqyaLLCb+ezmutvj+d1WFEZNibyIESMb5lGlI7CejxjtTqPbTgW1Dzbhb/tXxyr4aakLZgufyxhS/5ONOUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CnQ+NZnF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CnQ+NZnF" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1F96CC2BCF6; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1784735282; bh=64xabAWb6b96UxIec7wnq6bHoMDXnZdqDarHAvAS0o0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=CnQ+NZnFI9iKaFjxDbne3CppK/GxH/u6p4xh/PXOonyvybu9haDP0MGo2qgA2R8HL 1C7nCv5BtthpLsUI9vgOE9ffChSUGJ5L7KqwVVDGX3Lod4WiEUdghIdwOWQb+CL9xt Tfno0DgYYHczZn5jA7pIcoa1WZ7eCkEffSUT4fof9arodalRZVkozq0STOrl5JrHE8 nJXcZsdT+//sZfoHcLaUFUipNLCbQgFBkVUEWXMwDobP17EJ7dn8d7OcM1j7seKgr2 IIh0MI4AWfxRkWrUmK133lQMiEclko0rI/LMFoHT/jccum3KIGXoCwVqMb4Y4RXwi0 OvZ8Aib55JqWQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F009C531BC; Wed, 22 Jul 2026 15:48:02 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Wed, 22 Jul 2026 10:47:49 -0500 Subject: [PATCH 4/4] dmaengine: dmatest: Optionally make test errors fatal Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260722-dmatest-fixes-and-fatal-errors-v1-4-8287709987ea@amd.com> References: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> In-Reply-To: <20260722-dmatest-fixes-and-fatal-errors-v1-0-8287709987ea@amd.com> To: Vinod Koul , Frank Li Cc: Tycho Andersen , Wei Huang , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Lynch X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784735280; l=5353; i=nathan.lynch@amd.com; s=20260722; h=from:subject:message-id; bh=r1oLdav/T8y/iZ+lMH1y1LszIWGqEDNjroTj5YnSY/4=; b=OOwqmJqiFUGXTYHXFgESLpyGa7lUqTmyJjMfbbR3vznkOSnvTfOdXf9mbAyyi7YQOWiKEpExS U17QLqCOaLVC5eww7va6h+oYHPDL0A/tt5R5r/BtrX1yI9Rn7g5PPxi X-Developer-Key: i=nathan.lynch@amd.com; a=ed25519; pk=pO5+BCw/TENGLvwX5NYZOZmZihcxjkxeFSMuk47erps= X-Endpoint-Received: by B4 Relay for nathan.lynch@amd.com/20260722 with auth_id=891 X-Original-From: Nathan Lynch Reply-To: nathan.lynch@amd.com From: Nathan Lynch For automated testing it is useful to have dmatest halt the machine when errors occur rather than logging them and continuing, so that the system state at the point of failure can be captured instead of allowing the run to carry on. Add a 'fatal_errors' module parameter, defaulting to 0. When set to a non-zero value N, panic the kernel once N test errors have accumulated in a run; the count is reset at the start of each run. The panic is triggered after the existing result() line is logged, so the specific error (data mismatch, mapping/prep/submit error, timeout, or bad completion status) is recorded before the crash. Assisted-by: Claude:claude-opus-4-8 [Claude-Code] Signed-off-by: Nathan Lynch Reviewed-by: Tycho Andersen (AMD) --- drivers/dma/dmatest.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 0d7752c2451a..a070ce6f2fa9 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -7,6 +7,7 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include #include #include #include @@ -92,6 +93,11 @@ static bool polled; module_param(polled, bool, 0644); MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts= "); =20 +static unsigned int fatal_errors; +module_param(fatal_errors, uint, 0644); +MODULE_PARM_DESC(fatal_errors, + "Panic after this many test errors in a run; 0 =3D never (default: 0)"); + /** * struct dmatest_params - test parameters. * @nobounce: prevent using swiotlb buffer @@ -109,6 +115,7 @@ MODULE_PARM_DESC(polled, "Use polling for completion in= stead of interrupts"); * @alignment: custom data address alignment taken as 2^alignment * @transfer_size: custom transfer size in bytes * @polled: use polling for completion instead of interrupts + * @fatal_errors: panic after this many test errors in a run (0 =3D never) */ struct dmatest_params { bool nobounce; @@ -126,6 +133,7 @@ struct dmatest_params { int alignment; unsigned int transfer_size; bool polled; + unsigned int fatal_errors; }; =20 /** @@ -133,6 +141,7 @@ struct dmatest_params { * @params: test parameters * @channels: channels under test * @nr_channels: number of channels under test + * @error_count: test errors in the current run (for fatal_errors) * @lock: access protection to the fields of this structure * @did_init: module has been initialized completely * @last_error: test has faced configuration issues @@ -144,6 +153,7 @@ struct dmatest_info { /* Internal state */ struct list_head channels; unsigned int nr_channels; + atomic_t error_count; int last_error; struct mutex lock; bool did_init; @@ -487,6 +497,24 @@ static void dbg_result(const char *err, unsigned int n= , unsigned int src_off, dbg_result(err, n, src_off, dst_off, len, data);\ }) =20 +/* + * Record a test error whose details were just logged via result(). When + * fatal_errors is set, panic once that many errors have accumulated in the + * current run. + */ +static void dmatest_note_error(struct dmatest_info *info) +{ + unsigned int errors; + + if (!info->params.fatal_errors) + return; + + errors =3D atomic_inc_return(&info->error_count); + if (errors >=3D info->params.fatal_errors) + panic("dmatest: fatal_errors=3D%u and %u error(s) encountered\n", + info->params.fatal_errors, errors); +} + static unsigned long long dmatest_persec(s64 runtime, unsigned int val) { unsigned long long per_sec =3D 1000000; @@ -583,7 +611,7 @@ static int dmatest_func(void *data) struct dma_device *dev; struct device *dma_dev; unsigned int error_count; - unsigned int failed_tests =3D 0; + unsigned int failed_tests =3D 0; /* for this thread */ unsigned int total_tests =3D 0; dma_cookie_t cookie; enum dma_status status; @@ -755,6 +783,7 @@ static int dmatest_func(void *data) failed_tests++; result("unmap data NULL", total_tests, src->off, dst->off, len, ret); + dmatest_note_error(info); continue; } =20 @@ -910,6 +939,7 @@ static int dmatest_func(void *data) result("data error", total_tests, src->off, dst->off, len, error_count); failed_tests++; + dmatest_note_error(info); } else { verbose_result("test passed", total_tests, src->off, dst->off, len, 0); @@ -920,6 +950,7 @@ static int dmatest_func(void *data) error_unmap_continue: dmaengine_unmap_put(um); failed_tests++; + dmatest_note_error(info); } ktime =3D ktime_sub(ktime_get(), ktime); ktime =3D ktime_sub(ktime, comparetime); @@ -1135,6 +1166,7 @@ static void add_threaded_test(struct dmatest_info *in= fo) params->alignment =3D alignment; params->transfer_size =3D transfer_size; params->polled =3D polled; + params->fatal_errors =3D fatal_errors; =20 request_channels(info, DMA_MEMCPY); request_channels(info, DMA_MEMSET); @@ -1147,6 +1179,8 @@ static void run_pending_tests(struct dmatest_info *in= fo) struct dmatest_chan *dtc; unsigned int thread_count =3D 0; =20 + atomic_set(&info->error_count, 0); + list_for_each_entry(dtc, &info->channels, node) { struct dmatest_thread *thread; =20 --=20 2.54.0