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=1796379450; b=bUKgxCyER1XLMGvioG20W8KgvneU7vshqcpxYobMG1eAxesFmhYf6xxP+ho0eAh2zpus 3L11Hyp8Bu50F4ByYe380A55SbnbVkc2/Szvp1HEgeB4/++upnuX/KtsfxO/8bSuAPyzD YTGoepVwYtLJWXEryRZ9+HzWbQpqVe+MGvfCAOdCJTPfetK0b9jmv8+XdwTIyHAzhPPtL XDYzpKD/Z5XlsCqv1+zQjp8sRF5K7yDFNed8nTzkPlc3LzyEG4XsYPvbWm8qy+LQk8EQE M3nzHRp2HVZTZov9cfW5pDn6uutXcaN7T0lxl7zbzmA1HlzlLv3rBx6prAZdkplJS8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379450; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XSS0DTUKbSpBwrCt370tvJYs4p7ws5HOWiJplgdXVOE=; b=Njf17E650/rbvIwCesPB5bP44KcYM0iX9NF11OirOEDOqE/JL3s/BZ9JQRlGd6OEA7gW vw0ld0VlDrAKsTOQgQvqpDcN1xaKXpH72Kfsoz8RY/VO7KWsIRLQxOnYdoS8K8gcn8FOt 6vZ1WdZtR0fW/f5zZrKqa4MgnB0piLetfKIPvpJltlNhxSuKcRfSCKfdtx7tItw54P6aE IOtxoafNHhXwmHSwuYmwwLkuJx97H0O8p+/XwgQ3xyR3CEzbTgPpNuUHImI5WsdaSvevs dmoJusdR8NVe6dKKlyjvtvc0LW+gew4qIz2yAInOzeqi9OV29y9pyQ8P/KAoiqFfkPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ctqfLKxf; 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 1735E606A32F for ; Fri, 4 Dec 2026 10:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ctqfLKxf Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F7D1F000CE; Fri, 4 Dec 2026 10:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796379449; bh=XSS0DTUKbSpBwrCt370tvJYs4p7ws5HOWiJplgdXVOE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ctqfLKxfmEFXWwJN0C4jjWUvKCKYd0VF0KbvNzukTuP6peo4qeTG/pjUS556VXccd hok9xbCh8T3EaUnDoBaFmFolXuZdyXZ7ZNp4Id0ON1q2v7pOkFSd149vAWdEWru416 8a7XH8pKaLcxvxbrCDWRdYw+NuEztH2IS6uMzksliIQma1WeC8kJGf54FX2CkJloJX KblThz7CGe8BWHeT3QzdeqGZGX3WdwMmgCXt7jDdP5X5t9lk7BbN1t0Kr+FtM4sUUV M+eoYX5FQc/gXVL6/N3g47NrvMGS3PlTP9lf+kIzUYef8XB9VCrMa8A9jEkIiIYo3a NDrhSlWNKap7Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] serial: 8250: calculate TX length before preparing DMA flow control Reply-To: sashiko-reviews@lists.linux.dev To: "James Hilliard" Cc: linux-serial@vger.kernel.org In-Reply-To: <20261204-submit-serial-8250-dma-tx-length-v1-v3-1-7a6250992bd6@gmail.com> References: <20261204-submit-serial-8250-dma-tx-length-v1-v3-1-7a6250992bd6@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:17:29 +0000 X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] serial: 8250: multi-SG TX wrap breaks RZ/N1 peripheral DMA flow control -- commit 657ef7e8d98bc808e1f5202a741d3828179f07d3 Author: James Hilliard serial: 8250: calculate TX length before preparing DMA flow control This commit moves serial8250_do_prepare_tx_dma() after the scatterlist length summation in serial8250_tx_dma() so dma->tx_size reflects the current transfer. > diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250= /8250_dma.c > index 1da605cc86011..2dc47adafec05 100644 > --- a/drivers/tty/serial/8250/8250_dma.c > +++ b/drivers/tty/serial/8250/8250_dma.c > @@ -110,8 +110,6 @@ int serial8250_tx_dma(struct uart_8250_port *p) > return 0; > } > =20 > - serial8250_do_prepare_tx_dma(p); > - > sg_init_table(sgl, ARRAY_SIZE(sgl)); > =20 > ret =3D kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, sgl, ARRAY_SIZE= (sgl), > @@ -122,6 +120,8 @@ int serial8250_tx_dma(struct uart_8250_port *p) > for_each_sg(sgl, sg, ret, i) > dma->tx_size +=3D sg_dma_len(sg); > =20 > + serial8250_do_prepare_tx_dma(p); > + > desc =3D dmaengine_prep_slave_sg(dma->txchan, sgl, ret, > DMA_MEM_TO_DEV, > DMA_PREP_INTERRUPT | DMA_CTRL_ACK); [Severity: High] Can this read past the end of the TX kfifo buffer and stall TX DMA when pending data wraps around UART_XMIT_SIZE? When tport->xmit_fifo wraps, kfifo_dma_out_prepare_mapped() populates both entries of sgl with two non-contiguous segments and returns 2. Summing both into dma->tx_size makes dw8250_prepare_tx_dma() program RZN1_UART_TDMACR for a single UART block covering both segments. Meanwhile, dwc_prep_slave_sg() in drivers/dma/dw/core.c configures DW_DMA_FC_P_M2P because dma->txconf.device_fc is set, and chains two LLI descriptors with DWC_CTLL_INT_EN only on the second one. In peripheral-flow-controller mode, the DW-AHB-DMAC ends an LLI on the peripheral's dma_last handshake rather than the segment length. During the first LLI, it reads past dma->tx_addr + UART_XMIT_SIZE into adjacent kernel memory and transmits those bytes over the UART. Once the UART asserts dma_last after the combined length, the DMAC moves to the second LLI and stalls waiting for requests from the completed UART block, so __dma_tx_complete() never runs and dma->tx_running stays set. Limiting kfifo_dma_out_prepare_mapped() to 1 entry when dma->txconf.device_fc is set would keep each flow-controlled block contiguous and let __dma_tx_complete() submit the wrapped remainder next. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-submit-ser= ial-8250-dma-tx-length-v1-v3-1-7a6250992bd6@gmail.com?part=3D1