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=1796380647; b=iZntfEm0y8L/4KRIwtihHma2CmraqafDgdhDEikHR1/HjDflBidzTKSANWXrGRSTB9DA XvsSjYHjsuAjEwp7BsvkaOrD5bORQw/VOprmC5A9DBstcjAXb0DQgjNpq7dpxAck+dA04 lc0Ig4s0MzfV3H271NZJzgLiNDx99+gohhKf2yNEX7yIpbfYS/xzCf9qsykU4zr5bwREF O8NYMzXHWcOBBY1oH3nNMigjiT34nrpKd/hjNxpaP3xTcdUbkkXPGsibzRFssSf37Kdmq yBAAhl2peste20ju4K5NBSricjlWkPzd3sA3ELWNI86T2kgqH6Hn9ndBYLcxSGiZ9fQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380647; 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=5jjdHTQ7tcEWVbltJv391YNwvrkHra/nAhf9bdJJtIQ=; b=cWngaclAowf9sGXVi2VQ85oyqcKM10Q+2Ad9Kmq718Y1YCBuddr0lNWRlAOI+aEgKGCv u1z0bUY9aL22Xx98RA1V7Vi2RDbgtsdxiAb2qVI+rn0bM2WhepSiPLMRZAJ/Iv3DOFxcu u7+fTpnzAVNAZmYlxaBgD2Ngr7bNVWH6kF8EAsGJCfue5bzg1PIdOByPjbj9WOMJngfUP oig0O14/zkKD0n9kJD806wGOyJeDzeURevRrm7QXvy1iRwWm+NckNHJ0akOdCrtB/phl1 mqCPyoRWU0hSBeq7nEmjR3EA4v2BSCxidn8444wITED5MwOdyWwIk1z0BI41wlCqRLQ== 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=DqCcW6ab; 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 BB509606A334; Fri, 4 Dec 2026 10:37:27 +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=DqCcW6ab Received: by smtp.kernel.org (Postfix) with ESMTPSA id 365BE1F000CE; Fri, 4 Dec 2026 10:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380647; bh=5jjdHTQ7tcEWVbltJv391YNwvrkHra/nAhf9bdJJtIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DqCcW6abf5Sj2UqBNVHdEupF5L7XwZsJYE/XfITXbi0nHONd0lJ0j2aY9iEah+ZNR BOSaSm/xSKNBMXCO9G3JVdDSKg5IcpE0Cn1ijSkjRKjinII3YEeWp5Dj77aDh1nfSw /lqiVzOb2z0IMXOrufrxmv/95kqKf/0B/vdtEaNQ= 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 7.3 366/742] accel/rocket: number the cores by devicetree position, not bind order Date: Fri, 4 Dec 2026 19:03:50 +0900 Message-ID: <20261204100644.807596300@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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++;