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=1795960364; b=iAd86gNS77WwmKB/l+tgt3gLLcQPDksx+teVHsDCCtPrtPpWnw1ZuFQ8vKuLS2nGJBc1 bKmWX8KJa/mnHwwWbzB9cLBCrW39f7d9yfKv3HUzR48QxRZn8Z5Wo1IJn64mhSVwRFZOW aMsxqMsGBo1P+NWwMmj8RTLdTYPjYqduha6Dgink54BZ7+ktlnL4IYbNsifQVMkpZ1M0S QcoRsG5xD5bgi9FslG0H297mbqv+hTrsxIsbbjczDbs50QZRoSVsIzyq+APoq15sKPqfO 0oJBtgpEcldBgV0sZQiIwOGzlzlf6WmTXpx7YZGo3T5A6aCzL+3AkiU/tZPg7MskbNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795960364; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=hIXrtYkAc3lX77EtPSqTPR2KerIGkjut8btAqe+HRUk=; b=P//NY/x1Df0a++MQVPgiLZMSyG59N/UGyJGeL+terdtN3bVBS+dFUVoWvNQ/b5EWXz1s tZth4k7qJ3eBF2O3sgacM9wnxtuGKJkJ1q7Bd1lhe2tKzp9U2MIc9y7pmxTGvSnPAaTDE a5WzaDZNOqTYmyuOIh0A3P632+6aZJ27C3PT0chPWFzQEu+CTmV87qXPmkwc0kSXe2Q7A EusRnOSeMA0Z45z1J/1xs+yvqfb5lN//iig1w+DQyOjH/Po5uapvz84ZOO4mZADv0od3B zqPRTNptCoDfGKGJJNc0mhvr9ehLgVva3OvgdAyTXEcBAh9MnsfxHIR25at3zTYo3iA== 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=st9EY0Jl; 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 6BB33606A31C; Sun, 29 Nov 2026 13:52:44 +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=st9EY0Jl Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2AE51F000C1; Sun, 29 Nov 2026 13:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795960363; bh=hIXrtYkAc3lX77EtPSqTPR2KerIGkjut8btAqe+HRUk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=st9EY0JlhItvtaPTmAifeDdW8OxGuLNoem/QlcnBDGU2F5JMqMHlh9Nf5M4xW23Wf Lo6usewaf14kRFvjqrNCYOuA+V4A5xF0xYT4RgpkJe7ENLlrJMqPBid+nz/4OVc40I qDTVgRY8OdgOahVQCVaxhjMS9uXS5h00dqMYm6CY= Date: Sun, 29 Nov 2026 14:52:40 +0100 From: Greg KH To: Akito Nakano Cc: ovidiu.panait.oss@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: axis-fifo: flush the whole packet on RX read errors Message-ID: <2026112903-diffusion-babied-69aa@gregkh> References: <20261129075921.2897492-1-kero.io.frog@gmail.com> 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261129075921.2897492-1-kero.io.frog@gmail.com> On Sun, Nov 29, 2026 at 04:59:21PM +0900, Akito Nakano wrote: > 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 > If you have this hardware, any objection to moving this out of staging and maintaining it in drivers/misc/ as a real driver? I don't think anything is "left" to be done with it now, so I think it can be moved out unless someone else has any issues? thanks, greg k-h