From nobody Fri Apr 3 09:43:25 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48CC433554D for ; Wed, 18 Feb 2026 22:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453332; cv=none; b=txC73RedvT2wM+rOfWFJMXKuuXiNzUH2roEeXlOI8aNlClPGhykqAwSc7ELU3GKW0rTYefY8uqvn09nAF2Rk0FXM9OLpoVQtA4Dq/3Q02zBoPFtcUUjLauYo3sCNQbeMTr7mzHUOj+3AtlGm+QSC8OcZQ7PqmJAl8EW2ExEzwn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453332; c=relaxed/simple; bh=kczQf5pveMrT0v9OOfXTflG7Z8dLFCGJWHb4Bpgb2OU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UgDDsEDpvAkDhxLf5IT/vs3AUk+e6Cst1Z6hpfLSVzGrUYyFKUfsjS4faOsDb/pR7hYUzvPEvdi9JfBLB0Bcafd/tL5QLLkrvadF3BBPrydoYWQMx3rU1c3d8yse0JBU6hJUxsfpv3I5WBdDsbcQNtwNOhdbx+ghCXTsZjJY5mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nTInkkkb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nTInkkkb" 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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/ethos= u_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; } =20 +static void ethosu_job_err_cleanup(struct ethosu_job *job) +{ + unsigned int i; + + for (i =3D 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 =3D container_of(ref, struct ethosu_job, refcount); - unsigned int i; =20 pm_runtime_put_autosuspend(job->dev->base.dev); =20 dma_fence_put(job->done_fence); dma_fence_put(job->inference_done_fence); =20 - for (i =3D 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); } =20 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 =3D ethosu_job_push(ejob); + if (!ret) { + ethosu_job_put(ejob); + return 0; + } =20 out_cleanup_job: if (ret) drm_sched_job_cleanup(&ejob->base); out_put_job: - ethosu_job_put(ejob); + ethosu_job_err_cleanup(ejob); =20 return ret; } --=20 2.51.0