From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382202; b=IamCIavy193gevnARXPg3Z1B4n67+wxV/4Kf/EhZCEXyI0em1Ee8TMlB7r6rZhRm74w7 tr1CCVfgNMOu5ejsJXSAyx7ThOFpgQdCzvLm6eg4QJ9qgwAbu5mGAzXYWNu/VkCARi2pa gCKCGQP5HJd/EuxnjDsEC0XWFjPOkrV0h5ZJr9FfEcpFrXeIRJFiliKPShsqTB2jw76am kSjQhcERzraiuC1A5iZssvfTkkzVrpGcSbgZTlj/Obzc79BzLUUsoUqAMwQrhKHoxqo3n IVkI0zfC8PpsmIBvc5S0gH4490Ozh2OqNeao8O+qu6qag5JHe+shbmL4Zku+hy1Rz1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382202; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=g+kIIZIjO5nSnuioKBfcdasgGqInfUB9zZRlntybaG4=; b=5YJpx40mT3jB7cbb101OZc/1Qd0ak6gUt1HXw0uHjz1gg0O6i9cw7/55XdcYxAx7lwKu Yl75eh9uZbBPi9hDEx426rR2wjZV7ks/rtqxh3o21olI2xiHA/ypTUOIzIOJGo59LZbCD xRtH0Uruv6oUVybjJDUrySuIFO/ewvQu2NkcMBwr8Yu3DsigXj1yxpVEGSEN4kGgr6aNu krDUOzWr529U5JezsMRF94ceCsKwEYPkQsFanPYVWsyI4h7cr1Xctfj0gFYnrfx97df/b LzG2kpKdwv0iGeEyXlUmGfcJUoLeKgHhvSYZ8zlkKJVrWI4Wg+F+fc5FeOOU/YkBogA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FD6zgoGO; arc=none 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 DA7E3606A322; Fri, 4 Dec 2026 11:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FD6zgoGO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AD41F000C2; Fri, 4 Dec 2026 11:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382202; bh=g+kIIZIjO5nSnuioKBfcdasgGqInfUB9zZRlntybaG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FD6zgoGOmLK8pPc2dUbVlD0lm3Mh212X63giI5UbQpnkp2rGi+Ut72o3UtnapOc/4 /ixea49SX/uKwTLKhU+y6tb5KfFaBaLXjUpTin6wN6Cou3jDQOru+xXDPHUyCI8Hwq WaBM0tiQWA7mw7Og4uJkC2Ifh8IacJfkNRKvSgMI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Igor Paunovic , Heiko Stuebner , Tomeu Vizoso Subject: [PATCH 6.18 352/703] accel/rocket: number the cores by devicetree position, not bind order Date: Fri, 4 Dec 2026 19:04:11 +0900 Message-ID: <20261204100637.161609280@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Igor Paunovic commit 97e48904cbdb32e4a66bd60d26ce45657f58bc46 upstream. rocket_job_hw_submit() programs the S_POINTER registers of a core with an extra bit derived from core->index, the way the vendor driver derives it from the hardware number of the core. rocket_probe() sets core->index to the slot the core takes in rdev->cores[], which is the order the cores bind in. The two agree only while the cores that bind are a prefix of the core nodes in the devicetree, in devicetree order. Unbind them and bind them back with a different core first, have one core's probe deferred behind a sibling's, or disable a core other than the last one, and every task submitted to a core whose slot is not its hardware number times out after 500 ms. The reset that follows does not help, and the inference finishes with wrong output. Observed on an Orange Pi 5 Plus with a KASAN build, over all six bind orders of the three cores: only the devicetree order ran clean. The other five produced 27 to 141 "NPU job timed out". In four of them no output tensor changed with the input, and the harness gave up before its first measured round; the fifth got through a six-second run with 27 timeouts and a wrong top-1 class. All but one of the timeouts land on the cores whose slot is not their hardware number, in proportion to the tasks the scheduler hands them, and in both directions of the mismatch. Number the cores by their position among the core nodes in the devicetree instead, which is what the hardware number is. The wrong value has been assigned since the driver was added, but it only reached the hardware once the extra bit was introduced, hence the Fixes tag below. Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL") Cc: stable@vger.kernel.org Assisted-by: LLM sparse Signed-off-by: Igor Paunovic Reviewed-by: Heiko Stuebner [tomeu: shortened the comments and dropped checkpatch from Assisted-by] Reviewed-by: Tomeu Vizoso Signed-off-by: Tomeu Vizoso Link: https://patch.msgid.link/20260922080114.44662-3-royalnet026@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/accel/rocket/rocket_core.h | 4 ++++ drivers/accel/rocket/rocket_drv.c | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) --- a/drivers/accel/rocket/rocket_core.h +++ b/drivers/accel/rocket/rocket_core.h @@ -30,6 +30,10 @@ struct rocket_core { struct device *dev; struct rocket_device *rdev; + /* + * Hardware number of the core: its position among the core nodes in + * the devicetree. + */ unsigned int index; int irq; --- a/drivers/accel/rocket/rocket_drv.c +++ b/drivers/accel/rocket/rocket_drv.c @@ -157,10 +157,30 @@ static const struct drm_driver rocket_dr .desc = "rocket DRM", }; +static int rocket_core_hw_index(struct device *dev) +{ + struct device_node *np; + int index = 0; + + for_each_matching_node(np, dev->driver->of_match_table) { + if (np == dev->of_node) { + of_node_put(np); + return index; + } + index++; + } + + return -ENODEV; +} + static int rocket_probe(struct platform_device *pdev) { + int index = rocket_core_hw_index(&pdev->dev); int ret; + if (index < 0) + return index; + if (rdev == NULL) { /* First core probing, initialize DRM device. */ rdev = rocket_device_init(drm_dev, &rocket_drm_driver); @@ -179,7 +199,7 @@ static int rocket_probe(struct platform_ rdev->cores[core].rdev = rdev; rdev->cores[core].dev = &pdev->dev; - rdev->cores[core].index = core; + rdev->cores[core].index = index; rdev->num_cores++;