From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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.subspace.kernel.org (Postfix) with ESMTPS id 14B6D606A6B1 for ; Sat, 5 Dec 2026 06:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=m+GXwJzV; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n5a1NndD DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:Message-Id :Date:Subject:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=edW/PK1B+YKgaNSmKf3I9wsK/zWQ1lhYa09YtJqWZsc=; b=m+GXwJzVaBAaWOAoY9UWvK18ES ffqRZS1LOzGvPUlN3EROXUWWp7DO4P0lUD5Q+3djZUknhpo1efrRXNEor2WAwfkKgDDG8UXlNHTpM vIpUVsTFjvrG/qgmKl2B4aecsx0OhGHJBPXJ4YzjRM+W56uzQberusgYK36U7mLUZKjWGBrVZOYgA UOUXGjFNSUHdSZxYPqGZPzuA6ACw4ykvijxHD7LJ7Pp0rF/VS5G+afJSVIP+mowPioIoVaThBxZVQ CHr1P5lsW/zro9onedBgaNFMWkqw3+WICil9Lb2xQ7M1Dd2KcuestNPxVFXMGqjUVah2VTj37nBsu PlEB2iNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZjby-000000025EO-1QbD; Sat, 05 Dec 2026 06:51:10 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZjbw-000000025Dr-1oaF for linux-rockchip@lists.infradead.org; Sat, 05 Dec 2026 06:51:08 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 3634344080; Sat, 5 Dec 2026 06:51:07 +0000 (UTC) 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=1796453467; b=JutGukFb0ZBYRNCQtCYt/0uehlRNPjXIZp0P14E+1BdAJiqMqdNzhy1mrNjLMyRNLAiE SFIg2fUWV3KztRXH07+5DTBqP+INVQOJ1JevouUpFgXKZMKfREg8HXP9fUwbfWR3j4E0s lH1En5ZHIUZ4nsUhD/zQTC1XlAiGMdEkDObtUnrl/C1mYpM4A2NaSz/CyXH/gE3V5DnfY IK7umjo9yZnUv7feznzlVsgQA3fPl/UZEY3C75MqcS5wIGWhe07iD/+FQMOU3hAyr4bxD lHuHqVuqxvNuLioAhtFWH29lH6BRziOELixqW/CgNaFJaXHeQqm4ow5JbBqAGUQSu/g== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796453467; 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=Av8THbB792w16e3ax7vVn7j/qe6SieN21TnhCYcel2k=; b=Wd9RiaU/+MgC8I4qlil1BLYjY7KbEaAIWtU351pvSJJtPw3aohIRagUhfLdpNVF0eYUX iEacE7p0plB4BxfNKp+E5VQrVrZ6MnaAKpBcy8L6zy/bY5dvFxTeNQASCzF5DFuWff0Hq yToBTHHE0ONLPx7eYhT/ehp5AnmrEgN9+CVTYHn7xNFfSmJMP8yiRR3aQCk7X6fHE2cRl CmCVo0ZxRgLsMIV8sRG4bCgmEHgCVzypWF4k88YleICXIaLDYfiARwJo33CPqDyScixK+ 8lYrGju/8taR375H4PtLxhID5EkQJ0LaRrNT3k8h2G4q1JzFDnmUQ9P2dA2p/+0w1fA== 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 6CA621F0092B; Sat, 5 Dec 2026 06:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796453467; bh=Av8THbB792w16e3ax7vVn7j/qe6SieN21TnhCYcel2k=; h=From:Subject:Date:To:Cc:Reply-To; b=n5a1NndDZAMvMzOhqQJrzxSYHIw75T/uykvVy8QNSoISFJG2ATkR+feDqct/YwSAx IbYC/RNMQyvv59OtRKpAQBPPAqKPfhRY9+ov4RiEd/pVWtSlIwJ1Fplneezvl3eTLm 5ipkgugY4UF8tUn9zDYbJNlTBilzqioDRtzr0nYl5ynUHhi0JrT3hMSX8wJ8GCaVBZ cOAv0aMyI8DQx5v5HVZyUvLTYC8ZnWqOdS4hFAMIP0PyKZiB9XX5rCIbOEstKpcxCj e8SLsg9cNqDJqHYJCCzZumABO/ubqZLSSP/tSvogGn3jWzsutRF/uUg/Ei7r/szunP ty0XO6Ld0yHCw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id C3D08501CD; Sat, 5 Dec 2026 06:51:05 +0000 (UTC) From: Arun Iyengar via B4 Relay Subject: [PATCH v3 0/7] accel/rocket: Fix teardown with a job on the NPU Date: Sat, 05 Dec 2026 06:51:04 +0000 Message-Id: <20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com> X-Archived-By: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/12Oyw6CMBBFf4V0bU1fEnDlfxgXdBygKtS0tdEQ/ t0WNuLy5t5zZibi0Rn05FhMxGE03tgxBbkrCPTN2CE115SJYKLkXDLqLNwx0Na80VPkSlbQCKk RSUKeDpciEefLmv1L3xBCduRFb3yw7rPcizzvVrVgfKuOnDJaVyVIPABqpU7d0JjHHuxAsjqKX 1j9wSLBWLe11mWbvt7A8zx/AY4YDGz3AAAA 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=1796453465; l=3805; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=B/+Czs1tQESj01JJ3GK30r72kVusM0Ekhx9qzOs7YGk=; b=5tENH6audnuGTwLdsQky41e4/L5g3pwdmr1fdXNAaA24sVklr2yXdK3uck2GE7RAt1u54N4S8 KIhv9q+71kMCzUUijBqgAG7lzyZbjzWvJ6o/Tun5gmFy6/KrcDuERLK 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 X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: aiyengar1990@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_REPLYTO_END_DIGIT, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 and removal (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 in drm_sched_entity_select_rq(). After: none of these in 70 kills, 10 faulting jobs and 3-5 runs of each unbind case (job running, hung, pending, idle, during a forced timeout or a slowed reset, two and three cores at once). Inference is unchanged after the rebinds in the tests of patches 3-5, and a file open across an unbind and rebind gets the core back. 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 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 | 57 +++++++++++-- drivers/accel/rocket/rocket_drv.h | 8 ++ drivers/accel/rocket/rocket_job.c | 156 ++++++++++++++++++++++++++++++----- drivers/accel/rocket/rocket_job.h | 4 + 8 files changed, 210 insertions(+), 30 deletions(-) --- base-commit: 502ea48d0d8fa5dd0c31dc449efb3d82deef8efe change-id: 20261130-rocket-fixes-e1438ca23bee Best regards, -- Arun Iyengar _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip