From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795939179; b=GdWBg89diEYy+IxzjN4reZR5BmM7wf4wR84prlkzfQuIG9EVFdgeUWIUUnJYhFdMN7qk f+wu/sA6wbFhrY3KqvxMmuG8jibvAa1XMiAoCp4r9QZerRrwqA1EDh83S4lQbsqGN3fkn uMQT/ou0aWc3q1G3094FQ7P1IAsDWqiWnYA8fB7gq4MUJMR0f68HlGXxgtWBQfHa6snMv A+IpsZqCu2nIxhR976C9wCzcTYiUiB6HEgfT6/kUkLi8WSiDAq34dieaAcVgLEHTpm2Hd JpKJLU1tBjQq1T8JZjS/biCPQd+BuIan6BeY8iKfw2nd5u1VbxcdcnrWP/xROWrbXpw== 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=1qn5T0cFlPI/K8qk9G/y3CkEI4unPggibe6L8FU8r4oYs1rgUnJJfF0YKYW5qXvj+i/K W1KTMtUppABRuj2y/xozor3O0k1tx8Ey+676rZ3uZ5s7b9FuEcZw5HvJ8rULA6kuSjZOr BrPesJYrNO6r65JSBOPivrbvL9K2wDPl/soPiDFete+S1+yALTZsVcOX5SFbtIvSaB/UC l2V21O97mmcJoIJ3p4PKVRAaoufkqUPuqvD8n2xUau4YRgooo4gO7ACqKobRUkEeF0PY1 TZc06EK54IolUHXZatdOlB1DdtnJcKwey/OZ8KPPKifNq0cAtcwEBDMnq0JeUIuY2kA== 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=KCoD1R59; arc=none smtp.remote-ip=209.85.216.53 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 B1398606A323 for ; Sun, 29 Nov 2026 07:59:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B1398606A323 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=KCoD1R59 Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-3b44bdcea8aso5461236a91.1 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=lists.linux.dev; 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=KCoD1R59IFwx2Q69n8zkLPlxf8ckwq+NcQ+NXa288gFT4PaQJERl9fxxi2yO91QMuj KxGNHNlgNjwmNiL9yFaToqvTA8anL+/CO9DRTGKddxEri1UASznhmFM5TKVi1D4LCTLo qK6K7ZVxJ9oPVHp9sGUi/QqT5c9ausnY5TyJIcht0uGqbal+WEBVJfuhv4Ox+nREvTEw cE/Dkt3QhEGDCTynO9YVH5khGznsmB8ZA6Sxl0N0dM0p4OtmgfGuSHFryvIxYufSRhIn Z+kBC93cTXpylz4FoViXfNn7EvW8g9XutyF9IZKUXnVcfsz+6lHbYN23emaqEDVQt+5e hTbA== 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=o9nX/8GiUBnEQdAjsJ3tRXM11jiXr+rvewsnP+PVugJ07JUTlbjWFFQFXeWIMpUZ66 HxWsIELGmhVkprif36YeP/P9ih7jTBEU2siNudymuWvuoVbiqVOQKgHnn93sGUDpkQR9 0XHgAI5opztxgvCBNSB33ieY6iKJHEIj812hNe/zZ8hWMZ93vcbjoqFfd4eSPSythkcQ ek2fB0805ho2amj0JMRMDKJSfnuy9l51u5ZCjbomAY/eMPgV6KdrtbJkjBBMvtk+Xv61 A+zsL/vrBskce0Uwvf3zmdkc4VByKwscoyrhtOt23POYKOaFlox3mzTmou8yY0h+iDQK VOhg== X-Forwarded-Encrypted: i=1; AL+hErHCzcdYKRkahv6oXn8XAxxSQiT98RZF3okZwVYoGppEfZA3gByiW3xxflmD6EHRBDSf/CkQ/+SqHoABnxNz@lists.linux.dev X-Gm-Message-State: APuU4Z8kHpRRHznYM9MjXBQT+TrZhc5ip+Oz9QCaWW7WB8zF6we8hIAP TMLivuApRkkrW1hmmNJ8HV69DiHJFZ4FcJx+iMsI/8HtcAurmFmy8Rp1 X-Gm-Gg: AZFdTZdW+eMuE3iLR+RGXcDO3pw2qME3J5Ksrf7YZuZlwkw/Uu6ktLC75zy9CX1M9KT OV6WRBXVX+F9D8Smar38TYX0EXbF4QpWSSunhrouqs4gnpGGfcQOcklJCi0LKGHlAcJHHYbHmq3 lhhRLfg9UD9YE6qt6/OT5s8AUsXQ7tItbIISdkzz8z4jBj9faRyNxbDnsIsdVScyhiIoToQwMXN VfvpDM4NRApO6qB/JFcQ6mqGXgUmdc2xDTDrMQ9r97VVr/XVEwoWuyrLps+Hr4r3qKMHCcCA6OW G+NhbEyCs6kc/PrB+AWaYzQH9s1d2bU7TPA4sulMy1h+prz6ZqSeJmov1sQTGL04OnWBELU0FbS 1FJZxLDV+B1VKCrxqvVPF7g07Xbpbvo1zqNSeK+RDUDSZSdQqiRjpfShhIP4WMhOi0qPnkoiG0w LI5gFwQzAqy4/HnjtmQi9jlzPYKxLWqOwbUDi3WKcQ2iQCPUJdoGfybgFL+fX77ZStfL6yxLz8R jG/mGhOyvH6aiYYD6h7//+Xp1+2wu9Ct7mZBJ8W8VSMrFhIPFJQzvYLUtJAT9Z4Zz40IOPI7suI UA9ANdx40/SiqljjBwDk5xqBzC+vZ0GXJeXZ+d7b1WkpvS/GluSa2DEeMgmBCUXrx4A0KWgJx+X 8Vcv4tJoBxxs= 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-staging@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 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