From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795939179; b=LYYbrxfg84Sz2OaUYgD5HDU4c4LpkwsQOIkQZySblL6VFCnHQyLRKyKqs9PiGuhSifKx Xfix9lHrJK9T8mkTMG0vl4fYXEVxo8s4EgYk/luU6a075sRlzqEahoKu+jue/rhBLA/tA do5oHKbTtZP4DDu9Z6EF+oBnKQIU7nBaWgaJ8WLSLd8LzMot74cQOgFOY4R6HGSLoPoDN Ujk4yECmvqjRWo4zWdUCeImQUJXpRGs4hdVB0mo50ReXLgunUUoXQYOVLjqK91CzuCFu7 Vd2aZYWkEjH4bExDKufWPnSXGXXqlPmAGV2vYX8SlIh+MgPOiJWCKz1YaEKpnhSsJrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795939179; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=XMdIeTTPD+LVsgiLa1ViPAdbdO9gHZzqVdrf1f1jbLc=; b=tJuyjshFFj0kI+jvuhc3zBC+ZFM5gRV0GshdIXjBMEepfoSm4Lqbsjl9LE7k0a8NO6WZ VgMD1r4KIMQiuLPoPJaBrIMHFKZnxcEi0m/+mLJCQsdhW8XC9TGBbCY3AcElEenr/ap9T RZNyomvKrndD4eiMEiManSE4XrLhkw6zORFF7MVb76Bn+FJuLWyFSSagChwCzp+H9hMI+ nNQaYwF25CIM2QLZKt33dPGRx1jCJKT835iOSHM5aiH/2cZBYst1pW7lqFCHViVnaSRpt uX29aiWYkd4sVBthHEWgcF1k+BALhCSm+m8rEx0r8fjSIoDAPy7/Vk10pOg3JCIRkZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="f/vEF/fD"; arc=none smtp.remote-ip=209.85.216.47 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD963606A31C for ; Sun, 29 Nov 2026 07:59:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD963606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=f/vEF/fD Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3ae6b4c669fso7971772a91.0 for ; Sat, 28 Nov 2026 23:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795939178; x=1796543978; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XMdIeTTPD+LVsgiLa1ViPAdbdO9gHZzqVdrf1f1jbLc=; b=f/vEF/fDe92u1N29cp+LjXVp83c9FHST4piW7stdQ1Na2A7Swdat0i1DMo3yFvQwM4 GWCr+1vRrdEqWpUV17bbzoVvVD8TQbPOVtPMiZj7toDfx4idiF46YRJ2ymmQWGfMack/ dNgFCN1FFoLgrOxPi+Rf/JANdCI6ouM6ZolDfPSYKLKHGxDSl6OM0wf7ev+9DswFj4PV BJnhnaxTqCa+zQ2V7LNxLY2BGjXP2GZJVgGO+C/I5Sh/1JgYGRdekAfBOlqXl1tmRwpe fsyZjKAHQhV6SNxczo3smS4a3lBPcpw3s0rLhQeM1bZ95ZKsdN/a1GHcQv12RvZsVBto mVRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795939178; x=1796543978; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XMdIeTTPD+LVsgiLa1ViPAdbdO9gHZzqVdrf1f1jbLc=; b=VHf+gmawyEuBQimIYZfkTJ9ZLLv5SmyN5X5X5BwshIDWRWcOchszcj7Xu8petgiubU NlJlw6rc5jnAc3pvHdfETfonPICxNOW/e5EnC6e43qZ34lCGoYZddilqgQc2+ohgESkB Hh93Y9c4WEDrGNoVMosvnfQQx4pxrzs3LfiZJNVdOftrSueMnl/9pMzTfBaA8BXoHfHP 3NHnVyq01kfKULODxDPLn30wvA9hEM72UtYH1ybSW7owNdyDntNgKzUqg1O2jqXUnkqM twVExVp5x9bXfd65kOkcAH3dKNhoZ2tyEQ1no1NPI9KykkLJImpSNxZYofAL0IQMXWdf YCkQ== X-Forwarded-Encrypted: i=1; AL+hErEE9J1Qh/s5l7ujCsHjGiik6oaqBPwmBWJBA4UTJ10XhG1q+ZhWEvQW7a6bhlNw1qFrULVWkUf1ttVVemk=@vger.kernel.org X-Gm-Message-State: APuU4Z9a3LRtC+cQUW8tZWp4XqVnV8gJT0HA0Cc7N/wlk/1Su0BVgcMU cL921RLKpt7h+f/qjl+GCJBmaUXkkA1alfWEQU9xRLJ5j4NB1uCAic4Y X-Gm-Gg: AZFdTZfCDSCwUQtYBJJPcD0KGbwYLMNDLEkmZHIXZNK+qknR2wfdwn4RaW9vw2EiWwX tFEz9QLZk6RZZ7L+WPk7JQc7sGVn6S49dIYc+9+e4gbA8bOnji00Zbn67sVfsi/s5hGn73XMRJN LR8u6s4De8BBua/2kIcvCKJBaJOjhEQ4ZXSXDpK7Y6Nx81Uk6yx0vCyLiGfSscZWtx2p09rIlGz 9QDMjrAT/4Jc8sKNFp/iPNKfkbBD46TW7PuzzhdDnzV3P98LD+Uk+dzu6nz9/q6cmLy+0rX9+MA e+6sXnU8rG+hWgkpVu4/0PTmkk8oWljZoPKZQBNy1g4EmWE6O0O8fhWu/HVh+h7NPJOrTCq3WbF 6XK8aPhcpgJhQmAg2q7QgK/EzXF961DIknf6K/Ea4LOEEdMaPhspc/y5dUqnTkmGemvKakTN+aI 8qhLZL44AmJclqtBtRDQMcpgyjRvTRxZe+Agep3CQ05V2Og8gyrUcgOgteZvJMfOp2e6OvMs/SC S2kL7VQMDBxqn8JHcJqVtAqrsdUCsVW3QbOeeL1AzSIf2ct0pveddcqXwRmTkZJ9tV+XqeBBPfv XdBWs17r89SddrxfGdqGjgm06xZJE8yXj0nPQBR3NJe0fYsIdYZ/1+BneXHMJ701Xr1iAWdgbD3 0SZNOz2JFLp4= X-Received: by 2002:a17:90b:4406:b0:3ac:36c7:c144 with SMTP id 98e67ed59e1d1-3b41c93cbfdmr19794066a91.28.1795939177931; Sat, 28 Nov 2026 23:59:37 -0800 (PST) Received: from kero-io-MS-7E27.tailc6cdfc.ts.net (zaq7718fef9.rev.zaq.ne.jp. [119.24.254.249]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b405d63728sm52645669a91.8.2026.11.28.23.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 23:59:37 -0800 (PST) From: Akito Nakano To: gregkh@linuxfoundation.org Cc: ovidiu.panait.oss@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Akito Nakano Subject: [PATCH] staging: axis-fifo: flush the whole packet on RX read errors Date: Sun, 29 Nov 2026 16:59:21 +0900 Message-ID: <20261129075921.2897492-1-kero.io.frog@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit axis_fifo_read() flushes the remaining packet data from the RX FIFO on errors so that stale data does not remain for the next packet. The number of words to flush is computed as bytes_available / sizeof(u32), which rounds down. The RLR register reports the packet length in bytes. Packets whose length is not a multiple of 4 are valid for this IP, for example when TKEEP, the AXI4-Stream signal that marks the valid bytes of a beat, covers only part of the last beat. For such a packet, the driver reports "received a packet that isn't word-aligned" and flushes the FIFO, but the rounded-down word count leaves the last partial word in the FIFO. That leftover word is then returned as the first word of the next packet. This was observed on Zynq-7000 with AXI4-Stream FIFO v4.3. When a source whose last beat has TKEEP=0001 sends 29 bytes, RLR is 29 and RDFO is 8. After the failed read, sending the same packet again gives RDFO=9 instead of 8, and the first word read is the leftover one. Round the word count up so that the error path flushes the entire packet. Fixes: 82a051e2553b ("staging: axis-fifo: flush RX FIFO on read errors") Signed-off-by: Akito Nakano --- drivers/staging/axis-fifo/axis-fifo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 233d2b153934..96653e4afa3d 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -145,7 +145,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf, } bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET); - words_available = bytes_available / sizeof(u32); + words_available = DIV_ROUND_UP(bytes_available, sizeof(u32)); if (bytes_available > len) { ret = -EINVAL; -- 2.43.0