From nobody Fri Apr 3 07:59:12 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 From nobody Fri Apr 3 07:59:12 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 359FE3358BA for ; Wed, 18 Feb 2026 22:22:13 +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=1771453333; cv=none; b=Q5pxDq4A0kvKB+vAZ961jotpXiBKrMYuN9dIMi2kfwCZkGCHLByDAcUi1xfvyZg11/MUo3cfQ754Wc5+OGls8N7pJY33jQzlQNzRSdee9aw7RIHxHDzh3g09BU2FBa83hOZzw7kPYIxK/rHY8R9TC7TwIL1WAOMykI2AIyjDlbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453333; c=relaxed/simple; bh=6MIqgY4UQrceA2s9yZ6szCOXqUxXrfrLCpqE1Gg3myk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tIhO6PEAEjfKkELNbwfka3q2B7KI/DNlZ0gpj4SU4N3JsOnmtBW4OMQT79zHN7RFjwT+difWQLl/svWGD8wIz40kaRR1RQeHL8gvVwkyU/OSZwbzGMRldEArxwwZ2QDzLJgi9HB2GQACJ3NF6Vs6AMdxl+bghgKQyF52Rzi3YXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vPX4atLZ; 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="vPX4atLZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA34FC116D0; Wed, 18 Feb 2026 22:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771453333; bh=6MIqgY4UQrceA2s9yZ6szCOXqUxXrfrLCpqE1Gg3myk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vPX4atLZTSW93kyNyMIi+fG3N9D0EjyclpzEMVtLRoowsgTf/FrN+hf1c4+VmKLEN /w7aucS3uAtnHcbabrTiosuFLWg1zBWtLxyNzrG3CuubJULpWf7RVsJ7JJodhVQV/V U/JLAqRTOtRXKoOYIRrGy2uEtum7SZm6EpW10UGCf16wfUhErEuh4A8rLl6hqbbeKB eJPHUeHfctSsWt/HdTINKbesNhAM8inNAsVUceXmyVCCqkVMILIJ0EjlwDjHvLeVYD 8ltTE3uNyMw3C8aSdkyZk1p0ErZQIrkXtG8H0nKSj9yh2fDUsRZ53NBAkwZuHi1qDF bIPo83l08a8NQ== From: "Rob Herring (Arm)" Date: Wed, 18 Feb 2026 16:21:56 -0600 Subject: [PATCH 2/3] accel: ethosu: Fix NPU_OP_ELEMENTWISE validation with scalar 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-2-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 The NPU_OP_ELEMENTWISE instruction uses a scalar value for IFM2 if the IFM2_BROADCAST "scalar" mode is set. It is a bit (7) on the u65 and part of a field (bits 3:0) on the u85. The driver was hardcoded to the u85. Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver") Signed-off-by: Rob Herring (Arm) --- drivers/accel/ethosu/ethosu_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethos= u_gem.c index 473b5f5d7514..a735f860a119 100644 --- a/drivers/accel/ethosu/ethosu_gem.c +++ b/drivers/accel/ethosu/ethosu_gem.c @@ -417,7 +417,10 @@ static int ethosu_gem_cmdstream_copy_and_validate(stru= ct drm_device *ddev, return ret; break; case NPU_OP_ELEMENTWISE: - use_ifm2 =3D !((st.ifm2.broadcast =3D=3D 8) || (param =3D=3D 5) || + use_scale =3D ethosu_is_u65(edev) ? + (st.ifm2.broadcast & 0x80) : + (st.ifm2.broadcast =3D=3D 8); + use_ifm2 =3D !(use_scale || (param =3D=3D 5) || (param =3D=3D 6) || (param =3D=3D 7) || (param =3D=3D 0x24)); use_ifm =3D st.ifm.broadcast !=3D 8; ret =3D calc_sizes_elemwise(ddev, info, cmd, &st, use_ifm, use_ifm2); --=20 2.51.0 From nobody Fri Apr 3 07:59:12 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 24CFA304BDF for ; Wed, 18 Feb 2026 22:22:14 +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=1771453334; cv=none; b=uf2QtHdXFq+5Hnsufp7Ox2pWPQPqJQT2rbZKLq8eQGR4SWlITc+zs23WjGPHrj68xFOUrecbAhcFrh/RRCtdafqJmZYwHWpvnTPX+BpPfZJk6JpnkzI90mvylj2c2XveSOR94r/VTArCwTLbAzchMnZLC9fN19CPiVR/HnXlScM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453334; c=relaxed/simple; bh=ZHxw9mjElurFBBFJ5JXCeGqeCu/86mNjtr5wW+CUw/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y0/tTkfGuQljEZl2CFDhsE+s4Pa6wacs0n2H0JsR5xi9IDQTQ4zArA4UaBfYLgJ449Uzc8aty7mBV3k9PQunLyyCEdYE+UnDEw4FQ7f9oZGa6nc1AwtjoFhJt+PXR1N+3an5sOCdJV4pu/QzSVXMwzoUUwhzk6zprmZu+XLdMpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cTqtQAr9; 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="cTqtQAr9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1F6FC19421; Wed, 18 Feb 2026 22:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771453334; bh=ZHxw9mjElurFBBFJ5JXCeGqeCu/86mNjtr5wW+CUw/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cTqtQAr94tPVsOJC9u3krItTnDDk/5NByGKEubxgdIs3mXY2vpsEbjUT5inY0oRFt 6G1ot150bG357fmIMNMluq6CER1Yn9BFXCtn4J5bsJPe/GrrewSveDyMukPpA7gNNb +vrQvQNY/NlqAbvtGuxyAihB2DSxDpAZmMfVVaxKRsfOM1xNyF4F5RWIk0+wzZGwBX Fx9QLOYn6d/f2v4igRPB4xVzRvhdni4ePHbk6JD6wspYnycMp51SEdFVE0WEOrEOE0 ZXeilo/XUEB2wzDXYBuL5skC6VT3Eb/wMyhSgX0glnNGaJgC0l5ZR16y1VcET2Go0M 85HkWvZfhd0Eg== From: "Rob Herring (Arm)" Date: Wed, 18 Feb 2026 16:21:57 -0600 Subject: [PATCH 3/3] accel: ethosu: Handle possible underflow in IFM size calculations 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-3-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 command stream has larger padding sizes than the IFM and OFM diminsions, then the calculations will underflow to a negative value. The result is a very large region bounds which is caught on submit, but it's better to catch it earlier. Current mesa ethosu driver has a signedness bug which resulted in padding of 127 (the max) and triggers this issue. Signed-off-by: Rob Herring (Arm) --- drivers/accel/ethosu/ethosu_gem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethos= u_gem.c index a735f860a119..d1169001c83d 100644 --- a/drivers/accel/ethosu/ethosu_gem.c +++ b/drivers/accel/ethosu/ethosu_gem.c @@ -245,11 +245,14 @@ static int calc_sizes(struct drm_device *ddev, ((st->ifm.stride_kernel >> 1) & 0x1) + 1; u32 stride_x =3D ((st->ifm.stride_kernel >> 5) & 0x2) + (st->ifm.stride_kernel & 0x1) + 1; - u32 ifm_height =3D st->ofm.height[2] * stride_y + + s32 ifm_height =3D st->ofm.height[2] * stride_y + st->ifm.height[2] - (st->ifm.pad_top + st->ifm.pad_bottom); - u32 ifm_width =3D st->ofm.width * stride_x + + s32 ifm_width =3D st->ofm.width * stride_x + st->ifm.width - (st->ifm.pad_left + st->ifm.pad_right); =20 + if (ifm_height < 0 || ifm_width < 0) + return -EINVAL; + len =3D feat_matrix_length(info, &st->ifm, ifm_width, ifm_height, st->ifm.depth); dev_dbg(ddev->dev, "op %d: IFM:%d:0x%llx-0x%llx\n", --=20 2.51.0