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=1796110090; b=kFp/DjcUNJgajebnzbP+MHtF6TOmFljUoR3GBSIgHmN+OyeIGQ2tBZctRCGCjFJfvyKV cZLQR4Gwvv38FB3ujHacJMbBKtHAoHCsAQD9mREWauKBL/Fn8YCjfSGIGKaTcwyUlr5OD KcZ09nVY9KHaG8nxxB4mwpLWscMlRemvk0MTETbVSOj4yw7qak1tcXwBzsKSHFllla4O3 wB/fMbEc20vaCr7u4r8puPTc8opTOBmHA2z8/nZUSg29HCUr0iHkPvUqBE2OQd+lh38MT 80Ik8NtfoxlthDMLG12mF45wiJhBjYaPF3B3HcOkkjh1MA3QNongxB+i0pEf1LLyBGw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110090; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=3mzU2r4OucJZqHSrJreJudboUfFRG8tvg3A1Uz07sVk=; b=yw3PbMQ6iDzNEIWDG0Y2JvCkWGBpZc0Y24nLQWQN+J3ho4o+ETIlxslfS1sVJu5BLPrE h5w9Ydz9YrdSSFI+QUbwvX0KjDC86WMFZ3P6xEqx6RO/s/Xj1Bl6H1ldgJ9Nymx9NFMYL PG2pcpVqjuBHpaUU3/Blul+WN0hYQzCXnWvm5wGuz3+2eUAGikIQ2t7M/7wjLcH/IkL0z mkm/g802UVZGyKctfwQ27PHGE9ezlYCTREY+C/XpZr46uxTEf2Hd9LeFAQRpA7je2hckp 4iDIqDojNio0Uj97RJQ+YV1XMLTX2jfQRuf9oEPdLKjg+DvcFVdmGiNbWjZmFhkMiIg== 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=dYFVLs7W; 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 E8A81606A33A; Tue, 1 Dec 2026 07:28:09 +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=dYFVLs7W 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=1796110089; b=WuZxQya35K8azHi2ATrqCfOz+wazwv9w5jiVzejJi+V4BT45s0Xhl2fzGtQf63BcFb8d BuYGLWwpZvEwDbjuNKn7kq5/skp4UztV/H6Nd77pi7G5Wj6tfWFBstY9ZUNXkxI4Xz27h 79KTGdDbNp1pdbEDs0UE4zWAKo9vdQZ1/rGiIIrvxHOsyZcl8BYxZq7nnUxc8sULXWDo8 Nu0XAF4jOBRfrXgMmG+DxWrmAk0UqdSeVeCIBU5UL8M+1Wsivt4rFb0o2RXfydbq6TVmd EdL/ni3NcRjbWTK7BFczwSPN1/m9VFIXoW3NpLneM5YRZ2yPsKxeZF9UmYKlZwD507Q== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796110089; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=3mzU2r4OucJZqHSrJreJudboUfFRG8tvg3A1Uz07sVk=; b=uNWMym/9/j5K/NLN7yOd1uDuDuRpuEzfZcjd4jU5J5idOyJCy8yvNOmOViZJfZuaKxYf RfMsXbpwugaNqZXHHpnG6rGyjLPSWYnM8e5r7eJ/srELbTFCT9y06FnpWd31simmn0F18 Dll8xn+v15j/hDnud62UTOiGZBUMKsrnDyC039HwqLAZg3/dugfj5b2DrSO0T1tzceRj3 62ZGeGh0La7PLsU6pLPbzwYbTLrDYU92e63k/3xxER0ghVWQwMLwtM6b4AHucLUAMxUxO PGnxig3wK4m4caaJ812LPUrNZuqAr/KOjvsJFmaITcNQ4S8ycGUO8hcaAt4f4aO+ysQ== 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 DCF4C1F00898; Tue, 1 Dec 2026 07:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796110089; bh=3mzU2r4OucJZqHSrJreJudboUfFRG8tvg3A1Uz07sVk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=dYFVLs7WnaloDOdrQjvncwoJLM0Uh19aNuF5Z3yDFktNTeV9V8eQ+zT80A82DG5ba /ggvKagn+/smwjfyeCwOJ4NNDDV0+nyQGmPUzWEyB7e6g1FijAMdTt3r4x/s+33fNq 5jwetFSbZf0AhDsStRKeORxh5wHNjifyY0a33qKRPXTnrCBWVrVi/ZY3x1wAndnUQr 8AIXX6J20WLCJyskzUOtCkdhrjQm+z12T11fc6Sn7iXz7eNPUaDc1IcoZkF7yRNRPm fuqIT06E1+3RoX85Si5hcpVwucbyNK+Tn6Y1GkbOtxb8buFYEdah9mEKQATx8vIvvQ mr0YU+hftiK/w== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 647E44EC39; Tue, 1 Dec 2026 07:28:08 +0000 (UTC) From: Arun Iyengar via B4 Relay Date: Tue, 01 Dec 2026 07:28:08 +0000 Subject: [PATCH 1/2] accel/rocket: Wait for in-flight jobs before releasing the file's BOs X-Mailing-List: stable@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" Message-Id: <20261201-rocket-fixes-v1-1-986c3e5ceb44@gmail.com> References: <20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com> In-Reply-To: <20261201-rocket-fixes-v1-0-986c3e5ceb44@gmail.com> To: Tomeu Vizoso , Oded Gabbay Cc: Heiko Stuebner , Jeff Hugo , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Philipp Stanner , 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=1796110087; l=4388; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=LmGB7IX2m0n7xXkTUFs9Q6ABTiFHAvWnQXeZumKW8Ic=; b=8ZCNFVRlIB5FkQ8COW6yLrJp9zqDQbZS76oraEXUr4r6cORhB19Dh+onN4q9BD967KPkvuyHZ rdz1qHvh9ZbAoJNcbA+inxRvn0XPb4yLxDuFoSLx4gL3yxU3phEXYMl 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 Content-Transfer-Encoding: 7bit From: Arun Iyengar drm_release() drops the GEM handles before calling postclose, where the scheduler entity is torn down. Jobs already on the NPU can use any BO of the file by address, not only the ones they list, so a killed process gets its BOs unmapped under a running job. The job then times out. Tear the entity down from the release fop instead, and wait for the file's last job to finish there. Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL") Cc: stable@vger.kernel.org Signed-off-by: Arun Iyengar --- drivers/accel/rocket/rocket_drv.c | 28 ++++++++++++++++++++++++++-- drivers/accel/rocket/rocket_drv.h | 2 ++ drivers/accel/rocket/rocket_job.c | 14 ++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c index e62a20edeca7..9251f2ab0154 100644 --- a/drivers/accel/rocket/rocket_drv.c +++ b/drivers/accel/rocket/rocket_drv.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -122,7 +123,6 @@ rocket_postclose(struct drm_device *dev, struct drm_file *file) { struct rocket_file_priv *rocket_priv = file->driver_priv; - rocket_job_close(rocket_priv); rocket_vm_put(rocket_priv->vm); kfree(rocket_priv); module_put(THIS_MODULE); @@ -138,7 +138,31 @@ static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = { ROCKET_IOCTL(FINI_BO, fini_bo), }; -DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops); +/* + * drm_release() drops the GEM handles before calling postclose. Stop the + * file's jobs first, as they still use those BOs. + */ +static int rocket_release(struct inode *inode, struct file *filp) +{ + struct drm_file *file = filp->private_data; + + rocket_job_close(file->driver_priv); + + return drm_release(inode, filp); +} + +static const struct file_operations rocket_accel_driver_fops = { + .owner = THIS_MODULE, + .open = accel_open, + .release = rocket_release, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .poll = drm_poll, + .read = drm_read, + .llseek = noop_llseek, + .mmap = drm_gem_mmap, + .fop_flags = FOP_UNSIGNED_OFFSET, +}; /* * Rocket driver version: diff --git a/drivers/accel/rocket/rocket_drv.h b/drivers/accel/rocket/rocket_drv.h index 7069ececffc4..f7a77ea98467 100644 --- a/drivers/accel/rocket/rocket_drv.h +++ b/drivers/accel/rocket/rocket_drv.h @@ -26,6 +26,8 @@ struct rocket_file_priv { struct drm_gpu_scheduler **scheds; struct drm_sched_entity sched_entity; + + struct dma_fence *last_job_fence; }; struct rocket_vm *rocket_vm_get(struct rocket_file_priv *rocket_priv); diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c index 454d465a39e3..32926afb0144 100644 --- a/drivers/accel/rocket/rocket_job.c +++ b/drivers/accel/rocket/rocket_job.c @@ -210,7 +210,8 @@ static void rocket_attach_object_fences(struct drm_gem_object **bos, dma_resv_add_fence(bos[i]->resv, fence, usage); } -static int rocket_job_push(struct rocket_job *job) +static int rocket_job_push(struct rocket_file_priv *file_priv, + struct rocket_job *job) { struct rocket_device *rdev = job->rdev; struct drm_gem_object **bos; @@ -246,6 +247,9 @@ static int rocket_job_push(struct rocket_job *job) kref_get(&job->refcount); /* put by scheduler job completion */ + dma_fence_put(file_priv->last_job_fence); + file_priv->last_job_fence = dma_fence_get(job->inference_done_fence); + drm_sched_entity_push_job(&job->base); } @@ -585,6 +589,12 @@ void rocket_job_close(struct rocket_file_priv *rocket_priv) struct drm_sched_entity *entity = &rocket_priv->sched_entity; drm_sched_entity_destroy(entity); + + if (rocket_priv->last_job_fence) { + dma_fence_wait(rocket_priv->last_job_fence, false); + dma_fence_put(rocket_priv->last_job_fence); + } + kfree(rocket_priv->scheds); } @@ -641,7 +651,7 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file rjob->out_bo_count = job->out_bo_handle_count; - ret = rocket_job_push(rjob); + ret = rocket_job_push(file_priv, rjob); if (ret) goto out_cleanup_job; -- 2.55.0