From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796541434; b=OLOldEspQE/I2g5LlnWaQIfnkaeHyI323UGXmucJTExSFAJwCYloAvayhYItSmDLcbsV wGs4pt+wcDoQNyQs7gsDhPb3eF7uTuQlZMi8bV7g9vlnm8KX3Lh5F/eyKMTEEBrxs2emh IgBjsvnJCZrvNGVuCaVHgCpFw6L10IoHONQk0mn88ylsLMsXVV33duUPeDTSiyJ6bmnkf O08iMqzGRR/MSIiguKqtDWWeoffZZ5VsaDdCLfsvMNgS55HTXaVpYsOU5GzmLYd/enTnC 8LypXx9myefPgdMu61TfcaKiHTg90pGu+Y8z2hOYRoC8GElbkh3c0zpAeMT7MtoHI7g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796541434; h=Received:DKIM-Signature:Received:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=TQgDwMBni6yMmb/51DVnvOZwL0FHvL85TNPXqX+3XOI=; b=vNMk5BLYMl5r02aZdHs2j1lBcel4biRKo9RykCzT0pQYA+fWhKRNn1VwcHWBMoXrBqVI uXJUT97MTpHt2cf9CkqXKLizTfrMAgAgpMofVXxJmPzgGu1gCToZfUPjLObgnAWNxZ+Hw Tvw2qTNg+Scqiq1SWSdd3KaVjI0v3wOqLRByPQZlOBLa7mXCqCZAhBA2YOopta8QG0f+u Dh4IFO1hQv53vhr9hJ1V9FjoLG0CSsBc9LCxp4orm4E/vbW4DYamRkByM8/kQyfgrTn6/ H1/12sQdOiRX7uO+LO+omFx2S0EI3PFCehiFp5xtOkvitGMvxYtDFDbiJAbT0EnSibA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="nMI7/XV0"; arc=pass header.oldest-pass=0 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 953D8606A33A; Sun, 6 Dec 2026 07:17:14 +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=nMI7/XV0 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796541434; b=NelWil+5DDUiej2dR9J8xdDB2GnM7l88GUeKSSNP0ix41FkhAtZItrv/qTtGWzC3C4qJ PP35e8e/vgZabqjMDyxjNs7rBNYlJxxiH1Ko1syC2lhl09Nnecly9ayAqZa0xv0LUa7Rj dVxgyEgvVr312J89Ith0dYs7REY3TUFmbAir1MI9+U8etJoDP6ZwyXwT1w6hj22gcFzEJ Z3uu8q8tQ64eQDxQcFQv10EbxGqOmrZpAihGDzAgL3hfJ2asQAV5+s1eXG7wyoEZvWnBV HNi2XYmFmzHTTuUcE2Fw7sEvB3HBac8EVY2n8uysZVkMkZFATrlgBk8+kSZfCQYKSxw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796541434; h=DKIM-Signature:Received:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=TQgDwMBni6yMmb/51DVnvOZwL0FHvL85TNPXqX+3XOI=; b=BHGtBTVfnC5FBdSUTxMNQFGdG+FOOvLkerCVRAVxqWrNv10jOQvNxe3B4+voMvxrND11 O7sqt+Kx1JF43Wn6QchWsSI7Dqk88CPUknOfQjRF7vpSl4P5+CVr+rqpGgmD8Hg3hn+yq IeEhKk+WV/JOUve93SBuozbiNrtOi29RDNA0M8F5d6NW0RKmlAfjOzAxi8cex+QBso+vQ jQxiUpFyWDdbycjjM68dY5Yq83DptmjLI1IxE2aInLUVK8e8aAvSXoe8uRb2zJorYrvKX w5ArfHZAL84ajcA/JUwn5zLrCQoA+/OKPb4ghxLAiOj6mVeT0dI9aQ/nosAG4//S2lg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 2D7851F0092B; Sun, 6 Dec 2026 07:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796541434; bh=TQgDwMBni6yMmb/51DVnvOZwL0FHvL85TNPXqX+3XOI=; h=From:Subject:Date:To:Cc:Reply-To; b=nMI7/XV0usNS63zxUjsRXhmAPlPwtIqcPlYlJ1+8jl7bzOPQz78Rd3vSwiIND9VPp n4X6mqw4CBDHY4BpXStJJG/wSLJyOO1kYTYQRNqt1kAgphbQNyH1kWYXdnVyITIIjI rVXOSM2cna7oWpWZo/f+Q9lbMPnN5gwiD9bDGUHoGoRWlaZ5xyRO/Cx8pn22D0H8SJ fCIOyGtwpJrNRNmr4gXkOwKggPh5QL9zqkiyXhPmZGn94UgCJsfa9/VjJYg9SBfV+n YNX8Ll4mz++C6g4donuYEfcGggufLR2nF1t66lXPaThJSFHjIZn622kYvZlqiHc7Hv /L9+QYkc8gzrQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 7D3D550675; Sun, 6 Dec 2026 07:17:12 +0000 (UTC) From: Arun Iyengar via B4 Relay Subject: [PATCH v4 0/7] accel/rocket: Fix teardown with a job on the NPU Date: Sun, 06 Dec 2026 07:17:11 +0000 Message-Id: <20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/2XOTQ6CMBAF4KuYrq3pHwRceQ/joq1TqAo1LTYaw t1tYYO4fJn53syIAngLAR13I/IQbbCuT0Hsd0i3sm8A22vKiBFWUsoJ9k7fYcDGviFgoIJXWjK uAFAiTw/zIInzZcnhpW6gh9yRN1obBuc/871I895SzQj9rY4UE1xXpeZQaFBCnJpO2sdBuw7l6 sjWWGwwSxhqUytVmvT1H+ZrXGwwz7ggnBkpSCX5Gk/T9AVQvwzgNAEAAA== X-Change-ID: 20261130-rocket-fixes-e1438ca23bee To: Tomeu Vizoso , Oded Gabbay Cc: Heiko Stuebner , Jeff Hugo , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Philipp Stanner , Danilo Krummrich , Matthew Brost , Igor Paunovic , Midgy BALON , Jiaxing Hu , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, stable@vger.kernel.org, Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796541431; l=4385; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=yQxV9ODYWuGW7SJpG0CEFOP+pAIs2AKqhjX5P1VZkw8=; b=oOFMz+/CQUnt0RHIPWNz0LU6Dqo94nCsGF0ZMJOwP2NiQJj9iN4P+cORCFgprTpFYJEcrgWkC sh2bGIVfOG6BiDbu3zPFJcoIKbghmMkR30sCELaKJIdRTg2tZu2gSbg X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 X-Original-From: Arun Iyengar Reply-To: aiyengar1990@gmail.com Fixes for teardown with a job on the NPU: at file close, in the timeout reset and at core unbind. 1: wait for the file's jobs before its BOs are released. 2: reset the core before detaching its IOMMU (same change as Midgy Balon's RK3568 RFC, linked in the patch). 3: stop the scheduler before releasing the IOMMU group. 4: serialise core probe, removal and open (the slot part overlaps Igor Paunovic's pending patch, linked in the patch). 5: reset the core at unbind, which also cancels the job on the NPU. 6: free the jobs left at scheduler teardown. 7: move open files off a core at unbind, and back onto it at bind. Tested on an Orange Pi 5 (RK3588), 7.3, KASAN, unbinding the second of the three cores. Before: SIGKILL during inference timed out 12 times in 10 kills, faulting jobs gave IOMMU stall timeouts, an unbind during a timeout oopsed in iommu_detach_group(), close hung on a hung job, and an unbind with queued jobs hit a use-after-free. After: none of these in 70 kills, 10 faulting jobs and 3-5 runs of each unbind case; on v4 also an open during a core's probe, SIGKILL of the unbinding task and close of a killed file after the last unbind (all three reproduced on v3, the last a use-after-free oops). No KASAN or lockdep report; inference unchanged after rebinds. The NULL detach from the interrupt handler in patch 5 follows from the code; I could not trigger it. Developed with Claude (Anthropic), which wrote the code and the commit messages. I reviewed every change. Signed-off-by: Arun Iyengar --- Changes in v4: - Patch 4: hold the lock across open, so a file never gets a core whose probe is still running; READ_ONCE()/WRITE_ONCE() on the core's .dev (Sashiko). - Patch 7: close waits until the file's jobs are freed, as killed jobs are freed later and use the core (Sashiko). - Patch 7: only entities on the unbound core are rebuilt; the others, and all at bind, get the new core list. No wait for other files' jobs, and a signal to the unbinding task no longer kills them (Sashiko). - Link to v3: https://patch.msgid.link/20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com Changes in v3: - Patch 1: wait for the last job that reached the NPU, set in rocket_job_run(), not the last one pushed: close no longer waits for killed jobs or their fences (Sashiko). - New patch 4: serialise core probe and removal, take a free slot. - Patch 5: timeouts during unbind leave the core to the unbind reset and do not restart the scheduler (Sashiko). - Patch 5: the reset work sets reset.pending itself, so a concurrent timeout cannot skip the unbind reset (Sashiko). - New patch 6: .cancel_job, so drm_sched_fini() frees the jobs left pending (Sashiko). - New patch 7: move open files off a core at unbind (was "Not fixed"), and back at bind. - Link to v2: https://patch.msgid.link/20261204-rocket-fixes-v2-0-e9f9bb6f1304@gmail.com Changes in v2: - New patch 3: stop the scheduler before releasing the IOMMU group (Sashiko). - New patch 4: reset the core at unbind. - Patch 1: drop a comment that repeated the commit message. - Patch 2 unchanged. - Link to v1: https://patch.msgid.link/20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com --- Arun Iyengar (7): accel/rocket: Wait for in-flight jobs before releasing the file's BOs accel/rocket: Reset the core before detaching its IOMMU accel/rocket: Stop the scheduler before releasing the IOMMU group accel/rocket: Serialise core probe and removal accel/rocket: Reset the core at unbind accel/rocket: Free the jobs left at scheduler teardown accel/rocket: Move open files off a core at unbind drivers/accel/rocket/rocket_core.c | 4 +- drivers/accel/rocket/rocket_core.h | 2 + drivers/accel/rocket/rocket_device.c | 7 +- drivers/accel/rocket/rocket_device.h | 2 + drivers/accel/rocket/rocket_drv.c | 79 ++++++++++++--- drivers/accel/rocket/rocket_drv.h | 10 ++ drivers/accel/rocket/rocket_job.c | 189 +++++++++++++++++++++++++++++++---- drivers/accel/rocket/rocket_job.h | 3 + 8 files changed, 256 insertions(+), 40 deletions(-) --- base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe change-id: 20261130-rocket-fixes-e1438ca23bee Best regards, -- Arun Iyengar