Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: "Ferry Toth" <ftoth@exalondelft.nl>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"John Ogness" <john.ogness@linutronix.de>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Cc: neil.armstrong@linaro.org, AlCooper <alcooperx@gmail.com>,
	AlexanderShiyan <shc_work@mail.ru>,
	AlexandreBelloni <alexandre.belloni@bootlin.com>,
	AlexandreTorgue <alexandre.torgue@foss.st.com>,
	AlimAkhtar <alim.akhtar@samsung.com>,
	AndrewMorton <akpm@linux-foundation.org>,
	"AneeshKumarK . V" <aneesh.kumar@kernel.org>,
	AngeloGioacchinoDelRegno
	<angelogioacchino.delregno@collabora.com>,
	BaolinWang <baolin.wang@linux.alibaba.com>,
	BaruchSiach <baruch@tkos.co.il>,
	BjornAndersson <andersson@kernel.org>,
	ClaudiuBeznea <claudiu.beznea@tuxon.dev>,
	"DavidS . Miller" <davem@davemloft.net>,
	FabioEstevam <festevam@gmail.com>,
	HammerHsieh <hammerh0314@gmail.com>,
	"Christian König" <christian.koenig@amd.com>,
	ChristopheLeroy <christophe.leroy@csgroup.eu>,
	ChunyanZhang <zhang.lyra@gmail.com>,
	JeromeBrunet <jbrunet@baylibre.com>,
	JonathanHunter <jonathanh@nvidia.com>,
	KevinHilman <khilman@baylibre.com>,
	KonradDybcio <konrad.dybcio@linaro.org>,
	KrzysztofKozlowski <krzysztof.kozlowski@linaro.org>,
	KumaravelThiagarajan <kumaravel.thiagarajan@microchip.com>,
	LaxmanDewangan <ldewangan@nvidia.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	"MaciejW . Rozycki" <macro@orcam.me.uk>,
	ManivannanSadhasivam <manivannan.sadhasivam@linaro.org>,
	MartinBlumenstingl <martin.blumenstingl@googlemail.com>,
	MatthiasBrugger <matthias.bgg@gmail.com>,
	MaximeCoquelin <mcoquelin.stm32@gmail.com>,
	MichaelEllerman <mpe@ellerman.id.au>,
	MichalSimek <michal.simek@amd.com>,
	"NaveenN . Rao" <naveen.n.rao@linux.ibm.com>,
	NicolasFerre <nicolas.ferre@microchip.com>,
	NicholasPiggin <npiggin@gmail.com>,
	OrsonZhai <orsonzhai@gmail.com>, "Pali Rohár" <pali@kernel.org>,
	PatriceChotard <patrice.chotard@foss.st.com>,
	PeterKorsgaard <jacmet@sunsite.dk>,
	RichardGenoud <richard.genoud@gmail.com>,
	RussellKing <linux@armlinux.org.uk>,
	SaschaHauer <s.hauer@pengutronix.de>,
	ShawnGuo <shawnguo@kernel.org>,
	StefaniSeibold <stefani@seibold.net>,
	SumitSemwal <sumit.semwal@linaro.org>,
	TaichiSugaya <sugaya.taichi@socionext.com>,
	TakaoOrito <orito.takao@socionext.com>,
	TharunKumarP <tharunkumar.pasumarthi@microchip.com>,
	ThierryReding <thierry.reding@gmail.com>,
	TimurTabi <timur@kernel.org>, VineetGupta <vgupta@kernel.org>,
	MarekSzyprowski <m.szyprowski@samsung.com>,
	PhilEdworthy <phil.edworthy@renesas.com>
Subject: Re: [PATCH/RFC v1 1/1] tty: serial: 8250_dma: use sgl with 2 nents to take care of buffer wrap
Date: Mon, 8 Jul 2024 08:10:17 +0200	[thread overview]
Message-ID: <5619cca5-6d5b-4682-bbf7-51b851cef37e@kernel.org> (raw)
In-Reply-To: <20240703212613.56024-2-ftoth@exalondelft.nl>

On 03. 07. 24, 22:56, Ferry Toth wrote:
> Previously 8250_dma used a circular xmit->buf as DMA output buffer. This
> causes messages that wrap around in the circular buffer to be
> transmitted using 2 DMA transfers. Depending on baud rate and processor
> load this can cause an interchar gap in the middle of the message. On
> the receiving end the gap may cause a short receive timeout, possibly
> long enough to terminate a DMA transfer, but too short to restart a
> receive DMA transfer in time thus causing a receive buffer overrun.
> 
> This is especially a problem for devices with high speed UARTs (HSU)
> where even deep 64 byte FIFO's are not sufficient to handle interrupt
> latency.
> 
> The circular buffer has now been replaced by kfifo which requires a SG
> list with a single entry, which still causes 2 dma transfers when a wrap
> around occurs. Fix this by allowing up to 2 entries in the sgl.

As I stated earlier, from the DMA and TTY perspective, this looks all 
good™. So I welcome this.

 From the devices perspective, obviously testers needed ;). I believe we 
can merge this in 6.12-rc1 (or even 6.11-rc1?) and see. So please post a 
non-RFC patch.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> Signed-off-by: Ferry Toth <ftoth@exalondelft.nl>
> ---
>   drivers/tty/serial/8250/8250_dma.c | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
> index 8a353e3cc3dd..d215c494ee24 100644
> --- a/drivers/tty/serial/8250/8250_dma.c
> +++ b/drivers/tty/serial/8250/8250_dma.c
> @@ -89,7 +89,9 @@ int serial8250_tx_dma(struct uart_8250_port *p)
>   	struct tty_port			*tport = &p->port.state->port;
>   	struct dma_async_tx_descriptor	*desc;
>   	struct uart_port		*up = &p->port;
> -	struct scatterlist sg;
> +	struct scatterlist		*sg;
> +	struct scatterlist		sgl[2];
> +	int i;
>   	int ret;
>   
>   	if (dma->tx_running) {
> @@ -110,18 +112,17 @@ int serial8250_tx_dma(struct uart_8250_port *p)
>   
>   	serial8250_do_prepare_tx_dma(p);
>   
> -	sg_init_table(&sg, 1);
> -	/* kfifo can do more than one sg, we don't (quite yet) */
> -	ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, &sg, 1,
> +	sg_init_table(sgl, ARRAY_SIZE(sgl));
> +
> +	ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, sgl, ARRAY_SIZE(sgl),
>   					   UART_XMIT_SIZE, dma->tx_addr);
>   
> -	/* we already checked empty fifo above, so there should be something */
> -	if (WARN_ON_ONCE(ret != 1))
> -		return 0;
> +	dma->tx_size = 0;
>   
> -	dma->tx_size = sg_dma_len(&sg);
> +	for_each_sg(sgl, sg, ret, i)
> +		dma->tx_size += sg_dma_len(sg);
>   
> -	desc = dmaengine_prep_slave_sg(dma->txchan, &sg, 1,
> +	desc = dmaengine_prep_slave_sg(dma->txchan, sgl, ret,
>   				       DMA_MEM_TO_DEV,
>   				       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>   	if (!desc) {

-- 
js


      reply	other threads:[~2024-07-08  6:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 20:56 [PATCH/RFC v1 0/1] Ferry Toth
2024-07-03 20:56 ` [PATCH/RFC v1 1/1] tty: serial: 8250_dma: use sgl with 2 nents to take care of buffer wrap Ferry Toth
2024-07-08  6:10   ` Jiri Slaby [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5619cca5-6d5b-4682-bbf7-51b851cef37e@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alcooperx@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=alim.akhtar@samsung.com \
    --cc=andersson@kernel.org \
    --cc=aneesh.kumar@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baruch@tkos.co.il \
    --cc=christian.koenig@amd.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=festevam@gmail.com \
    --cc=ftoth@exalondelft.nl \
    --cc=gregkh@linuxfoundation.org \
    --cc=hammerh0314@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jacmet@sunsite.dk \
    --cc=jbrunet@baylibre.com \
    --cc=john.ogness@linutronix.de \
    --cc=jonathanh@nvidia.com \
    --cc=khilman@baylibre.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kumaravel.thiagarajan@microchip.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=macro@orcam.me.uk \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=michal.simek@amd.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=neil.armstrong@linaro.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=npiggin@gmail.com \
    --cc=orito.takao@socionext.com \
    --cc=orsonzhai@gmail.com \
    --cc=pali@kernel.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=phil.edworthy@renesas.com \
    --cc=richard.genoud@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=shc_work@mail.ru \
    --cc=stefani@seibold.net \
    --cc=sugaya.taichi@socionext.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tglx@linutronix.de \
    --cc=tharunkumar.pasumarthi@microchip.com \
    --cc=thierry.reding@gmail.com \
    --cc=timur@kernel.org \
    --cc=vgupta@kernel.org \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox