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 C2609606A6BA for ; Sun, 6 Dec 2026 07:17:22 +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=sPIBcJG0; 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=nMI7/XV0 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=Z7rIiK+piiC+BkHMsg96GBd8C6jsAJsTiauAC2sJZG8=; b=sPIBcJG0CRNzPJ28GeoHg2Lqdl luw/Y1Wfr9rZrCwoQJjye77ihQWubVQkKNcyXrLHPSYXD98bWnYbMTors/esV/dyf6kbYHFdnoZ9H qy6cLnOGv4/9OcbS+jpXpTgV/GN95PWM/Y0Q0Sd9gBpm6iBkiOl+UHv5UOxdqEJUraHxnFA2xumKv Go6Rstm/KHYlF1DhTFzQXFuGQGUsVNo8hs8HHIlUzHBMS0FLvakvmoMVZZGQRpsj4cHb8bpvmu2BR IQQtTVf3vLl9m75V/sbz+263H6z9cGdq9GH/rPOi4+ZABc9Mls4xptYcljL1n00HjjVEghALdZzsn Am3XT/bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa6Un-00000003MTP-2JEZ; Sun, 06 Dec 2026 07:17:17 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xa6Ul-00000003MSX-2MsT for linux-rockchip@lists.infradead.org; Sun, 06 Dec 2026 07:17:15 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 4E6F3413F8; Sun, 6 Dec 2026 07:17:14 +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=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-Archived-By: MIME-Version: 1.0 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 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, 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 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip