Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp916485pxb; Wed, 6 Apr 2022 04:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLeNbVfLpIRi0mFcO9TDnJlXmoF8LAko2V+pgwhk/Mi0mgnU6TCZmhRxH1vhoUNUJwwNxe X-Received: by 2002:a17:902:e889:b0:14f:c4bc:677b with SMTP id w9-20020a170902e88900b0014fc4bc677bmr8013306plg.68.1649243515597; Wed, 06 Apr 2022 04:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243515; cv=none; d=google.com; s=arc-20160816; b=On6ohPzsakfda8B6s/Cpcu96MgLSo1dTsEGZz3Eo1GxEjqHf+YucBT89hUvRVA54tR 5gVTB5c+IlGaq5zBHLrtABwua/w04fVlCrHSdmCRuWWzsQ+DCLAhVM61NLqDt1iLQFjD 3ec+S7o6fRWfsuR055+79EGn+vHBR2KgQi0LFz2HpQ2yW3ILcX68X0ygIuRGmMJLXuya JPYShOzkTrbXVIvAIxqhf2bDOmYLAwskd2O0SX0Vu0hfqKM+YdTwJyQVFow1jBC7TVWv MZUt/y5fy3pbuyotA/rdDwxRWJitionJSLTyt2yMcN74EbBVcD1JdnbuZeOVamqtnSKh NoDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DrpwGcrnrIQaogJ9LA9xAv/fB4YhGC3/RzgKlCJKRuA=; b=bHYMyNSBkNLv+LMYC6EdVfFtSRl0l2vCvgn7/O0qeCP3qt1r3diXewj2w83Y2TyFwF QAjPTzSDE/ZDKi06GjfWrYiZ4knhzaZ2d5wnjuP3Gf5PRf2+9kOa6NgeE8wXJStu6BPw qlREVxkJa5NqCsGPRYJH66W9NpK4o4C6+LjIQ7VnskKszrn9gc9XTahqhWJab/LA0b7q Jq2jbSvC9EDswMmRssHM7objEUxZsrWIqBFMfRqUIA6wkIlouO+9kJK6GWq8lGZbbAAA WBMB73I+Ir4Fx9oHk8Ix/l+m+ARQSvUYLGk7Yzf2qudfHge7W79SjfPgyoOlcoT/nDOi rjZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqAcSEtm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id fa15-20020a17090af0cf00b001ca11b51caesi4584678pjb.0.2022.04.06.04.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:11:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqAcSEtm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A92744960A; Wed, 6 Apr 2022 02:36:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1840777AbiDFBLv (ORCPT + 99 others); Tue, 5 Apr 2022 21:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358764AbiDELR0 (ORCPT ); Tue, 5 Apr 2022 07:17:26 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DD602ED56; Tue, 5 Apr 2022 03:20:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9F1C1CE1CA2; Tue, 5 Apr 2022 10:20:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5829C385A1; Tue, 5 Apr 2022 10:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649154016; bh=2gQjB33XM7C25Q4/qKWtlPGZmLvN9J7n1DMtrmV3+84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VqAcSEtmcF3T62/paCdCDZ92yHv6mbHCswr2nh+K/hFJPL2bVgrzr6HhHD6UMoT2s JmwwFGAl5CqXjS/aeIo9V02rLGjBj15kXB1IKFlkhKqb7zg4AerEkzsZ6q2cIWjmyo UmYcBVeUkZK+UJY+aQQ7PXWJ34dJCsO8QLyShHUg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilles Buloz , Andy Shevchenko , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 5.10 427/599] serial: 8250: fix XOFF/XON sending when DMA is used Date: Tue, 5 Apr 2022 09:32:01 +0200 Message-Id: <20220405070311.540287191@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilpo Järvinen [ Upstream commit f58c252e30cf74f68b0054293adc03b5923b9f0e ] When 8250 UART is using DMA, x_char (XON/XOFF) is never sent to the wire. After this change, x_char is injected correctly. Create uart_xchar_out() helper for sending the x_char out and accounting related to it. It seems that almost every driver does these same steps with x_char. Except for 8250, however, almost all currently lack .serial_out so they cannot immediately take advantage of this new helper. The downside of this patch is that it might reintroduce the problems some devices faced with mixed DMA/non-DMA transfer which caused revert f967fc8f165f (Revert "serial: 8250_dma: don't bother DMA with small transfers"). However, the impact should be limited to cases with XON/XOFF (that didn't work with DMA capable devices to begin with so this problem is not very likely to cause a major issue, if any at all). Fixes: 9ee4b83e51f74 ("serial: 8250: Add support for dmaengine") Reported-by: Gilles Buloz Tested-by: Gilles Buloz Reviewed-by: Andy Shevchenko Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220314091432.4288-2-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_dma.c | 11 ++++++++++- drivers/tty/serial/8250/8250_port.c | 4 +--- drivers/tty/serial/serial_core.c | 14 ++++++++++++++ include/linux/serial_core.h | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index 890fa7ddaa7f..b3c3f7e5851a 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -64,10 +64,19 @@ int serial8250_tx_dma(struct uart_8250_port *p) struct uart_8250_dma *dma = p->dma; struct circ_buf *xmit = &p->port.state->xmit; struct dma_async_tx_descriptor *desc; + struct uart_port *up = &p->port; int ret; - if (dma->tx_running) + if (dma->tx_running) { + if (up->x_char) { + dmaengine_pause(dma->txchan); + uart_xchar_out(up, UART_TX); + dmaengine_resume(dma->txchan); + } return 0; + } else if (up->x_char) { + uart_xchar_out(up, UART_TX); + } if (uart_tx_stopped(&p->port) || uart_circ_empty(xmit)) { /* We have been called from __dma_tx_complete() */ diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 1733f03a7da7..3055353514e1 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1817,9 +1817,7 @@ void serial8250_tx_chars(struct uart_8250_port *up) int count; if (port->x_char) { - serial_out(up, UART_TX, port->x_char); - port->icount.tx++; - port->x_char = 0; + uart_xchar_out(port, UART_TX); return; } if (uart_tx_stopped(port)) { diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index be0d9922e320..19f0c5db11e3 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -676,6 +676,20 @@ static void uart_flush_buffer(struct tty_struct *tty) tty_port_tty_wakeup(&state->port); } +/* + * This function performs low-level write of high-priority XON/XOFF + * character and accounting for it. + * + * Requires uart_port to implement .serial_out(). + */ +void uart_xchar_out(struct uart_port *uport, int offset) +{ + serial_port_out(uport, offset, uport->x_char); + uport->icount.tx++; + uport->x_char = 0; +} +EXPORT_SYMBOL_GPL(uart_xchar_out); + /* * This function is used to send a high-priority XON/XOFF character to * the device diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index ff63c2963359..35b26743dbb2 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -463,6 +463,8 @@ extern void uart_handle_cts_change(struct uart_port *uport, extern void uart_insert_char(struct uart_port *port, unsigned int status, unsigned int overrun, unsigned int ch, unsigned int flag); +void uart_xchar_out(struct uart_port *uport, int offset); + #ifdef CONFIG_MAGIC_SYSRQ_SERIAL #define SYSRQ_TIMEOUT (HZ * 5) -- 2.34.1