From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C99E2E9A04E for ; Wed, 18 Feb 2026 22:22:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE29C10E323; Wed, 18 Feb 2026 22:22:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="nTInkkkb"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2AB6710E323 for ; Wed, 18 Feb 2026 22:22:13 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 589396132F; Wed, 18 Feb 2026 22:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD2EEC19421; Wed, 18 Feb 2026 22:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771453332; bh=kczQf5pveMrT0v9OOfXTflG7Z8dLFCGJWHb4Bpgb2OU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nTInkkkbchdY2PxOwa8QHmu7TRmxC2KzPod/2wMz3GlOKzGhj0GBT+sqGvMlCK+Ti At4yoOYbjMm7KYIGplcHVUDN6UsvIWarUzKwaURgbk+HPWRGxFqvV35BuC+WaVEXjM VghcUoyh9Aeki3KvKIIuZqXmRZdfrV68CXENucMVYJWjAXo+K2BFft/mw6QCItG7Gw Ud32b25nIYWkjt7PuplVLNyLo5A/7F8lO4+PKF+nlyM6zEBvw7qela8hJsNkiTqS9J 8XLLF823TigOf9VJ5vCd1whC9X59OkM00yGBKgFc4CGLnQE37VRt6uvaCgYevNycLy dSaIsY3m39w9A== From: "Rob Herring (Arm)" Date: Wed, 18 Feb 2026 16:21:55 -0600 Subject: [PATCH 1/3] accel: ethosu: Fix job submit error clean-up refcount underflows MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260218-ethos-fixes-v1-1-be3fa3ea9a30@kernel.org> References: <20260218-ethos-fixes-v1-0-be3fa3ea9a30@kernel.org> In-Reply-To: <20260218-ethos-fixes-v1-0-be3fa3ea9a30@kernel.org> To: Tomeu Vizoso , Anders Roxell , Oded Gabbay , Thomas Zimmermann , Frank Li Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15-dev X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If the job submit fails before adding the job to the scheduler queue such as when the GEM buffer bounds checks fail, then doing a ethosu_job_put() results in a pm_runtime_put_autosuspend() without the corresponding pm_runtime_resume_and_get(). The dma_fence_put()'s are also unnecessary, but seem to be harmless. Split the ethosu_job_cleanup() function into 2 parts for the before and after the job is queued. Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver") Signed-off-by: Rob Herring (Arm) --- drivers/accel/ethosu/ethosu_job.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c index 26e7a2f64d71..70a144803b09 100644 --- a/drivers/accel/ethosu/ethosu_job.c +++ b/drivers/accel/ethosu/ethosu_job.c @@ -143,23 +143,29 @@ static int ethosu_job_push(struct ethosu_job *job) return ret; } +static void ethosu_job_err_cleanup(struct ethosu_job *job) +{ + unsigned int i; + + for (i = 0; i < job->region_cnt; i++) + drm_gem_object_put(job->region_bo[i]); + + drm_gem_object_put(job->cmd_bo); + + kfree(job); +} + static void ethosu_job_cleanup(struct kref *ref) { struct ethosu_job *job = container_of(ref, struct ethosu_job, refcount); - unsigned int i; pm_runtime_put_autosuspend(job->dev->base.dev); dma_fence_put(job->done_fence); dma_fence_put(job->inference_done_fence); - for (i = 0; i < job->region_cnt; i++) - drm_gem_object_put(job->region_bo[i]); - - drm_gem_object_put(job->cmd_bo); - - kfree(job); + ethosu_job_err_cleanup(job); } static void ethosu_job_put(struct ethosu_job *job) @@ -454,12 +460,16 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file } } ret = ethosu_job_push(ejob); + if (!ret) { + ethosu_job_put(ejob); + return 0; + } out_cleanup_job: if (ret) drm_sched_job_cleanup(&ejob->base); out_put_job: - ethosu_job_put(ejob); + ethosu_job_err_cleanup(ejob); return ret; } -- 2.51.0